@Test
    public void testPackDocFromGenericDoc() {
        DocumentType bookGeneric = new DocumentType("book");
        DocumentType somethingElse = new DocumentType("somethingElse");
        bookGeneric.addField("author", DataType.STRING);
        bookGeneric.addField("title", DataType.STRING);
        Document genBook = new Document(bookGeneric, new DocumentId("id:book:book::0"));
        genBook.setFieldValue("author", new StringFieldValue("Melville"));
        genBook.setFieldValue("title", new StringFieldValue("Moby Dick"));
        Document notBook = new Document(somethingElse, new DocumentId("id:notbook:somethingElse::0"));

        assertNull(pack(notBook));
        Book book = pack(genBook);
        assertEquals(book.getTitle(), "Moby Dick");
        assertEquals(book.getAuthor(), "Melville");
    }
Tests vespa-documentgen-plugin

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