Search in sources :

Example 1 with InvoiceLineService

use of org.folio.services.invoice.InvoiceLineService 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);
}
Also used : VendorRetrieveService(org.folio.services.VendorRetrieveService) RestClient(org.folio.rest.core.RestClient) AddressConverter(org.folio.converters.AddressConverter) InvoiceService(org.folio.services.invoice.InvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) JsonObject(io.vertx.core.json.JsonObject) VoucherService(org.folio.rest.impl.VoucherService) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) InvoiceLinesRetrieveService(org.folio.services.InvoiceLinesRetrieveService) OrderLineService(org.folio.services.order.OrderLineService) VoucherValidator(org.folio.services.validator.VoucherValidator) BatchVoucher(org.folio.rest.jaxrs.model.BatchVoucher) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) ConfigurationService(org.folio.services.configuration.ConfigurationService) RequestContext(org.folio.rest.core.models.RequestContext) OrderService(org.folio.services.order.OrderService) InvoiceRetrieveService(org.folio.services.InvoiceRetrieveService) BatchVoucherExport(org.folio.rest.jaxrs.model.BatchVoucherExport) Test(org.junit.jupiter.api.Test)

Example 2 with InvoiceLineService

use of org.folio.services.invoice.InvoiceLineService 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();
    });
}
Also used : VendorRetrieveService(org.folio.services.VendorRetrieveService) RestClient(org.folio.rest.core.RestClient) AddressConverter(org.folio.converters.AddressConverter) InvoiceService(org.folio.services.invoice.InvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) VoucherService(org.folio.rest.impl.VoucherService) ExchangeRateProviderResolver(org.folio.services.exchange.ExchangeRateProviderResolver) InvoiceLinesRetrieveService(org.folio.services.InvoiceLinesRetrieveService) OrderLineService(org.folio.services.order.OrderLineService) VoucherValidator(org.folio.services.validator.VoucherValidator) BatchVoucher(org.folio.rest.jaxrs.model.BatchVoucher) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) ConfigurationService(org.folio.services.configuration.ConfigurationService) RequestContext(org.folio.rest.core.models.RequestContext) OrderService(org.folio.services.order.OrderService) InvoiceRetrieveService(org.folio.services.InvoiceRetrieveService) BatchVoucherExport(org.folio.rest.jaxrs.model.BatchVoucherExport) Test(org.junit.jupiter.api.Test)

Example 3 with InvoiceLineService

use of org.folio.services.invoice.InvoiceLineService 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());
}
Also used : RestClient(org.folio.rest.core.RestClient) BeforeEach(org.junit.jupiter.api.BeforeEach) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Vertx(io.vertx.core.Vertx) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) ApiTestSuite.mockPort(org.folio.ApiTestSuite.mockPort) Context(io.vertx.core.Context) ApiTestBase(org.folio.rest.impl.ApiTestBase) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Voucher(org.folio.rest.jaxrs.model.Voucher) Map(java.util.Map) RequestContext(org.folio.rest.core.models.RequestContext) Assertions(org.junit.jupiter.api.Assertions) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) RestClient(org.folio.rest.core.RestClient) JsonObject(io.vertx.core.json.JsonObject) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) RequestContext(org.folio.rest.core.models.RequestContext) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) Voucher(org.folio.rest.jaxrs.model.Voucher) Test(org.junit.jupiter.api.Test)

Example 4 with InvoiceLineService

use of org.folio.services.invoice.InvoiceLineService 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());
}
Also used : RestClient(org.folio.rest.core.RestClient) BeforeEach(org.junit.jupiter.api.BeforeEach) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) Context(io.vertx.core.Context) InvoiceService(org.folio.services.invoice.InvoiceService) Voucher(org.folio.rest.jaxrs.model.Voucher) Map(java.util.Map) RequestContext(org.folio.rest.core.models.RequestContext) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) OrderService(org.folio.services.order.OrderService) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) Vertx(io.vertx.core.Vertx) IOException(java.io.IOException) ApiTestSuite.mockPort(org.folio.ApiTestSuite.mockPort) ApiTestBase(org.folio.rest.impl.ApiTestBase) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) Assertions(org.junit.jupiter.api.Assertions) Invoice(org.folio.rest.jaxrs.model.Invoice) InvoiceService(org.folio.services.invoice.InvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) BaseInvoiceService(org.folio.services.invoice.BaseInvoiceService) RestClient(org.folio.rest.core.RestClient) JsonObject(io.vertx.core.json.JsonObject) Voucher(org.folio.rest.jaxrs.model.Voucher) InvoiceCollection(org.folio.rest.jaxrs.model.InvoiceCollection) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) RequestContext(org.folio.rest.core.models.RequestContext) Test(org.junit.jupiter.api.Test)

Example 5 with InvoiceLineService

use of org.folio.services.invoice.InvoiceLineService 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());
}
Also used : RestClient(org.folio.rest.core.RestClient) BeforeEach(org.junit.jupiter.api.BeforeEach) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Vertx(io.vertx.core.Vertx) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) ApiTestSuite.mockPort(org.folio.ApiTestSuite.mockPort) Context(io.vertx.core.Context) ApiTestBase(org.folio.rest.impl.ApiTestBase) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Voucher(org.folio.rest.jaxrs.model.Voucher) Map(java.util.Map) RequestContext(org.folio.rest.core.models.RequestContext) Assertions(org.junit.jupiter.api.Assertions) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) RestClient(org.folio.rest.core.RestClient) JsonObject(io.vertx.core.json.JsonObject) Voucher(org.folio.rest.jaxrs.model.Voucher) InvoiceLineService(org.folio.services.invoice.InvoiceLineService) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) RequestContext(org.folio.rest.core.models.RequestContext) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

RestClient (org.folio.rest.core.RestClient)6 RequestContext (org.folio.rest.core.models.RequestContext)6 InvoiceLineService (org.folio.services.invoice.InvoiceLineService)6 Test (org.junit.jupiter.api.Test)6 JsonObject (io.vertx.core.json.JsonObject)5 Context (io.vertx.core.Context)4 Vertx (io.vertx.core.Vertx)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 ExecutionException (java.util.concurrent.ExecutionException)4 Collectors.toList (java.util.stream.Collectors.toList)4 ApiTestSuite.mockPort (org.folio.ApiTestSuite.mockPort)4 OKAPI_URL (org.folio.rest.RestConstants.OKAPI_URL)4 ApiTestBase (org.folio.rest.impl.ApiTestBase)4 Voucher (org.folio.rest.jaxrs.model.Voucher)4 VoucherCollection (org.folio.rest.jaxrs.model.VoucherCollection)4 BaseInvoiceService (org.folio.services.invoice.BaseInvoiceService)4