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/03 23:15:05 UTC

[GitHub] [nifi] patalwell commented on a diff in pull request #5905: NiFi-9817 Add a Validator for the PutCloudWatchMetric Processor's Unit Field

patalwell commented on code in PR #5905:
URL: https://github.com/apache/nifi/pull/5905#discussion_r864325036


##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/cloudwatch/TestPutCloudWatchMetric.java:
##########
@@ -264,27 +265,34 @@ public void testMetricExpressionInvalidRoutesToFailure() throws Exception {
         runner.enqueue(new byte[] {}, attributes);
         runner.run();
 
-        assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
+        Assert.assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
         runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
     }
 
-    @Test
-    public void testInvalidUnitRoutesToFailure() throws Exception {
+    @ParameterizedTest
+    @CsvSource({"nan","percent","count"})
+    public void testInvalidUnit(String unit) throws Exception {
         MockPutCloudWatchMetric mockPutCloudWatchMetric = new MockPutCloudWatchMetric();
-        mockPutCloudWatchMetric.throwException = new InvalidParameterValueException("Unit error message");
         final TestRunner runner = TestRunners.newTestRunner(mockPutCloudWatchMetric);
 
         runner.setProperty(PutCloudWatchMetric.NAMESPACE, "TestNamespace");
         runner.setProperty(PutCloudWatchMetric.METRIC_NAME, "TestMetric");
-        runner.setProperty(PutCloudWatchMetric.UNIT, "BogusUnit");
-        runner.setProperty(PutCloudWatchMetric.VALUE, "1");
-        runner.assertValid();
+        runner.setProperty(PutCloudWatchMetric.UNIT, unit);
+        runner.setProperty(PutCloudWatchMetric.VALUE, "1.0");
+        runner.assertNotValid();
+    }
 
-        runner.enqueue(new byte[] {});
-        runner.run();
+    @ParameterizedTest
+    @CsvSource({"Count","Bytes","Percent"})

Review Comment:
   Done :)



-- 
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