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