@Test public void shouldReturnTokenResponseWithErrorWhenErrorOccurs() throws WorldpayModelTransformationException { final PaymentService paymentServiceReply = new PaymentService(); final Reply reply = new Reply(); final List<Object> responses = reply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken(); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_VALUE); responses.add(error); paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(reply); when(serviceResponseTransformerHelperMock.checkForError(any(ServiceResponse.class), eq(reply))).thenReturn(true); final ServiceResponse result = testObj.transform(paymentServiceReply); verify(serviceResponseTransformerHelperMock).checkForError(result, reply); }
@Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final CreateTokenResponse createTokenResponse = new CreateTokenResponse(); final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay create 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); if (getServiceResponseTransformerHelper().checkForError(createTokenResponse, intReply)) { return createTokenResponse; } else if (response instanceof Token) { createTokenResponse.setToken(getServiceResponseTransformerHelper().buildTokenReply((Token) response)); } return createTokenResponse; }
CreateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final CreateTokenResponse createTokenResponse = new CreateTokenResponse(); final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay create 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); if (getServiceResponseTransformerHelper().checkForError(createTokenResponse, intReply)) { return createTokenResponse; } else if (response instanceof Token) { createTokenResponse.setToken(getServiceResponseTransformerHelper().buildTokenReply((Token) response)); } return createTokenResponse; } }
CreateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final CreateTokenResponse createTokenResponse = new CreateTokenResponse(); final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay create 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); if (getServiceResponseTransformerHelper().checkForError(createTokenResponse, intReply)) { return createTokenResponse; } else if (response instanceof Token) { createTokenResponse.setToken(getServiceResponseTransformerHelper().buildTokenReply((Token) response)); } return createTokenResponse; }  }
CreateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final CreateTokenResponse createTokenResponse = new CreateTokenResponse(); final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay create 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); if (getServiceResponseTransformerHelper().checkForError(createTokenResponse, intReply)) { return createTokenResponse; } else if (response instanceof Token) { createTokenResponse.setToken(getServiceResponseTransformerHelper().buildTokenReply((Token) response)); } return createTokenResponse; }  @Override ServiceResponse transform(final PaymentService paymentService); }
CreateTokenResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentService) throws WorldpayModelTransformationException { final CreateTokenResponse createTokenResponse = new CreateTokenResponse(); final Object responseType = paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay create 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); if (getServiceResponseTransformerHelper().checkForError(createTokenResponse, intReply)) { return createTokenResponse; } else if (response instanceof Token) { createTokenResponse.setToken(getServiceResponseTransformerHelper().buildTokenReply((Token) response)); } return createTokenResponse; }  @Override ServiceResponse transform(final PaymentService paymentService);  }