InMemoryPermissionsImpl implements PermissionsInterface { @Override public void removePermission(User user, Workflow workflow, String email, Role role) { PermissionsInterface.checkUserNotOriginalOwner(email, workflow); Map<String, Role> userPermissionMap = resourceToUsersAndRolesMap.get(workflow.getWorkflowPath()); if (userPermissionMap != null) { userPermissionMap.remove(email); } }  @Override List<Permission> setPermission(User requester, Workflow workflow, Permission permission); @Override Map<Role, List<String>> workflowsSharedWithUser(User user); @Override List<Permission> getPermissionsForWorkflow(User user, Workflow workflow); @Override List<Role.Action> getActionsForWorkflow(User user, Workflow workflow); @Override void removePermission(User user, Workflow workflow, String email, Role role); @Override boolean canDoAction(User user, Workflow workflow, Role.Action action); @Override void selfDestruct(User user); @Override boolean isSharing(User user);  }
@Test public void removePermission() { Assert.assertEquals(inMemoryPermissions.workflowsSharedWithUser(johnDoeUser).size(), 0); final Permission permission = new Permission("jane", Role.WRITER); inMemoryPermissions.setPermission(johnDoeUser, fooWorkflow, permission); inMemoryPermissions.setPermission(johnDoeUser, gooWorkflow, permission); final Map<Role, List<String>> sharedWithUser = inMemoryPermissions.workflowsSharedWithUser(janeDoeUser); Assert.assertEquals(1, sharedWithUser.size()); Assert.assertEquals(2, sharedWithUser.entrySet().iterator().next().getValue().size()); inMemoryPermissions.removePermission(johnDoeUser, fooWorkflow, "jane", Role.WRITER); final Map<Role, List<String>> sharedWithUser1 = inMemoryPermissions.workflowsSharedWithUser(janeDoeUser); Assert.assertEquals(1, sharedWithUser1.size()); Assert.assertEquals(1, sharedWithUser1.entrySet().iterator().next().getValue().size()); }