You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2015/02/18 05:30:14 UTC

[12/29] incubator-nifi git commit: Adding a test for a destination of attributes and only one JsonPath expression evaluates to a found result.

Adding a test for a destination of attributes and only one JsonPath expression evaluates to a found result.


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/68970907
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/68970907
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/68970907

Branch: refs/heads/NIFI-360
Commit: 6897090771434fc1553b722b835c3b67e8dd14a9
Parents: d4a94c3
Author: Aldrin Piri <al...@gmail.com>
Authored: Mon Feb 16 18:26:35 2015 -0500
Committer: Aldrin Piri <al...@gmail.com>
Committed: Mon Feb 16 18:26:35 2015 -0500

----------------------------------------------------------------------
 .../standard/TestEvaluateJsonPath.java          | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/68970907/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateJsonPath.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateJsonPath.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateJsonPath.java
index 6a1fbad..fc125c2 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateJsonPath.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateJsonPath.java
@@ -140,6 +140,28 @@ public class TestEvaluateJsonPath {
     }
 
     @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
     public void testExtractPath_destinationContent() throws Exception {
         String jsonPathAttrKey = "JsonPath";