@Override public void populateAddressISOCountrySub(Address address) { if (StringUtils.isBlank(address.getIsoCountrySubdivision()) && address.getIsoCountryAlpha2() != null && StringUtils.isNotBlank(address.getStateProvinceRegion())) { String friendlyStateProvRegion = address.getStateProvinceRegion(); CountrySubdivision isoCountrySub = countrySubdivisionService.findSubdivisionByCountryAndAltAbbreviation(address.getIsoCountryAlpha2().getAlpha2(), friendlyStateProvRegion); if (isoCountrySub == null) { isoCountrySub = countrySubdivisionService.findSubdivisionByCountryAndName(address.getIsoCountryAlpha2().getAlpha2(), friendlyStateProvRegion); } if (isoCountrySub != null) { address.setIsoCountrySubdivision(isoCountrySub.getAbbreviation()); } } }
/** * This method only exists because so many other tests depend on it, but should be removed once tests are more isolated * @param customerAddress */ @Deprecated @Test(groups = "createCustomerAddress", dataProvider = "setupCustomerAddress", dataProviderClass = CustomerAddressDataProvider.class, dependsOnGroups = {"readCustomer", "createCountry", "createState"}) @Transactional @Rollback(false) public void createCustomerAddress(CustomerAddress customerAddress) { userName = "customer1"; Customer customer = customerService.readCustomerByUsername(userName); assert customerAddress.getId() == null; customerAddress.setCustomer(customer); State state = stateService.findStateByAbbreviation("KY"); customerAddress.getAddress().setState(state); Country country = countryService.findCountryByAbbreviation("US"); customerAddress.getAddress().setCountry(country); customerAddress.getAddress().setIsoCountrySubdivision("US-KY"); ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code("US"); customerAddress.getAddress().setIsoCountryAlpha2(isoCountry); customerAddress = customerAddressService.saveCustomerAddress(customerAddress); assert customer.equals(customerAddress.getCustomer()); userId = customerAddress.getCustomer().getId(); }
/** * Saves a customerAddress with state KY and country US. Requires that createCountry() and createState() have been called * @param customerAddress */ public CustomerAddress saveCustomerAddress(CustomerAddress customerAddress) { State state = stateService.findStateByAbbreviation("KY"); customerAddress.getAddress().setState(state); Country country = countryService.findCountryByAbbreviation("US"); customerAddress.getAddress().setCountry(country); customerAddress.getAddress().setIsoCountrySubdivision("US-KY"); ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code("US"); customerAddress.getAddress().setIsoCountryAlpha2(isoCountry); return customerAddressService.saveCustomerAddress(customerAddress); }
address.setIsoCountrySubdivision(isoCountrySub.getAbbreviation()); address.setStateProvinceRegion(isoCountrySub.getName()); } else {
cloned.setFullName(fullName); cloned.setIsoCountryAlpha2(isoCountryAlpha2); cloned.setIsoCountrySubdivision(isoCountrySubdivision); cloned.setStreet(isStreet); cloned.setZipFour(zipFour);
address.setIsoCountrySubdivision("US-TX"); address.setIsoCountryAlpha2(isoCountry);
address.setIsoCountrySubdivision("US-TX"); address.setIsoCountryAlpha2(isoCountry); group1.setAddress(address);
dest.setState(orig.getState()); dest.setCounty(orig.getCounty()); dest.setIsoCountrySubdivision(orig.getIsoCountrySubdivision()); dest.setStateProvinceRegion(orig.getStateProvinceRegion()); dest.setPostalCode(orig.getPostalCode());
address1.setIsoCountrySubdivision("US-TX"); fg1.setAddress(address1); fg1.setOrder(order); address2.setIsoCountrySubdivision("US-TX"); fg2.setAddress(address2); fg2.setOrder(order);
address1.setIsoCountrySubdivision("US-TX"); fg1.setAddress(address1); fg1.setOrder(order); address2.setIsoCountrySubdivision("US-TX"); fg2.setAddress(address2); fg2.setOrder(order);
address.setState(state); address.setCountry(country); address.setIsoCountrySubdivision("US-TX"); address.setIsoCountryAlpha2(isoCountry);
address.setState(stateService.findStateByAbbreviation("KY")); address.setCountry(countryService.findCountryByAbbreviation("US")); address.setIsoCountrySubdivision("US-KY"); address.setIsoCountryAlpha2(isoService.findISOCountryByAlpha2Code("US"));
@Override public Address updateEntity(final Address address, final AddressDto addressDto) { address.setAddressLine1(Optional.ofNullable(addressDto.getAddressLine1()).orElse("")); address.setAddressLine2(addressDto.getAddressLine2()); address.setAddressLine3(addressDto.getAddressLine3()); address.setFirstName(addressDto.getFirstName()); address.setLastName(addressDto.getLastName()); address.setCity(Optional.ofNullable(addressDto.getCity()).orElse("")); address.setPostalCode(addressDto.getPostalCode()); address.setCompanyName(addressDto.getCompanyName()); address.setCounty(addressDto.getCountrySubdivisionCode()); address.setIsoCountrySubdivision(addressDto.getCountrySubdivisionCode()); Optional.ofNullable(addressDto.getCountryCode()) .ifPresent(countryCode -> address.setIsoCountryAlpha2(isoService.findISOCountryByAlpha2Code(countryCode))); address.setEmailAddress(addressDto.getEmail()); Optional.ofNullable(addressDto.getPhone()).ifPresent(phone -> address.setPhonePrimary(phoneNumberFormat.parseObject(phone, new ParsePosition(0))) ); return address; }