@Test public void givenWorkspaceExistAndEmptyRulesButManagementRulesWhenExecuteThenReturnResponseOK() throws Exception { JsonNode archiveUnit_MGT_only = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(ARCHIVE_UNIT_RULE_MGT_ONLY)); action.getInput().clear(); action.getInput().add(archiveUnit_MGT_only); when(adminManagementClient.getRules(any())).thenReturn(getRulesInReferential()); final WorkerParameters params = WorkerParametersFactory.newWorkerParameters().setUrlWorkspace(FAKE_URL) .setUrlMetadata("http: .setObjectNameList(Lists.newArrayList("objectName")) .setObjectName("objectName").setCurrentStep("currentStep").setContainerName("containerName"); final ItemStatus response = plugin.execute(params, action); assertEquals(response.getGlobalStatus(), StatusCode.OK); JsonNode management = archiveUnit_MGT_only.get("ArchiveUnit").get("_mgt"); assertNotNull(management); assertNull(management.get("StorageRule")); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { LOGGER.debug("UNITS_RULES_COMPUTE in execute"); final long time = System.currentTimeMillis(); final ItemStatus itemStatus = new ItemStatus(CHECK_RULES_TASK_ID); try { calculateMaturityDate(params, itemStatus, handler); itemStatus.increment(StatusCode.OK); } catch (InvalidRuleException e) { itemStatus.increment(StatusCode.KO); UnitRulesComputeStatus status = e.getUnitRulesComputeStatus(); switch (status) { case REF_INCONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.setEvDetailData(e.getMessage()); itemStatus.increment(StatusCode.KO); break; case UNKNOWN: case CONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.increment(StatusCode.KO); ItemStatus is = new ItemStatus(status.name()); is.setEvDetailData(e.getMessage()); is.increment(StatusCode.KO); itemStatus.setSubTaskStatus(e.getObjectId(), is); itemStatus.setItemId(status.name()); return new ItemStatus(itemStatus.getItemId()).setItemsStatus(itemStatus.getItemId(), itemStatus); } } catch (final ProcessingException e) { LOGGER.debug(e); final ObjectNode object = JsonHandler.createObjectNode(); object.put("UnitRuleCompute", e.getMessage()); itemStatus.setEvDetailData(object.toString()); itemStatus.increment(StatusCode.KO); } LOGGER.debug("[exit] execute... /Elapsed Time:" + (System.currentTimeMillis() - time) / 1000 + "s"); return new ItemStatus(CHECK_RULES_TASK_ID).setItemsStatus(CHECK_RULES_TASK_ID, itemStatus); }
UnitsRulesComputePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { LOGGER.debug("UNITS_RULES_COMPUTE in execute"); final long time = System.currentTimeMillis(); final ItemStatus itemStatus = new ItemStatus(CHECK_RULES_TASK_ID); try { calculateMaturityDate(params, itemStatus, handler); itemStatus.increment(StatusCode.OK); } catch (InvalidRuleException e) { itemStatus.increment(StatusCode.KO); UnitRulesComputeStatus status = e.getUnitRulesComputeStatus(); switch (status) { case REF_INCONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.setEvDetailData(e.getMessage()); itemStatus.increment(StatusCode.KO); break; case UNKNOWN: case CONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.increment(StatusCode.KO); ItemStatus is = new ItemStatus(status.name()); is.setEvDetailData(e.getMessage()); is.increment(StatusCode.KO); itemStatus.setSubTaskStatus(e.getObjectId(), is); itemStatus.setItemId(status.name()); return new ItemStatus(itemStatus.getItemId()).setItemsStatus(itemStatus.getItemId(), itemStatus); } } catch (final ProcessingException e) { LOGGER.debug(e); final ObjectNode object = JsonHandler.createObjectNode(); object.put("UnitRuleCompute", e.getMessage()); itemStatus.setEvDetailData(object.toString()); itemStatus.increment(StatusCode.KO); } LOGGER.debug("[exit] execute... /Elapsed Time:" + (System.currentTimeMillis() - time) / 1000 + "s"); return new ItemStatus(CHECK_RULES_TASK_ID).setItemsStatus(CHECK_RULES_TASK_ID, itemStatus); } }
UnitsRulesComputePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { LOGGER.debug("UNITS_RULES_COMPUTE in execute"); final long time = System.currentTimeMillis(); final ItemStatus itemStatus = new ItemStatus(CHECK_RULES_TASK_ID); try { calculateMaturityDate(params, itemStatus, handler); itemStatus.increment(StatusCode.OK); } catch (InvalidRuleException e) { itemStatus.increment(StatusCode.KO); UnitRulesComputeStatus status = e.getUnitRulesComputeStatus(); switch (status) { case REF_INCONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.setEvDetailData(e.getMessage()); itemStatus.increment(StatusCode.KO); break; case UNKNOWN: case CONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.increment(StatusCode.KO); ItemStatus is = new ItemStatus(status.name()); is.setEvDetailData(e.getMessage()); is.increment(StatusCode.KO); itemStatus.setSubTaskStatus(e.getObjectId(), is); itemStatus.setItemId(status.name()); return new ItemStatus(itemStatus.getItemId()).setItemsStatus(itemStatus.getItemId(), itemStatus); } } catch (final ProcessingException e) { LOGGER.debug(e); final ObjectNode object = JsonHandler.createObjectNode(); object.put("UnitRuleCompute", e.getMessage()); itemStatus.setEvDetailData(object.toString()); itemStatus.increment(StatusCode.KO); } LOGGER.debug("[exit] execute... /Elapsed Time:" + (System.currentTimeMillis() - time) / 1000 + "s"); return new ItemStatus(CHECK_RULES_TASK_ID).setItemsStatus(CHECK_RULES_TASK_ID, itemStatus); } UnitsRulesComputePlugin(); @VisibleForTesting  UnitsRulesComputePlugin(AdminManagementClientFactory adminManagementClientFactory); }
UnitsRulesComputePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { LOGGER.debug("UNITS_RULES_COMPUTE in execute"); final long time = System.currentTimeMillis(); final ItemStatus itemStatus = new ItemStatus(CHECK_RULES_TASK_ID); try { calculateMaturityDate(params, itemStatus, handler); itemStatus.increment(StatusCode.OK); } catch (InvalidRuleException e) { itemStatus.increment(StatusCode.KO); UnitRulesComputeStatus status = e.getUnitRulesComputeStatus(); switch (status) { case REF_INCONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.setEvDetailData(e.getMessage()); itemStatus.increment(StatusCode.KO); break; case UNKNOWN: case CONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.increment(StatusCode.KO); ItemStatus is = new ItemStatus(status.name()); is.setEvDetailData(e.getMessage()); is.increment(StatusCode.KO); itemStatus.setSubTaskStatus(e.getObjectId(), is); itemStatus.setItemId(status.name()); return new ItemStatus(itemStatus.getItemId()).setItemsStatus(itemStatus.getItemId(), itemStatus); } } catch (final ProcessingException e) { LOGGER.debug(e); final ObjectNode object = JsonHandler.createObjectNode(); object.put("UnitRuleCompute", e.getMessage()); itemStatus.setEvDetailData(object.toString()); itemStatus.increment(StatusCode.KO); } LOGGER.debug("[exit] execute... /Elapsed Time:" + (System.currentTimeMillis() - time) / 1000 + "s"); return new ItemStatus(CHECK_RULES_TASK_ID).setItemsStatus(CHECK_RULES_TASK_ID, itemStatus); } UnitsRulesComputePlugin(); @VisibleForTesting  UnitsRulesComputePlugin(AdminManagementClientFactory adminManagementClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); }
UnitsRulesComputePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { LOGGER.debug("UNITS_RULES_COMPUTE in execute"); final long time = System.currentTimeMillis(); final ItemStatus itemStatus = new ItemStatus(CHECK_RULES_TASK_ID); try { calculateMaturityDate(params, itemStatus, handler); itemStatus.increment(StatusCode.OK); } catch (InvalidRuleException e) { itemStatus.increment(StatusCode.KO); UnitRulesComputeStatus status = e.getUnitRulesComputeStatus(); switch (status) { case REF_INCONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.setEvDetailData(e.getMessage()); itemStatus.increment(StatusCode.KO); break; case UNKNOWN: case CONSISTENCY: itemStatus.setGlobalOutcomeDetailSubcode(status.name()); itemStatus.increment(StatusCode.KO); ItemStatus is = new ItemStatus(status.name()); is.setEvDetailData(e.getMessage()); is.increment(StatusCode.KO); itemStatus.setSubTaskStatus(e.getObjectId(), is); itemStatus.setItemId(status.name()); return new ItemStatus(itemStatus.getItemId()).setItemsStatus(itemStatus.getItemId(), itemStatus); } } catch (final ProcessingException e) { LOGGER.debug(e); final ObjectNode object = JsonHandler.createObjectNode(); object.put("UnitRuleCompute", e.getMessage()); itemStatus.setEvDetailData(object.toString()); itemStatus.increment(StatusCode.KO); } LOGGER.debug("[exit] execute... /Elapsed Time:" + (System.currentTimeMillis() - time) / 1000 + "s"); return new ItemStatus(CHECK_RULES_TASK_ID).setItemsStatus(CHECK_RULES_TASK_ID, itemStatus); } UnitsRulesComputePlugin(); @VisibleForTesting  UnitsRulesComputePlugin(AdminManagementClientFactory adminManagementClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler);  }