@Test public void should_invalidate_correctly_unit() throws Exception { String unitToUpdate = "aeeaaaaaagehslhxabfh2all2cnh4zyaaaaq"; HandlerIO handlerIO = mock(HandlerIO.class); WorkerParameters workerParameters = mock(WorkerParameters.class); when(workerParameters.getObjectNameList()).thenReturn(Collections.singletonList(unitToUpdate)); when(metaDataClient.updateUnitBulk(any(JsonNode.class))).thenReturn(new RequestResponseOK<JsonNode>()); computeInheritedRulesInvalidatorPlugin.executeList(workerParameters, handlerIO); ArgumentCaptor valueCapture = ArgumentCaptor.forClass(ObjectNode.class); verify(metaDataClient).updateUnitBulk((JsonNode) valueCapture.capture()); UpdateMultiQuery expectedUpdate = new UpdateMultiQuery(); expectedUpdate.addRoots(unitToUpdate); expectedUpdate.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); ObjectNode expectedArgument = expectedUpdate.getFinalUpdate(); assertEquals(expectedArgument, valueCapture.getValue()); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.debug(String.format("executeList from plugin '%s'", PLUGIN_NAME)); List<String> units = workerParameters.getObjectNameList(); UpdateMultiQuery update = new UpdateMultiQuery(); try(MetaDataClient mdClient = metaDataClientFactory.getClient()) { update.addRoots(units.toArray(new String[0])); update.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); RequestResponse<JsonNode> requestResponse = mdClient.updateUnitBulk(update.getFinalUpdate()); if(!requestResponse.isOk()) { throw new ProcessingException("error during bulk update"); } } catch (InvalidCreateOperationException | InvalidParseOperationException | MetaDataException e) { throw new ProcessingException(e); } return buildBulkItemStatus(workerParameters, PLUGIN_NAME, StatusCode.OK); }
ComputeInheritedRulesInvalidatorPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.debug(String.format("executeList from plugin '%s'", PLUGIN_NAME)); List<String> units = workerParameters.getObjectNameList(); UpdateMultiQuery update = new UpdateMultiQuery(); try(MetaDataClient mdClient = metaDataClientFactory.getClient()) { update.addRoots(units.toArray(new String[0])); update.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); RequestResponse<JsonNode> requestResponse = mdClient.updateUnitBulk(update.getFinalUpdate()); if(!requestResponse.isOk()) { throw new ProcessingException("error during bulk update"); } } catch (InvalidCreateOperationException | InvalidParseOperationException | MetaDataException e) { throw new ProcessingException(e); } return buildBulkItemStatus(workerParameters, PLUGIN_NAME, StatusCode.OK); } }
ComputeInheritedRulesInvalidatorPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.debug(String.format("executeList from plugin '%s'", PLUGIN_NAME)); List<String> units = workerParameters.getObjectNameList(); UpdateMultiQuery update = new UpdateMultiQuery(); try(MetaDataClient mdClient = metaDataClientFactory.getClient()) { update.addRoots(units.toArray(new String[0])); update.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); RequestResponse<JsonNode> requestResponse = mdClient.updateUnitBulk(update.getFinalUpdate()); if(!requestResponse.isOk()) { throw new ProcessingException("error during bulk update"); } } catch (InvalidCreateOperationException | InvalidParseOperationException | MetaDataException e) { throw new ProcessingException(e); } return buildBulkItemStatus(workerParameters, PLUGIN_NAME, StatusCode.OK); } ComputeInheritedRulesInvalidatorPlugin(); @VisibleForTesting  ComputeInheritedRulesInvalidatorPlugin(MetaDataClientFactory metaDataClientFactory); }
ComputeInheritedRulesInvalidatorPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.debug(String.format("executeList from plugin '%s'", PLUGIN_NAME)); List<String> units = workerParameters.getObjectNameList(); UpdateMultiQuery update = new UpdateMultiQuery(); try(MetaDataClient mdClient = metaDataClientFactory.getClient()) { update.addRoots(units.toArray(new String[0])); update.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); RequestResponse<JsonNode> requestResponse = mdClient.updateUnitBulk(update.getFinalUpdate()); if(!requestResponse.isOk()) { throw new ProcessingException("error during bulk update"); } } catch (InvalidCreateOperationException | InvalidParseOperationException | MetaDataException e) { throw new ProcessingException(e); } return buildBulkItemStatus(workerParameters, PLUGIN_NAME, StatusCode.OK); } ComputeInheritedRulesInvalidatorPlugin(); @VisibleForTesting  ComputeInheritedRulesInvalidatorPlugin(MetaDataClientFactory metaDataClientFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
ComputeInheritedRulesInvalidatorPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.debug(String.format("executeList from plugin '%s'", PLUGIN_NAME)); List<String> units = workerParameters.getObjectNameList(); UpdateMultiQuery update = new UpdateMultiQuery(); try(MetaDataClient mdClient = metaDataClientFactory.getClient()) { update.addRoots(units.toArray(new String[0])); update.addActions( set(VitamFieldsHelper.validComputedInheritedRules(), false), unset(VitamFieldsHelper.computedInheritedRules()) ); RequestResponse<JsonNode> requestResponse = mdClient.updateUnitBulk(update.getFinalUpdate()); if(!requestResponse.isOk()) { throw new ProcessingException("error during bulk update"); } } catch (InvalidCreateOperationException | InvalidParseOperationException | MetaDataException e) { throw new ProcessingException(e); } return buildBulkItemStatus(workerParameters, PLUGIN_NAME, StatusCode.OK); } ComputeInheritedRulesInvalidatorPlugin(); @VisibleForTesting  ComputeInheritedRulesInvalidatorPlugin(MetaDataClientFactory metaDataClientFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler);  }