### Question:
PermissionChecker { void checkAlterRoleAccess(AuthenticatedUser performer, RoleResource role, RoleOptions options) { if (performer.isSuper()) { return; } if (isPermissionRequired(performer, role, options) && !hasPermissionToAlterRole(performer, role)) { throw new UnauthorizedException(String.format("User %s is not authorized to alter role %s", performer.getName(), role.getRoleName())); } } PermissionChecker();   PermissionChecker(IAuthorizer authorizer);   }### Answer:
@Test public void superUserCanChangeAllAttributes() { AuthenticatedUser performer = givenSuperUser(); RoleResource grantee = givenNormalRole(); RoleOptions options = givenAllOptions(); permissionChecker.checkAlterRoleAccess(performer, grantee, options); }
@Test public void normalUserCanChangeOwnPassword() { AuthenticatedUser performer = givenNormalUser(); RoleResource grantee = givenNormalRole(); RoleOptions options = givenPasswordOptions(); permissionChecker.checkAlterRoleAccess(performer, grantee, options); }
@Test public void normalUserCanAlterOtherOptionMap() { AuthenticatedUser performer = givenNormalUser(); RoleResource grantee = givenOtherRole(); RoleOptions options = givenOptionsOptions(); permissionChecker.checkAlterRoleAccess(performer, grantee, options); }
@Test public void normalUserCanNotAlterOtherAllAttributes() { AuthenticatedUser performer = givenNormalUser(); RoleResource grantee = givenOtherRole(); RoleOptions options = givenAllOptions(); assertThatExceptionOfType(UnauthorizedException.class) .isThrownBy(() -> permissionChecker.checkAlterRoleAccess(performer, grantee, options)); }
@Test public void trustedUserCanAlterOtherAllAttributes() { AuthenticatedUser performer = givenTrustedUser(); RoleResource grantee = givenOtherRole(); RoleOptions options = givenAllOptions(); permissionChecker.checkAlterRoleAccess(performer, grantee, options); }