### Question:
AgendaProgressTimeoutConsumer implements Consumer<String> { protected boolean updateAgendaProgress(String agendaProgressId) { AgendaProgress agendaProgress = retrieveAgendaProgress(agendaProgressId); if(agendaProgress == null) return false; AgendaProgress updatedAgendaProgress = new AgendaProgress(); updatedAgendaProgress.setId(agendaProgressId); updatedAgendaProgress.setCustomerId(agendaProgress.getCustomerId()); updatedAgendaProgress.setProcessingState(ProcessingState.COMPLETE); updatedAgendaProgress.setProcessingStateMessage(CompleteStateMessage.FAILED.toString()); DiagnosticEvent diagnosticEvent = new DiagnosticEvent("AgendaProgress timed out."); DiagnosticEvent[] existingDiagnosticEvents = agendaProgress.getDiagnosticEvents(); if(existingDiagnosticEvents == null) updatedAgendaProgress.setDiagnosticEvents(new DiagnosticEvent[]{ diagnosticEvent }); else { LinkedList<DiagnosticEvent> existingEvents = new LinkedList<>(Arrays.asList(existingDiagnosticEvents)); existingEvents.add(diagnosticEvent); updatedAgendaProgress.setDiagnosticEvents(existingEvents.toArray(new DiagnosticEvent[0])); } try { logger.info("Reclaiming Agenda: {} Updating AgendaProgress: {}", agendaProgress.getAgendaId(), updatedAgendaProgress.getId()); if(!logReclaimOnly) agendaProgressClient.updateObject(updatedAgendaProgress, updatedAgendaProgress.getId()); } catch (Exception e) { logger.error(String.format("Failed to reclaim Agenda: %1$s", agendaProgress.getAgendaId()), e); return false; } return true; } AgendaProgressTimeoutConsumer(HttpObjectClient<AgendaProgress> agendaProgressClient); @Override ConsumerResult<String> consume(Collection<String> collection, Instant endProcessingInstant); boolean getLogReclaimOnly(); AgendaProgressTimeoutConsumer setLogReclaimOnly(boolean logReclaimOnly);  }### Answer:
@Test public void testUpdateAgendaProgressException() { doThrow(new RuntimeException()).when(mockAgendaProgressClient).updateObject(any(), any()); Assert.assertFalse(consumer.updateAgendaProgress(AGENDA_PROGRESS_ID)); verify(mockAgendaProgressClient, times(1)).updateObject(any(), any()); }
@Test(dataProvider = "updateAgendaProgressProvider") public void testUpdateAgendaProgress(AgendaProgress existingProgress) { final String AGENDA_PROGRESS_ID = "0"; final int EXPECTED_DIAGNOSTICS_COUNT = existingProgress.getDiagnosticEvents() == null ? 1 : existingProgress.getDiagnosticEvents().length + 1; doReturn(createResponse(existingProgress)).when(mockAgendaProgressClient).getObject(anyString()); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { AgendaProgress agendaProgress = (AgendaProgress)invocationOnMock.getArguments()[0]; Assert.assertEquals(ProcessingState.COMPLETE, agendaProgress.getProcessingState()); Assert.assertEquals(CompleteStateMessage.FAILED.toString(), agendaProgress.getProcessingStateMessage()); Assert.assertNotNull(agendaProgress.getDiagnosticEvents()); Assert.assertEquals(agendaProgress.getDiagnosticEvents().length, EXPECTED_DIAGNOSTICS_COUNT); return new DefaultDataObjectResponse<AgendaProgress>(); } }).when(mockAgendaProgressClient).updateObject(any(), any()); Assert.assertTrue(consumer.updateAgendaProgress(AGENDA_PROGRESS_ID)); verify(mockAgendaProgressClient, times(1)).updateObject(any(), any()); }