use of org.folio.TestMockDataConstants.MOCK_ENCUMBRANCES_LIST in project mod-invoice by folio-org.
the class BaseTransactionServiceTest method testShouldSuccessRetrieveExistedTransactions.
@Test
public void testShouldSuccessRetrieveExistedTransactions() throws Exception {
// given
BaseTransactionService service = spy(new BaseTransactionService(restClient));
JsonObject encumbranceList = new JsonObject(getMockData(MOCK_ENCUMBRANCES_LIST));
List<Transaction> encumbrances = encumbranceList.getJsonArray("transactions").stream().map(obj -> ((JsonObject) obj).mapTo(Transaction.class)).collect(toList());
TransactionCollection trCollection = new TransactionCollection().withTransactions(encumbrances);
RequestContext requestContext = new RequestContext(ctxMock, okapiHeaders);
doReturn(completedFuture(trCollection)).when(restClient).get(any(RequestEntry.class), any(RequestContext.class), eq(TransactionCollection.class));
// When
List<String> transactionIds = encumbrances.stream().map(Transaction::getId).collect(toList());
List<Transaction> actEncumbrances = service.getTransactions(transactionIds, requestContext).join();
// Then
assertThat(actEncumbrances, hasSize(1));
assertThat(actEncumbrances.get(0).getId(), equalTo(encumbrances.get(0).getId()));
verify(restClient).get(any(RequestEntry.class), any(RequestContext.class), eq(TransactionCollection.class));
}
use of org.folio.TestMockDataConstants.MOCK_ENCUMBRANCES_LIST in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupGetTransactions.
private void setupGetTransactions(Invoice invoice) throws IOException {
TransactionCollection creditCollection = getMockAs(MOCK_CREDITS_LIST, TransactionCollection.class);
TransactionCollection encumbranceCollection = getMockAs(MOCK_ENCUMBRANCES_LIST, TransactionCollection.class);
TransactionCollection paymentCollection = getMockAs(MOCK_PAYMENTS_LIST, TransactionCollection.class);
TransactionCollection pendingPaymentCollection = getMockAs(MOCK_PENDING_PAYMENTS_LIST, TransactionCollection.class);
TransactionCollection trCollection = mergeCollections(List.of(creditCollection, encumbranceCollection, paymentCollection, pendingPaymentCollection));
String query = String.format("sourceInvoiceId==%s", invoice.getId());
RequestEntry requestEntry = new RequestEntry(TRANSACTIONS_ENDPOINT).withQuery(query).withLimit(Integer.MAX_VALUE).withOffset(0);
doReturn(completedFuture(trCollection)).when(restClient).get(argThat(re -> sameRequestEntry(requestEntry, re)), eq(requestContextMock), eq(TransactionCollection.class));
}
Aggregations