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