@Test
    public void testRequireThatChangingDocumentTypeChecksId() {
        MyDocumentReader reader = new MyDocumentReader();

        Document doc = new Document(reader);
        doc.setId(new DocumentId("id:namespace:mytype::foo"));
        DocumentType docType = new DocumentType("mytype");
        doc.setDataType(docType);

        Document notOkDoc = new Document(reader);
        notOkDoc.setId(new DocumentId("id:namespace:mytype::foo"));
        DocumentType wrongType = new DocumentType("wrongtype");
        assertThrows(IllegalArgumentException.class,
                     () -> notOkDoc.setDataType(wrongType));
    }
Test for Document and all its features, including (de)serialization.

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