esecules commented on code in PR #10079:
URL: https://github.com/apache/nifi/pull/10079#discussion_r2198218637
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/StandardNiFiServiceFacadeTest.java:
##########
@@ -1076,13 +1076,90 @@ public void testGetRuleViolationsForGroupIsRecursive()
throws Exception {
grandChildRuleViolation1, grandChildRuleViolation2,
grandChildRuleViolation3
));
+ when(processGroupDAO.getProcessGroup("root")).thenReturn(processGroup);
+ reset(ruleViolationsManager);
+ when(ruleViolationsManager.isEmpty()).thenReturn(false);
+
when(ruleViolationsManager.getAllRuleViolations()).thenReturn(expected);
+
+ // WHEN
+ Collection<RuleViolation> actual =
serviceFacade.getRuleViolationStream(processGroup.getIdentifier()).collect(Collectors.toSet());
+
+ // THEN
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testGetRuleViolationsEmpty() throws Exception {
+ // GIVEN
+ String groupId = "groupId";
+
+ ProcessGroup processGroup = mockProcessGroup(
+ groupId,
+ Arrays.asList(),
+ Arrays.asList()
+ );
+
+ Collection<RuleViolation> expected = new HashSet<>(List.of());
+
+ when(ruleViolationsManager.isEmpty()).thenReturn(true);
+
// WHEN
Collection<RuleViolation> actual =
serviceFacade.getRuleViolationStream(processGroup.getIdentifier()).collect(Collectors.toSet());
// THEN
assertEquals(expected, actual);
}
+ @Test
+ public void testGetRuleViolationsForGroupIsRecursive() throws Exception {
+ // GIVEN
+ int ruleViolationCounter = 0;
+
+ String groupId = "groupId";
+ String childGroupId = "childGroupId";
+ String grandChildGroupId = "grandChildGroupId";
+
+ RuleViolation ruleViolation1 = createRuleViolation(groupId,
ruleViolationCounter++);
+ RuleViolation ruleViolation2 = createRuleViolation(groupId,
ruleViolationCounter++);
+
+ RuleViolation childRuleViolation1 = createRuleViolation(childGroupId,
ruleViolationCounter++);
+ RuleViolation childRuleViolation2 = createRuleViolation(childGroupId,
ruleViolationCounter++);
+
+ RuleViolation grandChildRuleViolation1 =
createRuleViolation(grandChildGroupId, ruleViolationCounter++);
+ RuleViolation grandChildRuleViolation2 =
createRuleViolation(grandChildGroupId, ruleViolationCounter++);
+ RuleViolation grandChildRuleViolation3 =
createRuleViolation(grandChildGroupId, ruleViolationCounter++);
+
+ ProcessGroup grandChildProcessGroup = mockProcessGroup(
+ grandChildGroupId,
+ Collections.emptyList(),
+ Arrays.asList(grandChildRuleViolation1,
grandChildRuleViolation2, grandChildRuleViolation3)
+ );
+ ProcessGroup childProcessGroup = mockProcessGroup(
+ childGroupId,
+ Arrays.asList(grandChildProcessGroup),
+ Arrays.asList(childRuleViolation1, childRuleViolation2)
+ );
+ ProcessGroup processGroup = mockProcessGroup(
+ groupId,
+ Arrays.asList(childProcessGroup),
+ Arrays.asList(ruleViolation1, ruleViolation2)
+ );
+
+ Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
+ childRuleViolation1, childRuleViolation2,
+ grandChildRuleViolation1, grandChildRuleViolation2,
grandChildRuleViolation3
+ ));
+
+
when(processGroupDAO.getProcessGroup(groupId)).thenReturn(processGroup);
+ when(ruleViolationsManager.isEmpty()).thenReturn(false);
Review Comment:
Thanks for the suggestions and explanation.
--
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]