コード例 #1
0
  @Test
  public void preventsDuplicateEmail() {

    Customer dave = repository.findByEmailAddress(new EmailAddress("*****@*****.**"));

    Customer anotherDave = new Customer("Dave", "Matthews");
    anotherDave.setEmailAddress(dave.getEmailAddress());

    repository.save(anotherDave);
  }
コード例 #2
0
  @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));
  }
コード例 #3
0
  @Test
  public void savesCustomerCorrectly() {

    EmailAddress email = new EmailAddress("*****@*****.**");

    Customer dave = new Customer("Alicia", "Keys");
    dave.setEmailAddress(email);
    dave.add(new Address("27 Broadway", "New York", "United States"));

    Customer result = repository.save(dave);
    assertThat(result.getId(), is(notNullValue()));
  }