@SuppressWarnings({ "cast", "unchecked", "rawtypes" })
    @Test
    public void testArithmeticOperators() throws IOException {
        Tuple2[] operations = new Tuple2[] {
                new Tuple2<>(UPDATE_DECREMENT,
                             ArithmeticValueUpdate.Operator.SUB),
                new Tuple2<>(UPDATE_DIVIDE,
                        ArithmeticValueUpdate.Operator.DIV),
                new Tuple2<>(UPDATE_INCREMENT,
                        ArithmeticValueUpdate.Operator.ADD),
                new Tuple2<>(UPDATE_MULTIPLY,
                        ArithmeticValueUpdate.Operator.MUL) };
        for (Tuple2<String, Operator> operator : operations) {
            DocumentUpdate doc = parseUpdate("""
                                             {
                                               "update": "id:unittest:testset::whee",
                                               "fields": {
                                                 "actualset": {
                                                   "match": {
                                                     "element": "person",
                                                     "%s": 13
                                                   }
                                                 }
                                               }
                                             }
                                             """.formatted(operator.first));

            Map<String, Tuple2<Number, Operator>> matches = new HashMap<>();
            FieldUpdate x = doc.getFieldUpdate("actualset");
            for (ValueUpdate v : x.getValueUpdates()) {
                MapValueUpdate adder = (MapValueUpdate) v;
                final String key = ((StringFieldValue) adder.getValue())
                        .getString();
                Operator op = ((ArithmeticValueUpdate) adder
                        .getUpdate()).getOperator();
                Number n = ((ArithmeticValueUpdate) adder.getUpdate())
                        .getOperand();
                matches.put(key, new Tuple2<>(n, op));
            }
            assertEquals(1, matches.size());
            final String o = "person";
            assertSame(operator.second, matches.get(o).second);
            assertEquals(Double.valueOf(13), matches.get(o).first);
        }
    }
Basic test of JSON streams to Vespa document instances.

@author Steinar Knutsen
@author bratseth
document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java