use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupUpdateTransactionSummary.
private void setupUpdateTransactionSummary(Invoice invoice) {
RequestEntry requestEntry = new RequestEntry(INVOICE_TRANSACTION_SUMMARIES_BY_ID_ENDPOINT).withPathParameter("id", invoice.getId());
InvoiceTransactionSummary summary = new InvoiceTransactionSummary().withId(invoice.getId()).withNumPaymentsCredits(3).withNumPendingPayments(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 BatchVoucherGenerateServiceTest method positiveGenerateBatchVoucherTest.
@Test
public void positiveGenerateBatchVoucherTest() throws IOException, ExecutionException, InterruptedException {
RestClient restClient = new RestClient();
VoucherRetrieveService voucherRetrieveService = new VoucherRetrieveService(restClient);
ConfigurationService configurationService = new ConfigurationService(new RestClient());
VoucherCommandService voucherCommandService = new VoucherCommandService(restClient, new VoucherNumberService(new RestClient()), voucherRetrieveService, new VoucherValidator(), configurationService, new ExchangeRateProviderResolver());
VendorRetrieveService vendorRetrieveService = new VendorRetrieveService(restClient);
AddressConverter addressConverter = AddressConverter.getInstance();
VoucherService voucherService = new VoucherService(voucherRetrieveService, voucherCommandService, vendorRetrieveService, addressConverter);
InvoiceLinesRetrieveService invoiceLinesRetrieveService = new InvoiceLinesRetrieveService(new InvoiceLineService(restClient));
InvoiceLineService invoiceLineService = new InvoiceLineService(new RestClient());
OrderLineService orderLineService = new OrderLineService(restClient);
InvoiceService invoiceService = new BaseInvoiceService(new RestClient(), invoiceLineService, new OrderService(new RestClient(), invoiceLineService, orderLineService));
InvoiceRetrieveService invoiceRetrieveService = new InvoiceRetrieveService(invoiceService);
BatchVoucherGenerateService service = new BatchVoucherGenerateService(okapiHeaders, context, "en", vendorRetrieveService, invoiceRetrieveService, invoiceLinesRetrieveService, voucherService, addressConverter);
BatchVoucherExport batchVoucherExport = new JsonObject(getMockData(BATCH_VOUCHER_EXPORT_SAMPLE_PATH)).mapTo(BatchVoucherExport.class);
CompletableFuture<BatchVoucher> future = service.generateBatchVoucher(batchVoucherExport, new RequestContext(context, okapiHeaders));
BatchVoucher batchVoucher = future.get();
Assertions.assertNotNull(batchVoucher);
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class BatchVoucherGenerateServiceTest method negativeGetBatchVoucherIfVouchersIsAbsentTest.
@Test
public void negativeGetBatchVoucherIfVouchersIsAbsentTest() {
Assertions.assertThrows(CompletionException.class, () -> {
RestClient restClient = new RestClient();
VoucherRetrieveService voucherRetrieveService = new VoucherRetrieveService(restClient);
ConfigurationService configurationService = new ConfigurationService(restClient);
VoucherCommandService voucherCommandService = new VoucherCommandService(restClient, new VoucherNumberService(restClient), voucherRetrieveService, new VoucherValidator(), configurationService, new ExchangeRateProviderResolver());
VendorRetrieveService vendorRetrieveService = new VendorRetrieveService(restClient);
AddressConverter addressConverter = AddressConverter.getInstance();
VoucherService voucherService = new VoucherService(voucherRetrieveService, voucherCommandService, vendorRetrieveService, addressConverter);
InvoiceLinesRetrieveService invoiceLinesRetrieveService = new InvoiceLinesRetrieveService(new InvoiceLineService(restClient));
InvoiceLineService invoiceLineService = new InvoiceLineService(new RestClient());
OrderLineService orderLineService = new OrderLineService(restClient);
InvoiceService invoiceService = new BaseInvoiceService(new RestClient(), invoiceLineService, new OrderService(new RestClient(), invoiceLineService, orderLineService));
InvoiceRetrieveService invoiceRetrieveService = new InvoiceRetrieveService(invoiceService);
BatchVoucherGenerateService service = new BatchVoucherGenerateService(okapiHeaders, context, "en", vendorRetrieveService, invoiceRetrieveService, invoiceLinesRetrieveService, voucherService, addressConverter);
BatchVoucherExport batchVoucherExport = new BatchVoucherExport();
CompletableFuture<BatchVoucher> future = service.generateBatchVoucher(batchVoucherExport, new RequestContext(context, okapiHeaders));
future.join();
});
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceLinesRetrieveServiceTest method positiveGetInvoiceLinesByChunksTest.
@Test
public void positiveGetInvoiceLinesByChunksTest() 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);
CompletableFuture<List<InvoiceLineCollection>> future = service.getInvoiceLineByChunks(vouchers, new RequestContext(context, okapiHeaders));
List<InvoiceLineCollection> lineCollections = future.get();
Assertions.assertEquals(3, lineCollections.get(0).getInvoiceLines().size());
}
use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.
the class InvoiceRetrieveServiceTest method positiveGetInvoicesByChunksTest.
@Test
public void positiveGetInvoicesByChunksTest() throws IOException, ExecutionException, InterruptedException {
InvoiceService invoiceService = new BaseInvoiceService(new RestClient(), invoiceLineService, orderService);
InvoiceRetrieveService service = new InvoiceRetrieveService(invoiceService);
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);
CompletableFuture<List<InvoiceCollection>> future = service.getInvoicesByChunks(vouchers, new RequestContext(context, okapiHeaders));
List<InvoiceCollection> lineCollections = future.get();
Assertions.assertEquals(3, lineCollections.get(0).getInvoices().size());
}
Aggregations