@Test public void testTransformShouldCreateServiceResponseFromPaymentServiceWithPaymentAndReference() throws WorldpayModelTransformationException { final PaymentService paymentServiceReply = new PaymentService(); final Reply reply = new Reply(); final List<Object> responses = reply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken(); final OrderStatus orderStatus = new OrderStatus(); orderStatus.setOrderCode(ORDER_CODE); responses.add(orderStatus); final List<Object> orderStatusType = orderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); final Payment payment = new Payment(); orderStatusType.add(payment); final Reference reference = new Reference(); reference.setId(REFERENCE_ID); reference.setvalue(REFERENCE_VALUE); orderStatusType.add(reference); final Token token = new Token(); orderStatusType.add(token); final EchoData echoData = new EchoData(); echoData.setvalue(ECHO_DATA); orderStatusType.add(echoData); paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(reply); when(serviceResponseTransformerHelperMock.buildPaymentReply(payment)).thenReturn(paymentReplyMock); when(serviceResponseTransformerHelperMock.buildTokenReply(token)).thenReturn(tokenReplyMock); final DirectAuthoriseServiceResponse result = (DirectAuthoriseServiceResponse) testObj.transform(paymentServiceReply); assertEquals(paymentReplyMock, result.getPaymentReply()); assertEquals(tokenReplyMock, result.getToken()); assertNotNull(result.getPaymentReply()); assertNotNull(result.getRedirectReference()); assertNull(result.getRequest3DInfo()); assertEquals(ORDER_CODE, result.getOrderCode()); assertEquals(ECHO_DATA, result.getEchoData()); assertEquals(REFERENCE_ID, result.getRedirectReference().getId()); assertEquals(REFERENCE_VALUE, result.getRedirectReference().getValue()); }
@Override public ServiceResponse transform(final PaymentService paymentServiceReply) throws WorldpayModelTransformationException { final Object responseType = paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final DirectAuthoriseServiceResponse authResponse = new DirectAuthoriseServiceResponse(); if (getServiceResponseTransformerHelper().checkForError(authResponse, intReply)) { return authResponse; } final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); if (response instanceof OrderStatus) { final OrderStatus intOrderStatus = (OrderStatus) response; authResponse.setOrderCode(intOrderStatus.getOrderCode()); final List<Object> intOrderStatusElements = intOrderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); for (final Object orderStatusType : intOrderStatusElements) { transformOrderStatus(authResponse, intOrderStatus, orderStatusType); } } else { throw new WorldpayModelTransformationException("No order status returned in Worldpay reply message"); } return authResponse; }
DirectAuthoriseResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentServiceReply) throws WorldpayModelTransformationException { final Object responseType = paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final DirectAuthoriseServiceResponse authResponse = new DirectAuthoriseServiceResponse(); if (getServiceResponseTransformerHelper().checkForError(authResponse, intReply)) { return authResponse; } final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); if (response instanceof OrderStatus) { final OrderStatus intOrderStatus = (OrderStatus) response; authResponse.setOrderCode(intOrderStatus.getOrderCode()); final List<Object> intOrderStatusElements = intOrderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); for (final Object orderStatusType : intOrderStatusElements) { transformOrderStatus(authResponse, intOrderStatus, orderStatusType); } } else { throw new WorldpayModelTransformationException("No order status returned in Worldpay reply message"); } return authResponse; } }
DirectAuthoriseResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentServiceReply) throws WorldpayModelTransformationException { final Object responseType = paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final DirectAuthoriseServiceResponse authResponse = new DirectAuthoriseServiceResponse(); if (getServiceResponseTransformerHelper().checkForError(authResponse, intReply)) { return authResponse; } final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); if (response instanceof OrderStatus) { final OrderStatus intOrderStatus = (OrderStatus) response; authResponse.setOrderCode(intOrderStatus.getOrderCode()); final List<Object> intOrderStatusElements = intOrderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); for (final Object orderStatusType : intOrderStatusElements) { transformOrderStatus(authResponse, intOrderStatus, orderStatusType); } } else { throw new WorldpayModelTransformationException("No order status returned in Worldpay reply message"); } return authResponse; }  }
DirectAuthoriseResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentServiceReply) throws WorldpayModelTransformationException { final Object responseType = paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final DirectAuthoriseServiceResponse authResponse = new DirectAuthoriseServiceResponse(); if (getServiceResponseTransformerHelper().checkForError(authResponse, intReply)) { return authResponse; } final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); if (response instanceof OrderStatus) { final OrderStatus intOrderStatus = (OrderStatus) response; authResponse.setOrderCode(intOrderStatus.getOrderCode()); final List<Object> intOrderStatusElements = intOrderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); for (final Object orderStatusType : intOrderStatusElements) { transformOrderStatus(authResponse, intOrderStatus, orderStatusType); } } else { throw new WorldpayModelTransformationException("No order status returned in Worldpay reply message"); } return authResponse; }  @Override ServiceResponse transform(final PaymentService paymentServiceReply); }
DirectAuthoriseResponseTransformer extends AbstractServiceResponseTransformer { @Override public ServiceResponse transform(final PaymentService paymentServiceReply) throws WorldpayModelTransformationException { final Object responseType = paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); if (responseType == null) { throw new WorldpayModelTransformationException("No reply message in Worldpay response"); } if (!(responseType instanceof Reply)) { throw new WorldpayModelTransformationException("Reply type from Worldpay not the expected type"); } final Reply intReply = (Reply) responseType; final DirectAuthoriseServiceResponse authResponse = new DirectAuthoriseServiceResponse(); if (getServiceResponseTransformerHelper().checkForError(authResponse, intReply)) { return authResponse; } final Object response = intReply.getOrderStatusOrBatchStatusOrErrorOrAddressCheckResponseOrRefundableAmountOrAccountBatchOrShopperOrOkOrFuturePayAgreementStatusOrShopperAuthenticationResultOrFuturePayPaymentResultOrPricePointOrCheckCardResponseOrPaymentOptionOrToken().get(0); if (response instanceof OrderStatus) { final OrderStatus intOrderStatus = (OrderStatus) response; authResponse.setOrderCode(intOrderStatus.getOrderCode()); final List<Object> intOrderStatusElements = intOrderStatus.getReferenceOrBankAccountOrApmEnrichedDataOrErrorOrPaymentOrQrCodeOrCardBalanceOrPaymentAdditionalDetailsOrBillingAddressDetailsOrExemptionResponseOrOrderModificationOrJournalOrRequestInfoOrChallengeRequiredOrFxApprovalRequiredOrPbbaRTPOrContentOrJournalTypeDetailOrTokenOrDateOrEchoDataOrPayAsOrderUseNewOrderCodeOrAuthenticateResponse(); for (final Object orderStatusType : intOrderStatusElements) { transformOrderStatus(authResponse, intOrderStatus, orderStatusType); } } else { throw new WorldpayModelTransformationException("No order status returned in Worldpay reply message"); } return authResponse; }  @Override ServiceResponse transform(final PaymentService paymentServiceReply);  }