Search in sources :

Example 1 with JsonRootNodeOperationFactory

use of com.nextdoor.bender.operation.json.key.JsonRootNodeOperationFactory in project bender by Nextdoor.

the class JsonRootNodeMutatorTest method testMutateRootNode.

@Test
public void testMutateRootNode() throws JsonSyntaxException, UnsupportedEncodingException, IOException {
    JsonParser parser = new JsonParser();
    JsonElement input = parser.parse(getResourceString("basic_input.json"));
    DummpyEvent devent = new DummpyEvent();
    devent.payload = input.getAsJsonObject();
    JsonRootNodeOperationFactory f = new JsonRootNodeOperationFactory();
    JsonRootNodeOperation operation = new JsonRootNodeOperation("$.i.ia");
    InternalEvent ievent = new InternalEvent("", null, 0);
    ievent.setEventObj(devent);
    operation.perform(ievent);
    assertEquals("{\"iaa\":\"bar\"}", devent.payload.toString());
}
Also used : JsonRootNodeOperationFactory(com.nextdoor.bender.operation.json.key.JsonRootNodeOperationFactory) JsonElement(com.google.gson.JsonElement) JsonRootNodeOperation(com.nextdoor.bender.operation.json.key.JsonRootNodeOperation) JsonParser(com.google.gson.JsonParser) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test) OperationTest(com.nextdoor.bender.operations.json.OperationTest)

Aggregations

JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 InternalEvent (com.nextdoor.bender.InternalEvent)1 JsonRootNodeOperation (com.nextdoor.bender.operation.json.key.JsonRootNodeOperation)1 JsonRootNodeOperationFactory (com.nextdoor.bender.operation.json.key.JsonRootNodeOperationFactory)1 OperationTest (com.nextdoor.bender.operations.json.OperationTest)1 Test (org.junit.Test)1