@Test public void one_$parent_setSimpleFieldTest() throws Exception { UpdateExpression expr = EvalTestContext .updateExpressionFromJson("[ {'$set' : { 'field2.$parent.field1' : 'set1', 'field3.$parent.field2':'set2', 'field2.$parent.field5': 0, 'field2.$parent.field6.nf1':'set6' } }, {'$add' : { 'field2.$parent.field3':1 } } ] "); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals("set1", jsonDoc.get(new Path("field1")).asText()); Assert.assertEquals("set2", jsonDoc.get(new Path("field2")).asText()); Assert.assertEquals(4, jsonDoc.get(new Path("field3")).asInt()); Assert.assertFalse(jsonDoc.get(new Path("field5")).asBoolean()); Assert.assertEquals("set6", jsonDoc.get(new Path("field6.nf1")).asText()); }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; }
UpdateExpressionListEvaluator extends Updater { @Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } }
UpdateExpressionListEvaluator extends Updater { @Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } UpdateExpressionListEvaluator(JsonNodeFactory factory, FieldTreeNode context, UpdateExpressionList expr); }
UpdateExpressionListEvaluator extends Updater { @Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } UpdateExpressionListEvaluator(JsonNodeFactory factory, FieldTreeNode context, UpdateExpressionList expr); @Override void getUpdateFields(Set<Path> fields); @Override boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath); }
UpdateExpressionListEvaluator extends Updater { @Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; for (Updater x : updaters) { if (x.update(doc, contextMd, contextPath)) { ret = true; } } return ret; } UpdateExpressionListEvaluator(JsonNodeFactory factory, FieldTreeNode context, UpdateExpressionList expr); @Override void getUpdateFields(Set<Path> fields); @Override boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath);  }