CompleteCancelSnapshotTaskRunner extends SpaceModifyingSnapshotTaskRunner { @Override public String performTask(String taskParameters) { log.info("performing task: params={}", taskParameters); CompleteCancelSnapshotTaskParameters taskParams = CompleteCancelSnapshotTaskParameters.deserialize(taskParameters); String spaceId = taskParams.getSpaceId(); removeSnapshotIdFromSpaceProps(spaceId); removeSnapshotProps(spaceId); removeSnapshotUserPermissions(spaceId); return new CompleteCancelSnapshotTaskResult("completed cancellation for " + spaceId).serialize(); } CompleteCancelSnapshotTaskRunner(StorageProvider snapshotProvider,
                                            SnapshotStorageProvider unwrappedSnapshotProvider,
                                            String dcSnapshotUser,
                                            String bridgeAppHost,
                                            String bridgeAppPort,
                                            String bridgeAppUser,
                                            String bridgeAppPass); @Override String getName(); @Override String performTask(String taskParameters);  }
@Test public void testPerform() { String spaceId = "space-id"; String snapshotId = "snapshot-id"; snapshotProvider.deleteContent(eq(spaceId), eq(Constants.SNAPSHOT_PROPS_FILENAME)); expectLastCall().once(); Map<String, String> spaceProps = new HashMap<>(); spaceProps.put(Constants.SNAPSHOT_ID_PROP, snapshotId); EasyMock.expect(snapshotProvider.getSpaceProperties(spaceId)) .andReturn(spaceProps); Capture<Map<String, String>> propsCapture = new Capture<>(); unwrappedSnapshotProvider.setNewSpaceProperties(EasyMock.eq(spaceId), EasyMock.capture(propsCapture)); expectLastCall().once(); String aclUserName = "acl-" + dcSnapshotUser; AclType aclValue = AclType.READ; Map<String, AclType> spaceACLs = new HashMap<>(); spaceACLs.put(aclUserName, aclValue); EasyMock.expect(snapshotProvider.getSpaceACLs(spaceId)) .andReturn(spaceACLs); Capture<Map<String, AclType>> spaceACLsCapture = new Capture<>(); snapshotProvider.setSpaceACLs(EasyMock.eq(spaceId), EasyMock.capture(spaceACLsCapture)); replayAll(); setupSubject(); taskRunner.performTask("{\"spaceId\":\"" + spaceId + "\"}"); spaceProps = propsCapture.getValue(); assertFalse(spaceProps.containsKey(Constants.SNAPSHOT_ID_PROP)); spaceACLs = spaceACLsCapture.getValue(); assertFalse(spaceProps.containsKey(aclUserName)); }