WorldpayChoosePaymentMethodCheckoutStepController extends AbstractWorldpayPaymentMethodCheckoutStepController { @RequestMapping(value = "/getDeclineMessage", method = GET) @ResponseBody public String getDeclineMessage() { final String worldpayDeclineCode = getCheckoutFacade().getCheckoutCart().getWorldpayDeclineCode(); if (worldpayDeclineCode != null && !"0".equalsIgnoreCase(worldpayDeclineCode)) { return getLocalisedDeclineMessage(worldpayDeclineCode); } return EMPTY; }  @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 testGetDeclineMessageShouldReturnEmptyStringWhenDeclineCodeIsZERO() { when(checkoutFacadeMock.getCheckoutCart().getWorldpayDeclineCode()).thenReturn("0"); final String result = testObj.getDeclineMessage(); assertTrue(StringUtils.isEmpty(result)); }
@Test public void testGetDeclineMessageShouldReturnEmptyStringWhenDeclineCodeIsNull() { when(checkoutFacadeMock.getCheckoutCart().getWorldpayDeclineCode()).thenReturn(null); final String result = testObj.getDeclineMessage(); assertTrue(StringUtils.isEmpty(result)); }
@Test public void testGetDeclineMessageShouldReturnDeclineMessageWhenDeclineCodeIsNotZERO() { when(checkoutFacadeMock.getCheckoutCart().getWorldpayDeclineCode()).thenReturn("1"); when(i18NServiceMock.getCurrentLocale()).thenReturn(UK); when(themeSourceMock.getMessage(anyString(), eq(null), eq(UK))).thenReturn(DECLINE_MESSAGE); final String result = testObj.getDeclineMessage(); assertEquals(DECLINE_MESSAGE, result); }