Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2443#discussion_r170034475
  
    --- Diff: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoTest.java
 ---
    @@ -296,4 +298,55 @@ public void testQueryAttribute() {
                 Assert.assertEquals("Value was wrong", val, "{}");
             }
         }
    +    public void testQueryLocationConfig() {
    +        //Test EL
    +        Map attributes = new HashMap();
    +        attributes.put("field", "c");
    +        attributes.put("value", "4");
    +        String query = "{ \"${field}\": { \"$gte\": ${value}}}";
    +        runner.setProperty(GetMongo.QUERY, query);
    +        runner.setProperty(GetMongo.RESULTS_PER_FLOWFILE, "10");
    +        runner.setValidateExpressionUsage(true);
    +        runner.enqueue("test", attributes);
    +        runner.run(1, true, true);
    +
    +        runner.assertTransferCount(GetMongo.REL_FAILURE, 0);
    +        runner.assertTransferCount(GetMongo.REL_ORIGINAL, 1);
    +        runner.assertTransferCount(GetMongo.REL_SUCCESS, 1);
    +
    +        runner.clearTransferState();
    +
    +        query = "{ \"c\": { \"$gte\": 4 }}";
    +        runner.setProperty(GetMongo.QUERY, query);
    +        runner.run(1, true, true);
    +        runner.assertTransferCount(GetMongo.REL_FAILURE, 0);
    +        runner.assertTransferCount(GetMongo.REL_ORIGINAL, 0);
    +        runner.assertTransferCount(GetMongo.REL_SUCCESS, 1);
    +
    +        runner.clearTransferState();
    +
    +        runner.removeProperty(GetMongo.QUERY);
    +        runner.enqueue(query);
    +        runner.run(1, true, true);
    +
    +        runner.assertTransferCount(GetMongo.REL_FAILURE, 0);
    +        runner.assertTransferCount(GetMongo.REL_ORIGINAL, 1);
    +        runner.assertTransferCount(GetMongo.REL_SUCCESS, 1);
    +
    +        runner.clearTransferState();
    +
    +        boolean exception = false;
    +        try {
    +            runner.assertValid();
    +            runner.setIncomingConnection(false);
    +            runner.run(1, true, true);
    +        } catch (Throwable pe) {
    +            exception = true;
    +        }
    +
    +        Assert.assertTrue("No exception was thrown!", exception);
    --- End diff --
    
    After changing to throw a ProcessException, you could instead have an 
Exception object set to null (rather than a boolean set to false), then you can 
assertNotNull(exception) as well as assertTrue(exception instanceof 
ProcessException).


---

Reply via email to