### Question:
UserRevokeSuperAdminRightsService { @Validated @UseCaseAdministratorRevokesAdminRightsFromAdmin( @Step( number = 2, name = "Service revokes user admin rights.", next = { 3, 4 }, description = "The service will revoke user admin righs and triggers asynchronous events")) public void revokeSuperAdminRightsFrom(String userId) { String sanitizedLogUserId = logSanitizer.sanitize(userId,30); auditLogService.log("Triggered revoking admin rights from user {}",sanitizedLogUserId); assertion.isValidUserId(userId); User user = userRepository.findOrFailUser(userId); if (!user.isSuperAdmin()) { LOG.info("User:{} was already no super administrator, so just ignored",sanitizedLogUserId); return; } assertNotLastSuperAdmin(); user.superAdmin=false; userRepository.save(user); requestUserRoleRecalculaton(user); informUserNoLongerSuperadmin(user); }  @Validated @UseCaseAdministratorRevokesAdminRightsFromAdmin( @Step( number = 2, name = "Service revokes user admin rights.", next = { 3, 4 }, description = "The service will revoke user admin righs and triggers asynchronous events")) /* @formatter:on */ void revokeSuperAdminRightsFrom(String userId);  }### Answer:
@Test public void when_last_admin_user_rights_cannot_be_revoked() { User exampleUser = new User(); exampleUser.superAdmin = true; when(userRepository.count(eq(Example.of(exampleUser)))).thenReturn(1L); expected.expect(NotAcceptableException.class); serviceToTest.revokeSuperAdminRightsFrom(ADMIN_USER); }
@Test public void when_not_last_admin_user_rights_can_be_revoked() { User capture = new User(); capture.superAdmin = true; when(userRepository.count(eq(Example.of(capture)))).thenReturn(2L); serviceToTest.revokeSuperAdminRightsFrom(ADMIN_USER); }