@Test
    public void testFieldUpdatesInDocUp() {
        DocumentType t1 = new DocumentType("doo");
        Field f1 = new Field("field1", DataType.STRING);
        Field f2 = new Field("field2", DataType.STRING);
        t1.addField(f1);
        t1.addField(f2);

        DocumentUpdate documentUpdate = new DocumentUpdate(t1, new DocumentId("id:ns:doo::is:a:test"));

        assertEquals(0, documentUpdate.size());

        FieldUpdate fu1 = FieldUpdate.createAssign(f1, new StringFieldValue("banana"));
        FieldUpdate fu2 = FieldUpdate.createAssign(f2, new StringFieldValue("apple"));
        documentUpdate.addFieldUpdate(fu1);

        assertEquals(1, documentUpdate.size());

        documentUpdate.clearFieldUpdates();

        assertEquals(0, documentUpdate.size());

        documentUpdate.addFieldUpdate(fu1);
        documentUpdate.addFieldUpdate(fu2);

        assertEquals(2, documentUpdate.size());


        assertSame(fu1, documentUpdate.getFieldUpdate(f1));

        try {
            documentUpdate.setFieldUpdates(null);
            fail("Should have gotten NullPointerException");
        } catch (NullPointerException npe) {
            //ok!
        }

        List<FieldUpdate> fus = new ArrayList<>();
        fus.add(fu1);
        fus.add(fu2);

        documentUpdate.setFieldUpdates(fus);
        assertEquals(2, documentUpdate.size());
        assertSame(fu1, documentUpdate.getFieldUpdate(fu1.getField()));
        assertSame(fu2, documentUpdate.getFieldUpdate(fu2.getField()));

        documentUpdate.removeFieldUpdate(fu2.getField());
        assertEquals(1, documentUpdate.size());
        assertSame(fu1, documentUpdate.getFieldUpdate(fu1.getField()));


        documentUpdate.toString();

        assertFalse(documentUpdate.isEmpty());

        Iterator<FieldPathUpdate> fpUpdates = documentUpdate.iterator();
        assertFalse(fpUpdates.hasNext());
    }
Tests applying and serializing document updates.

@author Einar M R Rosenvinge
document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java