You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/05/15 05:26:30 UTC

[GitHub] [nifi] pymoura commented on a diff in pull request #5978: NIFI-9867 Adding new tests to increase Test Coverage of GetTwitter processor

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


##########
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);

Review Comment:
   Removed it. 



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org