@Test public void validateGender() { when(person.getGender()).thenReturn(null); exception.expect(GenderNotProvidedException.class); subject.execute(person); }
@Test public void validateName_personWithBlankName() { when(person.getName()).thenReturn(""); exception.expect(PersonsNameNotProvidedException.class); subject.execute(person); }
@Test public void execute() { subject.execute(person); verify(createContact).execute(contact); verify(repository).findByContactEmail(PERSONS_EMAIL); verify(repository).save(person); }
@Test public void validateSingleness_personAlreadyRegistered() { when(repository.findByContactEmail(PERSONS_EMAIL)).thenReturn(Optional.of(person)); exception.expect(PersonAlreadyRegisteredException.class); subject.execute(person); }
@Test public void validateBirthDate() { when(birthDate.after(any(Date.class))).thenReturn(true); when(person.getBirthDate()).thenReturn(birthDate); exception.expect(InvalidBirthDateException.class); subject.execute(person); }
@Test public void validateIfPersonIsNull() { exception.expect(NoPersonProvidedException.class); subject.execute(null); }