WorldpayHopResponseController extends WorldpayChoosePaymentMethodCheckoutStepController { @RequestMapping(value = "/hop-cancel", method = RequestMethod.GET) @RequireHardLogIn public String doCancelPayment() { String redirectUrl = REDIRECT_URL_CHOOSE_PAYMENT_METHOD; if (!getCheckoutFacade().hasValidCart()) { redirectUrl = REDIRECT_URL_CART; } else if (getCheckoutFacade().hasNoDeliveryAddress()) { redirectUrl = REDIRECT_URL_ADD_DELIVERY_ADDRESS; } else if (getCheckoutFacade().hasNoDeliveryMode()) { redirectUrl = REDIRECT_URL_CHOOSE_DELIVERY_METHOD; } return redirectUrl; }  @RequireHardLogIn @RequestMapping(value = "/hop-response", method = RequestMethod.GET) String doHandleHopResponse(final HttpServletRequest request, final Model model, final RedirectAttributes redirectAttributes); @RequireHardLogIn @RequestMapping(value = "/hop-pending", method = RequestMethod.GET) String doHandlePendingHopResponse(final HttpServletRequest request, final Model model, final RedirectAttributes redirectAttributes); @RequireHardLogIn @RequestMapping(value = "bank-transfer/hop-response", method = RequestMethod.GET) String doHandleBankTransferHopResponse(final HttpServletRequest request, final Model model, final RedirectAttributes redirectAttributes); @RequireHardLogIn @RequestMapping(value = "bank-transfer/hop-failure", method = RequestMethod.GET) String doHandleBankTransferHopFailure(final HttpServletRequest request, final RedirectAttributes redirectAttributes); @RequestMapping(value = "/hop-cancel", method = RequestMethod.GET) @RequireHardLogIn String doCancelPayment(); @RequestMapping(value = "/error", method = RequestMethod.GET) @RequireHardLogIn String doHostedOrderPageError(@RequestParam(value = "paymentStatus", required = false) final String paymentStatus, final RedirectAttributes redirectAttributes); @RequestMapping(value = "/billingaddressform", method = RequestMethod.GET) String getCountryAddressForm(@RequestParam("countryIsoCode") final String countryIsoCode,
                                        @RequestParam("useDeliveryAddress") final boolean useDeliveryAddress, final Model model);  }
@Test public void shouldReturnChoosePaymentMethodURL() { final String result = testObj.doCancelPayment(); assertEquals(REDIRECT_URL_CHOOSE_PAYMENT_METHOD, result); }
@Test public void shouldReturnCartURLWhenInvalidCart() { when(checkoutFacadeMock.hasValidCart()).thenReturn(false); final String result = testObj.doCancelPayment(); assertEquals(AbstractController.REDIRECT_PREFIX + "/cart", result); }
@Test public void shouldReturnAddDeliveryAddressURLWhenHasNoDeliveryAddress() { when(checkoutFacadeMock.hasNoDeliveryAddress()).thenReturn(true); final String result = testObj.doCancelPayment(); assertEquals(REDIRECT_URL_ADD_DELIVERY_ADDRESS, result); }
@Test public void shouldReturnChooseDeliveryMethodURLWhenHasNoDeliveryMode() { when(checkoutFacadeMock.hasNoDeliveryMode()).thenReturn(true); final String result = testObj.doCancelPayment(); assertEquals(REDIRECT_URL_CHOOSE_DELIVERY_METHOD, result); }