@Test @RunWithCustomExecutor public void testDeleteObjectGroup_OK() throws Exception { List<ItemStatus> itemStatuses = instance.executeList(params, handler); assertThat(itemStatuses).hasSize(2); assertThat(itemStatuses.get(0).getGlobalStatus()).isEqualTo(StatusCode.OK); assertThat(itemStatuses.get(1).getGlobalStatus()).isEqualTo(StatusCode.OK); Map<String, String> gotIdsWithStrategies = ImmutableMap.of("id_got_1", "default-fake", "id_got_2", "default-fake"); Map<String, String> objectsIdsWithStrategies = ImmutableMap .of("id_got1_object_1", "default-binary-fake", "id_got1_object_2", "default-binary-fake", "id_got2_object_1", "default-binary-fake"); verify(purgeDeleteService).deleteObjectGroups(argThat(new MapMatcher(gotIdsWithStrategies))); verify(purgeDeleteService).deleteObjects(argThat(new MapMatcher(objectsIdsWithStrategies))); }
@Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) { try { List<PurgeObjectGroupParams> objectGroupParams = param.getObjectMetadataList().stream() .map(og -> { try { return JsonHandler.getFromJsonNode(og, PurgeObjectGroupParams.class); } catch (InvalidParseOperationException e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); Map<String, String> objectGroupIdsWithStrategies = objectGroupParams.stream() .collect(Collectors.toMap(PurgeObjectGroupParams::getId, PurgeObjectGroupParams::getStrategyId)); processObjectGroups(objectGroupIdsWithStrategies); Map<String, String> objectIdsWithStrategies = objectGroupParams.stream() .flatMap(objectGroup -> objectGroup.getObjects().stream()) .collect(Collectors.toMap(PurgeObjectParams::getId, PurgeObjectParams::getStrategyId)); processObjects(objectIdsWithStrategies); return buildBulkItemStatus(param, actionId, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error("Purge of object groups failed with status " + e.getStatusCode(), e); return singletonList( buildItemStatus(actionId, e.getStatusCode(), e.getEventDetails())); } }
PurgeDeleteObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) { try { List<PurgeObjectGroupParams> objectGroupParams = param.getObjectMetadataList().stream() .map(og -> { try { return JsonHandler.getFromJsonNode(og, PurgeObjectGroupParams.class); } catch (InvalidParseOperationException e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); Map<String, String> objectGroupIdsWithStrategies = objectGroupParams.stream() .collect(Collectors.toMap(PurgeObjectGroupParams::getId, PurgeObjectGroupParams::getStrategyId)); processObjectGroups(objectGroupIdsWithStrategies); Map<String, String> objectIdsWithStrategies = objectGroupParams.stream() .flatMap(objectGroup -> objectGroup.getObjects().stream()) .collect(Collectors.toMap(PurgeObjectParams::getId, PurgeObjectParams::getStrategyId)); processObjects(objectIdsWithStrategies); return buildBulkItemStatus(param, actionId, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error("Purge of object groups failed with status " + e.getStatusCode(), e); return singletonList( buildItemStatus(actionId, e.getStatusCode(), e.getEventDetails())); } } }
PurgeDeleteObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) { try { List<PurgeObjectGroupParams> objectGroupParams = param.getObjectMetadataList().stream() .map(og -> { try { return JsonHandler.getFromJsonNode(og, PurgeObjectGroupParams.class); } catch (InvalidParseOperationException e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); Map<String, String> objectGroupIdsWithStrategies = objectGroupParams.stream() .collect(Collectors.toMap(PurgeObjectGroupParams::getId, PurgeObjectGroupParams::getStrategyId)); processObjectGroups(objectGroupIdsWithStrategies); Map<String, String> objectIdsWithStrategies = objectGroupParams.stream() .flatMap(objectGroup -> objectGroup.getObjects().stream()) .collect(Collectors.toMap(PurgeObjectParams::getId, PurgeObjectParams::getStrategyId)); processObjects(objectIdsWithStrategies); return buildBulkItemStatus(param, actionId, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error("Purge of object groups failed with status " + e.getStatusCode(), e); return singletonList( buildItemStatus(actionId, e.getStatusCode(), e.getEventDetails())); } } PurgeDeleteObjectGroupPlugin(String actionId); @VisibleForTesting protected  PurgeDeleteObjectGroupPlugin(
        String actionId, PurgeDeleteService purgeDeleteService); }
PurgeDeleteObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) { try { List<PurgeObjectGroupParams> objectGroupParams = param.getObjectMetadataList().stream() .map(og -> { try { return JsonHandler.getFromJsonNode(og, PurgeObjectGroupParams.class); } catch (InvalidParseOperationException e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); Map<String, String> objectGroupIdsWithStrategies = objectGroupParams.stream() .collect(Collectors.toMap(PurgeObjectGroupParams::getId, PurgeObjectGroupParams::getStrategyId)); processObjectGroups(objectGroupIdsWithStrategies); Map<String, String> objectIdsWithStrategies = objectGroupParams.stream() .flatMap(objectGroup -> objectGroup.getObjects().stream()) .collect(Collectors.toMap(PurgeObjectParams::getId, PurgeObjectParams::getStrategyId)); processObjects(objectIdsWithStrategies); return buildBulkItemStatus(param, actionId, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error("Purge of object groups failed with status " + e.getStatusCode(), e); return singletonList( buildItemStatus(actionId, e.getStatusCode(), e.getEventDetails())); } } PurgeDeleteObjectGroupPlugin(String actionId); @VisibleForTesting protected  PurgeDeleteObjectGroupPlugin(
        String actionId, PurgeDeleteService purgeDeleteService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); }
PurgeDeleteObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) { try { List<PurgeObjectGroupParams> objectGroupParams = param.getObjectMetadataList().stream() .map(og -> { try { return JsonHandler.getFromJsonNode(og, PurgeObjectGroupParams.class); } catch (InvalidParseOperationException e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); Map<String, String> objectGroupIdsWithStrategies = objectGroupParams.stream() .collect(Collectors.toMap(PurgeObjectGroupParams::getId, PurgeObjectGroupParams::getStrategyId)); processObjectGroups(objectGroupIdsWithStrategies); Map<String, String> objectIdsWithStrategies = objectGroupParams.stream() .flatMap(objectGroup -> objectGroup.getObjects().stream()) .collect(Collectors.toMap(PurgeObjectParams::getId, PurgeObjectParams::getStrategyId)); processObjects(objectIdsWithStrategies); return buildBulkItemStatus(param, actionId, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error("Purge of object groups failed with status " + e.getStatusCode(), e); return singletonList( buildItemStatus(actionId, e.getStatusCode(), e.getEventDetails())); } } PurgeDeleteObjectGroupPlugin(String actionId); @VisibleForTesting protected  PurgeDeleteObjectGroupPlugin(
        String actionId, PurgeDeleteService purgeDeleteService); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler);  }