WorldpayChoosePaymentMethodCheckoutStepController extends AbstractWorldpayPaymentMethodCheckoutStepController { protected void handleAndSaveAddresses(final @Valid PaymentDetailsForm paymentDetailsForm) { final Boolean useDeliveryAddress = paymentDetailsForm.getUseDeliveryAddress(); final AddressData addressData = getAddressData(paymentDetailsForm.getBillingAddress(), useDeliveryAddress); addressData.setEmail(getCheckoutCustomerStrategy().getCurrentUserForCheckout().getContactEmail()); if (shouldSaveAddressInProfile(useDeliveryAddress)) { getUserFacade().addAddress(addressData); } worldpayPaymentCheckoutFacade.setBillingDetails(addressData); }  @Override @RequestMapping(method = GET, value = {"", "/", "/add-cse-payment-details", "/add-payment-details"}) @RequireHardLogIn @PreValidateCheckoutStep(checkoutStep = CHOOSE_PAYMENT_METHOD) String enterStep(final Model model, final RedirectAttributes redirectAttributes); @RequestMapping(value = "/getDeclineMessage", method = GET) @ResponseBody String getDeclineMessage(); @RequestMapping(value = "/choose", method = GET) @RequireHardLogIn String doSelectPaymentMethod(@RequestParam("selectedPaymentMethodId") final String selectedPaymentMethodId); @ModelAttribute(value = "getTermsAndConditionsUrl") String getTermsAndConditionsUrl(final HttpServletRequest request); @RequestMapping(value = "/remove", method = POST) @RequireHardLogIn String remove(@RequestParam(value = "paymentInfoId") final String paymentMethodId,
                         final RedirectAttributes redirectAttributes); @RequestMapping(value = "/back", method = GET) @RequireHardLogIn @Override String back(final RedirectAttributes redirectAttributes); @RequestMapping(value = "/next", method = GET) @RequireHardLogIn @Override String next(final RedirectAttributes redirectAttributes); String getRedirectToPaymentMethod(); PaymentDetailsFormValidator getPaymentDetailsFormValidator(); MessageSource getThemeSource();  }
@Test public void shouldNotSaveDeliveryAddress() { when(paymentDetailsFormMock.getUseDeliveryAddress()).thenReturn(true); when(cartDataMock.getDeliveryAddress()).thenReturn(addressDataMock); testObj.handleAndSaveAddresses(paymentDetailsFormMock); verify(userFacadeMock, never()).addAddress(addressDataMock); verify(worldpayPaymentCheckoutFacadeMock).setBillingDetails(addressDataMock); }