HttpRequestAddressWsDTOPopulator extends AbstractHttpRequestWsDTOPopulator implements Populator<HttpServletRequest, AddressWsDTO> { @Override public void populate(final HttpServletRequest request, final AddressWsDTO addressData) { Assert.notNull(request, "Parameter request cannot be null."); Assert.notNull(addressData, "Parameter addressData cannot be null."); addressData.setId(updateStringValueFromRequest(request, ADDRESS_ID, addressData.getId())); addressData.setTitleCode(updateStringValueFromRequest(request, TITLE_CODE, addressData.getTitleCode())); addressData.setTitle(updateStringValueFromRequest(request, TITLE, addressData.getTitle())); addressData.setFirstName(updateStringValueFromRequest(request, FIRST_NAME, addressData.getFirstName())); addressData.setLastName(updateStringValueFromRequest(request, LAST_NAME, addressData.getLastName())); addressData.setLine1(updateStringValueFromRequest(request, LINE1, addressData.getLine1())); addressData.setLine2(updateStringValueFromRequest(request, LINE2, addressData.getLine2())); addressData.setTown(updateStringValueFromRequest(request, TOWN, addressData.getTown())); addressData.setPostalCode(updateStringValueFromRequest(request, POSTCODE, addressData.getPostalCode())); addressData.setCompanyName(updateStringValueFromRequest(request, COMPANY_NAME, addressData.getCompanyName())); addressData.setPhone(updateStringValueFromRequest(request, PHONE, addressData.getPhone())); addressData.setEmail(updateStringValueFromRequest(request, EMAIL, addressData.getEmail())); addressData.setFormattedAddress(updateStringValueFromRequest(request, FORMATTED_ADDRESS, addressData.getFormattedAddress())); addressData.setCountry(updateCountryFromRequest(request, addressData.getCountry())); addressData.setRegion(updateRegionFromRequest(request, addressData.getRegion())); addressData.setShippingAddress(updateBooleanValueFromRequest(request, SHIPPING_ADDRESS, Boolean.TRUE.equals(addressData.getShippingAddress()))); addressData.setVisibleInAddressBook(updateBooleanValueFromRequest(request, VISIBLE_IN_ADDRESS_BOOK, Boolean.TRUE.equals(addressData.getVisibleInAddressBook()))); }  @Override void populate(final HttpServletRequest request, final AddressWsDTO addressData); void setAddressPrefix(final String addressPrefix);  }
@Test public void testBasicPopulationOfAllFields() { testObject.populate(httpServletRequestMock, addressWsDTO); assertEquals(HttpRequestAddressWsDTOPopulator.COMPANY_NAME , addressWsDTO.getCompanyName()); assertEquals(HttpRequestAddressWsDTOPopulator.EMAIL, addressWsDTO.getEmail()); assertEquals(HttpRequestAddressWsDTOPopulator.FIRST_NAME, addressWsDTO.getFirstName()); assertEquals(HttpRequestAddressWsDTOPopulator.FORMATTED_ADDRESS, addressWsDTO.getFormattedAddress()); assertEquals(HttpRequestAddressWsDTOPopulator.ADDRESS_ID, addressWsDTO.getId()); assertEquals(HttpRequestAddressWsDTOPopulator.LAST_NAME, addressWsDTO.getLastName()); assertEquals(HttpRequestAddressWsDTOPopulator.LINE1, addressWsDTO.getLine1()); assertEquals(HttpRequestAddressWsDTOPopulator.LINE2, addressWsDTO.getLine2()); assertEquals(HttpRequestAddressWsDTOPopulator.PHONE, addressWsDTO.getPhone()); assertEquals(HttpRequestAddressWsDTOPopulator.POSTCODE, addressWsDTO.getPostalCode()); assertEquals(HttpRequestAddressWsDTOPopulator.TITLE_CODE, addressWsDTO.getTitleCode()); assertEquals(HttpRequestAddressWsDTOPopulator.TITLE, addressWsDTO.getTitle()); assertEquals(HttpRequestAddressWsDTOPopulator.TOWN, addressWsDTO.getTown()); assertFalse(addressWsDTO.getShippingAddress()); assertFalse(addressWsDTO.getVisibleInAddressBook()); assertEquals(COUNTRY, addressWsDTO.getCountry().getIsocode()); assertEquals(REGION, addressWsDTO.getRegion().getIsocode()); }