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));
}
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());
}
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));
}
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));
}
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));
}
Aggregations