Search in sources :

Example 6 with InvoiceLine

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

the class InvoiceLinesApiTest method checkNumberOfRequests.

private void checkNumberOfRequests(String invoiceLineId) {
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    invoiceLine.setId(invoiceLineId);
    verifyPut(invoiceLineId, invoiceLine, "", HttpStatus.SC_NO_CONTENT);
    MatcherAssert.assertThat(getInvoiceLineRetrievals(), hasSize(1));
    MatcherAssert.assertThat(getInvoiceRetrievals(), hasSize(1));
    MatcherAssert.assertThat(getInvoiceLineUpdates(), hasSize(1));
    // All totals are unchanged
    MatcherAssert.assertThat(getInvoiceUpdates(), hasSize(0));
    clearServiceInteractions();
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine)

Example 7 with InvoiceLine

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

the class InvoiceLinesApiTest method testGetInvoicingInvoiceLinesByIdUpdateTotalException.

@Test
public void testGetInvoicingInvoiceLinesByIdUpdateTotalException() {
    logger.info("=== Test 500 when update in storage fails ===");
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_OUTDATED_TOTAL_PATH).mapTo(InvoiceLine.class);
    addMockEntry(INVOICE_LINES, invoiceLine.withId(ID_FOR_INTERNAL_SERVER_ERROR_PUT));
    // Check that invoice line update called which is expected to fail so invoice update is not triggered
    String endpointQuery = String.format(INVOICE_LINE_ID_PATH, invoiceLine.getId());
    verifyGet(endpointQuery, APPLICATION_JSON, 500);
    MatcherAssert.assertThat(getInvoiceUpdates(), hasSize(0));
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 8 with InvoiceLine

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

the class InvoiceLinesApiTest method testPostInvoiceLinesByIdLineWithoutId.

@Test
public void testPostInvoiceLinesByIdLineWithoutId() {
    logger.info("=== Test Post Invoice Lines By Id (empty id in body) ===");
    InvoiceLine reqData = getMockAsJson(INVOICE_LINE_WITH_APPROVED_INVOICE_SAMPLE_PATH).mapTo(InvoiceLine.class);
    reqData.setInvoiceId(null);
    String jsonBody = JsonObject.mapFrom(reqData).encode();
    Errors resp = verifyPostResponse(INVOICE_LINES_PATH, jsonBody, prepareHeaders(MockServer.NON_EXIST_CONFIG_X_OKAPI_TENANT), APPLICATION_JSON, 422).as(Errors.class);
    Assertions.assertEquals(1, resp.getErrors().size());
    Assertions.assertEquals(INVOICE_ID, resp.getErrors().get(0).getParameters().get(0).getKey());
    Assertions.assertEquals(NULL, resp.getErrors().get(0).getParameters().get(0).getValue());
}
Also used : Errors(org.folio.rest.jaxrs.model.Errors) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 9 with InvoiceLine

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

the class InvoiceLinesApiTest method checkInvoiceLineUpdateDoesNotTriggerInvoiceUpdateIfPoNumberAlreadyThere.

@Test
public void checkInvoiceLineUpdateDoesNotTriggerInvoiceUpdateIfPoNumberAlreadyThere() {
    logger.info("=== Check an invoice line update does not trigger the update of the invoice's poNumbers field if it already includes the new line's po number ===");
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINE_WITH_PO_NUMBER_PATH).mapTo(InvoiceLine.class);
    addMockEntry(INVOICE_LINES, invoiceLine);
    verifyPut(INVOICE_LINE_WITH_PO_NUMBER, JsonObject.mapFrom(invoiceLine), "", 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 10 with InvoiceLine

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

the class InvoiceLinesApiTest method testPutUpdatePoLineRef.

@Test
public void testPutUpdatePoLineRef() {
    logger.info("=== Test update invoice line by id with protected fields (all fields set) ===");
    InvoiceLine invoiceLine = getMockAsJson(INVOICE_LINES_MOCK_DATA_PATH + INVOICE_LINE_WITH_OPEN_EXISTED_INVOICE_ID + ".json").mapTo(InvoiceLine.class);
    invoiceLine.setPoLineId("0000edd1-b463-41ba-bf64-1b1d9f9d0001");
    // Invoice line updated (invoice status = APPROVED) - protected field not modified
    verifyPut(invoiceLine.getId(), invoiceLine, "", HttpStatus.SC_NO_CONTENT);
    MatcherAssert.assertThat(getInvoiceUpdates(), hasSize(0));
}
Also used : InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) Test(org.junit.jupiter.api.Test)

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