@Nonnull public Customer.Builder toBuilder() { return new Customer.Builder().withId(id) .withName(name) .withBillingAddress(billingAddressXml.toAddress()) .withVatNumber(vatNumber); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public void importCustomers() throws IOException { log.debug("importCustomers()"); final NativeAddressBook addressBook = NativeAddressBook.instance(); IBizUtils.loadConfiguration(path.resolve("clients")).getStream("clients").forEach(customerConfig -> { final String firstName = trim(customerConfig.getString("firstName")); final String clientCompany = customerConfig.getString("clientCompany"); final Contact contact = getContact(addressBook, firstName, clientCompany); customerRegistry.addCustomer().withId(customerConfig.getId("addressBookId")) .withName(firstName) .withBillingAddress(getAddress(contact)) .withVatNumber(getVatNumber(contact)) .create(); }); }
@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)")); } }
customerRegistry.addCustomer() .withId(new Id("" + nextId++)) .withName("ACME Consulting") .withBillingAddress(Address.builder().withStreet("Corso Italia 10") .withCity("Genova") customerRegistry.addCustomer() .withId(new Id("" + nextId++)) .withName("ACME Financing") .withBillingAddress(Address.builder().withStreet("Corso Magenta 20") .withCity("Milano")
.create(); final Customer c1 = Customer.builder().withId(new Id("1")) .withName("Acme Corp.") .withVatNumber("1233455345") .withBillingAddress(a1)