@Test
    public void testBaseAnnotations() {
        Book book = getBook();
        SpanTree authorTree = new SpanTree();
        Person p = new Person();
        p.setName("Melville");
        authorTree.annotate(p);
        StringFieldValue sfv =  ((StringFieldValue) book.getFieldValue("author"));
        sfv.setSpanTree(authorTree);
        book.setFieldValue("author", sfv);
        assertEquals(book.authorSpanTrees().values().iterator().next().iterator().next(), p);

        final SpanTree descTree = new SpanTree();
        Person p2 = new Person();
        p2.setName("H. Melville");
        descTree.annotate(p2);
        book.setDescriptionSpanTrees(new HashMap<>(){{ put(descTree.getName(), descTree); }});
        assertEquals(((Person) ((StringFieldValue) book.getFieldValue(book.getField("description"))).getSpanTrees().iterator().next().iterator().next()).getName(),
        "H. Melville");
        assertEquals(((Person) ((StringFieldValue) book.removeFieldValue("description")).getSpanTrees().iterator().next().iterator().next()).getName(), "H. Melville");
        assertNull(book.descriptionSpanTrees());
        assertNull((book.getFieldValue("description")));
        Artist a = new Artist();
        assertTrue(Person.class.isInstance(a));
        assertEquals(((StructDataType) a.getType().getDataType()).getField("name").getDataType(), DataType.STRING);
        assertEquals(((StructDataType) a.getType().getDataType()).getField("instrument").getDataType(), DataType.INT);
        assertEquals(((Struct) a.getFieldValue()).getField("name").getDataType(), DataType.STRING);
    }
Tests vespa-documentgen-plugin

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