OrderInquiryRequestTransformer implements ServiceRequestTransformer { @Override public PaymentService transform(ServiceRequest request) throws WorldpayModelTransformationException { if (request == null || request.getMerchantInfo() == null || request.getOrderCode() == null) { throw new WorldpayModelTransformationException("Request provided to do the order inquiry is invalid."); } final PaymentService paymentService = new PaymentService(); paymentService.setMerchantCode(request.getMerchantInfo().getMerchantCode()); paymentService.setVersion(configurationService.getConfiguration().getString(WORLDPAY_CONFIG_VERSION)); final Inquiry inquiry = new Inquiry(); buildInquiry(request, inquiry); paymentService.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().add(inquiry); return paymentService; }  @Override PaymentService transform(ServiceRequest request); @Required void setConfigurationService(final ConfigurationService configurationService);  }
@Test public void transformOrderInquiry() throws WorldpayModelTransformationException { when(orderInquiryRequestMock.getMerchantInfo()).thenReturn(merchantInfoMock); when(merchantInfoMock.getMerchantCode()).thenReturn(MERCHANT_CODE); when(orderInquiryRequestMock.getOrderCode()).thenReturn(WORLDPAY_ORDER_CODE); final PaymentService result = testObj.transform(orderInquiryRequestMock); assertThat(result.getMerchantCode()).isEqualTo(MERCHANT_CODE); assertThat(result.getVersion()).isEqualTo(VERSION); final Object inquiry = result.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); assertThat(inquiry).isInstanceOf(Inquiry.class); final Inquiry inquiryObject = (Inquiry) inquiry; final Object orderInquiry = inquiryObject.getOrderInquiryOrKlarnaConfirmationInquiryOrBatchInquiryOrAccountBatchInquiryOrRefundableAmountInquiryOrShopperAuthenticationOrPriceInquiryOrBankAccountInquiryOrIdentifyMeInquiryOrPaymentOptionsInquiryOrPaymentTokenInquiryOrShopperTokenRetrievalOrCardCheckInquiry().get(0); assertThat(orderInquiry).isInstanceOf(OrderInquiry.class); final OrderInquiry orderInquiryObject = (OrderInquiry) orderInquiry; assertThat(orderInquiryObject.getOrderCode()).isEqualTo(WORLDPAY_ORDER_CODE); }
@Test public void transformKlarnaOrderInquiry() throws WorldpayModelTransformationException { when(klarnaOrderInquiryRequestMock.getMerchantInfo()).thenReturn(merchantInfoMock); when(merchantInfoMock.getMerchantCode()).thenReturn(MERCHANT_CODE); when(klarnaOrderInquiryRequestMock.getOrderCode()).thenReturn(WORLDPAY_ORDER_CODE); final PaymentService result = testObj.transform(klarnaOrderInquiryRequestMock); assertThat(result.getMerchantCode()).isEqualTo(MERCHANT_CODE); assertThat(result.getVersion()).isEqualTo(VERSION); final Object inquiry = result.getSubmitOrModifyOrInquiryOrReplyOrNotifyOrVerify().get(0); assertThat(inquiry).isInstanceOf(Inquiry.class); final Inquiry inquiryObject = (Inquiry) inquiry; final Object orderInquiry = inquiryObject.getOrderInquiryOrKlarnaConfirmationInquiryOrBatchInquiryOrAccountBatchInquiryOrRefundableAmountInquiryOrShopperAuthenticationOrPriceInquiryOrBankAccountInquiryOrIdentifyMeInquiryOrPaymentOptionsInquiryOrPaymentTokenInquiryOrShopperTokenRetrievalOrCardCheckInquiry().get(0); assertThat(orderInquiry).isInstanceOf(KlarnaConfirmationInquiry.class); final KlarnaConfirmationInquiry klarnaConfirmationInquiryObject = (KlarnaConfirmationInquiry) orderInquiry; assertThat(klarnaConfirmationInquiryObject.getOrderCode()).isEqualTo(WORLDPAY_ORDER_CODE); }