DefaultOrderInquiryService implements OrderInquiryService { @Override public OrderInquiryServiceResponse inquireOrder(final MerchantInfo merchantInfo, final String worldpayOrderCode) throws WorldpayException { final OrderInquiryServiceRequest orderInquiryServiceRequest = createOrderInquiryServiceRequest(merchantInfo, worldpayOrderCode); return getOrderInquiryServiceResponse(orderInquiryServiceRequest); }  @Override OrderInquiryServiceResponse inquirePaymentTransaction(final MerchantInfo merchantConfig, final PaymentTransactionModel paymentTransactionModel); @Override void processOrderInquiryServiceResponse(final PaymentTransactionModel paymentTransactionModel, final OrderInquiryServiceResponse orderInquiryServiceResponse); @Override OrderInquiryServiceResponse inquireOrder(final MerchantInfo merchantInfo, final String worldpayOrderCode); @Override OrderInquiryServiceResponse inquiryKlarnaOrder(final MerchantInfo merchantInfo, final String worldpayOrderCode); @Required void setWorldpayPaymentInfoService(final WorldpayPaymentInfoService worldpayPaymentInfoService); @Required void setWorldpayServiceGateway(final WorldpayServiceGateway worldpayServiceGateway); @Required void setConfigurationService(final ConfigurationService configurationService);  }
@Test(expected = WorldpayException.class) public void shouldRetryInquiryPaymentDetailsWhenThereIsAnErrorAndFailWhenRetriesNumberAreExhausted() throws Exception { when(worldpayServiceGatewayMock.orderInquiry(orderInquiryServiceRequestMock)) .thenReturn(orderInquiryServiceResponseMock) .thenReturn(orderInquiryServiceResponseMock1) .thenReturn(orderInquiryServiceResponseMock2); final ErrorDetail errorDetail = new ErrorDetail("5", "Some Error Detail"); when(orderInquiryServiceResponseMock.getErrorDetail()).thenReturn(errorDetail); when(orderInquiryServiceResponseMock1.getErrorDetail()).thenReturn(errorDetail); when(orderInquiryServiceResponseMock2.getErrorDetail()).thenReturn(errorDetail); testObj.inquireOrder(merchantInfoMock, WORLDPAY_ORDER_CODE); }