use of org.folio.service.orders.OrderInvoiceRelationService in project mod-orders by folio-org.
the class PurchaseOrderHelperTest method testDeleteOrderLinkedToInvoiceWithError.
@Test
void testDeleteOrderLinkedToInvoiceWithError() {
// given
InvoiceLineService invoiceLineService = new InvoiceLineService(restClient);
RestClient restClient = mock(RestClient.class, CALLS_REAL_METHODS);
OrderInvoiceRelationService orderInvoiceRelationService = spy(new OrderInvoiceRelationService(restClient, invoiceLineService));
// for returning non empty collection
OrderInvoiceRelationshipCollection oirCollection = new OrderInvoiceRelationshipCollection().withOrderInvoiceRelationships(Collections.singletonList(new OrderInvoiceRelationship())).withTotalRecords(1);
doReturn(completedFuture(oirCollection)).when(restClient).get(any(), any(), any());
CompletableFuture<Void> future = orderInvoiceRelationService.checkOrderInvoiceRelationship(ORDER_ID, new RequestContext(ctxMock, okapiHeadersMock));
CompletionException exception = assertThrows(CompletionException.class, future::join);
HttpException httpException = (HttpException) exception.getCause();
assertEquals(ErrorCodes.ORDER_RELATES_TO_INVOICE.getDescription(), httpException.getMessage());
}
Aggregations