@Before
    public void setUp() {
        docMan = new DocumentTypeManager();

        docType = new DocumentType("foobar");
        docType.addField(new Field("strfoo", DataType.STRING));

        DataType stringarray = DataType.getArray(DataType.STRING);
        docType.addField(new Field("strarray", stringarray));

        DataType stringwset = DataType.getWeightedSet(DataType.STRING);
        docType.addField(new Field("strwset", stringwset));

        docType.addField(new Field(tensorField, new TensorDataType(tensorType)));
        docMan.register(docType);

        docType2 = new DocumentType("otherdoctype");
        docType2.addField(new Field("strinother", DataType.STRING));
        docMan.register(docType2);

        docUp = new DocumentUpdate(docType, new DocumentId("id:ns:foobar::bar"));

        assignSingle = FieldUpdate.createAssign(docType.getField("strfoo"), new StringFieldValue("something"));

        Array<StringFieldValue> assignList = new Array<>(docType.getField("strarray").getDataType());
        assignList.add(new StringFieldValue("assigned val 0"));
        assignList.add(new StringFieldValue("assigned val 1"));
        assignMultiList = FieldUpdate.createAssign(docType.getField("strarray"), assignList);

        WeightedSet<StringFieldValue> assignWset = new WeightedSet<>(docType.getField("strwset").getDataType());
        assignWset.put(new StringFieldValue("assigned val 0"), 5);
        assignWset.put(new StringFieldValue("assigned val 1"), 10);
        assignMultiWset = FieldUpdate.createAssign(docType.getField("strwset"), assignWset);

        clearSingleField = FieldUpdate.createClearField(docType.getField("strfoo"));

        removeMultiList = FieldUpdate.createRemove(docType.getField("strarray"), new StringFieldValue("remove val 1"));

        removeMultiWset = FieldUpdate.createRemove(docType.getField("strwset"), new StringFieldValue("remove val 1"));

        try {
            addSingle = FieldUpdate.createAdd(docType.getField("strfoo"), new StringFieldValue("add val"));
            fail("Shouldn't be able to add to a single-value field");
        } catch (UnsupportedOperationException uoe) {
            //success
        }

        List<StringFieldValue> addList = new ArrayList<>();
        addList.add(new StringFieldValue("bo"));
        addList.add(new StringFieldValue("ba"));
        addList.add(new StringFieldValue("by"));
        addMultiList = FieldUpdate.createAddAll(docType.getField("strarray"), addList);

        WeightedSet<StringFieldValue> addSet = new WeightedSet<StringFieldValue>(docType.getField("strwset").getDataType());
        addSet.put(new StringFieldValue("banana"), 137);
        addSet.put(new StringFieldValue("is"), 143);
        addSet.put(new StringFieldValue("a"), 157);
        addSet.put(new StringFieldValue("great"), 163);
        addSet.put(new StringFieldValue("fruit"), 189);
        addMultiWset = FieldUpdate.createAddAll(docType.getField("strwset"), addSet);
    }
Tests applying and serializing document updates.

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