@Test public void shouldRaiseWorldpayModelTransformationExceptionWhenThereIsNoReplyInThePaymentService() throws Exception { thrown.expect(WorldpayModelTransformationException.class); thrown.expectMessage("No reply message in Worldpay update token response"); when(paymentServiceMock.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify()).thenReturn(singletonList(null)); testObj.transform(paymentServiceMock); }
@Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay update token response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); final UpdateTokenResponse updateTokenResponse = new UpdateTokenResponse(); if (getServiceResponseTransformerHelper().checkForError(updateTokenResponse, intReply)) { return updateTokenResponse; } if (!(response instanceof Ok)) { throw new WorldpayModelTransformationException("UpdateTokenResponse did not contain an OK object"); } final Ok okResponse = (Ok) response; final Object updateTokenReceived = okResponse.getCancelReceivedOrVoidReceivedOrCaptureReceivedOrRevokeReceivedOrRefundReceivedOrBackofficeCodeReceivedOrAuthorisationCodeReceivedOrDefenceReceivedOrUpdateTokenReceivedOrDeleteTokenReceivedOrExtendExpiryDateReceivedOrOrderReceivedOrCancelRetryDoneOrVoidSaleReceived().get(0); if (updateTokenReceived instanceof UpdateTokenReceived) { updateTokenResponse.setUpdateTokenReply(getServiceResponseTransformerHelper().buildUpdateTokenReply((UpdateTokenReceived) updateTokenReceived)); } return updateTokenResponse; }
UpdateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay update token response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); final UpdateTokenResponse updateTokenResponse = new UpdateTokenResponse(); if (getServiceResponseTransformerHelper().checkForError(updateTokenResponse, intReply)) { return updateTokenResponse; } if (!(response instanceof Ok)) { throw new WorldpayModelTransformationException("UpdateTokenResponse did not contain an OK object"); } final Ok okResponse = (Ok) response; final Object updateTokenReceived = okResponse.getCancelReceivedOrVoidReceivedOrCaptureReceivedOrRevokeReceivedOrRefundReceivedOrBackofficeCodeReceivedOrAuthorisationCodeReceivedOrDefenceReceivedOrUpdateTokenReceivedOrDeleteTokenReceivedOrExtendExpiryDateReceivedOrOrderReceivedOrCancelRetryDoneOrVoidSaleReceived().get(0); if (updateTokenReceived instanceof UpdateTokenReceived) { updateTokenResponse.setUpdateTokenReply(getServiceResponseTransformerHelper().buildUpdateTokenReply((UpdateTokenReceived) updateTokenReceived)); } return updateTokenResponse; } }
UpdateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay update token response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); final UpdateTokenResponse updateTokenResponse = new UpdateTokenResponse(); if (getServiceResponseTransformerHelper().checkForError(updateTokenResponse, intReply)) { return updateTokenResponse; } if (!(response instanceof Ok)) { throw new WorldpayModelTransformationException("UpdateTokenResponse did not contain an OK object"); } final Ok okResponse = (Ok) response; final Object updateTokenReceived = okResponse.getCancelReceivedOrVoidReceivedOrCaptureReceivedOrRevokeReceivedOrRefundReceivedOrBackofficeCodeReceivedOrAuthorisationCodeReceivedOrDefenceReceivedOrUpdateTokenReceivedOrDeleteTokenReceivedOrExtendExpiryDateReceivedOrOrderReceivedOrCancelRetryDoneOrVoidSaleReceived().get(0); if (updateTokenReceived instanceof UpdateTokenReceived) { updateTokenResponse.setUpdateTokenReply(getServiceResponseTransformerHelper().buildUpdateTokenReply((UpdateTokenReceived) updateTokenReceived)); } return updateTokenResponse; }  }
UpdateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay update token response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); final UpdateTokenResponse updateTokenResponse = new UpdateTokenResponse(); if (getServiceResponseTransformerHelper().checkForError(updateTokenResponse, intReply)) { return updateTokenResponse; } if (!(response instanceof Ok)) { throw new WorldpayModelTransformationException("UpdateTokenResponse did not contain an OK object"); } final Ok okResponse = (Ok) response; final Object updateTokenReceived = okResponse.getCancelReceivedOrVoidReceivedOrCaptureReceivedOrRevokeReceivedOrRefundReceivedOrBackofficeCodeReceivedOrAuthorisationCodeReceivedOrDefenceReceivedOrUpdateTokenReceivedOrDeleteTokenReceivedOrExtendExpiryDateReceivedOrOrderReceivedOrCancelRetryDoneOrVoidSaleReceived().get(0); if (updateTokenReceived instanceof UpdateTokenReceived) { updateTokenResponse.setUpdateTokenReply(getServiceResponseTransformerHelper().buildUpdateTokenReply((UpdateTokenReceived) updateTokenReceived)); } return updateTokenResponse; }  @Override ServiceResponse transform(final PaymentService paymentService); }
UpdateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay update token response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); final UpdateTokenResponse updateTokenResponse = new UpdateTokenResponse(); if (getServiceResponseTransformerHelper().checkForError(updateTokenResponse, intReply)) { return updateTokenResponse; } if (!(response instanceof Ok)) { throw new WorldpayModelTransformationException("UpdateTokenResponse did not contain an OK object"); } final Ok okResponse = (Ok) response; final Object updateTokenReceived = okResponse.getCancelReceivedOrVoidReceivedOrCaptureReceivedOrRevokeReceivedOrRefundReceivedOrBackofficeCodeReceivedOrAuthorisationCodeReceivedOrDefenceReceivedOrUpdateTokenReceivedOrDeleteTokenReceivedOrExtendExpiryDateReceivedOrOrderReceivedOrCancelRetryDoneOrVoidSaleReceived().get(0); if (updateTokenReceived instanceof UpdateTokenReceived) { updateTokenResponse.setUpdateTokenReply(getServiceResponseTransformerHelper().buildUpdateTokenReply((UpdateTokenReceived) updateTokenReceived)); } return updateTokenResponse; }  @Override ServiceResponse transform(final PaymentService paymentService);  }