[ https://issues.apache.org/jira/browse/NIFI-4827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16373120#comment-16373120 ]
ASF GitHub Bot commented on NIFI-4827: -------------------------------------- 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). > Make GetMongo able to use flowfiles for queries > ----------------------------------------------- > > Key: NIFI-4827 > URL: https://issues.apache.org/jira/browse/NIFI-4827 > Project: Apache NiFi > Issue Type: Improvement > Reporter: Mike Thomsen > Assignee: Mike Thomsen > Priority: Minor > > GetMongo should be able to retrieve a valid query from the flowfile content > or allow the incoming flowfile to provide attributes to power EL statements > in the Query configuration field. Allowing the body to be used would allow > GetMongo to be used in a much more generic way. -- This message was sent by Atlassian JIRA (v7.6.3#76005)