DefaultWorldpayPaymentTransactionDao extends AbstractItemDao implements WorldpayPaymentTransactionDao { @Override public List<PaymentTransactionModel> findPendingPaymentTransactions(final int waitTimeInMinutes) { final FlexibleSearchQuery query = new FlexibleSearchQuery(PENDING_PAYMENT_TRANSACTION_QUERY); final Date creationTimeParameter = DateUtils.addMinutes(Date.from(Instant.now()), -waitTimeInMinutes); query.addQueryParameter(CREATION_TIME_PARAMETER, creationTimeParameter); query.addQueryParameter(ORDER_STATUS_PARAMETER, PAYMENT_PENDING); final SearchResult<PaymentTransactionModel> result = flexibleSearchService.search(query); return result.getResult(); }  @Override List<PaymentTransactionModel> findPendingPaymentTransactions(final int waitTimeInMinutes); @Override PaymentTransactionModel findPaymentTransactionByRequestIdFromOrdersOnly(final String requestId); @Override PaymentTransactionModel findPaymentTransactionByRequestId(final String requestId); @Override List<PaymentTransactionModel> findCancellablePendingAPMPaymentTransactions(); @Override FlexibleSearchService getFlexibleSearchService(); @Override @Required void setFlexibleSearchService(final FlexibleSearchService flexibleSearchService);  }
@Test public void testFindPendingPaymentTransactions() throws Exception { final List<Object> searchResult = singletonList(paymentTransactionModelMock); when(searchResultMock.getResult()).thenReturn(searchResult); final List<PaymentTransactionModel> result = testObj.findPendingPaymentTransactions(5); assertTrue(result.size() == 1); assertSame(paymentTransactionModelMock, result.get(0)); verify(flexibleSearchServiceMock).search(queryArgumentCaptor.capture()); final FlexibleSearchQuery queryArgumentCaptorValue = queryArgumentCaptor.getValue(); assertEquals(PENDING_PAYMENT_TRANSACTION_QUERY, queryArgumentCaptorValue.getQuery()); assertEquals(PAYMENT_PENDING, queryArgumentCaptorValue.getQueryParameters().get(ORDER_STATUS_PARAMETER)); assertTrue(queryArgumentCaptorValue.getQueryParameters().containsKey(CREATION_TIME_PARAMETER)); }