SamPermissionsImpl implements PermissionsInterface { List<Permission> accessPolicyResponseEntryToUserPermissions(List<AccessPolicyResponseEntry> accessPolicyList) { return accessPolicyList.stream().map(accessPolicy -> { Role role = samPermissionMap.get(accessPolicy.getPolicy().getRoles().get(0)); return accessPolicy.getPolicy().getMemberEmails().stream().map(email -> { Permission permission = new Permission(); permission.setRole(role); permission.setEmail(email); return permission; }); }).flatMap(s -> s).collect(Collectors.toList()); } SamPermissionsImpl(TokenDAO tokenDAO, DockstoreWebserviceConfiguration config); @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 testAccessPolicyResponseEntryToUserPermissions() { final List<Permission> permissions = samPermissionsImpl .accessPolicyResponseEntryToUserPermissions(Arrays.asList(ownerPolicy, writerPolicy)); Assert.assertEquals(permissions.size(), 2); Assert.assertTrue(permissions.contains(ownerPermission)); Assert.assertTrue(permissions.contains(writerPermission)); }