@Test @RunWithCustomExecutor public void should_return_item_status_KO_when_cannot_deserialize_report_entry() throws Exception { String probativeEntryIdInDistributionFile = "BATMAN_GOT_ID"; PreservationRequest request = new PreservationRequest(); Map<String, List<Integer>> notReportEntryObject = new HashMap<>(); notReportEntryObject.put("unitId", Arrays.asList(1, 2, 3)); notReportEntryObject.put("objectGroupId", Arrays.asList(1, 2, 3)); TestHandlerIO handler = new TestHandlerIO(); handler.transferFileToWorkspace("request", pojoToFile(request), false, false); handler.setInputStreamFromWorkspace( writeDistributionFile(new JsonLineModel(probativeEntryIdInDistributionFile, 0, null))); handler.transferFileToWorkspace(probativeEntryIdInDistributionFile, pojoToFile(notReportEntryObject), false, false); handler.setNewLocalFile(tempFolder.newFile(GUIDFactory.newGUID().getId())); String containerName = handler.getContainerName(); WorkerParameters build = workerParameterBuilder() .withContainerName(containerName) .build(); ItemStatus itemStatus = probativeCreateReport.execute(build, handler); assertThat(itemStatus.getGlobalStatus()).isEqualTo(FATAL); }
@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);  }