pymoura commented on code in PR #5978:
URL: https://github.com/apache/nifi/pull/5978#discussion_r873111445


##########
nifi-nar-bundles/nifi-social-media-bundle/nifi-twitter-processors/src/test/java/org/apache/nifi/processors/twitter/TestGetTwitter.java:
##########
@@ -86,4 +90,156 @@ public void 
testLocationValidatorWithSWLonGreaterThanNELon() {
         runner.setProperty(GetTwitter.LOCATIONS, 
"-122.75,36.8,-121.75,37.8,-74,40,-75,41");
         runner.assertNotValid();
     }
-}
+
+
+    // To test getSupportedDynamicPropertyDescriptor
+    @Test
+    public void testValidGetSupportedDynamicPropertyDescriptor() {
+        runner.setProperty(GetTwitter.MAX_CLIENT_ERROR_RETRIES, "5");
+        runner.setProperty(GetTwitter.CONSUMER_KEY, "consumerKey");
+        runner.setProperty(GetTwitter.CONSUMER_SECRET, "consumerSecret");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN, "accessToken");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN_SECRET, 
"accessTokenSecret");
+        PropertyDescriptor dynamicProperty = new PropertyDescriptor.Builder()
+                .name("foo")
+                .description("Adds a query parameter with name '" + "foo" + "' 
to the Twitter query")
+                .required(false)
+                .dynamic(true)
+                .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+                .build();
+        runner.setProperty(dynamicProperty, "{\"a\": \"a\"}");
+        runner.assertValid();
+    }
+
+
+    // To test customValidate - lines 222 to 224
+    @Test
+    public void testCustomValidatorWithoutTermsFollowingLocation() {
+        runner.setProperty(GetTwitter.ENDPOINT, GetTwitter.ENDPOINT_FILTER);
+        runner.setProperty(GetTwitter.MAX_CLIENT_ERROR_RETRIES, "5");
+        runner.setProperty(GetTwitter.CONSUMER_KEY, "consumerKey");
+        runner.setProperty(GetTwitter.CONSUMER_SECRET, "consumerSecret");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN, "accessToken");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN_SECRET, 
"accessTokenSecret");
+        runner.assertNotValid();
+    }
+
+    // To test onScheduled using ENDPOINT_SAMPLE and language
+    @Test
+    public void testRunsOnSchedulerEndpointSampleAndLanguage() {
+        runner.setProperty(GetTwitter.ENDPOINT, GetTwitter.ENDPOINT_SAMPLE);
+        runner.setProperty(GetTwitter.MAX_CLIENT_ERROR_RETRIES, "5");
+        runner.setProperty(GetTwitter.CONSUMER_KEY, "consumerKey");
+        runner.setProperty(GetTwitter.CONSUMER_SECRET, "consumerSecret");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN, "accessToken");
+        runner.setProperty(GetTwitter.ACCESS_TOKEN_SECRET, 
"accessTokenSecret");
+        runner.setProperty(GetTwitter.LANGUAGES, "en, pt, it");
+        runner.assertValid();
+
+        runner.setRunSchedule(30000);
+        runner.run(1);

Review Comment:
   Added Mock for Client and messageQueue instead to avoid make calls to the 
Twitter service 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to