@Test public void givenProcessErrorMetadataWhenExecuteThenReturnResponseFatal() throws Exception { final InputStream updatedRules = PropertiesUtils.getResourceAsStream(UPDATED_RULES_JSON); try { action.addOutIOParameters(out); when(workspaceClient.getObject(any(), eq("PROCESSING/updatedRules.json"))) .thenReturn(Response.status(Status.OK).entity(updatedRules).build()); when(metadataClient.selectUnits(any())) .thenThrow(new MetaDataExecutionException("Error while requesting Metadata")); assertThatThrownBy(() -> plugin.execute(params, action)).isExactlyInstanceOf(IllegalStateException.class); } finally { updatedRules.close(); } }
@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();  }