### Question:
GlobalPermissionEvaluator { public Set<UserRole> getGlobalUserRoles(Set<String> agentPrincipals) { return agentPrincipals.stream() .filter(p -> globalPrincipalToRole.containsKey(p)) .map(p -> globalPrincipalToRole.get(p)) .collect(Collectors.toSet()); } GlobalPermissionEvaluator(Properties properties); boolean hasGlobalPermission(Set<String> agentPrincipals, Permission permission); boolean hasGlobalPrincipal(Set<String> agentPrincipals); Set<UserRole> getGlobalUserRoles(Set<String> agentPrincipals);  }### Answer:
@Test public void getGlobalUserRoles() { addGlobalAssignment(UserRole.canManage, PRINC_GRP1); addGlobalAssignment(UserRole.canDescribe, PRINC_GRP2); evaluator = new GlobalPermissionEvaluator(configProperties); Set<UserRole> roles = evaluator.getGlobalUserRoles(principals); assertTrue(roles.contains(UserRole.canManage)); }
@Test public void getGlobalMultipleUserRoles() { principals = new HashSet<>(Arrays.asList(PRINC_GRP1, PRINC_GRP2)); addGlobalAssignment(UserRole.canManage, PRINC_GRP1); addGlobalAssignment(UserRole.canDescribe, PRINC_GRP2); evaluator = new GlobalPermissionEvaluator(configProperties); Set<UserRole> roles = evaluator.getGlobalUserRoles(principals); assertTrue(roles.contains(UserRole.canManage)); assertTrue(roles.contains(UserRole.canDescribe)); }
@Test public void getNoGlobalUserRoles() { addGlobalAssignment(UserRole.canDescribe, PRINC_GRP2); evaluator = new GlobalPermissionEvaluator(configProperties); Set<UserRole> roles = evaluator.getGlobalUserRoles(principals); assertTrue(roles.isEmpty()); }