@Test public void whenExecuteListThenOK() { HandlerIO handlerIO = mock(HandlerIO.class); WorkerParameters workerParameters = WorkerParametersFactory.newWorkerParameters(); workerParameters.setObjectNameList(Lists.newArrayList("a", "b", "c")); List<ItemStatus> itemStatuses = abstractGraphComputePlugin.executeList(workerParameters, handlerIO); assertThat(itemStatuses).hasSize(1); ItemStatus itemStatus = itemStatuses.iterator().next(); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.OK); List<Integer> statusMeter = itemStatus.getStatusMeter(); assertThat(statusMeter.get(3)).isEqualTo(3); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(getPluginKeyName()); List<ItemStatus> aggregateItemStatus = new ArrayList<>(); List<String> items = workerParameters.getObjectNameList(); Set<String> ids = new HashSet<>(items); int initialSize = ids.size(); int finalSize = 0; GraphComputeResponse graphComputeResponse = null; try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { graphComputeResponse = metaDataClient.computeGraph(getGraphComputeAction(), ids); switch (getGraphComputeAction()) { case UNIT: finalSize = graphComputeResponse.getUnitCount(); break; case OBJECTGROUP: finalSize = graphComputeResponse.getGotCount(); break; default: throw new IllegalStateException("Unexpected graph compute action " + getGraphComputeAction()); } } catch (VitamClientException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.FATAL); } finally { handler.setCurrentObjectId(null); } int fatal = Math.abs(initialSize - finalSize); if (0 == fatal) { itemStatus.increment(StatusCode.OK, finalSize); } else { if (null != graphComputeResponse && !Strings.isNullOrEmpty(graphComputeResponse.getErrorMessage())) { ObjectNode infoNode = JsonHandler.createObjectNode(); infoNode.put(SedaConstants.EV_DET_TECH_DATA, graphComputeResponse.getErrorMessage()); itemStatus.setEvDetailData(JsonHandler.unprettyPrint(infoNode)); } itemStatus.increment(StatusCode.OK, finalSize).increment(StatusCode.FATAL, fatal); } aggregateItemStatus.add(new ItemStatus(getPluginKeyName()).setItemsStatus(getPluginKeyName(), itemStatus)); return aggregateItemStatus; }
AbstractGraphComputePlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(getPluginKeyName()); List<ItemStatus> aggregateItemStatus = new ArrayList<>(); List<String> items = workerParameters.getObjectNameList(); Set<String> ids = new HashSet<>(items); int initialSize = ids.size(); int finalSize = 0; GraphComputeResponse graphComputeResponse = null; try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { graphComputeResponse = metaDataClient.computeGraph(getGraphComputeAction(), ids); switch (getGraphComputeAction()) { case UNIT: finalSize = graphComputeResponse.getUnitCount(); break; case OBJECTGROUP: finalSize = graphComputeResponse.getGotCount(); break; default: throw new IllegalStateException("Unexpected graph compute action " + getGraphComputeAction()); } } catch (VitamClientException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.FATAL); } finally { handler.setCurrentObjectId(null); } int fatal = Math.abs(initialSize - finalSize); if (0 == fatal) { itemStatus.increment(StatusCode.OK, finalSize); } else { if (null != graphComputeResponse && !Strings.isNullOrEmpty(graphComputeResponse.getErrorMessage())) { ObjectNode infoNode = JsonHandler.createObjectNode(); infoNode.put(SedaConstants.EV_DET_TECH_DATA, graphComputeResponse.getErrorMessage()); itemStatus.setEvDetailData(JsonHandler.unprettyPrint(infoNode)); } itemStatus.increment(StatusCode.OK, finalSize).increment(StatusCode.FATAL, fatal); } aggregateItemStatus.add(new ItemStatus(getPluginKeyName()).setItemsStatus(getPluginKeyName(), itemStatus)); return aggregateItemStatus; } }
AbstractGraphComputePlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(getPluginKeyName()); List<ItemStatus> aggregateItemStatus = new ArrayList<>(); List<String> items = workerParameters.getObjectNameList(); Set<String> ids = new HashSet<>(items); int initialSize = ids.size(); int finalSize = 0; GraphComputeResponse graphComputeResponse = null; try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { graphComputeResponse = metaDataClient.computeGraph(getGraphComputeAction(), ids); switch (getGraphComputeAction()) { case UNIT: finalSize = graphComputeResponse.getUnitCount(); break; case OBJECTGROUP: finalSize = graphComputeResponse.getGotCount(); break; default: throw new IllegalStateException("Unexpected graph compute action " + getGraphComputeAction()); } } catch (VitamClientException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.FATAL); } finally { handler.setCurrentObjectId(null); } int fatal = Math.abs(initialSize - finalSize); if (0 == fatal) { itemStatus.increment(StatusCode.OK, finalSize); } else { if (null != graphComputeResponse && !Strings.isNullOrEmpty(graphComputeResponse.getErrorMessage())) { ObjectNode infoNode = JsonHandler.createObjectNode(); infoNode.put(SedaConstants.EV_DET_TECH_DATA, graphComputeResponse.getErrorMessage()); itemStatus.setEvDetailData(JsonHandler.unprettyPrint(infoNode)); } itemStatus.increment(StatusCode.OK, finalSize).increment(StatusCode.FATAL, fatal); } aggregateItemStatus.add(new ItemStatus(getPluginKeyName()).setItemsStatus(getPluginKeyName(), itemStatus)); return aggregateItemStatus; } AbstractGraphComputePlugin(); @VisibleForTesting  AbstractGraphComputePlugin(MetaDataClientFactory metaDataClientFactory); }
AbstractGraphComputePlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(getPluginKeyName()); List<ItemStatus> aggregateItemStatus = new ArrayList<>(); List<String> items = workerParameters.getObjectNameList(); Set<String> ids = new HashSet<>(items); int initialSize = ids.size(); int finalSize = 0; GraphComputeResponse graphComputeResponse = null; try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { graphComputeResponse = metaDataClient.computeGraph(getGraphComputeAction(), ids); switch (getGraphComputeAction()) { case UNIT: finalSize = graphComputeResponse.getUnitCount(); break; case OBJECTGROUP: finalSize = graphComputeResponse.getGotCount(); break; default: throw new IllegalStateException("Unexpected graph compute action " + getGraphComputeAction()); } } catch (VitamClientException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.FATAL); } finally { handler.setCurrentObjectId(null); } int fatal = Math.abs(initialSize - finalSize); if (0 == fatal) { itemStatus.increment(StatusCode.OK, finalSize); } else { if (null != graphComputeResponse && !Strings.isNullOrEmpty(graphComputeResponse.getErrorMessage())) { ObjectNode infoNode = JsonHandler.createObjectNode(); infoNode.put(SedaConstants.EV_DET_TECH_DATA, graphComputeResponse.getErrorMessage()); itemStatus.setEvDetailData(JsonHandler.unprettyPrint(infoNode)); } itemStatus.increment(StatusCode.OK, finalSize).increment(StatusCode.FATAL, fatal); } aggregateItemStatus.add(new ItemStatus(getPluginKeyName()).setItemsStatus(getPluginKeyName(), itemStatus)); return aggregateItemStatus; } AbstractGraphComputePlugin(); @VisibleForTesting  AbstractGraphComputePlugin(MetaDataClientFactory metaDataClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); }
AbstractGraphComputePlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(getPluginKeyName()); List<ItemStatus> aggregateItemStatus = new ArrayList<>(); List<String> items = workerParameters.getObjectNameList(); Set<String> ids = new HashSet<>(items); int initialSize = ids.size(); int finalSize = 0; GraphComputeResponse graphComputeResponse = null; try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { graphComputeResponse = metaDataClient.computeGraph(getGraphComputeAction(), ids); switch (getGraphComputeAction()) { case UNIT: finalSize = graphComputeResponse.getUnitCount(); break; case OBJECTGROUP: finalSize = graphComputeResponse.getGotCount(); break; default: throw new IllegalStateException("Unexpected graph compute action " + getGraphComputeAction()); } } catch (VitamClientException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.FATAL); } finally { handler.setCurrentObjectId(null); } int fatal = Math.abs(initialSize - finalSize); if (0 == fatal) { itemStatus.increment(StatusCode.OK, finalSize); } else { if (null != graphComputeResponse && !Strings.isNullOrEmpty(graphComputeResponse.getErrorMessage())) { ObjectNode infoNode = JsonHandler.createObjectNode(); infoNode.put(SedaConstants.EV_DET_TECH_DATA, graphComputeResponse.getErrorMessage()); itemStatus.setEvDetailData(JsonHandler.unprettyPrint(infoNode)); } itemStatus.increment(StatusCode.OK, finalSize).increment(StatusCode.FATAL, fatal); } aggregateItemStatus.add(new ItemStatus(getPluginKeyName()).setItemsStatus(getPluginKeyName(), itemStatus)); return aggregateItemStatus; } AbstractGraphComputePlugin(); @VisibleForTesting  AbstractGraphComputePlugin(MetaDataClientFactory metaDataClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler);  }