@Test
 public void deactivate_user() throws Exception {
   MockUserSession.set().setLogin("simon").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
   service.deactivate("julien");
   verify(dao).deactivateUserByLogin("julien");
   verify(userService).index();
 }
 @Test
 public void self_deactivation_is_not_possible() throws Exception {
   try {
     MockUserSession.set().setLogin("simon").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
     service.deactivate("simon");
     fail();
   } catch (BadRequestException e) {
     assertThat(e).hasMessage("Self-deactivation is not possible");
     verify(dao, never()).deactivateUserByLogin("simon");
   }
 }
 @Test
 public void fail_to_deactivate_when_blank_login() throws Exception {
   MockUserSession.set().setLogin("simon").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
   try {
     service.deactivate("");
     fail();
   } catch (BadRequestException e) {
     assertThat(e).hasMessage("Login is missing");
     verifyZeroInteractions(dao);
   }
 }
 @Test
 public void user_deactivation_requires_admin_permission() throws Exception {
   try {
     MockUserSession.set()
         .setLogin("simon")
         .setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
     service.deactivate("julien");
     fail();
   } catch (ForbiddenException e) {
     verify(dao, never()).deactivateUserByLogin("simon");
   }
 }