Search in sources :

Example 26 with RestClient

use of org.folio.rest.core.RestClient in project mod-invoice by folio-org.

the class InvoiceRetrieveServiceTest method positiveGetInvoiceMapTest.

@Test
public void positiveGetInvoiceMapTest() 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);
    VoucherCollection voucherCollection = new VoucherCollection();
    voucherCollection.setVouchers(vouchers);
    CompletableFuture<Map<String, Invoice>> future = service.getInvoiceMap(voucherCollection, new RequestContext(context, okapiHeaders));
    Map<String, Invoice> lineMap = future.get();
    Assertions.assertEquals(3, lineMap.values().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) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) 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) 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)26 RequestContext (org.folio.rest.core.models.RequestContext)26 Test (org.junit.jupiter.api.Test)25 JsonObject (io.vertx.core.json.JsonObject)23 BeforeEach (org.junit.jupiter.api.BeforeEach)23 List (java.util.List)22 CompletableFuture (java.util.concurrent.CompletableFuture)21 Collectors.toList (java.util.stream.Collectors.toList)21 IOException (java.io.IOException)20 RequestEntry (org.folio.rest.core.models.RequestEntry)18 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)18 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)18 Mockito.verify (org.mockito.Mockito.verify)18 UUID (java.util.UUID)17 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)17 CompletionException (java.util.concurrent.CompletionException)17 Mockito.doReturn (org.mockito.Mockito.doReturn)17 Mockito.times (org.mockito.Mockito.times)17 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)16 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)16