mirror of https://github.com/apache/nifi.git
Adding a test for a destination of attributes and only one JsonPath expression evaluates to a found result.
This commit is contained in:
parent
d4a94c37ee
commit
6897090771
|
@ -139,6 +139,28 @@ public class TestEvaluateJsonPath {
|
||||||
Assert.assertEquals("Transferred flow file did not have the correct result for name attribute", "", out.getAttribute(jsonPathNameAttrKey));
|
Assert.assertEquals("Transferred flow file did not have the correct result for name attribute", "", out.getAttribute(jsonPathNameAttrKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExtractPath_destinationAttributes_twoPaths_oneFound() 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.nonexistent");
|
||||||
|
|
||||||
|
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", "", out.getAttribute(jsonPathNameAttrKey));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractPath_destinationContent() throws Exception {
|
public void testExtractPath_destinationContent() throws Exception {
|
||||||
String jsonPathAttrKey = "JsonPath";
|
String jsonPathAttrKey = "JsonPath";
|
||||||
|
|
Loading…
Reference in New Issue