use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupUpdateOrderTransactionSummary.
private void setupUpdateOrderTransactionSummary(PurchaseOrder order) {
RequestEntry requestEntry = new RequestEntry(ORDER_TRANSACTION_SUMMARIES_BY_ID_ENDPOINT).withPathParameter("id", order.getId());
OrderTransactionSummary summary = new OrderTransactionSummary().withId(order.getId()).withNumTransactions(1);
doReturn(completedFuture(null)).when(restClient).put(argThat(re -> sameRequestEntry(requestEntry, re)), eq(summary), eq(requestContextMock));
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupEncumbrancePutWithError.
private void setupEncumbrancePutWithError(Transaction transaction) {
RequestEntry requestEntry = new RequestEntry("/finance/encumbrances/{id}").withPathParameter("id", transaction.getId());
Transaction updatedTransaction = JsonObject.mapFrom(transaction).mapTo(Transaction.class);
updatedTransaction.getEncumbrance().setStatus(UNRELEASED);
HttpException ex = new HttpException(500, "Error test");
doReturn(failedFuture(ex)).when(restClient).put(argThat(re -> sameRequestEntry(requestEntry, re)), eq(updatedTransaction), eq(requestContextMock));
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupEncumbranceQuery.
private void setupEncumbranceQuery(List<PurchaseOrder> orders, List<PoLine> poLines, List<Transaction> transactions) {
List<PoLine> selectedPoLines = poLines.stream().filter(line -> orders.stream().anyMatch(order -> order.getId().equals(line.getPurchaseOrderId()) && order.getWorkflowStatus().equals(WorkflowStatus.OPEN))).collect(toList());
String poLineIdsQuery = selectedPoLines.stream().map(PoLine::getId).collect(joining(" or "));
String transactionQuery = "transactionType==Encumbrance and encumbrance.sourcePoLineId==(" + poLineIdsQuery + ")";
TransactionCollection transactionCollection = new TransactionCollection().withTransactions(transactions).withTotalRecords(transactions.size());
RequestEntry requestEntry = new RequestEntry(TRANSACTIONS_ENDPOINT).withQuery(transactionQuery).withOffset(0).withLimit(selectedPoLines.size());
doReturn(completedFuture(transactionCollection)).when(restClient).get(argThat(re -> sameRequestEntry(requestEntry, re)), eq(requestContextMock), eq(TransactionCollection.class));
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method initMocks.
@BeforeEach
public void initMocks() {
requestContextMock = Mockito.mock(RequestContext.class, new RuntimeExceptionAnswer());
restClient = Mockito.mock(RestClient.class, new RuntimeExceptionAnswer());
doReturn(Vertx.vertx().getOrCreateContext()).when(requestContextMock).getContext();
BaseTransactionService baseTransactionService = new BaseTransactionService(restClient);
OrderTransactionSummaryService orderTransactionSummaryService = new OrderTransactionSummaryService(restClient);
EncumbranceService encumbranceService = new EncumbranceService(baseTransactionService, orderTransactionSummaryService);
InvoiceTransactionSummaryService invoiceTransactionSummaryService = new InvoiceTransactionSummaryService(restClient);
VoucherRetrieveService voucherRetrieveService = new VoucherRetrieveService(restClient);
VoucherCommandService voucherCommandService = new VoucherCommandService(restClient, null, voucherRetrieveService, null, null, null);
OrderLineService orderLineService = new OrderLineService(restClient);
InvoiceLineService invoiceLineService = new InvoiceLineService(restClient);
OrderService orderService = new OrderService(restClient, invoiceLineService, orderLineService);
cancelService = new InvoiceCancelService(baseTransactionService, encumbranceService, invoiceTransactionSummaryService, voucherCommandService, orderLineService, orderService);
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceLinesRetrieveServiceTest method positiveGetInvoiceMapTest.
@Test
public void positiveGetInvoiceMapTest() throws IOException, ExecutionException, InterruptedException {
RestClient restClient = new RestClient();
InvoiceLinesRetrieveService service = new InvoiceLinesRetrieveService(new InvoiceLineService(restClient));
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
VoucherCollection voucherCollection = new VoucherCollection();
voucherCollection.setVouchers(vouchers);
CompletableFuture<Map<String, List<InvoiceLine>>> future = service.getInvoiceLineMap(voucherCollection, new RequestContext(context, okapiHeaders));
Map<String, List<InvoiceLine>> listMap = future.get();
Assertions.assertEquals(1, listMap.values().size());
}
Aggregations