mirror of https://github.com/apache/nifi.git
Adding a test for multiple attribute paths
This commit is contained in:
parent
974617d44e
commit
78ad0a3147
|
@ -95,6 +95,28 @@ public class TestEvaluateJsonPath {
|
|||
Assert.assertEquals("Transferred flow file did not have the correct result", "54df94072d5dbf7dc6340cc5", out.getAttribute(jsonPathAttrKey));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractPath_destinationAttributes_twoPaths() throws Exception {
|
||||
final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateJsonPath());
|
||||
testRunner.setProperty(EvaluateJsonPath.DESTINATION, EvaluateJsonPath.DESTINATION_ATTRIBUTE);
|
||||
|
||||
String jsonPathIdAttrKey = "evaluatejson.id";
|
||||
String jsonPathNameAttrKey = "evaluatejson.name";
|
||||
|
||||
testRunner.setProperty(jsonPathIdAttrKey, "$[0]._id");
|
||||
testRunner.setProperty(jsonPathNameAttrKey, "$[0].name");
|
||||
|
||||
testRunner.enqueue(JSON_SNIPPET);
|
||||
testRunner.run();
|
||||
|
||||
Relationship expectedRel = EvaluateJsonPath.REL_MATCH;
|
||||
|
||||
testRunner.assertAllFlowFilesTransferred(expectedRel, 1);
|
||||
final MockFlowFile out = testRunner.getFlowFilesForRelationship(expectedRel).get(0);
|
||||
Assert.assertEquals("Transferred flow file did not have the correct result for id attribute", "54df94072d5dbf7dc6340cc5", out.getAttribute(jsonPathIdAttrKey));
|
||||
Assert.assertEquals("Transferred flow file did not have the correct result for name attribute", "{\"first\":\"Shaffer\",\"last\":\"Pearson\"}", out.getAttribute(jsonPathNameAttrKey));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractPath_destinationContent() throws Exception {
|
||||
String jsonPathAttrKey = "JsonPath";
|
||||
|
|
Loading…
Reference in New Issue