コード例 #1
0
  @Test
  public void testDoStart_anyOperator() throws Exception {
    // Given
    when(placeController.getWhere()).thenReturn(new OperatorPlace(operator));
    HasValue<String> loginInput = mock(HasValue.class);
    HasValue<String> phoneInput = mock(HasValue.class);
    HasValue<String> lastNameInput = mock(HasValue.class);
    HasValue<String> firstNameInut = mock(HasValue.class);
    HasValue<String> emailInput = mock(HasValue.class);
    HasValue<String> passwordInput = mock(HasValue.class);
    HasValue<String> roleInput = mock(HasValue.class);
    when(operatorView.getLoginInput()).thenReturn(loginInput);
    when(operatorView.getFirstNameInput()).thenReturn(firstNameInut);
    when(operatorView.getPhoneInput()).thenReturn(phoneInput);
    when(operatorView.getLastNameInput()).thenReturn(lastNameInput);
    when(operatorView.getMailInput()).thenReturn(emailInput);
    when(operatorView.getPasswordInput()).thenReturn(passwordInput);
    when(operatorView.getRoleInput()).thenReturn(roleInput);

    // When
    presenter.doStart();

    // Then
    verify(operatorView).setPresenter(presenter);
    verify(placeController).getWhere();

    verify(operatorView).getLoginInput();
    verify(operatorView).getFirstNameInput();
    verify(operatorView).getPhoneInput();
    verify(operatorView).getLastNameInput();
    verify(operatorView).getMailInput();
    verify(operatorView).getPasswordInput();
    verify(operatorView).getRoleInput();

    verify(loginInput).setValue(eq("testOpLogin"));
    verify(phoneInput).setValue(eq("testOpPhone"));
    verify(lastNameInput).setValue(eq("testOpLastName"));
    verify(firstNameInut).setValue(eq("testOpFirstName"));
    verify(emailInput).setValue(eq("testOpEmail"));
    verify(passwordInput).setValue(eq("testOpPassword"));
    verify(roleInput).setValue(eq(OperatorRole.ADMINISTRATEUR.name()));

    verifyNoMoreInteractions(operatorView);
    verifyNoMoreInteractions(placeController);

    verifyNoMoreInteractions(loginInput);
    verifyNoMoreInteractions(phoneInput);
    verifyNoMoreInteractions(lastNameInput);
    verifyNoMoreInteractions(firstNameInut);
    verifyNoMoreInteractions(emailInput);
    verifyNoMoreInteractions(passwordInput);
    verifyNoMoreInteractions(roleInput);
  }
コード例 #2
0
  @Test
  public void testReset() throws Exception {
    // Given
    HasValue<String> loginInput = mock(HasValue.class);
    HasValue<String> phoneInput = mock(HasValue.class);
    HasValue<String> lastNameInput = mock(HasValue.class);
    HasValue<String> firstNameInut = mock(HasValue.class);
    HasValue<String> emailInput = mock(HasValue.class);
    HasValue<String> passwordInput = mock(HasValue.class);
    HasValue<String> roleInput = mock(HasValue.class);
    when(operatorView.getLoginInput()).thenReturn(loginInput);
    when(operatorView.getFirstNameInput()).thenReturn(firstNameInut);
    when(operatorView.getPhoneInput()).thenReturn(phoneInput);
    when(operatorView.getLastNameInput()).thenReturn(lastNameInput);
    when(operatorView.getMailInput()).thenReturn(emailInput);
    when(operatorView.getPasswordInput()).thenReturn(passwordInput);
    when(operatorView.getRoleInput()).thenReturn(roleInput);

    // When
    presenter.reset();

    // Then
    verify(operatorView).setPresenter(presenter);

    verify(operatorView).getLoginInput();
    verify(operatorView).getFirstNameInput();
    verify(operatorView).getPhoneInput();
    verify(operatorView).getLastNameInput();
    verify(operatorView).getMailInput();
    verify(operatorView).getPasswordInput();
    verify(operatorView).getRoleInput();

    verify(loginInput).setValue((String) isNull());
    verify(firstNameInut).setValue((String) isNull());
    verify(phoneInput).setValue((String) isNull());
    verify(lastNameInput).setValue((String) isNull());
    verify(emailInput).setValue((String) isNull());
    verify(passwordInput).setValue((String) isNull());
    verify(roleInput).setValue((String) isNull());

    verifyNoMoreInteractions(operatorView);

    verifyNoMoreInteractions(loginInput);
    verifyNoMoreInteractions(firstNameInut);
    verifyNoMoreInteractions(phoneInput);
    verifyNoMoreInteractions(lastNameInput);
    verifyNoMoreInteractions(emailInput);
    verifyNoMoreInteractions(passwordInput);
    verifyNoMoreInteractions(roleInput);
  }