private void applyShippingAddress(final Address address) { this.titleShipping = address.getTitle(); this.firstNameShipping = address.getFirstName(); this.lastNameShipping = address.getLastName(); this.streetNameShipping = address.getStreetName(); this.additionalStreetInfoShipping = address.getAdditionalStreetInfo(); this.cityShipping = address.getCity(); this.postalCodeShipping = address.getPostalCode(); this.countryShipping = address.getCountry().getAlpha2(); this.regionShipping = address.getRegion(); this.phoneShipping = address.getPhone(); this.emailShipping = address.getEmail(); }
private void applyBillingAddress(final Address address) { this.titleBilling = address.getTitle(); this.firstNameBilling = address.getFirstName(); this.lastNameBilling = address.getLastName(); this.streetNameBilling = address.getStreetName(); this.additionalStreetInfoBilling = address.getAdditionalStreetInfo(); this.cityBilling = address.getCity(); this.postalCodeBilling = address.getPostalCode(); this.countryBilling = address.getCountry().getAlpha2(); this.regionBilling = address.getRegion(); this.phoneBilling = address.getPhone(); this.emailBilling = address.getEmail(); }
@Test public void changeAddress() throws Exception { withCustomerWithOneAddress(client(), customer -> { final String city = "new city"; assertThat(customer.getAddresses()).hasSize(1); assertThat(customer.getAddresses().get(0).getCity()).isNotEqualTo(city); final Address oldAddress = customer.getAddresses().get(0); assertThat(oldAddress.getId()) .overridingErrorMessage("only fetched address contains an ID") .isNotNull(); final Address newAddress = oldAddress.withCity(city); final ChangeAddress updateAction = ChangeAddress.ofOldAddressToNewAddress(oldAddress, newAddress); final Customer customerWithReplacedAddress = client().executeBlocking(CustomerUpdateCommand.of(customer, updateAction)); assertThat(customerWithReplacedAddress.getAddresses()).hasSize(1); assertThat(customerWithReplacedAddress.getAddresses().get(0).getCity()).contains(city); Query<CustomerAddressChangedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(customer)) .withSort(m -> m.createdAt().sort().desc()) .withLimit(1L) .forMessageType(CustomerAddressChangedMessage.MESSAGE_HINT); assertEventually(() -> { final PagedQueryResult<CustomerAddressChangedMessage> queryResult = client().executeBlocking(messageQuery); assertThat(queryResult.head()).isPresent(); final CustomerAddressChangedMessage message = queryResult.head().get(); assertThat(message.getAddress()).isEqualTo(newAddress); }); }); }
@Test public void addAddress() throws Exception { withCustomer(client(), customer -> { final String city = "addAddress"; final Address newAddress = AddressBuilder.of(DE).city(city).build(); final Predicate<Address> containsNewAddressPredicate = a -> a.getCity().equals(city); assertThat(customer.getAddresses().stream() .anyMatch(containsNewAddressPredicate)) .overridingErrorMessage("address is not present, yet") .isFalse(); final Customer updatedCustomer = client().executeBlocking(CustomerUpdateCommand.of(customer, AddAddress.of(newAddress))); assertThat(updatedCustomer.getAddresses().stream() .anyMatch(containsNewAddressPredicate)).isTrue(); Query<CustomerAddressAddedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(customer)) .withSort(m -> m.createdAt().sort().desc()) .withLimit(1L) .forMessageType(CustomerAddressAddedMessage.MESSAGE_HINT); assertEventually(() -> { final PagedQueryResult<CustomerAddressAddedMessage> queryResult = client().executeBlocking(messageQuery); assertThat(queryResult.head()).isPresent(); }); }); }
protected void fillAddressFields(final AddressBean bean, final Address address) { bean.setTitle(address.getTitle()); bean.setFirstName(address.getFirstName()); bean.setLastName(address.getLastName()); bean.setStreetName(address.getStreetName()); bean.setAdditionalStreetInfo(address.getAdditionalStreetInfo()); bean.setCity(address.getCity()); bean.setRegion(address.getRegion()); bean.setPostalCode(address.getPostalCode()); bean.setCountry(getDisplayCountry(address)); bean.setPhone(address.getPhone()); bean.setEmail(address.getEmail()); }