use of org.folio.rest.jaxrs.model.Invoice.Status in project mod-invoice by folio-org.
the class InvoicesApiTest method testInvoiceTransitionFailureOnPaidStatus.
@Test
void testInvoiceTransitionFailureOnPaidStatus() {
logger.info("=== Test invoice cannot be transitioned to \"Open\", \"Reviewed\" or \"Approved\" status if it is in \"Paid\" status ===");
for (Status status : Invoice.Status.values()) {
if (status != Invoice.Status.PAID && status != Status.CANCELLED) {
Invoice reqData = createMockEntryInStorage();
// Try to update storage entry
reqData.setStatus(status);
verifyInvoiceTransitionFailure(reqData);
}
}
}
use of org.folio.rest.jaxrs.model.Invoice.Status in project mod-invoice by folio-org.
the class InvoicesApiTest method checkNumberOfRequests.
private void checkNumberOfRequests(Invoice.Status[] statuses) {
// Invoice status open - expect no GET invoice rq + PUT invoice rq
for (Invoice.Status status : statuses) {
// MODINVOICE-76 prepare mock invoice with appropriate statuses
Invoice invoice;
String mockFilePath;
switch(status) {
case OPEN:
mockFilePath = OPEN_INVOICE_SAMPLE_PATH;
break;
case REVIEWED:
mockFilePath = REVIEWED_INVOICE_SAMPLE_PATH;
break;
default:
mockFilePath = APPROVED_INVOICE_SAMPLE_PATH;
break;
}
invoice = getMockAsJson(mockFilePath).mapTo(Invoice.class).withStatus(status);
prepareMockVoucher(invoice.getId());
verifyPut(String.format(INVOICE_ID_PATH, invoice.getId()), JsonObject.mapFrom(invoice).encode(), "", HttpStatus.SC_NO_CONTENT);
assertThat(serverRqRs.row(INVOICES).get(HttpMethod.GET), hasSize(1));
assertThat(serverRqRs.row(INVOICES).get(HttpMethod.PUT), hasSize(1));
List<JsonObject> invoiceLinesUpdates = Optional.ofNullable(serverRqRs.get(INVOICE_LINES, HttpMethod.PUT)).orElse(emptyList());
List<InvoiceLine> lines = invoiceLinesUpdates.stream().map(entry -> entry.mapTo(InvoiceLine.class)).collect(toList());
assertThat(lines, everyItem(hasProperty("invoiceLineStatus", is(InvoiceLine.InvoiceLineStatus.fromValue(status.value())))));
clearServiceInteractions();
}
}
Aggregations