示例#1
0
  @Test(expected = UserNotInSessionException.class)
  public void accessUserDoesNotExist() {

    RemoveUserIntegrator service =
        new RemoveUserIntegrator(USERNAME_DOES_NOT_EXIST, USERNAME_TO_DELETE);
    service.execute();
  }
示例#2
0
  @Test(expected = UnauthorizedOperationException.class)
  public void notRootUser() {

    String ars = addUserToSession(USERNAME);
    RemoveUserIntegrator service = new RemoveUserIntegrator(ars, USERNAME_TO_DELETE);
    service.execute();
  }
示例#3
0
  /*
   * accessUsername exists, is in session and is root toDeleteUsername exists
   * and is not in session
   */
  @Test(expected = UserNotInSessionException.class)
  public void successToDeleteIsNotInSession() {

    removeUserFromSession(root);
    RemoveUserIntegrator service = new RemoveUserIntegrator(root, USERNAME_TO_DELETE);
    service.execute();
  }
示例#4
0
  @Test(expected = UserNotInSessionException.class)
  public void notInSessionAndNotRoot() {

    String ars = addUserToSession(USERNAME);
    removeUserFromSession(ars);
    RemoveUserIntegrator service = new RemoveUserIntegrator(ars, USERNAME_TO_DELETE);
    service.execute();
  }
示例#5
0
  @Test(expected = UnavailableServiceException.class)
  public void testMockRemoteInvocationException(@Mocked final IDRemoteServices remoteService)
      throws Exception {

    new Expectations() {
      {
        remoteService.removeUser(anyString);
        result = new RemoteInvocationException();
      }
    };

    RemoveUserIntegrator integrator = new RemoveUserIntegrator(root, USERNAME);
    integrator.execute();
  }
示例#6
0
  /*
   * accessUsername exists, is in session and is root toDeleteUsername exists
   * and is in session Test if user and session are both deleted
   */
  @Test
  public void successToDeleteIsInSession(@Mocked final IDRemoteServices remoteService)
      throws Exception {

    new Expectations() {
      {
        remoteService.removeUser(anyString);
      }
    };

    String token = addUserToSession(USERNAME_TO_DELETE);
    RemoveUserIntegrator service = new RemoveUserIntegrator(root, USERNAME_TO_DELETE);
    service.execute();
    assertNull("Removed user but not removed from session", getUserFromSession(token));
  }
示例#7
0
  @Test
  public void success(@Mocked final IDRemoteServices remoteService) {

    new Expectations() {
      {
        remoteService.removeUser(anyString);
      }
    };

    RemoveUserIntegrator integrator = new RemoveUserIntegrator(root, USERNAME_TO_DELETE);
    integrator.execute();

    boolean deleted = getUserFromUsername(USERNAME_TO_DELETE) == null;

    assertTrue("user was not deleted", deleted);
    assertNull("Spreadsheet was not deleted", getSpreadSheet(SPREADSHEET_NAME));
  }
示例#8
0
  @Test
  public void successCompensation(@Mocked final IDRemoteServices remoteService) throws Exception {

    new Expectations() {
      {
        remoteService.removeUser(anyString);
        result = new RemoteInvocationException();
      }
    };

    RemoveUserIntegrator integrator = new RemoveUserIntegrator(root, USERNAME);

    try {
      integrator.execute();
    } catch (UnavailableServiceException e) {
      User user = getUserFromUsername(USERNAME);
      assertNotNull(user.getName());
      assertNotNull(user.getEmail());
    }
  }
示例#9
0
  @Test(expected = LoginBubbleDocsException.class)
  public void userToDeleteDoesNotExist() {

    RemoveUserIntegrator service = new RemoveUserIntegrator(root, USERNAME_DOES_NOT_EXIST);
    service.execute();
  }