DefaultWorldpayPaymentInfoService implements WorldpayPaymentInfoService { @Override public WorldpayAPMPaymentInfoModel createWorldpayApmPaymentInfo(final PaymentTransactionModel paymentTransactionModel) throws WorldpayConfigurationException { final WorldpayAPMPaymentInfoModel apmPaymentInfoModel = modelService.clone(paymentTransactionModel.getInfo(), WorldpayAPMPaymentInfoModel.class); final WorldpayAPMConfigurationModel worldpayAPMConfigurationModel = apmConfigurationLookupService.getAPMConfigurationForCode(apmPaymentInfoModel.getPaymentType()); apmPaymentInfoModel.setApmConfiguration(worldpayAPMConfigurationModel); apmPaymentInfoModel.setSaved(false); apmPaymentInfoModel.setMerchantId(worldpayMerchantInfoService.getMerchantInfoFromTransaction(paymentTransactionModel).getMerchantCode()); apmPaymentInfoModel.setTimeoutDate(calculateAPMTimeoutDate(paymentTransactionModel.getCreationtime(), apmPaymentInfoModel.getApmConfiguration())); modelService.save(apmPaymentInfoModel); return apmPaymentInfoModel; } DefaultWorldpayPaymentInfoService(final ModelService modelService, final EnumerationService enumerationService, final APMConfigurationLookupService apmConfigurationLookupService, final ConfigurationService configurationService, final WorldpayMerchantInfoService worldpayMerchantInfoService); @Override void savePaymentType(final PaymentTransactionModel transactionModel, final String methodCode); @Override void setPaymentInfoModel(final PaymentTransactionModel paymentTransactionModel, final AbstractOrderModel orderModel, final OrderNotificationMessage orderNotificationMessage); @Override void updateAndAttachPaymentInfoModel(final PaymentTransactionModel paymentTransactionModel, final AbstractOrderModel orderModel, final PaymentInfoModel paymentInfoModel); @Override WorldpayAPMPaymentInfoModel createWorldpayApmPaymentInfo(final PaymentTransactionModel paymentTransactionModel); @Override PaymentInfoModel createPaymentInfo(final CartModel cartModel); @Override PaymentInfoModel createPaymentInfoGooglePay(final CartModel cartModel, final GooglePayAdditionalAuthInfo googleAuthInfo); @Override PaymentInfoModel createPaymentInfoApplePay(final CartModel cartModel, final ApplePayAdditionalAuthInfo applePayAdditionalAuthInfo); @Override CreditCardPaymentInfoModel createCreditCardPaymentInfo(final AbstractOrderModel abstractOrderModel, final TokenReply tokenReply, final boolean saveCard, final String merchantId); @Override void setCreditCardType(final CreditCardPaymentInfoModel creditCardPaymentInfoModel, final PaymentReply paymentReply); @Override Optional<CreditCardPaymentInfoModel> updateCreditCardPaymentInfo(final CartModel cartModel, final UpdateTokenServiceRequest updateTokenServiceRequest); @Override void setTransactionIdentifierOnPaymentInfo(final PaymentInfoModel paymentInfoModel, final String transactionIdentifier);  }
@Test public void shouldCreateWorldpayApmPaymentInfo() throws WorldpayConfigurationException { testObj.createWorldpayApmPaymentInfo(paymentTransactionModelMock); verify(worldpayAPMPaymentInfoModelMock).setApmConfiguration(worldpayAPMConfigurationModelMock); verify(worldpayAPMPaymentInfoModelMock).setSaved(false); verify(worldpayAPMPaymentInfoModelMock).setMerchantId(MERCHANT_ID); verify(worldpayAPMPaymentInfoModelMock).setTimeoutDate(DateUtils.addMinutes(CREATION_TIME, TIMEOUT_IN_MINUTES)); verify(modelServiceMock).save(worldpayAPMPaymentInfoModelMock); }