Adding tests for indefinite results with and without the usage of operators.

This commit is contained in:
Aldrin Piri 2015-02-16 18:33:48 -05:00
parent 6897090771
commit 7e581307b7
1 changed files with 35 additions and 0 deletions

View File

@ -177,4 +177,39 @@ public class TestEvaluateJsonPath {
testRunner.assertAllFlowFilesTransferred(expectedRel, 1); testRunner.assertAllFlowFilesTransferred(expectedRel, 1);
testRunner.getFlowFilesForRelationship(expectedRel).get(0).assertContentEquals("54df94072d5dbf7dc6340cc5"); testRunner.getFlowFilesForRelationship(expectedRel).get(0).assertContentEquals("54df94072d5dbf7dc6340cc5");
} }
@Test
public void testExtractPath_destinationAttribute_indefiniteResult() throws Exception {
String jsonPathAttrKey = "friends.indefinite.id.list";
final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateJsonPath());
testRunner.setProperty(EvaluateJsonPath.DESTINATION, EvaluateJsonPath.DESTINATION_CONTENT);
testRunner.setProperty(jsonPathAttrKey, "$[0].friends.[*].id");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
Relationship expectedRel = EvaluateJsonPath.REL_MATCH;
testRunner.assertAllFlowFilesTransferred(expectedRel, 1);
testRunner.getFlowFilesForRelationship(expectedRel).get(0).assertContentEquals("[0,1,2]");
}
@Test
public void testExtractPath_destinationAttribute_indefiniteResult_operators() throws Exception {
String jsonPathAttrKey = "friends.indefinite.id.list";
final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateJsonPath());
testRunner.setProperty(EvaluateJsonPath.DESTINATION, EvaluateJsonPath.DESTINATION_CONTENT);
testRunner.setProperty(jsonPathAttrKey, "$[0].friends[?(@.id < 3)].id");
testRunner.enqueue(JSON_SNIPPET);
testRunner.run();
Relationship expectedRel = EvaluateJsonPath.REL_MATCH;
testRunner.assertAllFlowFilesTransferred(expectedRel, 1);
testRunner.getFlowFilesForRelationship(expectedRel).get(0).assertContentEquals("[0,1,2]");
}
} }