aksharau commented on code in PR #6335: URL: https://github.com/apache/nifi/pull/6335#discussion_r971684738
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/StandardNiFiServiceFacadeTest.java: ########## @@ -555,4 +583,179 @@ private RemoteProcessGroupDTO createRemoteProcessGroupDTO(String id, boolean tra return remoteProcessGroup; } + + + @Test + public void testUpdateProcessGroup_WithProcessorBulletin() { + //GIVEN + final String groupId = UUID.randomUUID().toString(); + final ProcessGroup processGroup = mock(ProcessGroup.class); + when(processGroup.getIdentifier()).thenReturn(groupId); + + ProcessGroupStatus processGroupStatus = new ProcessGroupStatus(); + processGroupStatus.setId(groupId); + processGroupStatus.setName(GROUP_NAME_1); + + final ControllerFacade controllerFacade = mock(ControllerFacade.class); + when(controllerFacade.getProcessGroupStatus(any())).thenReturn(processGroupStatus); + + final StandardNiFiServiceFacade serviceFacadeSpy = spy(serviceFacade); + serviceFacadeSpy.setControllerFacade(controllerFacade); + final DtoFactory dtoFactory = new DtoFactory(); + ProcessGroupDTO processGroupDTO = new ProcessGroupDTO(); + processGroupDTO.setId(groupId); + when(processGroupDAO.getProcessGroup(groupId)).thenReturn(processGroup); + when(processGroupDAO.updateProcessGroup(processGroupDTO)).thenReturn(processGroup); + + final RevisionManager revisionManager = mock(RevisionManager.class); + Revision revision = new Revision(1L,"a","b"); + final FlowModification lastModification = new FlowModification(revision,"a"); + RevisionUpdate<Object> snapshot = new StandardRevisionUpdate<>(processGroupDTO,lastModification); + when(revisionManager.updateRevision(any(),any(),any())).thenReturn((RevisionUpdate<Object> )snapshot); + serviceFacadeSpy.setRevisionManager(revisionManager); + serviceFacadeSpy.setDtoFactory(dtoFactory); + + MockTestBulletinRepository bulletinRepository = new MockTestBulletinRepository(); + serviceFacadeSpy.setBulletinRepository(bulletinRepository); + bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, GROUP_NAME_1, PROCESSOR_ID_1, + ComponentType.PROCESSOR,PROCESSOR_NAME_1,BULLETIN_CATEGORY,BULLETIN_SEVERITY,BULLETIN_MESSAGE_1,PATH_TO_GROUP_1)); + bulletinRepository.addBulletin(BulletinFactory.createBulletin(RANDOM_GROUP_ID,GROUP_NAME_2, PROCESSOR_ID_2, + ComponentType.PROCESSOR,PROCESSOR_NAME_2, BULLETIN_CATEGORY,BULLETIN_SEVERITY, BULLETIN_MESSAGE_2,PATH_TO_GROUP_2)); + //WHEN Review Comment: done, I split it to multiple lines also added comments -- 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-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org