Search in sources :

Example 1 with OrderLineService

use of org.folio.services.order.OrderLineService 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 OrderLineService

use of org.folio.services.order.OrderLineService 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 OrderLineService

use of org.folio.services.order.OrderLineService 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);
}
Also used : InvoiceTransactionSummaryService(org.folio.services.finance.transaction.InvoiceTransactionSummaryService) BaseTransactionService(org.folio.services.finance.transaction.BaseTransactionService) RestClient(org.folio.rest.core.RestClient) OrderTransactionSummaryService(org.folio.services.finance.transaction.OrderTransactionSummaryService) VoucherCommandService(org.folio.services.voucher.VoucherCommandService) VoucherRetrieveService(org.folio.services.voucher.VoucherRetrieveService) OrderLineService(org.folio.services.order.OrderLineService) EncumbranceService(org.folio.services.finance.transaction.EncumbranceService) RequestContext(org.folio.rest.core.models.RequestContext) OrderService(org.folio.services.order.OrderService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RestClient (org.folio.rest.core.RestClient)3 RequestContext (org.folio.rest.core.models.RequestContext)3 OrderLineService (org.folio.services.order.OrderLineService)3 OrderService (org.folio.services.order.OrderService)3 AddressConverter (org.folio.converters.AddressConverter)2 VoucherService (org.folio.rest.impl.VoucherService)2 BatchVoucher (org.folio.rest.jaxrs.model.BatchVoucher)2 BatchVoucherExport (org.folio.rest.jaxrs.model.BatchVoucherExport)2 InvoiceLinesRetrieveService (org.folio.services.InvoiceLinesRetrieveService)2 InvoiceRetrieveService (org.folio.services.InvoiceRetrieveService)2 VendorRetrieveService (org.folio.services.VendorRetrieveService)2 ConfigurationService (org.folio.services.configuration.ConfigurationService)2 ExchangeRateProviderResolver (org.folio.services.exchange.ExchangeRateProviderResolver)2 BaseInvoiceService (org.folio.services.invoice.BaseInvoiceService)2 InvoiceLineService (org.folio.services.invoice.InvoiceLineService)2 InvoiceService (org.folio.services.invoice.InvoiceService)2 VoucherValidator (org.folio.services.validator.VoucherValidator)2 Test (org.junit.jupiter.api.Test)2 JsonObject (io.vertx.core.json.JsonObject)1 BaseTransactionService (org.folio.services.finance.transaction.BaseTransactionService)1