@Test
    public void testFactory() {
        Book b = (Book) ConcreteDocumentFactory.getDocument("book", new DocumentId("id:book:book::10"));
        b.setAuthor("Per Ulv");
        final Date d = (Date) ConcreteDocumentFactory.getAnnotation("date");
        d.setExacttime(79L);
        b.setAuthorSpanTrees(new HashMap<>() {{ put("root", new SpanTree("root").annotate(d));  }});
        StringFieldValue authorCheck=(StringFieldValue) b.getFieldValue("author");
        assertEquals(authorCheck.getWrappedValue(), "Per Ulv");
        SpanTree treeCheck = authorCheck.getSpanTrees().iterator().next();
        Annotation authorAnnCheck = treeCheck.iterator().next();
        assertEquals(((Struct) authorAnnCheck.getFieldValue()).getFieldValue("exacttime").getWrappedValue(), 79L);

        b.setMystruct(((Ss1) ConcreteDocumentFactory.getStruct("ss1")).setS1("Test s1!"));
        assertEquals(((Struct) b.getFieldValue("mystruct")).getFieldValue("s1").getWrappedValue(), "Test s1!");

        Ss1 fss1=(Ss1)ConcreteDocumentFactory.getStruct("ss1");
        fss1.setD1(678d);
        b.setMystruct(fss1);
        assertEquals(b.getMystruct().getFieldValue("d1").getWrappedValue(), 678d);
        assertEquals(b.getMystruct().getD1(), (Double)678d);

        assertEquals(ConcreteDocumentFactory.documentTypeObjects.size(), 10);
        assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("music"), Music.type);
        assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("parent"), Parent.type);
        assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("common"), Common.type);
    }
Tests vespa-documentgen-plugin

@author vegardh
documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java