@Test public void shouldRaiseErrorIfResponseTypeIsNotReply() throws WorldpayModelTransformationException { thrown.expect(WorldpayModelTransformationException.class); thrown.expectMessage("Reply type from Worldpay not the expected type"); when(paymentServiceReplyMock.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify()).thenReturn(singletonList(new Submit())); testObj.transform(paymentServiceReplyMock); }
@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);  }