@Test @RunWithCustomExecutor public void testExecute_OK() throws Exception { givenValidRequestJson(); List<JsonNode> unitsWithInheritedRules = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream("EliminationAnalysis/PreparationUnitsWithInheritedRules.json"), List.class, JsonNode.class); doReturn(new RequestResponseOK<JsonNode>().addAllResults(unitsWithInheritedRules).toJsonNode()) .when(metaDataClient).selectUnitsWithInheritedRules(any()); ItemStatus execute = instance.execute(parameters, handlerIO); assertThat(execute.getGlobalStatus()).isEqualTo(StatusCode.OK); assertThat(writtenFiles).hasSize(1); try (BufferedReader reader = new BufferedReader(new InputStreamReader(writtenFiles.get("units.jsonl")))) { JsonNode actual_unit1 = JsonHandler.getFromString(reader.readLine()); JsonNode actual_unit2 = JsonHandler.getFromString(reader.readLine()); assertJsonEquals("EliminationAnalysis/PreparationExpectedDistribution_unit1.json", actual_unit1); assertJsonEquals("EliminationAnalysis/PreparationExpectedDistribution_unit2.json", actual_unit2); assertThat(reader.readLine()).isNull(); } }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); process(eliminationRequestBody, param, handler); LOGGER.info("Elimination analysis preparation succeeded"); EliminationEventDetails eventDetails = new EliminationEventDetails() .setExpirationDate(eliminationRequestBody.getDate()); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, StatusCode.OK, eventDetails); } catch (ProcessingStatusException e) { LOGGER.error("Elimination analysis preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, e.getStatusCode(), e.getEventDetails()); } }
EliminationAnalysisPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); process(eliminationRequestBody, param, handler); LOGGER.info("Elimination analysis preparation succeeded"); EliminationEventDetails eventDetails = new EliminationEventDetails() .setExpirationDate(eliminationRequestBody.getDate()); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, StatusCode.OK, eventDetails); } catch (ProcessingStatusException e) { LOGGER.error("Elimination analysis preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } }
EliminationAnalysisPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); process(eliminationRequestBody, param, handler); LOGGER.info("Elimination analysis preparation succeeded"); EliminationEventDetails eventDetails = new EliminationEventDetails() .setExpirationDate(eliminationRequestBody.getDate()); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, StatusCode.OK, eventDetails); } catch (ProcessingStatusException e) { LOGGER.error("Elimination analysis preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationAnalysisPreparationHandler(); @VisibleForTesting  EliminationAnalysisPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService); }
EliminationAnalysisPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); process(eliminationRequestBody, param, handler); LOGGER.info("Elimination analysis preparation succeeded"); EliminationEventDetails eventDetails = new EliminationEventDetails() .setExpirationDate(eliminationRequestBody.getDate()); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, StatusCode.OK, eventDetails); } catch (ProcessingStatusException e) { LOGGER.error("Elimination analysis preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationAnalysisPreparationHandler(); @VisibleForTesting  EliminationAnalysisPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId(); }
EliminationAnalysisPreparationHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { EliminationRequestBody eliminationRequestBody = loadRequestJsonFromWorkspace(handler); process(eliminationRequestBody, param, handler); LOGGER.info("Elimination analysis preparation succeeded"); EliminationEventDetails eventDetails = new EliminationEventDetails() .setExpirationDate(eliminationRequestBody.getDate()); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, StatusCode.OK, eventDetails); } catch (ProcessingStatusException e) { LOGGER.error("Elimination analysis preparation failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(ELIMINATION_ANALYSIS_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } EliminationAnalysisPreparationHandler(); @VisibleForTesting  EliminationAnalysisPreparationHandler(
        MetaDataClientFactory metaDataClientFactory,
        EliminationAnalysisService eliminationAnalysisService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId();  }