@Test @RunWithCustomExecutor public void should_backup_existing_report_when_report_already_stored_in_workspace() throws Exception { String containerName = "MyContainerName"; HandlerIO handler = mock(HandlerIO.class); doReturn(true).when(handler).isExistingFileInWorkspace(containerName + JSON); doReturn(containerName).when(handler).getContainerName(); WorkerParameters build = workerParameterBuilder() .withContainerName(containerName) .build(); probativeCreateReport.execute(build, handler); verify(handler, never()).getFileFromWorkspace(any()); verify(handler, never()).transferAtomicFileToWorkspace(anyString(), any()); verify(backupService) .storeIntoOffers(eq(containerName), eq(containerName + JSON), eq(REPORT), eq(containerName + JSON), eq(VitamConfiguration.getDefaultStrategy())); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String reportFileName = param.getContainerName() + JSON; generateReportToWorkspace(param, handler, reportFileName); storeReportToOffers(handler, reportFileName); return buildItemStatusWithMasterData(HANDLER_ID, StatusCode.OK, EventDetails.of("Probative value report success."), JsonHandler.unprettyPrint(REPORT_VERSION_2)); } catch (Exception e) { LOGGER.error(e); return buildItemStatus(HANDLER_ID, StatusCode.FATAL, EventDetails.of("Probative value report error.")); } }
ProbativeCreateReport extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String reportFileName = param.getContainerName() + JSON; generateReportToWorkspace(param, handler, reportFileName); storeReportToOffers(handler, reportFileName); return buildItemStatusWithMasterData(HANDLER_ID, StatusCode.OK, EventDetails.of("Probative value report success."), JsonHandler.unprettyPrint(REPORT_VERSION_2)); } catch (Exception e) { LOGGER.error(e); return buildItemStatus(HANDLER_ID, StatusCode.FATAL, EventDetails.of("Probative value report error.")); } } }
ProbativeCreateReport extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String reportFileName = param.getContainerName() + JSON; generateReportToWorkspace(param, handler, reportFileName); storeReportToOffers(handler, reportFileName); return buildItemStatusWithMasterData(HANDLER_ID, StatusCode.OK, EventDetails.of("Probative value report success."), JsonHandler.unprettyPrint(REPORT_VERSION_2)); } catch (Exception e) { LOGGER.error(e); return buildItemStatus(HANDLER_ID, StatusCode.FATAL, EventDetails.of("Probative value report error.")); } } @VisibleForTesting  ProbativeCreateReport(BackupService backupService);  ProbativeCreateReport(); }
ProbativeCreateReport extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String reportFileName = param.getContainerName() + JSON; generateReportToWorkspace(param, handler, reportFileName); storeReportToOffers(handler, reportFileName); return buildItemStatusWithMasterData(HANDLER_ID, StatusCode.OK, EventDetails.of("Probative value report success."), JsonHandler.unprettyPrint(REPORT_VERSION_2)); } catch (Exception e) { LOGGER.error(e); return buildItemStatus(HANDLER_ID, StatusCode.FATAL, EventDetails.of("Probative value report error.")); } } @VisibleForTesting  ProbativeCreateReport(BackupService backupService);  ProbativeCreateReport(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
ProbativeCreateReport extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String reportFileName = param.getContainerName() + JSON; generateReportToWorkspace(param, handler, reportFileName); storeReportToOffers(handler, reportFileName); return buildItemStatusWithMasterData(HANDLER_ID, StatusCode.OK, EventDetails.of("Probative value report success."), JsonHandler.unprettyPrint(REPORT_VERSION_2)); } catch (Exception e) { LOGGER.error(e); return buildItemStatus(HANDLER_ID, StatusCode.FATAL, EventDetails.of("Probative value report error.")); } } @VisibleForTesting  ProbativeCreateReport(BackupService backupService);  ProbativeCreateReport(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }