### Question:
GlobalPermissionEvaluator { public boolean hasGlobalPermission(Set<String> agentPrincipals, Permission permission) { return agentPrincipals.stream().anyMatch(p -> { Set<String> permissions = globalPrincipalToPermissions.get(p); if (permissions == null) { return false; } return permissions.contains(permission.name()); }); } 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 hasGlobalPermissionTest() { addGlobalAssignment(UserRole.administrator, PRINC_GRP1); evaluator = new GlobalPermissionEvaluator(configProperties); assertTrue(evaluator.hasGlobalPermission(principals, Permission.destroy)); }
@Test public void noPermissionTest() { addGlobalAssignment(UserRole.canAccess, PRINC_GRP1); evaluator = new GlobalPermissionEvaluator(configProperties); assertFalse(evaluator.hasGlobalPermission(principals, Permission.destroy)); }
@Test public void nonroleProperties() { configProperties.setProperty("some.property", "value"); addGlobalAssignment(UserRole.canAccess, PRINC_GRP1); configProperties.setProperty("some.other.property", "val"); evaluator = new GlobalPermissionEvaluator(configProperties); assertTrue(evaluator.hasGlobalPermission(principals, Permission.viewHidden)); }
@Test public void noRoleProperties() { configProperties.setProperty("some.property", "value"); evaluator = new GlobalPermissionEvaluator(configProperties); assertFalse(evaluator.hasGlobalPermission(principals, Permission.viewHidden)); }
@Test public void noPrincipalsTest() { addGlobalAssignment(UserRole.administrator, PRINC_GRP1); evaluator = new GlobalPermissionEvaluator(configProperties); assertFalse(evaluator.hasGlobalPermission(Collections.emptySet(), Permission.viewHidden)); }
@Test public void multiplePrincipalsTest() { addGlobalAssignment(UserRole.canManage, PRINC_GRP1); addGlobalAssignment(UserRole.canDescribe, PRINC_GRP2); evaluator = new GlobalPermissionEvaluator(configProperties); assertTrue(evaluator.hasGlobalPermission(principals, Permission.markForDeletion)); Set<String> principals2 = new HashSet<>(Arrays.asList(PRINC_GRP2)); assertTrue(evaluator.hasGlobalPermission(principals2, Permission.editDescription)); assertFalse(evaluator.hasGlobalPermission(principals2, Permission.markForDeletion)); Set<String> principalsCombined = new HashSet<>(Arrays.asList(PRINC_GRP2, PRINC_GRP1)); assertTrue(evaluator.hasGlobalPermission(principalsCombined, Permission.editDescription)); assertTrue(evaluator.hasGlobalPermission(principalsCombined, Permission.markForDeletion)); }