@Test @RunWithCustomExecutor public void testExecute_EmptyResultSet_Warn() throws Exception { doReturn(PropertiesUtils .getResourceAsStream("EliminationAction/EliminationActionUnitPreparationHandler/request.json")) .when(handler).getInputStreamFromWorkspace(REQUEST_JSON); doReturn(JsonHandler.getFromInputStream(PropertiesUtils .getResourceAsStream( "EliminationAction/EliminationActionUnitPreparationHandler/emptyUnitsWithInheritedRules.json"))) .when(metaDataClient).selectUnitsWithInheritedRules(any()); ItemStatus itemStatus = instance.execute(params, handler); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.WARNING); EliminationEventDetails eventDetails = JsonHandler.getFromString(itemStatus.getEvDetailData(), EliminationEventDetails.class); assertThat(eventDetails.getExpirationDate()).isEqualTo("2015-01-01"); assertThat(eventDetails.getNbDestroyableUnits()).isEqualTo(0); assertThat(eventDetails.getNbNonDestroyableUnits()).isEqualTo(0); assertThat(reportEntries).hasSize(0); ArgumentCaptor<File> fileArgumentCaptor = ArgumentCaptor.forClass(File.class); verify(handler).transferFileToWorkspace( eq(UNITS_TO_DELETE_FILE), fileArgumentCaptor.capture(), eq(true), eq(false)); try (JsonLineGenericIterator<JsonLineModel> jsonLineIterator = new JsonLineGenericIterator<>( new FileInputStream(fileArgumentCaptor.getValue()), TYPE_REFERENCE)) { List<JsonLineModel> entries = IteratorUtils.toList(jsonLineIterator); assertThat(entries).isEmpty(); } }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); ItemStatus itemStatus = process(eliminationRequestBody, param, handler); LOGGER.info("Elimination action unit preparation succeeded"); return itemStatus; } catch (ProcessingStatusException e) { LOGGER.error("Elimination action unit preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ACTION_UNIT_PREPARATION, e.getStatusCode(), e.getEventDetails()); } }
EliminationActionUnitPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); ItemStatus itemStatus = process(eliminationRequestBody, param, handler); LOGGER.info("Elimination action unit preparation succeeded"); return itemStatus; } catch (ProcessingStatusException e) { LOGGER.error("Elimination action unit preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ACTION_UNIT_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } }
EliminationActionUnitPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); ItemStatus itemStatus = process(eliminationRequestBody, param, handler); LOGGER.info("Elimination action unit preparation succeeded"); return itemStatus; } catch (ProcessingStatusException e) { LOGGER.error("Elimination action unit preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ACTION_UNIT_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationActionUnitPreparationHandler(); @VisibleForTesting  EliminationActionUnitPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService,
        EliminationActionReportService eliminationActionReportService); }
EliminationActionUnitPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); ItemStatus itemStatus = process(eliminationRequestBody, param, handler); LOGGER.info("Elimination action unit preparation succeeded"); return itemStatus; } catch (ProcessingStatusException e) { LOGGER.error("Elimination action unit preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ACTION_UNIT_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationActionUnitPreparationHandler(); @VisibleForTesting  EliminationActionUnitPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService,
        EliminationActionReportService eliminationActionReportService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId(); }
EliminationActionUnitPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); ItemStatus itemStatus = process(eliminationRequestBody, param, handler); LOGGER.info("Elimination action unit preparation succeeded"); return itemStatus; } catch (ProcessingStatusException e) { LOGGER.error("Elimination action unit preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ACTION_UNIT_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationActionUnitPreparationHandler(); @VisibleForTesting  EliminationActionUnitPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService,
        EliminationActionReportService eliminationActionReportService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId();  }