exceptionfactory commented on code in PR #10699:
URL: https://github.com/apache/nifi/pull/10699#discussion_r2651848102
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java:
##########
@@ -502,6 +506,98 @@ public void testActivateControllerServicesStateEnabled() {
assertEquals(expectedServicesIds, serviceIds);
}
+ @Test
+ public void testClearBulletinsIncludesControllerServices() {
+ // This test verifies that when clearing bulletins for a process group,
+ // controller services are included in the components to clear
+
+ // Create a mock process group with processors, ports, and controller
services
+ final ProcessGroup processGroup = mock(ProcessGroup.class);
+
+ // Mock a processor with write permissions
+ final ProcessorNode processor = mock(ProcessorNode.class);
+ when(processor.getIdentifier()).thenReturn("processor-1");
+ when(processor.isAuthorized(any(), any(), any())).thenReturn(true);
+
+ // Mock an input port with write permissions
+ final Port inputPort = mock(Port.class);
+ when(inputPort.getIdentifier()).thenReturn("input-port-1");
+ when(inputPort.isAuthorized(any(), any(), any())).thenReturn(true);
+
+ // Mock an output port with write permissions
+ final Port outputPort = mock(Port.class);
+ when(outputPort.getIdentifier()).thenReturn("output-port-1");
+ when(outputPort.isAuthorized(any(), any(), any())).thenReturn(true);
+
+ // Mock a remote process group
+ final RemoteProcessGroup remoteProcessGroup =
mock(RemoteProcessGroup.class);
+ when(remoteProcessGroup.getIdentifier()).thenReturn("rpg-1");
+ when(remoteProcessGroup.isAuthorized(any(), any(),
any())).thenReturn(true);
+
+ // Mock a controller service with write permissions
+ final ControllerServiceNode controllerService =
mock(ControllerServiceNode.class);
+
when(controllerService.getIdentifier()).thenReturn("controller-service-1");
+ when(controllerService.isAuthorized(any(), any(),
any())).thenReturn(true);
+
+ // Mock another controller service without write permissions (should
be excluded)
+ final ControllerServiceNode unauthorizedControllerService =
mock(ControllerServiceNode.class);
+ // Use lenient because getIdentifier() won't be called for
unauthorized components
+
lenient().when(unauthorizedControllerService.getIdentifier()).thenReturn("controller-service-2");
+ when(unauthorizedControllerService.isAuthorized(any(), any(),
any())).thenReturn(false);
+
+ // Set up the process group to return all components
+ when(processGroup.findAllProcessors()).thenReturn(List.of(processor));
+ when(processGroup.findAllInputPorts()).thenReturn(List.of(inputPort));
+
when(processGroup.findAllOutputPorts()).thenReturn(List.of(outputPort));
+
when(processGroup.findAllRemoteProcessGroups()).thenReturn(List.of(remoteProcessGroup));
+
when(processGroup.findAllControllerServices()).thenReturn(Set.of(controllerService,
unauthorizedControllerService));
+
+ // Create a function that simulates the component gathering logic in
clearBulletins
+ // This mirrors the logic in FlowResource.clearBulletins when
components are null
+ final Function<ProcessGroup, Set<String>> gatherComponentsFunction =
group -> {
Review Comment:
Is this function needed? It seems that the set of component IDs could be
defined directly instead of calling this function.
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java:
##########
@@ -502,6 +506,98 @@ public void testActivateControllerServicesStateEnabled() {
assertEquals(expectedServicesIds, serviceIds);
}
+ @Test
+ public void testClearBulletinsIncludesControllerServices() {
Review Comment:
This method does not call `clearBulletins`, so it does not seem to be
verifying the changes.
--
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]