@Test @RunWithCustomExecutor public void checkEligibilityWithWarningThanWarning() throws Exception { doAnswer(args -> { ((CleanupReportManager)args.getArgument(1)).reportUnitWarning("unit1", "message"); return null; }).when(ingestCleanupEligibilityService).checkUnitUpdatesFromOtherOperations(any(), any()); ItemStatus itemStatus = instance.execute(params, handler); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.WARNING); Optional<CleanupReportManager> cleanupReportManager = CleanupReportManager.loadReportDataFromWorkspace(handler); assertThat(cleanupReportManager.isPresent()).isTrue(); assertThat(cleanupReportManager.get().getGlobalStatus()).isEqualTo(StatusCode.WARNING); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); CleanupReportManager cleanupReportManager = CleanupReportManager.newReport(ingestOperationId); checkUnits(ingestOperationId, cleanupReportManager); checkObjectGroups(ingestOperationId, cleanupReportManager); cleanupReportManager.persistReportDataToWorkspace(handler); StatusCode globalStatusCode = cleanupReportManager.getGlobalStatus(); if (globalStatusCode.isGreaterOrEqualToKo()) { LOGGER.error("Blocking validation errors..."); } else if (globalStatusCode.isGreaterOrEqualToWarn()) { LOGGER.warn("Non blocking validation errors..."); } else { LOGGER.info("Ingest cleanup eligibility validation succeeded"); } return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, globalStatusCode); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Cleanup eligibility validation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, e.getStatusCode(), e.getEventDetails()); } }
IngestCleanupEligibilityValidationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); CleanupReportManager cleanupReportManager = CleanupReportManager.newReport(ingestOperationId); checkUnits(ingestOperationId, cleanupReportManager); checkObjectGroups(ingestOperationId, cleanupReportManager); cleanupReportManager.persistReportDataToWorkspace(handler); StatusCode globalStatusCode = cleanupReportManager.getGlobalStatus(); if (globalStatusCode.isGreaterOrEqualToKo()) { LOGGER.error("Blocking validation errors..."); } else if (globalStatusCode.isGreaterOrEqualToWarn()) { LOGGER.warn("Non blocking validation errors..."); } else { LOGGER.info("Ingest cleanup eligibility validation succeeded"); } return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, globalStatusCode); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Cleanup eligibility validation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, e.getStatusCode(), e.getEventDetails()); } } }
IngestCleanupEligibilityValidationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); CleanupReportManager cleanupReportManager = CleanupReportManager.newReport(ingestOperationId); checkUnits(ingestOperationId, cleanupReportManager); checkObjectGroups(ingestOperationId, cleanupReportManager); cleanupReportManager.persistReportDataToWorkspace(handler); StatusCode globalStatusCode = cleanupReportManager.getGlobalStatus(); if (globalStatusCode.isGreaterOrEqualToKo()) { LOGGER.error("Blocking validation errors..."); } else if (globalStatusCode.isGreaterOrEqualToWarn()) { LOGGER.warn("Non blocking validation errors..."); } else { LOGGER.info("Ingest cleanup eligibility validation succeeded"); } return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, globalStatusCode); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Cleanup eligibility validation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupEligibilityValidationPlugin(); @VisibleForTesting  IngestCleanupEligibilityValidationPlugin(IngestCleanupEligibilityService ingestCleanupEligibilityService); }
IngestCleanupEligibilityValidationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); CleanupReportManager cleanupReportManager = CleanupReportManager.newReport(ingestOperationId); checkUnits(ingestOperationId, cleanupReportManager); checkObjectGroups(ingestOperationId, cleanupReportManager); cleanupReportManager.persistReportDataToWorkspace(handler); StatusCode globalStatusCode = cleanupReportManager.getGlobalStatus(); if (globalStatusCode.isGreaterOrEqualToKo()) { LOGGER.error("Blocking validation errors..."); } else if (globalStatusCode.isGreaterOrEqualToWarn()) { LOGGER.warn("Non blocking validation errors..."); } else { LOGGER.info("Ingest cleanup eligibility validation succeeded"); } return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, globalStatusCode); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Cleanup eligibility validation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupEligibilityValidationPlugin(); @VisibleForTesting  IngestCleanupEligibilityValidationPlugin(IngestCleanupEligibilityService ingestCleanupEligibilityService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
IngestCleanupEligibilityValidationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); CleanupReportManager cleanupReportManager = CleanupReportManager.newReport(ingestOperationId); checkUnits(ingestOperationId, cleanupReportManager); checkObjectGroups(ingestOperationId, cleanupReportManager); cleanupReportManager.persistReportDataToWorkspace(handler); StatusCode globalStatusCode = cleanupReportManager.getGlobalStatus(); if (globalStatusCode.isGreaterOrEqualToKo()) { LOGGER.error("Blocking validation errors..."); } else if (globalStatusCode.isGreaterOrEqualToWarn()) { LOGGER.warn("Non blocking validation errors..."); } else { LOGGER.info("Ingest cleanup eligibility validation succeeded"); } return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, globalStatusCode); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Cleanup eligibility validation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_ELIGIBILITY_VALIDATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupEligibilityValidationPlugin(); @VisibleForTesting  IngestCleanupEligibilityValidationPlugin(IngestCleanupEligibilityService ingestCleanupEligibilityService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }