@RunWithCustomExecutor @Test public void should_fatal_when_logbook_exception() throws Exception { HandlerIO handler = mock(HandlerIO.class); VitamThreadUtils.getVitamSession().setTenantId(0); VitamThreadUtils.getVitamSession().setRequestId(PROCESS_ID_OK); WorkerParameters workerParameters = WorkerParametersFactory.newWorkerParameters() .setWorkerGUID(GUIDFactory.newGUID().getId()) .setContainerName(VitamThreadUtils.getVitamSession().getRequestId()) .setRequestId(VitamThreadUtils.getVitamSession().getRequestId()) .setProcessId(VitamThreadUtils.getVitamSession().getRequestId()).setObjectId("0") .setCurrentStep("StepName"); workerParameters.putParameterValue(WorkerParameterName.auditActions, "AUDIT_FILE_EXISTING"); workerParameters.putParameterValue(WorkerParameterName.auditType, "tenant"); Mockito.doNothing().when(auditReportService).storeReportToWorkspace(reportInfosCaptor.capture()); when(logbookClient.selectOperationById(any())).thenThrow(new LogbookClientException("Logbook exception")); when(auditReportService.isReportWrittenInWorkspace(anyString())).thenReturn(false); ItemStatus response = auditFinalizePlugin.execute(workerParameters, handler); assertEquals(StatusCode.FATAL, response.getGlobalStatus()); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { generateAuditReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param); LOGGER.info("Audit object finalization succeeded"); return buildItemStatus(OBJECT_AUDIT_FINALIZE, StatusCode.OK, null); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Audit object finalization failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(OBJECT_AUDIT_FINALIZE, e.getStatusCode(), null); } }
AuditFinalizePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { generateAuditReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param); LOGGER.info("Audit object finalization succeeded"); return buildItemStatus(OBJECT_AUDIT_FINALIZE, StatusCode.OK, null); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Audit object finalization failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(OBJECT_AUDIT_FINALIZE, e.getStatusCode(), null); } } }
AuditFinalizePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { generateAuditReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param); LOGGER.info("Audit object finalization succeeded"); return buildItemStatus(OBJECT_AUDIT_FINALIZE, StatusCode.OK, null); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Audit object finalization failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(OBJECT_AUDIT_FINALIZE, e.getStatusCode(), null); } } AuditFinalizePlugin(); @VisibleForTesting  AuditFinalizePlugin(AuditReportService auditReportService,
        LogbookOperationsClientFactory logbookOperationsClientFactory); }
AuditFinalizePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { generateAuditReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param); LOGGER.info("Audit object finalization succeeded"); return buildItemStatus(OBJECT_AUDIT_FINALIZE, StatusCode.OK, null); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Audit object finalization failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(OBJECT_AUDIT_FINALIZE, e.getStatusCode(), null); } } AuditFinalizePlugin(); @VisibleForTesting  AuditFinalizePlugin(AuditReportService auditReportService,
        LogbookOperationsClientFactory logbookOperationsClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
AuditFinalizePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { generateAuditReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param); LOGGER.info("Audit object finalization succeeded"); return buildItemStatus(OBJECT_AUDIT_FINALIZE, StatusCode.OK, null); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Audit object finalization failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(OBJECT_AUDIT_FINALIZE, e.getStatusCode(), null); } } AuditFinalizePlugin(); @VisibleForTesting  AuditFinalizePlugin(AuditReportService auditReportService,
        LogbookOperationsClientFactory logbookOperationsClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }