@Test public void preventsDuplicateEmail() { Customer dave = repository.findByEmailAddress(new EmailAddress("*****@*****.**")); Customer anotherDave = new Customer("Dave", "Matthews"); anotherDave.setEmailAddress(dave.getEmailAddress()); repository.save(anotherDave); }
@Test public void readsCustomerByEmail() { EmailAddress email = new EmailAddress("*****@*****.**"); Customer alicia = new Customer("Alicia", "Keys"); alicia.setEmailAddress(email); repository.save(alicia); Customer result = repository.findByEmailAddress(email); assertThat(result, is(alicia)); }