@Test public void shouldThrowExceptionWhenOrderStatusTypeIsNull() throws WorldpayModelTransformationException { thrown.expect(WorldpayModelTransformationException.class); thrown.expectMessage("No order status type returned in Worldpay reply message"); 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(); orderStatusType.add(null); paymentServiceReply.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(reply); testObj.transform(paymentServiceReply); }
@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);  }