GenericJsonEvent implements DeserializedEvent { @Override public void setField(String fieldName, Object value) throws FieldNotFoundException { if (this.payload == null) { throw new FieldNotFoundException("payload is null"); } if (!fieldName.startsWith("$.")) { fieldName = "$." + fieldName; } JsonPathProvider.setField(this.payload, value, fieldName); } GenericJsonEvent(JsonObject payload); @Override Object getPayload(); @Override Object getField(String field); @Override void setPayload(Object object); @Override void setField(String fieldName, Object value); @Override String getFieldAsString(String fieldName); @Override Object removeField(String fieldName); @Override void deleteField(String fieldName); @Override GenericJsonEvent copy();  }
@Test public void testSetField() throws FieldNotFoundException { GenericJsonEvent event = getEmptyEvent(); event.setField("$.foo", "bar"); JsonObject payload = (JsonObject) event.getPayload(); assertEquals("bar", payload.get("foo").getAsString()); assertEquals("b", payload.get("a").getAsString()); }