@Test
    public void testWeightedSets() {
        Book book = getBook();
        assertTrue(book.getField("mywsinteger").getDataType() instanceof WeightedSetDataType);
        Field ws = book.getField("mywsinteger");
        assertEquals(book.getMywsinteger().get(2), (Integer)200);
        WeightedSet integerWs = (WeightedSet) book.getFieldValue("mywsinteger");
        assertEquals(integerWs.get(new IntegerFieldValue(2)), (Integer)200);
        integerWs.remove(new IntegerFieldValue(2));
        assertNull(book.getMywsinteger().get(2));
        assertEquals(((WeightedSet)book.getFieldValue(ws)).get(new IntegerFieldValue(1)), (Integer)100);

        Map<Integer, Integer> ws2 = new HashMap<>();
        ws2.put(1, 1000);
        ws2.put(2, 2000);
        ws2.put(3, 3000);
        book.setMywsinteger(ws2);
        assertEquals(book.getMywsinteger().get(2), (Integer)2000);
        integerWs = (WeightedSet) book.getFieldValue("mywsinteger");
        assertEquals(integerWs.get(new IntegerFieldValue(2)), (Integer)2000);
        assertEquals(integerWs.size(), 3);
        ws2.put(4, 4000);
        assertEquals(book.getMywsinteger().get(4), (Integer)4000);
        book.getMywsinteger().remove(4);
        assertNull(book.getMywsinteger().get(4));
        assertNull(ws2.get(4));
        assertEquals(((WeightedSet)book.getFieldValue(ws)).get(new IntegerFieldValue(1)), (Integer)1000);
    }
Tests vespa-documentgen-plugin

@author vegardh
documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java