private Document getSertestDocument() {
        Document doc = new Document(docMan.getDocumentType("sertest"), new DocumentId("id:ns:sertest::foobar"));
        doc.setFieldValue("mailid", "emailfromalicetobob");
        doc.setFieldValue("date", -2013512400); // 03/13/06 11:00:00
        doc.setFieldValue("attachmentcount", 2);

        byte[] rawBytes = new byte[100];
        for (int i = 0; i < rawBytes.length; i++) {
            rawBytes[i] = (byte)i;
        }

        doc.setFieldValue("rawfield", new Raw(ByteBuffer.wrap(rawBytes)));

        Document docInDoc = new Document(docMan.getDocumentType("docindoc"), new DocumentId("id:ns:docindoc::inserted"));
        docInDoc.setFieldValue("tull", "ball");
        doc.setFieldValue("docindoc", docInDoc);

        WeightedSet<StringFieldValue> wset = new WeightedSet<>(DataType.getWeightedSet(DataType.STRING));
        wset.put(new StringFieldValue("this is a test"), 5);
        wset.put(new StringFieldValue("this is another test, blah blah"), 10);
        doc.setFieldValue("weightedfield", wset);

        MapFieldValue<StringFieldValue, StringFieldValue> map = new MapFieldValue<>(new MapDataType(DataType.STRING, DataType.STRING));
        map.put(new StringFieldValue("foo1"), new StringFieldValue("bar1"));
        map.put(new StringFieldValue("foo2"), new StringFieldValue("bar2"));
        doc.setFieldValue("mapfield", map);
        doc.setFieldValue("myboolfield", new BoolFieldValue(true));

        return doc;
    }
Test for Document and all its features, including (de)serialization.

@author Thomas Gundersen
@author bratseth
document/src/test/java/com/yahoo/document/DocumentTestCase.java