WorldpayChoosePaymentMethodCheckoutStepController extends AbstractWorldpayPaymentMethodCheckoutStepController { @RequestMapping(value = "/choose", method = GET) @RequireHardLogIn public String doSelectPaymentMethod(@RequestParam("selectedPaymentMethodId") final String selectedPaymentMethodId) { if (isNotBlank(selectedPaymentMethodId)) { getSessionService().setAttribute(SAVED_CARD_SELECTED_ATTRIBUTE, Boolean.TRUE); getCheckoutFacade().setPaymentDetails(selectedPaymentMethodId); worldpayCartFacade.setBillingAddressFromPaymentInfo(); } return getCheckoutStep().nextStep(); }  @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 shouldRedirectToNextStep() { when(checkoutStepMock.nextStep()).thenReturn(NEXT_PAGE); final String result = testObj.doSelectPaymentMethod(SELECTED_PAYMENT_METHOD_ID); verify(sessionServiceMock).setAttribute(SAVED_CARD_SELECTED_ATTRIBUTE, true); verify(checkoutFacadeMock).setPaymentDetails(SELECTED_PAYMENT_METHOD_ID); verify(worldpayCartFacadeMock).setBillingAddressFromPaymentInfo(); assertEquals(NEXT_PAGE, result); }
@Test public void shouldRedirectToNextStepAndNotSetPaymentMethod() { when(checkoutStepMock.nextStep()).thenReturn(NEXT_PAGE); final String result = testObj.doSelectPaymentMethod(""); verify(checkoutFacadeMock, never()).setPaymentDetails(any()); assertEquals(NEXT_PAGE, result); }