DefaultWorldpayCustomerAccountService extends DefaultCustomerAccountService { @Override public void deleteCCPaymentInfo(final CustomerModel customerModel, final CreditCardPaymentInfoModel creditCardPaymentInfo) { try { final MerchantInfo merchantInfo = worldpayMerchantInfoService.getCurrentSiteMerchant(); worldpayDirectOrderService.deleteToken(merchantInfo, creditCardPaymentInfo); } catch (final WorldpayException e) { LOG.error("Error deleting token at worldpay ", e); } super.deleteCCPaymentInfo(customerModel, creditCardPaymentInfo); }  @Override void deleteCCPaymentInfo(final CustomerModel customerModel, final CreditCardPaymentInfoModel creditCardPaymentInfo); @Required void setWorldpayDirectOrderService(final WorldpayDirectOrderService worldpayDirectOrderService); @Required void setWorldpayMerchantInfoService(final WorldpayMerchantInfoService worldpayMerchantInfoService);  }
@Test public void testDeleteTokenCalled() throws WorldpayException { testObj.deleteCCPaymentInfo(customerModelMock, creditCardPaymentInfoModelMock); verify(worldpayDirectOrderServiceMock).deleteToken(merchantInfoMock, creditCardPaymentInfoModelMock); verify(modelService).save(creditCardPaymentInfoModelMock); verify(modelService).refresh(customerModelMock); }
@Test public void testHandleExceptionsFromDeleteTokenCall() throws WorldpayException { doThrow(new WorldpayException("Exception in delete token")).when(worldpayDirectOrderServiceMock).deleteToken(merchantInfoMock, creditCardPaymentInfoModelMock); testObj.deleteCCPaymentInfo(customerModelMock, creditCardPaymentInfoModelMock); }