WorldpaySummaryCheckoutStepController extends AbstractWorldpayDirectCheckoutStepController { @RequestMapping(value = "/express", method = RequestMethod.GET) @RequireHardLogIn public String performExpressCheckout(final Model model, final RedirectAttributes redirectModel, final HttpServletResponse response) throws CMSItemNotFoundException { if (getSessionService().getAttribute(WebConstants.CART_RESTORATION) != null && CollectionUtils.isNotEmpty(((CartRestorationData) getSessionService().getAttribute(WebConstants.CART_RESTORATION)) .getModifications())) { return REDIRECT_URL_CART; } String returnCode = REDIRECT_URL_CART; if (getCheckoutFlowFacade().hasValidCart()) { switch (getCheckoutFacade().performExpressCheckout()) { case SUCCESS: returnCode = enterStep(model, redirectModel, response); break; case ERROR_DELIVERY_ADDRESS: addFlashMessage(redirectModel, ERROR_MESSAGES_HOLDER, "checkout.express.error.deliveryAddress"); returnCode = REDIRECT_URL_ADD_DELIVERY_ADDRESS; break; case ERROR_DELIVERY_MODE: case ERROR_CHEAPEST_DELIVERY_MODE: addFlashMessage(redirectModel, ERROR_MESSAGES_HOLDER, "checkout.express.error.deliveryMode"); returnCode = REDIRECT_URL_CHOOSE_DELIVERY_METHOD; break; case ERROR_PAYMENT_INFO: addFlashMessage(redirectModel, ERROR_MESSAGES_HOLDER, "checkout.express.error.paymentInfo"); returnCode = REDIRECT_URL_CHOOSE_PAYMENT_METHOD; break; default: addFlashMessage(redirectModel, ERROR_MESSAGES_HOLDER, "checkout.express.error.notAvailable"); } } return returnCode; }  @RequestMapping(value = "/view", method = RequestMethod.GET) @RequireHardLogIn @PreValidateCheckoutStep(checkoutStep = SUMMARY) String enterStep(final Model model, final RedirectAttributes redirectAttributes, final HttpServletResponse response); @RequestMapping(value = "/placeOrder") @RequireHardLogIn String placeOrder(@ModelAttribute("csePaymentForm") final CSEPaymentForm csePaymentForm, final Model model,
                             final HttpServletRequest request, final RedirectAttributes redirectAttributes, final HttpServletResponse response); @RequestMapping(value = "/express", method = RequestMethod.GET) @RequireHardLogIn String performExpressCheckout(final Model model, final RedirectAttributes redirectModel, final HttpServletResponse response); @GetMapping(value = "/DDCIframe") @RequireHardLogIn String getDDCIframeContent(final Model model); @GetMapping(value = "/challengeIframe") @RequireHardLogIn String getChallengeIframeContent(final Model model); @RequestMapping(value = "/back", method = RequestMethod.GET) @RequireHardLogIn @Override String back(final RedirectAttributes redirectAttributes); @RequestMapping(value = "/next", method = RequestMethod.GET) @RequireHardLogIn @Override String next(final RedirectAttributes redirectAttributes); @Override CheckoutFlowFacade getCheckoutFlowFacade();  }
@Test public void performExpressCheckoutShouldRedirectToCartPageWhenItIsRestored() throws CMSItemNotFoundException { when(sessionServiceMock.getAttribute(WebConstants.CART_RESTORATION)).thenReturn(cartRestorationDataMock); when(cartRestorationDataMock.getModifications()).thenReturn(singletonList(cartModificationDataMock)); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_PREFIX + CART_SUFFIX, result); verify(checkoutFlowFacadeMock, never()).hasValidCart(); }
@Test public void performExpressCheckoutShouldRedirectSummaryPageWhenCartIsValidAndPerformExpressCheckoutIsSUCCESS() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.SUCCESS); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(CHECKOUT_SUMMARY_PAGE, result); }
@Test public void performExpressCheckoutShouldRedirectAddDeliveryAddressWhenCartIsValidAndPerformExpressCheckoutIsErrorDeliveryAddress() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.ERROR_DELIVERY_ADDRESS); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_PREFIX + "/checkout/multi/delivery-address/add", result); }
@Test public void performExpressCheckoutShouldRedirectChooseDeliveryMethodWhenCartIsValidAndPerformExpressCheckoutIsErrorDeliveryMode() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.ERROR_DELIVERY_MODE); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_PREFIX + CHECKOUT_MULTI_DELIVERY_METHOD_CHOOSE, result); }
@Test public void performExpressCheckoutShouldRedirectChooseDeliveryMethodWhenCartIsValidAndPerformExpressCheckoutIsCheapestDeliveryMode() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.ERROR_CHEAPEST_DELIVERY_MODE); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_PREFIX + CHECKOUT_MULTI_DELIVERY_METHOD_CHOOSE, result); }
@Test public void performExpressCheckoutShouldRedirectChoosePaymentMethodWhenCartIsValidAndPerformExpressCheckoutIsErrorPaymentInfo() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.ERROR_PAYMENT_INFO); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_URL_CHOOSE_PAYMENT_METHOD, result); }
@Test public void performExpressCheckoutShouldRedirectCartPageWhenCartIsValidAndPerformExpressCheckoutIsErrorNotAvailable() throws CMSItemNotFoundException { when(checkoutFacadeMock.performExpressCheckout()).thenReturn(AcceleratorCheckoutFacade.ExpressCheckoutResult.ERROR_NOT_AVAILABLE); final String result = testObj.performExpressCheckout(modelMock, redirectAttributesMock, responseMock); assertEquals(REDIRECT_PREFIX + CART_SUFFIX, result); }