Search in sources :

Example 11 with InvoiceLine

use of org.folio.rest.jaxrs.model.InvoiceLine in project mod-invoice by folio-org.

the class InvoiceLinesApiTest method testPutInvoicingInvoiceLinesInvalidIdFormat.

@Test
public void testPutInvoicingInvoiceLinesInvalidIdFormat() {
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    reqData.setId(ID_BAD_FORMAT);
    String jsonBody = JsonObject.mapFrom(reqData).encode();
    verifyPut(ID_BAD_FORMAT, jsonBody, APPLICATION_JSON, 422);
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 12 with InvoiceLine

use of org.folio.rest.jaxrs.model.InvoiceLine in project mod-invoice by folio-org.

the class InvoiceLinesApiTest method postInvoicingInvoiceLinesTest.

@Test
public void postInvoicingInvoiceLinesTest() {
    logger.info("=== Test create invoice line - 201 successfully created ===");
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    reqData.setInvoiceId(OPEN_INVOICE_ID);
    Double actualTotal = 2.00d;
    assertThat(actualTotal, equalTo(reqData.getTotal()));
    String body = JsonObject.mapFrom(reqData).encodePrettily();
    final InvoiceLine respData = verifyPostResponse(INVOICE_LINES_PATH, body, prepareHeaders(X_OKAPI_TENANT), APPLICATION_JSON, 201).as(InvoiceLine.class);
    String invoiceId = respData.getId();
    String invoiceLineNo = respData.getInvoiceLineNumber();
    // MODINVOICE-86 Verify total is calculated upon invoice-line creation
    Double expectedTotal = 2.42d;
    assertThat(respData.getTotal(), equalTo(expectedTotal));
    assertThat(invoiceId, notNullValue());
    assertThat(invoiceLineNo, is("1"));
    assertThat(MockServer.serverRqRs.get(INVOICE_LINE_NUMBER, HttpMethod.GET), hasSize(1));
    compareRecordWithSentToStorage(respData);
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 13 with InvoiceLine

use of org.folio.rest.jaxrs.model.InvoiceLine in project mod-invoice by folio-org.

the class InvoiceLinesApiTest method checkNoPoNumbersUpdateIfAnotherLineIsLinkedToSamePO.

@Test
public void checkNoPoNumbersUpdateIfAnotherLineIsLinkedToSamePO() {
    logger.info("=== Check an invoice line update removing the po line link does not triggers the update of the invoice's poNumbers field if another invoice line links to the same PO ===");
    InvoiceLine invoiceLine1 = getMockAsJson(INVOICE_LINE_WITH_PO_NUMBER_PATH).mapTo(InvoiceLine.class);
    invoiceLine1.setId(UUID.randomUUID().toString());
    addMockEntry(INVOICE_LINES, invoiceLine1);
    InvoiceLine invoiceLine2 = getMockAsJson(INVOICE_LINE_WITH_PO_NUMBER_PATH).mapTo(InvoiceLine.class);
    invoiceLine2.setPoLineId(null);
    verifyPut(INVOICE_LINE_WITH_PO_NUMBER, JsonObject.mapFrom(invoiceLine2), "", 204);
    List<JsonObject> objects = serverRqRs.get(INVOICES, HttpMethod.PUT);
    assertThat(objects, nullValue());
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 14 with InvoiceLine

use of org.folio.rest.jaxrs.model.InvoiceLine in project mod-invoice by folio-org.

the class InvoiceLinesApiTest method checkInvoiceLineUpdateFailsToUpdateInvoicePoNumbers.

@Test
public void checkInvoiceLineUpdateFailsToUpdateInvoicePoNumbers() {
    logger.info("=== Check the returned error when a poNumbers field cannot be updated ===");
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_PO_NUMBER_PATH).mapTo(InvoiceLine.class);
    invoiceLine.setInvoiceId(OPEN_INVOICE_ID);
    invoiceLine.setPoLineId(PO_LINE_WITH_NO_PO_ID);
    // updating poNumbers will fail because it cannot get the PO from the PO line
    verifyPut(INVOICE_LINE_WITH_PO_NUMBER, JsonObject.mapFrom(invoiceLine), "", 500);
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Test(org.junit.jupiter.api.Test)

Example 15 with InvoiceLine

use of org.folio.rest.jaxrs.model.InvoiceLine in project mod-invoice by folio-org.

the class InvoiceLinesApiTest method compareRecordWithSentToStorage.

private void compareRecordWithSentToStorage(InvoiceLine invoiceLine) {
    // Verify that invoice line sent to storage is the same as in response
    assertThat(getInvoiceLineCreations(), hasSize(1));
    InvoiceLine invoiceLineToStorage = getInvoiceLineCreations().get(0).mapTo(InvoiceLine.class);
    assertThat(invoiceLine, equalTo(invoiceLineToStorage));
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine)

Aggregations

InvoiceLine (org.folio.rest.jaxrs.model.InvoiceLine)120 Test (org.junit.jupiter.api.Test)88 Invoice (org.folio.rest.jaxrs.model.Invoice)83 Matchers.containsString (org.hamcrest.Matchers.containsString)58 Adjustment (org.folio.rest.jaxrs.model.Adjustment)45 JsonObject (io.vertx.core.json.JsonObject)39 Errors (org.folio.rest.jaxrs.model.Errors)36 Headers (io.restassured.http.Headers)34 Error (org.folio.rest.jaxrs.model.Error)30 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)26 ArrayList (java.util.ArrayList)25 InvoiceLineCollection (org.folio.rest.jaxrs.model.InvoiceLineCollection)25 List (java.util.List)24 RequestContext (org.folio.rest.core.models.RequestContext)22 Collections (java.util.Collections)21 Fund (org.folio.rest.acq.model.finance.Fund)20 Voucher (org.folio.rest.jaxrs.model.Voucher)20 Vertx (io.vertx.core.Vertx)19 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17