コード例 #1
0
  @Test
  public void validateGender() {
    when(person.getGender()).thenReturn(null);

    exception.expect(GenderNotProvidedException.class);

    subject.execute(person);
  }
コード例 #2
0
  @Test
  public void validateName_personWithBlankName() {
    when(person.getName()).thenReturn("");

    exception.expect(PersonsNameNotProvidedException.class);

    subject.execute(person);
  }
コード例 #3
0
  @Test
  public void execute() {
    subject.execute(person);

    verify(createContact).execute(contact);
    verify(repository).findByContactEmail(PERSONS_EMAIL);
    verify(repository).save(person);
  }
コード例 #4
0
  @Test
  public void validateSingleness_personAlreadyRegistered() {
    when(repository.findByContactEmail(PERSONS_EMAIL)).thenReturn(Optional.of(person));

    exception.expect(PersonAlreadyRegisteredException.class);

    subject.execute(person);
  }
コード例 #5
0
  @Test
  public void validateBirthDate() {
    when(birthDate.after(any(Date.class))).thenReturn(true);
    when(person.getBirthDate()).thenReturn(birthDate);

    exception.expect(InvalidBirthDateException.class);

    subject.execute(person);
  }
コード例 #6
0
  @Test
  public void validateIfPersonIsNull() {
    exception.expect(NoPersonProvidedException.class);

    subject.execute(null);
  }