Search in sources :

Example 1 with OrderInvoiceRelationshipCollection

use of org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection in project mod-invoice by folio-org.

the class OrderServiceTest method shouldDeleteOrderInvoiceRelationshipByInvoiceIdAndLineIdIfRelationExist.

@Test
void shouldDeleteOrderInvoiceRelationshipByInvoiceIdAndLineIdIfRelationExist() {
    String invoiceId = UUID.randomUUID().toString();
    String poLineId = UUID.randomUUID().toString();
    String orderId = UUID.randomUUID().toString();
    CompositePoLine poLine = new CompositePoLine().withId(poLineId).withPurchaseOrderId(orderId);
    OrderInvoiceRelationship relationship = new OrderInvoiceRelationship().withInvoiceId(invoiceId).withPurchaseOrderId(orderId);
    OrderInvoiceRelationshipCollection relationships = new OrderInvoiceRelationshipCollection().withOrderInvoiceRelationships(List.of(relationship)).withTotalRecords(1);
    doReturn(completedFuture(poLine)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(CompositePoLine.class));
    doReturn(completedFuture(relationships)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(OrderInvoiceRelationshipCollection.class));
    doReturn(completedFuture(null)).when(restClient).delete(any(RequestEntry.class), eq(requestContextMock));
    doReturn(completedFuture(poLine)).when(orderLineService).getPoLine(poLineId, requestContextMock);
    orderService.deleteOrderInvoiceRelationshipByInvoiceIdAndLineId(invoiceId, poLineId, requestContextMock).join();
    verify(restClient).delete(any(RequestEntry.class), eq(requestContextMock));
}
Also used : OrderInvoiceRelationshipCollection(org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) OrderInvoiceRelationship(org.folio.rest.acq.model.orders.OrderInvoiceRelationship) RequestEntry(org.folio.rest.core.models.RequestEntry) Test(org.junit.jupiter.api.Test)

Example 2 with OrderInvoiceRelationshipCollection

use of org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection in project mod-invoice by folio-org.

the class MockServer method handleGetOrderInvoiceRelations.

private void handleGetOrderInvoiceRelations(RoutingContext ctx) {
    OrderInvoiceRelationshipCollection collection = new OrderInvoiceRelationshipCollection().withTotalRecords(0);
    serverResponse(ctx, 200, APPLICATION_JSON, JsonObject.mapFrom(collection).encode());
}
Also used : OrderInvoiceRelationshipCollection(org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection)

Example 3 with OrderInvoiceRelationshipCollection

use of org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection in project mod-invoice by folio-org.

the class OrderServiceTest method shouldSkipDeletionOrderInvoiceRelationshipByInvoiceIdAndLineIdIfRelationNotExist.

@Test
void shouldSkipDeletionOrderInvoiceRelationshipByInvoiceIdAndLineIdIfRelationNotExist() {
    String invoiceId = UUID.randomUUID().toString();
    String poLineId = UUID.randomUUID().toString();
    String orderId = UUID.randomUUID().toString();
    CompositePoLine poLine = new CompositePoLine().withId(poLineId).withPurchaseOrderId(orderId);
    OrderInvoiceRelationshipCollection relationships = new OrderInvoiceRelationshipCollection().withOrderInvoiceRelationships(Collections.EMPTY_LIST).withTotalRecords(0);
    doReturn(completedFuture(poLine)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(CompositePoLine.class));
    doReturn(completedFuture(relationships)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(OrderInvoiceRelationshipCollection.class));
    doReturn(completedFuture(poLine)).when(orderLineService).getPoLine(poLineId, requestContextMock);
    orderService.deleteOrderInvoiceRelationshipByInvoiceIdAndLineId(invoiceId, poLineId, requestContextMock).join();
    verify(restClient, times(0)).delete(any(RequestEntry.class), eq(requestContextMock));
}
Also used : OrderInvoiceRelationshipCollection(org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection) CompositePoLine(org.folio.rest.acq.model.orders.CompositePoLine) RequestEntry(org.folio.rest.core.models.RequestEntry) Test(org.junit.jupiter.api.Test)

Example 4 with OrderInvoiceRelationshipCollection

use of org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection in project mod-invoice by folio-org.

the class OrderServiceTest method shouldDeleteOrderInvoiceRelationshipByInvoiceIdIfRelationExist.

@Test
void shouldDeleteOrderInvoiceRelationshipByInvoiceIdIfRelationExist() {
    String invoiceId = UUID.randomUUID().toString();
    String orderId = UUID.randomUUID().toString();
    OrderInvoiceRelationship relationship = new OrderInvoiceRelationship().withInvoiceId(invoiceId).withPurchaseOrderId(orderId);
    OrderInvoiceRelationshipCollection relationships = new OrderInvoiceRelationshipCollection().withOrderInvoiceRelationships(List.of(relationship)).withTotalRecords(1);
    doReturn(completedFuture(relationships)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(OrderInvoiceRelationshipCollection.class));
    doReturn(completedFuture(null)).when(restClient).delete(any(RequestEntry.class), eq(requestContextMock));
    orderService.deleteOrderInvoiceRelationshipByInvoiceId(invoiceId, requestContextMock).join();
    verify(restClient).delete(any(RequestEntry.class), eq(requestContextMock));
}
Also used : OrderInvoiceRelationshipCollection(org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection) OrderInvoiceRelationship(org.folio.rest.acq.model.orders.OrderInvoiceRelationship) RequestEntry(org.folio.rest.core.models.RequestEntry) Test(org.junit.jupiter.api.Test)

Example 5 with OrderInvoiceRelationshipCollection

use of org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection in project mod-invoice by folio-org.

the class OrderServiceTest method shouldNotDeleteOrderInvoiceRelationshipByInvoiceIdIfRelationNoExist.

@Test
void shouldNotDeleteOrderInvoiceRelationshipByInvoiceIdIfRelationNoExist() {
    String invoiceId = UUID.randomUUID().toString();
    OrderInvoiceRelationshipCollection relationships = new OrderInvoiceRelationshipCollection().withTotalRecords(0);
    doReturn(completedFuture(relationships)).when(restClient).get(any(RequestEntry.class), eq(requestContextMock), eq(OrderInvoiceRelationshipCollection.class));
    doReturn(completedFuture(null)).when(restClient).delete(any(RequestEntry.class), eq(requestContextMock));
    orderService.deleteOrderInvoiceRelationshipByInvoiceId(invoiceId, requestContextMock).join();
    verify(restClient, times(0)).delete(any(RequestEntry.class), eq(requestContextMock));
}
Also used : OrderInvoiceRelationshipCollection(org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection) RequestEntry(org.folio.rest.core.models.RequestEntry) Test(org.junit.jupiter.api.Test)

Aggregations

OrderInvoiceRelationshipCollection (org.folio.rest.acq.model.orders.OrderInvoiceRelationshipCollection)5 RequestEntry (org.folio.rest.core.models.RequestEntry)4 Test (org.junit.jupiter.api.Test)4 CompositePoLine (org.folio.rest.acq.model.orders.CompositePoLine)2 OrderInvoiceRelationship (org.folio.rest.acq.model.orders.OrderInvoiceRelationship)2