@Test public void toString_must_return_all_the_fields() { final Address a1 = Address.builder().withStreet("Foo Bar rd 20") .withCity("San Francisco") .withZip("12345") .withState("CA") .withCountry("USA") .create(); assertThat(a1.toString(), is("Address(street=Foo Bar rd 20, city=San Francisco, state=CA, country=USA, zip=12345)")); } }
@Nonnull public Address toAddress() { return Address.builder().withStreet(street) .withCity(city) .withZip(zip) .withState(state) .withCountry(country) .create(); } }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull private Address getAddress (final @Nonnull Contact contact) { Address.Builder addressBuilder = Address.builder(); if (contact.getAddress() != null) { final corny.addressbook.data.Address addr = contact.getAddress().getFirstHomeValue(); addressBuilder = addressBuilder.withCity(addr.getCity()) .withState(addr.getCountry()) .withStreet(addr.getStreet()) .withZip("" + addr.getZip()); } return addressBuilder.create(); }
.withName("ACME Consulting") .withBillingAddress(Address.builder().withStreet("Corso Italia 10") .withCity("Genova") .withState("GE") .withZip("16145") .withName("ACME Financing") .withBillingAddress(Address.builder().withStreet("Corso Magenta 20") .withCity("Milano") .withState("MI") .withZip("20100")
.withCity("San Francisco") .withZip("12345") .withState("CA")
@Test public void toString_must_return_all_the_fields() { final Address a1 = Address.builder().withStreet("Foo Bar rd 20") .withCity("San Francisco") .withZip("12345") .withState("CA") .withCountry("USA") .create(); final Customer c1 = Customer.builder().withId(new Id("the id")) .withName("Acme Corp.") .withVatNumber("1233455345") .withBillingAddress(a1) .create(); assertThat(c1.toString(), is("InMemoryCustomer(id=the id, name=Acme Corp., billingAddress=Address(street=Foo Bar rd 20, " + "city=San Francisco, state=CA, country=USA, zip=12345), vatNumber=1233455345)")); } }