@Test public void validateSingleness_personAlreadyRegistered() { when(repository.findByContactEmail(PERSONS_EMAIL)).thenReturn(Optional.of(person)); exception.expect(PersonAlreadyRegisteredException.class); subject.execute(person); }
private void configureRepository() { when(repository.findByContactEmail(PERSONS_EMAIL)).thenReturn(Optional.ofNullable(null)); }