### Question:
AgendaProgressProcessor { public void process(AgendaProgress eventAgendaProgress) { if(eventAgendaProgress == null) return; AgendaProgress agendaProgress = getAgendaProgress(eventAgendaProgress); if(agendaProgress != null && shouldRetry(agendaProgress)) { retryAgenda(agendaProgress); } } AgendaProgressProcessor(AgendaServiceClient agendaServiceClient, ObjectClient<AgendaProgress> agendaProgressClient); void process(AgendaProgress eventAgendaProgress);  }### Answer:
@Test(dataProvider = "ignoredProgressStateProvider") public void testIgnoredAgendaProgressState(AgendaProgress agendaProgress) { doReturn(createDataObjectResponse(agendaProgress)).when(mockAgendaProgressClient).getObject(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(0)).rerunAgenda(any()); }
@Test(dataProvider = "rerunProgressStateProvider") public void testRerunAgendaProgressState(AgendaProgress agendaProgress) { doReturn(createDataObjectResponse(agendaProgress)).when(mockAgendaProgressClient).getObject(any()); doReturn(new RerunAgendaResponse()).when(mockAgendaServiceClient).rerunAgenda(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(1)).rerunAgenda(any()); }
@Test public void testErrorRetrievingAgendaProgress() { AgendaProgress agendaProgress = createAgendaProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.toString(), 0, 3); DataObjectResponse<AgendaProgress> response = new DefaultDataObjectResponse<>(); response.setErrorResponse(ErrorResponseFactory.runtimeServiceException("", "")); doReturn(response).when(mockAgendaProgressClient).getObject(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(0)).rerunAgenda(any()); }
@Test public void testMissingAgendaProgress() { AgendaProgress agendaProgress = createAgendaProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.toString(), 0, 3); doReturn(new DefaultDataObjectResponse<>()).when(mockAgendaProgressClient).getObject(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(0)).rerunAgenda(any()); }
@Test public void testReigniteCallError() { AgendaProgress agendaProgress = createAgendaProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.toString(), 0, 3); RerunAgendaResponse rerunAgendaResponse = new RerunAgendaResponse(); rerunAgendaResponse.setErrorResponse(ErrorResponseFactory.runtimeServiceException("", "")); doReturn(createDataObjectResponse(agendaProgress)).when(mockAgendaProgressClient).getObject(any()); doReturn(rerunAgendaResponse).when(mockAgendaServiceClient).rerunAgenda(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(1)).rerunAgenda(any()); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Failed to call reignite for Agenda.*") public void testRerunException() { AgendaProgress agendaProgress = createAgendaProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.toString(), 0, 3); doReturn(createDataObjectResponse(agendaProgress)).when(mockAgendaProgressClient).getObject(any()); doThrow(new RuntimeException("RerunException")).when(mockAgendaServiceClient).rerunAgenda(any()); processor.process(agendaProgress); verify(mockAgendaServiceClient, times(1)).rerunAgenda(any()); }