exceptionfactory commented on code in PR #5978:
URL: https://github.com/apache/nifi/pull/5978#discussion_r859933202
##########
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:
Setting the run schedule should not be necessary.
##########
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:
Running the processor makes a request to the Twitter API that results in an
HTTP 401 Unauthorized response. For this reason, tests that make calls to the
Twitter service should be avoided.
--
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]