InMemoryPermissionsImpl implements PermissionsInterface { @Override public boolean isSharing(User user) { final String userKey = userKey(user); return user.getEntries().stream().anyMatch(e -> { if (e instanceof Workflow) { final Map<String, Role> map = resourceToUsersAndRolesMap.get(((Workflow)e).getWorkflowPath()); if (map != null && map.keySet().stream().anyMatch(u -> !userKey.equals(u))) { return true; } } return false; }); }  @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 testIsSharing() { Assert.assertFalse(inMemoryPermissions.isSharing(johnDoeUser)); final Permission permission = new Permission("jane", Role.OWNER); inMemoryPermissions.setPermission(johnDoeUser, fooWorkflow, permission); Assert.assertTrue(inMemoryPermissions.isSharing(johnDoeUser)); }