@Test public void returnsNothingWhenNoRolesAreConfigured() throws Exception { ByteArrayInputStream configuration = new ByteArrayInputStream("[]".getBytes()); JsonPermissionConfiguration instance = new JsonPermissionConfiguration(configuration); Set<Permission> permissions = instance.getPermissionsForRoles(Lists.newArrayList("USER")); assertThat(permissions, is(empty())); }
@Override public Set<Permission> getPermissionsForRoles(Collection<String> roles) { return rolePermissions.stream() .filter(rolePerm -> roles.contains(rolePerm.roleName)) .flatMap(rolePerm -> rolePerm.permissions.stream()) .collect(Collectors.toSet()); }
JsonPermissionConfiguration implements PermissionConfiguration { @Override public Set<Permission> getPermissionsForRoles(Collection<String> roles) { return rolePermissions.stream() .filter(rolePerm -> roles.contains(rolePerm.roleName)) .flatMap(rolePerm -> rolePerm.permissions.stream()) .collect(Collectors.toSet()); } }
JsonPermissionConfiguration implements PermissionConfiguration { @Override public Set<Permission> getPermissionsForRoles(Collection<String> roles) { return rolePermissions.stream() .filter(rolePerm -> roles.contains(rolePerm.roleName)) .flatMap(rolePerm -> rolePerm.permissions.stream()) .collect(Collectors.toSet()); } JsonPermissionConfiguration(InputStream permissionConfig); }
JsonPermissionConfiguration implements PermissionConfiguration { @Override public Set<Permission> getPermissionsForRoles(Collection<String> roles) { return rolePermissions.stream() .filter(rolePerm -> roles.contains(rolePerm.roleName)) .flatMap(rolePerm -> rolePerm.permissions.stream()) .collect(Collectors.toSet()); } JsonPermissionConfiguration(InputStream permissionConfig); @Override Set<Permission> getPermissionsForRoles(Collection<String> roles); }
JsonPermissionConfiguration implements PermissionConfiguration { @Override public Set<Permission> getPermissionsForRoles(Collection<String> roles) { return rolePermissions.stream() .filter(rolePerm -> roles.contains(rolePerm.roleName)) .flatMap(rolePerm -> rolePerm.permissions.stream()) .collect(Collectors.toSet()); } JsonPermissionConfiguration(InputStream permissionConfig); @Override Set<Permission> getPermissionsForRoles(Collection<String> roles);  }