@Test public void givenRunningProcessWhenExecuteThenReturnResponseOK() throws Exception { action.addOutIOParameters(out); try (InputStream updatedRules = PropertiesUtils.getResourceAsStream(UPDATED_RULES_JSON)) { final JsonNode archiveUnitsToBeUpdated = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(UPDATED_AU)); when(workspaceClient.getObject(any(), eq("PROCESSING/updatedRules.json"))).thenReturn(Response.status(Status.OK).entity(updatedRules).build()); when(metadataClient.selectUnits(any())).thenReturn(archiveUnitsToBeUpdated); saveWorkspacePutObject(UpdateWorkflowConstants.PROCESSING_FOLDER + "/" + UpdateWorkflowConstants.AU_TO_BE_UPDATED_JSON); saveWorkspacePutObject(UpdateWorkflowConstants.UNITS_FOLDER + "/" + "aeaqaaaaaagds5zjaabmaak5mlsoesaaaaba.json"); final ItemStatus response = plugin.execute(params, action); assertEquals(StatusCode.OK, response.getGlobalStatus()); String filename = UpdateWorkflowConstants.PROCESSING_FOLDER + "/" + UpdateWorkflowConstants.AU_TO_BE_UPDATED_JSON; JsonLineGenericIterator<JsonLineModel> lines = new JsonLineGenericIterator<>(new FileInputStream(getFullPath(filename)), TYPE_REFERENCE); assertEquals(3, lines.stream().count()); JsonNode aeaqaaaaaagds5zjaabmaak5mlsoesaaaaba = getSavedWorkspaceObject(UpdateWorkflowConstants.UNITS_FOLDER + "/" + "aeaqaaaaaagds5zjaabmaak5mlsoesaaaaba.json"); assertNotNull(aeaqaaaaaagds5zjaabmaak5mlsoesaaaaba); int numberOfRulesInvolved = 0; for (final JsonNode objNode : aeaqaaaaaagds5zjaabmaak5mlsoesaaaaba) { numberOfRulesInvolved++; } assertEquals(3, numberOfRulesInvolved); } }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(HANDLER_ID); try { Map<String, List<FileRulesModel>> archiveUnitGuidAndRulesToBeUpdated = new HashMap<>(); List<String> archiveUnitsToBeUpdated = new ArrayList<>(); selectListOfArchiveUnitsForUpdate(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); exportToWorkspace(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); itemStatus.increment(StatusCode.OK); } catch (ProcessingException e) { LOGGER.error("Fatal : ", e); itemStatus.increment(StatusCode.FATAL); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus); }
ListArchiveUnitsActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(HANDLER_ID); try { Map<String, List<FileRulesModel>> archiveUnitGuidAndRulesToBeUpdated = new HashMap<>(); List<String> archiveUnitsToBeUpdated = new ArrayList<>(); selectListOfArchiveUnitsForUpdate(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); exportToWorkspace(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); itemStatus.increment(StatusCode.OK); } catch (ProcessingException e) { LOGGER.error("Fatal : ", e); itemStatus.increment(StatusCode.FATAL); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus); } }
ListArchiveUnitsActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(HANDLER_ID); try { Map<String, List<FileRulesModel>> archiveUnitGuidAndRulesToBeUpdated = new HashMap<>(); List<String> archiveUnitsToBeUpdated = new ArrayList<>(); selectListOfArchiveUnitsForUpdate(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); exportToWorkspace(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); itemStatus.increment(StatusCode.OK); } catch (ProcessingException e) { LOGGER.error("Fatal : ", e); itemStatus.increment(StatusCode.FATAL); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus); } ListArchiveUnitsActionHandler();  ListArchiveUnitsActionHandler(MetaDataClientFactory metaDataClientFactory); }
ListArchiveUnitsActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(HANDLER_ID); try { Map<String, List<FileRulesModel>> archiveUnitGuidAndRulesToBeUpdated = new HashMap<>(); List<String> archiveUnitsToBeUpdated = new ArrayList<>(); selectListOfArchiveUnitsForUpdate(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); exportToWorkspace(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); itemStatus.increment(StatusCode.OK); } catch (ProcessingException e) { LOGGER.error("Fatal : ", e); itemStatus.increment(StatusCode.FATAL); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus); } ListArchiveUnitsActionHandler();  ListArchiveUnitsActionHandler(MetaDataClientFactory metaDataClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static final String getId(); }
ListArchiveUnitsActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(HANDLER_ID); try { Map<String, List<FileRulesModel>> archiveUnitGuidAndRulesToBeUpdated = new HashMap<>(); List<String> archiveUnitsToBeUpdated = new ArrayList<>(); selectListOfArchiveUnitsForUpdate(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); exportToWorkspace(handler, archiveUnitGuidAndRulesToBeUpdated, archiveUnitsToBeUpdated); itemStatus.increment(StatusCode.OK); } catch (ProcessingException e) { LOGGER.error("Fatal : ", e); itemStatus.increment(StatusCode.FATAL); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus); } ListArchiveUnitsActionHandler();  ListArchiveUnitsActionHandler(MetaDataClientFactory metaDataClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static final String getId();  }