HttpRequestPaymentDetailsWsDTOPopulator extends AbstractHttpRequestWsDTOPopulator implements
        ConfigurablePopulator<HttpServletRequest, PaymentDetailsWsDTO, PaymentDetailsWsDTOOption> { @Override public void populate(final HttpServletRequest request, final PaymentDetailsWsDTO target, final Collection<PaymentDetailsWsDTOOption> options) throws ConversionException { target.setAccountHolderName(updateStringValueFromRequest(request, ACCOUNT_HOLDER_NAME, target.getAccountHolderName())); target.setCardNumber(updateStringValueFromRequest(request, CARD_NUMBER, target.getCardNumber())); target.setCardType(updateCartTypeFromRequest(request, target.getCardType())); target.setIssueNumber(updateStringValueFromRequest(request, ISSUE_NUMBER, target.getIssueNumber())); target.setCseToken(updateStringValueFromRequest(request, CSE_TOKEN, target.getCseToken())); target.setExpiryMonth(updateStringValueFromRequest(request, EXPIRY_MONTH, target.getExpiryMonth())); target.setExpiryYear(updateStringValueFromRequest(request, EXPIRY_YEAR, target.getExpiryYear())); target.setStartMonth(updateStringValueFromRequest(request, START_MONTH, target.getStartMonth())); target.setStartYear(updateStringValueFromRequest(request, START_YEAR, target.getStartYear())); target.setSubscriptionId(updateStringValueFromRequest(request, SUBSCRIPTION_ID, target.getSubscriptionId())); target.setId(updateStringValueFromRequest(request, ID, target.getId())); target.setSaved(updateBooleanValueFromRequest(request, SAVED, Boolean.TRUE.equals(target.getSaved()))); target.setDefaultPayment(updateBooleanValueFromRequest(request, DEFAULT_PAYMENT_INFO, Boolean.TRUE.equals(target.getDefaultPayment()))); if (options.contains(PaymentDetailsWsDTOOption.BILLING_ADDRESS)) { final AddressWsDTO billingAddress = target.getBillingAddress() == null ? new AddressWsDTO() : target.getBillingAddress(); final HttpRequestAddressWsDTOPopulator billingAddressPopulator = getAddressPopulator(); billingAddressPopulator.setAddressPrefix("billingAddress"); billingAddressPopulator.populate(request, billingAddress); target.setBillingAddress(billingAddress); } }  @Override void populate(final HttpServletRequest request, final PaymentDetailsWsDTO target,
                         final Collection<PaymentDetailsWsDTOOption> options);  }
@Test public void testBasicPopulationOfBasicFields() { testObject.populate(httpServletRequestMock, paymentDetails, options); verifyBasic(paymentDetails); assertNull("Expect no billing address", paymentDetails.getBillingAddress()); }
@Test public void testBasicPopulationOfAllFields() { options.add(PaymentDetailsWsDTOOption.BILLING_ADDRESS); testObject.populate(httpServletRequestMock, paymentDetails, options); verifyBasic(paymentDetails); verify(httpRequestAddressWsDTOPopulatorMock).populate(httpServletRequestMock, paymentDetails.getBillingAddress()); verify(httpRequestAddressWsDTOPopulatorMock).setAddressPrefix("billingAddress"); assertNotNull("Expect billing address", paymentDetails.getBillingAddress()); }