DefaultWorldpayCartService implements WorldpayCartService { @Override public void resetDeclineCodeAndShopperBankOnCart(final String shopperBankCode) { if (cartService.hasSessionCart()) { final CartModel cart = cartService.getSessionCart(); cart.setShopperBankCode(shopperBankCode); cart.setWorldpayDeclineCode("0"); cartService.saveOrder(cart); } }  @Override void resetDeclineCodeAndShopperBankOnCart(final String shopperBankCode); @Override void setWorldpayDeclineCodeOnCart(String worldpayOrderCode, String declineCode); @Override CartModel findCartByWorldpayOrderCode(final String worldpayOrderCode); @Required void setWorldpayCartDao(final WorldpayCartDao worldpayCartDao); @Required void setCartService(final CartService cartService);  }
@Test public void setWorldpayDeclineCodeAndBankCodeOnCart() { when(cartServiceMock.hasSessionCart()).thenReturn(true); when(cartServiceMock.getSessionCart()).thenReturn(cartModelMock); testObj.resetDeclineCodeAndShopperBankOnCart(BANK_CODE); verify(cartModelMock).setWorldpayDeclineCode("0"); verify(cartModelMock).setShopperBankCode(BANK_CODE); verify(cartServiceMock).saveOrder(cartModelMock); }
@Test public void shouldDoNothigIfNoCartInSession() { when(cartServiceMock.hasSessionCart()).thenReturn(false); testObj.resetDeclineCodeAndShopperBankOnCart(BANK_CODE); verifyZeroInteractions(cartModelMock); verify(cartServiceMock, never()).saveOrder(cartModelMock); }