@Test
    public void testSerialization() {
        final Book book = getBook();
        assertEquals(book.getMystruct().getD1(), (Double)56.777);
        assertEquals(book.getFieldCount(), 13);
        assertEquals(book.getMystruct().getFieldCount(), 4);
        assertEquals(book.getContent().get(0), 3);
        assertEquals(book.getContent().get(1), 4);
        assertEquals(book.getContent().get(2), 5);
        final Document des = roundtripSerialize(book, typeManagerForBookType());
        assertEquals(des.getFieldCount(), 13);
        assertEquals(des.getDataType().getName(), "book");
        assertEquals(((Raw) des.getFieldValue("content")).getByteBuffer().get(0), 3);
        assertEquals(((Raw) des.getFieldValue("content")).getByteBuffer().get(1), 4);
        assertEquals(((Raw) des.getFieldValue("content")).getByteBuffer().get(2), 5);
        assertEquals(des.getFieldValue("author").toString(), "Herman Melville");
        assertEquals(des.getFieldValue("title").toString(), "Moby Dick - Or The Whale");
        assertEquals(des.getFieldValue("title").toString(), "Moby Dick - Or The Whale");
        assertEquals(des.getFieldValue("author").toString(), "Herman Melville");

        Struct mystruct = (Struct)des.getFieldValue("mystruct");
        FieldValue d1 = mystruct.getFieldValue("d1");
        assertEquals(d1.getWrappedValue(), 56.777d);

        Struct ss01 = (Struct) mystruct.getFieldValue("ss01");
        DoubleFieldValue ss01d0 = (DoubleFieldValue) ss01.getFieldValue("d0");
        assertEquals(ss01d0.getWrappedValue(), -238472634.78d);

        Array<IntegerFieldValue> a = (Array<IntegerFieldValue>) des.getFieldValue("myarrayint");
        assertEquals(a.size(), 3);
        assertEquals(a.get(0).getInteger(), 10);
        assertEquals(a.get(1).getInteger(), 20);
        assertEquals(a.get(2).getInteger(), 30);

        WeightedSet<IntegerFieldValue> ws = (WeightedSet<IntegerFieldValue>) des.getFieldValue("mywsinteger");
        assertEquals(ws.size(), 3);
        assertEquals(ws.get(new IntegerFieldValue(1)), (Integer)100);
        assertEquals(ws.get(new IntegerFieldValue(2)), (Integer)200);
        assertEquals(ws.get(new IntegerFieldValue(3)), (Integer)300);

        Array<Struct> sstrctArr = (Array<Struct>) des.getFieldValue("mysinglestructarray");
        assertEquals(sstrctArr.size(), 2);
        assertEquals(sstrctArr.get(0).getFieldValue("s1").getWrappedValue().toString(), "YEPS");
        assertEquals(sstrctArr.get(1).getFieldValue("s1").getWrappedValue().toString(), "JA");
    }
Packs the given doc to Book
@param d doc, never null
@return a Book object or null if input doc isn't a Book
documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java