From b516807811b000e101617711d495f4a1d8e023ff Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Thu, 14 Mar 2019 19:45:02 -0400 Subject: [PATCH 01/17] Update invoice.raml to define APIs --- .gitmodules | 11 +- ramls/acq-models | 1 + ramls/invoice.raml | 125 ++++++++++++++---- .../org/folio/rest/impl/InvoicesImpl.java | 105 ++++++++++++--- .../java/org/folio/rest/imp/InvoicesTest.java | 50 +++++-- src/test/resources/invoice.json | 32 +++++ 6 files changed, 264 insertions(+), 60 deletions(-) create mode 160000 ramls/acq-models create mode 100644 src/test/resources/invoice.json diff --git a/.gitmodules b/.gitmodules index 46ce860f9..9240bd5d2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,7 @@ -[submodule "ramls/raml-util"] - path = ramls/raml-util - url = https://github.com/folio-org/raml - branch = raml1.0 + [submodule "ramls/raml-util"] + path = ramls/raml-util + url = https://github.com/folio-org/raml + branch = raml1.0 +[submodule "ramls/acq-models"] + path = ramls/acq-models + url = https://github.com/folio-org/acq-models.git diff --git a/ramls/acq-models b/ramls/acq-models new file mode 160000 index 000000000..bd0d3eef6 --- /dev/null +++ b/ramls/acq-models @@ -0,0 +1 @@ +Subproject commit bd0d3eef661caaae0e448712886f52b8ec78aae7 diff --git a/ramls/invoice.raml b/ramls/invoice.raml index 87594d749..cbd91913a 100644 --- a/ramls/invoice.raml +++ b/ramls/invoice.raml @@ -10,9 +10,14 @@ documentation: content: This documents the API calls that can be made to manage invoices types: - invoice: !include invoice.json - invoiceCollection: !include ./invoiceCollection.json + invoice: !include acq-models/mod-invoice-storage/schemas/invoice.json + invoiceCollection: !include acq-models/mod-invoice-storage/schemas/invoice_collection.json + invoiceLine: !include acq-models/mod-invoice-storage/schemas/invoice_line.json + invoiceLineCollection: !include acq-models/mod-invoice-storage/schemas/invoice_line_collection.json errors: !include raml-util/schemas/errors.schema + UUID: + type: string + pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ traits: validate: !include raml-util/traits/validation.raml @@ -23,30 +28,100 @@ traits: resourceTypes: collection: !include raml-util/rtypes/collection.raml collection-item: !include raml-util/rtypes/item-collection.raml + get-only: !include raml-util/rtypes/get-only.raml -/invoices: - displayName: Invoice - description: Invoice - type: - collection: - schemaCollection: invoiceCollection - schemaItem: invoice - exampleCollection: !include examples/invoiceCollection.sample - exampleItem: !include examples/invoice.sample - - post: - is: [validate] - get: - is: [ - pageable, - validate - ] - /{id}: +/invoicing: + /invoices: displayName: Invoice - description: Get, Delete or Update a specific invoice + description: Manage Invoices + type: + collection: + schemaCollection: invoiceCollection + schemaItem: invoice + exampleCollection: !include acq-models/mod-invoice-storage/examples/invoice_collection.sample + exampleItem: !include acq-models/mod-invoice-storage/examples/invoice.sample + + post: + description: Post invoice and number of invoice lines; + is: [validate] + get: + is: [ pageable, validate ] + /{id}: + displayName: Invoice + description: Get, Delete or Update a specific invoice + type: + collection-item: + schema: invoice + exampleItem: !include examples/invoice.sample + get: + description: Return an invoice with given {id} + put: + is: [validate] + delete: + description: Delete an invoice with given {id} + /invoice-lines: + displayName: Invoice Lines + description: Manage Invoice lines + type: + collection: + schemaCollection: invoiceLineCollection + schemaItem: invoiceLine + exampleCollection: !include acq-models/mod-invoice-storage/examples/invoice_line_collection.sample + exampleItem: !include acq-models/mod-invoice-storage/examples/invoice_line.sample + is: [validate] + get: + is: [validate] + post: + description: Post an invoice lines to corresponding invoice + /{id}: + displayName: Invoice Line + description: Manage invoice line by id + uriParameters: + id: + description: The UUID of a invoice line + type: UUID + type: + collection-item: + exampleItem: !include acq-models/mod-invoice-storage/examples/invoice_line.sample + schema: invoiceLine + is: [validate] + get: + description: Return an invoice line with given {id} + put: + description: Update an invoice line with given {id} + delete: + description: Delete an invoice line with given {id} + /invoice-number: + displayName: Invoice Number + description: Manage Invoice Number type: - collection-item: - schema: invoice - exampleItem: !include examples/invoice.sample - put: + get-only: + schema: invoiceCollection + exampleCollection: !include acq-models/mod-invoice-storage/examples/invoice_collection.sample + get: + description: Get system generated Invoice Number is: [validate] + /validate: + displayName: Invoice Number Validation + post: + description: validate if Invoice Number is unique and matches the pattern specified + is: [validate, language] + body: + application/json: + responses: + 204: + description: "Valid Invoice Number" + 400: + description: "Bad request, e.g. existing Invoice Number. Details of the error provided in the response." + body: + application/json: + example: + strict: false + value: !include raml-util/examples/errors.sample + 500: + description: "Internal server error, e.g. due to misconfiguration" + body: + application/json: + example: + strict: false + value: !include raml-util/examples/errors.sample diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index 1c613796a..4d7ab55d4 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -4,7 +4,9 @@ import io.vertx.core.Context; import io.vertx.core.Handler; import org.folio.rest.jaxrs.model.Invoice; -import org.folio.rest.jaxrs.resource.Invoices; +import org.folio.rest.jaxrs.model.InvoiceLine; +import org.folio.rest.jaxrs.model.PoNumber; +import org.folio.rest.jaxrs.resource.Invoicing; import javax.ws.rs.core.Response; import java.util.Map; @@ -12,30 +14,89 @@ import static io.vertx.core.Future.succeededFuture; -public class InvoicesImpl implements Invoices { +public class InvoicesImpl implements Invoicing { - @Override - public void postInvoices(String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicesResponse.respond500WithTextPlain("Not supported"))); - } + @Override + public void postInvoicingInvoices(String lang, Invoice entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); + + } - @Override - public void getInvoices(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicesResponse.respond500WithTextPlain("Not supported"))); - } + @Override + public void getInvoicingInvoices(int offset, int limit, String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); + + } - @Override - public void putInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } + @Override + public void getInvoicingInvoicesById(String id, String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + + } - @Override - public void getInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } + @Override + public void putInvoicingInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + + } - @Override - public void deleteInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } + @Override + public void deleteInvoicingInvoicesById(String id, String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void getInvoicingInvoiceLines(String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void postInvoicingInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void getInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void putInvoicingInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void deleteInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void getInvoicingInvoiceNumber(String lang, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain("Not supported"))); + + } + + @Override + public void postInvoicingInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceNumberValidateResponse.respond500WithApplicationJson("Not supported"))); + + } } diff --git a/src/test/java/org/folio/rest/imp/InvoicesTest.java b/src/test/java/org/folio/rest/imp/InvoicesTest.java index a5fa85c03..cc414c65f 100644 --- a/src/test/java/org/folio/rest/imp/InvoicesTest.java +++ b/src/test/java/org/folio/rest/imp/InvoicesTest.java @@ -7,28 +7,35 @@ import io.vertx.core.json.JsonObject; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; + +import org.apache.commons.io.IOUtils; import org.folio.rest.RestVerticle; -import org.folio.rest.persist.PostgresClient; +import org.folio.rest.jaxrs.model.Invoice; import org.folio.rest.tools.client.test.HttpClientMock2; import org.folio.rest.tools.utils.NetworkUtils; import org.junit.BeforeClass; import org.junit.Test; import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Locale; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.stream.Stream; import static io.restassured.RestAssured.given; import static org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT; public class InvoicesTest { private static final Logger logger = LoggerFactory.getLogger(InvoicesTest.class); - public static final String INVOICE_ID_PATH = "/invoices/{id}"; + public static final String INVOICE_ID_PATH = "/invoicing/invoices/{id}"; private static Vertx vertx; private static int port = NetworkUtils.nextFreePort(); @@ -81,7 +88,7 @@ public void getInvoicesTest() throws MalformedURLException { given() .header(TENANT_HEADER) .contentType(ContentType.JSON) - .get(storageUrl("/invoices")) + .get(storageUrl("/invoicing/invoices")) .then() .statusCode(500); } @@ -98,10 +105,13 @@ public void getInvoicesByIdTest() throws MalformedURLException { } @Test - public void putInvoicesByIdTest() throws MalformedURLException { + public void putInvoicesByIdTest() throws Exception { + Invoice reqData = getMockDraftOrder().mapTo(Invoice.class); + String jsonBody = JsonObject.mapFrom(reqData).encode(); + given() - .pathParam("id", "1") - .body("{}") + .pathParam("id", reqData.getId()) + .body(jsonBody) .header(TENANT_HEADER) .contentType(ContentType.JSON) .put(storageUrl(INVOICE_ID_PATH)) @@ -121,14 +131,36 @@ public void deleteInvoicesByIdTest() throws MalformedURLException { } @Test - public void postInvoicesTest() throws MalformedURLException { + public void postInvoicesTest() throws Exception { + Invoice reqData = getMockDraftOrder().mapTo(Invoice.class); + String jsonBody = JsonObject.mapFrom(reqData).encode(); + given() - .body("{}") + .body(jsonBody) .header(TENANT_HEADER) .contentType(ContentType.JSON) - .post(storageUrl("/invoices")) + .post(storageUrl("/invoicing/invoices")) .then() .statusCode(500); } + private JsonObject getMockDraftOrder() throws Exception { + JsonObject invoice = new JsonObject(getMockData("invoice.json")); + return invoice; + } + + public static String getMockData(String path) throws IOException { + logger.info("Using mock datafile: {}", path); + try (InputStream resourceAsStream = InvoicesTest.class.getClassLoader().getResourceAsStream(path)) { + if (resourceAsStream != null) { + return IOUtils.toString(resourceAsStream, StandardCharsets.UTF_8); + } else { + StringBuilder sb = new StringBuilder(); + try (Stream lines = Files.lines(Paths.get(path))) { + lines.forEach(sb::append); + } + return sb.toString(); + } + } + } } diff --git a/src/test/resources/invoice.json b/src/test/resources/invoice.json new file mode 100644 index 000000000..d98c8c9ad --- /dev/null +++ b/src/test/resources/invoice.json @@ -0,0 +1,32 @@ +{ + "id": "c0d08448-347b-418a-8c2f-5fb50248d67e", + "approvedBy": "ab18897b-0e40-4f31-896b-9c9adc979a88", + "approvalDate": "2018-07-29T00:00:00.000+0000", + "chkSubscriptionOverlap": false, + "currency": "USD", + "folioInvoiceNo": "123invoicenumber45", + "invoiceDate": "2018-07-20T00:00:00.000+0000", + "note": "Some note", + "owner": "d79b0bcc-DcAD-1E4E-Abb7-DbFcaD5BB3bb", + "paymentDue": "2018-08-29T00:00:00.000+0000", + "paymentTerms": "Payment in Advance", + "paymentMethod": "EFT", + "prorata": false, + "status": "Open", + "source": "024b6f41-c5c6-4280-858e-33fba452a334", + "totalAmount": 5, + "vendorInvoiceNo": "YK75851", + "disbursementNumber": "58", + "voucherNumber": "478", + "paymentId": "a5065f0d-fb88-4d23-b0c1-57e754fba40e", + "disbursementDate": "2018-08-19T00:00:00.000+0000", + "poNumbers": [ + "AB268758XYZ" + ], + "vendorId": "168f8a63-d612-406e-813f-c7527f241ac3", + "manualPayment": true, + "metadata": { + "createdDate": "2018-07-19T00:00:00.000+0000", + "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1" + } +} \ No newline at end of file From a02653bfefc8d3d24dd47a2bddaef951845ed883 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Thu, 14 Mar 2019 19:56:53 -0400 Subject: [PATCH 02/17] Remove unused code and create final variables --- .../java/org/folio/rest/impl/InvoicesImpl.java | 1 - .../java/org/folio/rest/imp/InvoicesTest.java | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index 4d7ab55d4..8d1e463ae 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -5,7 +5,6 @@ import io.vertx.core.Handler; import org.folio.rest.jaxrs.model.Invoice; import org.folio.rest.jaxrs.model.InvoiceLine; -import org.folio.rest.jaxrs.model.PoNumber; import org.folio.rest.jaxrs.resource.Invoicing; import javax.ws.rs.core.Response; diff --git a/src/test/java/org/folio/rest/imp/InvoicesTest.java b/src/test/java/org/folio/rest/imp/InvoicesTest.java index cc414c65f..4d53d7228 100644 --- a/src/test/java/org/folio/rest/imp/InvoicesTest.java +++ b/src/test/java/org/folio/rest/imp/InvoicesTest.java @@ -35,7 +35,10 @@ public class InvoicesTest { private static final Logger logger = LoggerFactory.getLogger(InvoicesTest.class); - public static final String INVOICE_ID_PATH = "/invoicing/invoices/{id}"; + private static final String INVOICE_ID_PATH = "/invoicing/invoices/{id}"; + private static final String INVOICE_PATH = "/invoicing/invoices"; + private static final String INVOICE_SAMPLE_PATH = "invoice.json"; + private static final String ID = "id"; private static Vertx vertx; private static int port = NetworkUtils.nextFreePort(); @@ -88,7 +91,7 @@ public void getInvoicesTest() throws MalformedURLException { given() .header(TENANT_HEADER) .contentType(ContentType.JSON) - .get(storageUrl("/invoicing/invoices")) + .get(storageUrl(INVOICE_PATH)) .then() .statusCode(500); } @@ -110,7 +113,7 @@ public void putInvoicesByIdTest() throws Exception { String jsonBody = JsonObject.mapFrom(reqData).encode(); given() - .pathParam("id", reqData.getId()) + .pathParam(ID, reqData.getId()) .body(jsonBody) .header(TENANT_HEADER) .contentType(ContentType.JSON) @@ -122,7 +125,7 @@ public void putInvoicesByIdTest() throws Exception { @Test public void deleteInvoicesByIdTest() throws MalformedURLException { given() - .pathParam("id", "1") + .pathParam(ID, "1") .header(TENANT_HEADER) .contentType(ContentType.JSON) .delete(storageUrl(INVOICE_ID_PATH)) @@ -139,13 +142,13 @@ public void postInvoicesTest() throws Exception { .body(jsonBody) .header(TENANT_HEADER) .contentType(ContentType.JSON) - .post(storageUrl("/invoicing/invoices")) + .post(storageUrl(INVOICE_PATH)) .then() .statusCode(500); } private JsonObject getMockDraftOrder() throws Exception { - JsonObject invoice = new JsonObject(getMockData("invoice.json")); + JsonObject invoice = new JsonObject(getMockData(INVOICE_SAMPLE_PATH)); return invoice; } From eeab1ac642e8e32d9d34ff8e8e1b0dad7a2822fd Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Fri, 15 Mar 2019 11:47:22 -0400 Subject: [PATCH 03/17] Update module descriptor --- .gitmodules | 2 +- descriptors/ModuleDescriptor-template.json | 139 ++++++++++++++---- .../org/folio/rest/impl/InvoicesImpl.java | 12 -- 3 files changed, 109 insertions(+), 44 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9240bd5d2..416eb95e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ - [submodule "ramls/raml-util"] +[submodule "ramls/raml-util"] path = ramls/raml-util url = https://github.com/folio-org/raml branch = raml1.0 diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 32b1e99c0..74799ef81 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -9,29 +9,64 @@ "handlers": [ { "methods": ["GET"], - "pathPattern": "/invoice", - "permissionsRequired": ["invoice.collection.get"] + "pathPattern": "/invoicing/invoices", + "permissionsRequired": ["invoicing.collection.get"] }, { "methods": ["POST"], - "pathPattern": "/invoice", - "permissionsRequired": ["invoice.item.post"] + "pathPattern": "/invoicing/invoices", + "permissionsRequired": ["invoicing.item.post"] }, { "methods": ["GET"], - "pathPattern": "/invoice/{id}", - "permissionsRequired": ["invoice.item.get"] + "pathPattern": "/invoicing/invoices/{id}", + "permissionsRequired": ["invoicing.item.get"] }, { "methods": ["PUT"], - "pathPattern": "/invoice/{id}", - "permissionsRequired": ["invoice.item.put"] + "pathPattern": "/invoicing/invoices/{id}", + "permissionsRequired": ["invoicing.item.put"] }, { "methods": ["DELETE"], - "pathPattern": "/invoice/{id}", - "permissionsRequired": ["invoice.item.delete"] - } + "pathPattern": "/invoicing/invoices/{id}", + "permissionsRequired": ["invoicing.item.delete"] + }, + { + "methods": ["GET"], + "pathPattern": "/invoicing/invoice-lines", + "permissionsRequired": ["invoicing.invoice-lines.collection.get"] + }, + { + "methods": ["POST"], + "pathPattern": "/invoicing/invoice-lines", + "permissionsRequired": ["invoicing.invoice-lines.item.post"] + }, + { + "methods": ["GET"], + "pathPattern": "/invoicing/invoice-lines/{id}", + "permissionsRequired": ["invoicing.invoice-lines.item.get"] + }, + { + "methods": ["PUT"], + "pathPattern": "/invoicing/invoice-lines/{id}", + "permissionsRequired": ["invoicing.invoice-lines.item.put"] + }, + { + "methods": ["DELETE"], + "pathPattern": "/invoicing/invoice-lines/{id}", + "permissionsRequired": ["invoicing.invoice-lines.item.delete"] + }, + { + "methods": ["GET"], + "pathPattern": "/invoicing/invoice-number", + "permissionsRequired": ["invoicing.invoice-number.item.get"] + }, + { + "methods": ["POST"], + "pathPattern": "/invoicing/invoice-number/validate", + "permissionsRequired": ["invoicing.invoice-number.item.post"] + } ] }, { @@ -56,40 +91,82 @@ ], "permissionSets": [ { - "permissionName": "invoice.collection.get", - "displayName": "Invoice - get invoice collection", - "description": "Get invoice collection" + "permissionName": "invoicing.collection.get", + "displayName": "Invoice - get collection of Invoice", + "description": "Get collection of Invoice" }, { - "permissionName": "invoice.item.get", - "displayName": "Invoice - get individual invoice", - "description": "Get individual pet" + "permissionName": "invoicing.item.get", + "displayName": "Invoice - get an existing Invoice", + "description": "Get an existing Invoice" }, { - "permissionName": "invoice.item.post", - "displayName": "Invoice - create invoice", - "description": "Create invoice" + "permissionName": "invoicing.item.post", + "displayName": "Invoice - create a new Invoice", + "description": "Create a new invoice" }, { - "permissionName": "invoice.item.put", + "permissionName": "invoicing.item.put", "displayName": "Invoice - modify invoice", - "description": "Modify invoice" + "description": "Modify an existing Invoice" + }, + { + "permissionName": "invoicing.item.delete", + "displayName": "Invoice - delete an existing Invoice", + "description": "Delete an existing Invoice" + }, + { + "permissionName": "invoicing.invoice-lines.collection.get", + "displayName": "Invoice Line - get collection of Invoice lines", + "description": "Get collection of Invoice lines" + }, + { + "permissionName": "invoicing.invoice-lines.item.get", + "displayName": "Invoice - get an existing Invoice line", + "description": "Get an existing Invoice line" + }, + { + "permissionName": "invoicing.invoice-lines.item.post", + "displayName": "Invoice - create a new Invoice line", + "description": "Create a new Invoice line" }, { - "permissionName": "invoice.item.delete", - "displayName": "Invoice - delete invoice", - "description": "Delete invoice" + "permissionName": "invoicing.invoice-lines.item.put", + "displayName": "Invoice - modify an existing Invoice line", + "description": "Modify an existing Invoice line" }, { - "permissionName": "invoice.all", + "permissionName": "invoicing.invoice-lines.item.delete", + "displayName": "Invoice - delete an existing Invoice line", + "description": "Delete an existing Invoice line" + }, + { + "permissionName": "invoicing.invoice-number.item.get", + "displayName": "Invoice - generate a Invoice Number", + "description": "Generate a Invoice Number" + }, + { + "permissionName": "invoicing.invoice-number.item.post", + "displayName": "Invoice - validate a Invoice Number", + "description": "Validate a Invoice Number" + }, + { + "permissionName": "invoicing.all", "displayName": "Invoice module - all permissions", "description": "Entire set of permissions needed to use the invoice module", "subPermissions": [ - "invoice.collection.get", - "invoice.item.get", - "invoice.item.post", - "invoice.item.put", - "invoice.item.delete" + "invoicing.collection.get", + "invoicing.item.get", + "invoicing.item.post", + "invoicing.item.put", + "invoicing.item.delete", + "invoicing.invoice-line.collection.get", + "invoicing.invoice-line.item.get", + "invoicing.invoice-line.item.post", + "invoicing.invoice-line.item.put", + "invoicing.invoice-line.item.delete", + "invoicing.invoice-number.item.get", + "invoicing.invoice-number.item.post" ], "visible": false } diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index 8d1e463ae..93fc31258 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -19,83 +19,71 @@ public class InvoicesImpl implements Invoicing { public void postInvoicingInvoices(String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); - } @Override public void getInvoicingInvoices(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); - } @Override public void getInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void putInvoicingInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void deleteInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void getInvoicingInvoiceLines(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); - } @Override public void postInvoicingInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); - } @Override public void getInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void putInvoicingInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void deleteInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); - } @Override public void getInvoicingInvoiceNumber(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain("Not supported"))); - } @Override public void postInvoicingInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceNumberValidateResponse.respond500WithApplicationJson("Not supported"))); - } } From a34f0ae85971bc658ba159cd3bedb744d8765576 Mon Sep 17 00:00:00 2001 From: Varun Javalkar Date: Fri, 15 Mar 2019 12:02:17 -0400 Subject: [PATCH 04/17] Indentation --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 416eb95e9..b8ec4132e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,5 +3,5 @@ url = https://github.com/folio-org/raml branch = raml1.0 [submodule "ramls/acq-models"] - path = ramls/acq-models - url = https://github.com/folio-org/acq-models.git + path = ramls/acq-models + url = https://github.com/folio-org/acq-models.git From ce3de3c22b53d4aa7dc6953d5dc92fafb1fc6e5e Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Fri, 15 Mar 2019 14:31:56 -0400 Subject: [PATCH 05/17] Improve code coverage --- .../java/org/folio/rest/imp/InvoicesTest.java | 112 ++++++++++++++++-- src/test/resources/invoice_line.json | 40 +++++++ 2 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/invoice_line.json diff --git a/src/test/java/org/folio/rest/imp/InvoicesTest.java b/src/test/java/org/folio/rest/imp/InvoicesTest.java index 4d53d7228..d36f697d6 100644 --- a/src/test/java/org/folio/rest/imp/InvoicesTest.java +++ b/src/test/java/org/folio/rest/imp/InvoicesTest.java @@ -11,6 +11,7 @@ import org.apache.commons.io.IOUtils; import org.folio.rest.RestVerticle; import org.folio.rest.jaxrs.model.Invoice; +import org.folio.rest.jaxrs.model.InvoiceLine; import org.folio.rest.tools.client.test.HttpClientMock2; import org.folio.rest.tools.utils.NetworkUtils; import org.junit.BeforeClass; @@ -36,8 +37,13 @@ public class InvoicesTest { private static final Logger logger = LoggerFactory.getLogger(InvoicesTest.class); private static final String INVOICE_ID_PATH = "/invoicing/invoices/{id}"; + private static final String INVOICE_LINE_ID_PATH = "/invoicing/invoice-lines/{id}"; private static final String INVOICE_PATH = "/invoicing/invoices"; + private static final String INVOICE_LINES_PATH = "/invoicing/invoice-lines"; + private static final String INVOICE_NUMBER_PATH = "/invoicing/invoice-number"; + private static final String INVOICE_NUMBER_VALIDATE_PATH = "/invoicing/invoice-number/validate"; private static final String INVOICE_SAMPLE_PATH = "invoice.json"; + private static final String INVOICE_LINE_SAMPLE_PATH = "invoice_line.json"; private static final String ID = "id"; private static Vertx vertx; @@ -87,7 +93,7 @@ public static URL storageUrl(String path) throws MalformedURLException { } @Test - public void getInvoicesTest() throws MalformedURLException { + public void getInvoicingInvoicesTest() throws MalformedURLException { given() .header(TENANT_HEADER) .contentType(ContentType.JSON) @@ -97,7 +103,27 @@ public void getInvoicesTest() throws MalformedURLException { } @Test - public void getInvoicesByIdTest() throws MalformedURLException { + public void getInvoicingInvoiceLinesTest() throws MalformedURLException { + given() + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .get(storageUrl(INVOICE_LINES_PATH)) + .then() + .statusCode(500); + } + + @Test + public void getInvoicingInvoiceNumberTest() throws MalformedURLException { + given() + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .get(storageUrl(INVOICE_NUMBER_PATH)) + .then() + .statusCode(500); + } + + @Test + public void getInvoicingInvoicesByIdTest() throws MalformedURLException { given() .pathParam("id", "1") .header(TENANT_HEADER) @@ -108,8 +134,19 @@ public void getInvoicesByIdTest() throws MalformedURLException { } @Test - public void putInvoicesByIdTest() throws Exception { - Invoice reqData = getMockDraftOrder().mapTo(Invoice.class); + public void getInvoicingInvoiceLinesByIdTest() throws MalformedURLException { + given() + .pathParam("id", "1") + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .get(storageUrl(INVOICE_LINE_ID_PATH)) + .then() + .statusCode(500); + } + + @Test + public void putInvoicingInvoicesByIdTest() throws Exception { + Invoice reqData = getMockDraftInvoice().mapTo(Invoice.class); String jsonBody = JsonObject.mapFrom(reqData).encode(); given() @@ -123,7 +160,22 @@ public void putInvoicesByIdTest() throws Exception { } @Test - public void deleteInvoicesByIdTest() throws MalformedURLException { + public void putInvoicingInvoiceLinesByIdTest() throws Exception { + InvoiceLine reqData = getMockDraftInvoiceLine().mapTo(InvoiceLine.class); + String jsonBody = JsonObject.mapFrom(reqData).encode(); + + given() + .pathParam(ID, reqData.getId()) + .body(jsonBody) + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .put(storageUrl(INVOICE_LINE_ID_PATH)) + .then() + .statusCode(500); + } + + @Test + public void deleteInvoicingInvoicesByIdTest() throws MalformedURLException { given() .pathParam(ID, "1") .header(TENANT_HEADER) @@ -134,8 +186,19 @@ public void deleteInvoicesByIdTest() throws MalformedURLException { } @Test - public void postInvoicesTest() throws Exception { - Invoice reqData = getMockDraftOrder().mapTo(Invoice.class); + public void deleteInvoicingInvoiceLinesByIdTest() throws MalformedURLException { + given() + .pathParam(ID, "1") + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .delete(storageUrl(INVOICE_LINE_ID_PATH)) + .then() + .statusCode(500); + } + + @Test + public void postInvoicingInvoicesTest() throws Exception { + Invoice reqData = getMockDraftInvoice().mapTo(Invoice.class); String jsonBody = JsonObject.mapFrom(reqData).encode(); given() @@ -147,11 +210,44 @@ public void postInvoicesTest() throws Exception { .statusCode(500); } - private JsonObject getMockDraftOrder() throws Exception { + @Test + public void postInvoicingInvoiceNumberValidateTest() throws Exception { + Invoice reqData = getMockDraftInvoice().mapTo(Invoice.class); + String jsonBody = JsonObject.mapFrom(reqData).encode(); + + given() + .body(jsonBody) + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .post(storageUrl(INVOICE_NUMBER_VALIDATE_PATH)) + .then() + .statusCode(500); + } + + @Test + public void postInvoicingInvoiceLinesTest() throws Exception { + InvoiceLine reqData = getMockDraftInvoiceLine().mapTo(InvoiceLine.class); + String jsonBody = JsonObject.mapFrom(reqData).encode(); + + given() + .body(jsonBody) + .header(TENANT_HEADER) + .contentType(ContentType.JSON) + .post(storageUrl(INVOICE_LINES_PATH)) + .then() + .statusCode(500); + } + + private JsonObject getMockDraftInvoice() throws Exception { JsonObject invoice = new JsonObject(getMockData(INVOICE_SAMPLE_PATH)); return invoice; } + private JsonObject getMockDraftInvoiceLine() throws Exception { + JsonObject invoiceLine = new JsonObject(getMockData(INVOICE_LINE_SAMPLE_PATH)); + return invoiceLine; + } + public static String getMockData(String path) throws IOException { logger.info("Using mock datafile: {}", path); try (InputStream resourceAsStream = InvoicesTest.class.getClassLoader().getResourceAsStream(path)) { diff --git a/src/test/resources/invoice_line.json b/src/test/resources/invoice_line.json new file mode 100644 index 000000000..384f0fc43 --- /dev/null +++ b/src/test/resources/invoice_line.json @@ -0,0 +1,40 @@ +{ + "id": "e0d08448-343b-118a-8c2f-4fb50248d672", + "description": "Some description", + "poLineIds": [ + "c0d08448-347b-418a-8c2f-5fb50248d67e" + ], + "invoiceLineNumber": "123invoicenumber45-1", + "invoiceLineStatus": "Open", + "vendorRefNo": "1", + "productId": "9780764354113", + "productIdType": "ISBN", + "invoiceLineTax": 11.2, + "comment": "Sample invoice line", + "price": 2.2, + "quantity": 3.0, + "doNotReleaseEncumbrance": true, + "reportTax": 3.5, + "subscriptionInfo": "Subscription information", + "subscriptionStart": "2018-08-01T00:00:00.000+0000", + "subscriptionEnd": "2019-01-01T00:00:00.000+0000", + "pieceIds": [ + "5e317dc2-deeb-4429-b2a1-91e5cd0fd5f7" + ], + "invoiceId": "c0d08448-347b-418a-8c2f-5fb50248d67e", + "fundDistributions": [ + "HIST" + ], + "adjustmentsFieldSet": [ + { + "adjustmentLabel": "Adjustment label", + "adjustmentType": "Percentage", + "adjustmentValue": 10.1, + "proRateAdjustment": true + } + ], + "metadata": { + "createdDate": "2018-07-19T00:00:00.000+0000", + "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1" + } +} From c26766b6fea7960cfb19e2faab8d5f0d9a000599 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Fri, 15 Mar 2019 14:44:51 -0400 Subject: [PATCH 06/17] Fix Sonarcloud issues and add newline --- .../org/folio/rest/impl/InvoicesImpl.java | 26 ++++++++++--------- src/test/resources/invoice.json | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index 93fc31258..852bbcdf8 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -15,75 +15,77 @@ public class InvoicesImpl implements Invoicing { + private static final String NOT_SUPPORTED = "Not supported"; // To overcome sonarcloud warning + @Override public void postInvoicingInvoices(String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void getInvoicingInvoices(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void getInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void putInvoicingInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void deleteInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void getInvoicingInvoiceLines(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void postInvoicingInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void getInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void putInvoicingInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void deleteInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void getInvoicingInvoiceNumber(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain("Not supported"))); + asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Override public void postInvoicingInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceNumberValidateResponse.respond500WithApplicationJson("Not supported"))); + asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceNumberValidateResponse.respond500WithApplicationJson(NOT_SUPPORTED))); } } diff --git a/src/test/resources/invoice.json b/src/test/resources/invoice.json index d98c8c9ad..10d4e256b 100644 --- a/src/test/resources/invoice.json +++ b/src/test/resources/invoice.json @@ -29,4 +29,4 @@ "createdDate": "2018-07-19T00:00:00.000+0000", "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1" } -} \ No newline at end of file +} From 13f4ffa06650d32930bf578570d32d39ea92c05c Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 09:49:57 -0400 Subject: [PATCH 07/17] Consistent permission naming --- descriptors/ModuleDescriptor-template.json | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 74799ef81..dcbd3965a 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -10,27 +10,27 @@ { "methods": ["GET"], "pathPattern": "/invoicing/invoices", - "permissionsRequired": ["invoicing.collection.get"] + "permissionsRequired": ["invoicing.invoice.collection.get"] }, { "methods": ["POST"], "pathPattern": "/invoicing/invoices", - "permissionsRequired": ["invoicing.item.post"] + "permissionsRequired": ["invoicing.invoice.item.post"] }, { "methods": ["GET"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.item.get"] + "permissionsRequired": ["invoicing.invoice.item.get"] }, { "methods": ["PUT"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.item.put"] + "permissionsRequired": ["invoicing.invoice.item.put"] }, { "methods": ["DELETE"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.item.delete"] + "permissionsRequired": ["invoicing.invoice.item.delete"] }, { "methods": ["GET"], @@ -91,27 +91,27 @@ ], "permissionSets": [ { - "permissionName": "invoicing.collection.get", + "permissionName": "invoicing.invoice.collection.get", "displayName": "Invoice - get collection of Invoice", "description": "Get collection of Invoice" }, { - "permissionName": "invoicing.item.get", + "permissionName": "invoicing.invoice.item.get", "displayName": "Invoice - get an existing Invoice", "description": "Get an existing Invoice" }, { - "permissionName": "invoicing.item.post", + "permissionName": "invoicing.invoice.item.post", "displayName": "Invoice - create a new Invoice", "description": "Create a new invoice" }, { - "permissionName": "invoicing.item.put", + "permissionName": "invoicing.invoice.item.put", "displayName": "Invoice - modify invoice", "description": "Modify an existing Invoice" }, { - "permissionName": "invoicing.item.delete", + "permissionName": "invoicing.invoice.item.delete", "displayName": "Invoice - delete an existing Invoice", "description": "Delete an existing Invoice" }, @@ -155,11 +155,11 @@ "displayName": "Invoice module - all permissions", "description": "Entire set of permissions needed to use the invoice module", "subPermissions": [ - "invoicing.collection.get", - "invoicing.item.get", - "invoicing.item.post", - "invoicing.item.put", - "invoicing.item.delete", + "invoicing.invoice.collection.get", + "invoicing.invoice.item.get", + "invoicing.invoice.item.post", + "invoicing.invoice.item.put", + "invoicing.invoice.item.delete", "invoicing.invoice-line.collection.get", "invoicing.invoice-line.item.get", "invoicing.invoice-line.item.post", From 6bbbb543e09910148867cdbf4fbc0a281c88efdd Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 10:16:29 -0400 Subject: [PATCH 08/17] Update Jenkins file to enable publishModDescriptor, publishAPI, mvnDeploy, runLintRamlCop and docker --- Jenkinsfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 55f88c5df..aa93b8aef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,14 @@ buildMvn { - publishModDescriptor = false - publishAPI = false - mvnDeploy = false - runLintRamlCop = false + publishModDescriptor = 'yes' + publishAPI = 'yes' + mvnDeploy = 'yes' + runLintRamlCop = 'yes' doDocker = { buildJavaDocker { - publishMaster = 'no' - healthChk = 'no' + publishMaster = 'yes' + healthChk = 'yes' healthChkCmd = 'curl -sS --fail -o /dev/null http://localhost:8081/apidocs/ || exit 1' } } } - - From 2e8b81eb6f0151f0109530a2a246e66d1770efd3 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 14:04:24 -0400 Subject: [PATCH 09/17] Bump tenant version to 1.2 so this module can talk to Okapi --- descriptors/ModuleDescriptor-template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index dcbd3965a..f82a4c9a0 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -71,7 +71,7 @@ }, { "id": "_tenant", - "version": "1.0", + "version": "1.2", "interfaceType": "system", "handlers": [ { From 8c10b501459ae042d8426fcd166d90cca9a93e56 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 14:52:46 -0400 Subject: [PATCH 10/17] Add validate and fix raml-lint-cop errors --- ramls/invoice.json | 17 --------------- ramls/invoiceCollection.json | 21 ------------------- .../org/folio/rest/impl/InvoicesImpl.java | 14 +++++++++++++ 3 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 ramls/invoice.json delete mode 100644 ramls/invoiceCollection.json diff --git a/ramls/invoice.json b/ramls/invoice.json deleted file mode 100644 index a4d4da378..000000000 --- a/ramls/invoice.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "description": "An invoice", - "additionalProperties": false, - "properties": { - "id": { - "type": "string" - }, - "metadata": { - "description": "Metadata about creation and changes, provided by the server (client should not provide)", - "type": "object", - "$ref": "raml-util/schemas/metadata.schema", - "readonly": true - } - } -} diff --git a/ramls/invoiceCollection.json b/ramls/invoiceCollection.json deleted file mode 100644 index 9ad6a3885..000000000 --- a/ramls/invoiceCollection.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "description": "Collection of invoices", - "properties": { - "invoices": { - "type": "array", - "items": { - "type": "object", - "$ref": "./invoice.json" - } - }, - "totalRecords": { - "type": "integer" - } - }, - "required": [ - "invoices", - "totalRecords" - ] -} diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index 852bbcdf8..fc7573f4b 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -3,6 +3,8 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Context; import io.vertx.core.Handler; + +import org.folio.rest.annotations.Validate; import org.folio.rest.jaxrs.model.Invoice; import org.folio.rest.jaxrs.model.InvoiceLine; import org.folio.rest.jaxrs.resource.Invoicing; @@ -17,72 +19,84 @@ public class InvoicesImpl implements Invoicing { private static final String NOT_SUPPORTED = "Not supported"; // To overcome sonarcloud warning + @Validate @Override public void postInvoicingInvoices(String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void getInvoicingInvoices(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void getInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void putInvoicingInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void deleteInvoicingInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void getInvoicingInvoiceLines(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void postInvoicingInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void getInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void putInvoicingInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void deleteInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void getInvoicingInvoiceNumber(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain(NOT_SUPPORTED))); } + @Validate @Override public void postInvoicingInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { From 9ee9610d4e396a43e6048506bb1cf82610943f34 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 14:59:19 -0400 Subject: [PATCH 11/17] Update test with valid UUID --- src/test/java/org/folio/rest/imp/InvoicesTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/folio/rest/imp/InvoicesTest.java b/src/test/java/org/folio/rest/imp/InvoicesTest.java index d36f697d6..968dd0f1a 100644 --- a/src/test/java/org/folio/rest/imp/InvoicesTest.java +++ b/src/test/java/org/folio/rest/imp/InvoicesTest.java @@ -45,6 +45,7 @@ public class InvoicesTest { private static final String INVOICE_SAMPLE_PATH = "invoice.json"; private static final String INVOICE_LINE_SAMPLE_PATH = "invoice_line.json"; private static final String ID = "id"; + private static final String UUID = "8d3881f6-dd93-46f0-b29d-1c36bdb5c9f9"; private static Vertx vertx; private static int port = NetworkUtils.nextFreePort(); @@ -125,7 +126,7 @@ public void getInvoicingInvoiceNumberTest() throws MalformedURLException { @Test public void getInvoicingInvoicesByIdTest() throws MalformedURLException { given() - .pathParam("id", "1") + .pathParam(ID, UUID) .header(TENANT_HEADER) .contentType(ContentType.JSON) .get(storageUrl(INVOICE_ID_PATH)) @@ -136,7 +137,7 @@ public void getInvoicingInvoicesByIdTest() throws MalformedURLException { @Test public void getInvoicingInvoiceLinesByIdTest() throws MalformedURLException { given() - .pathParam("id", "1") + .pathParam(ID, UUID) .header(TENANT_HEADER) .contentType(ContentType.JSON) .get(storageUrl(INVOICE_LINE_ID_PATH)) @@ -177,7 +178,7 @@ public void putInvoicingInvoiceLinesByIdTest() throws Exception { @Test public void deleteInvoicingInvoicesByIdTest() throws MalformedURLException { given() - .pathParam(ID, "1") + .pathParam(ID, UUID) .header(TENANT_HEADER) .contentType(ContentType.JSON) .delete(storageUrl(INVOICE_ID_PATH)) @@ -188,7 +189,7 @@ public void deleteInvoicingInvoicesByIdTest() throws MalformedURLException { @Test public void deleteInvoicingInvoiceLinesByIdTest() throws MalformedURLException { given() - .pathParam(ID, "1") + .pathParam(ID, UUID) .header(TENANT_HEADER) .contentType(ContentType.JSON) .delete(storageUrl(INVOICE_LINE_ID_PATH)) From 95ad11382b76c65fc9ebffad426485bfb7e978c6 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Mon, 18 Mar 2019 17:01:45 -0400 Subject: [PATCH 12/17] Remove embed_postgres=true --- descriptors/DeploymentDescriptor-template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descriptors/DeploymentDescriptor-template.json b/descriptors/DeploymentDescriptor-template.json index ec0cc77fc..7314d9503 100644 --- a/descriptors/DeploymentDescriptor-template.json +++ b/descriptors/DeploymentDescriptor-template.json @@ -2,6 +2,6 @@ "srvcId": "${artifactId}-${version}", "nodeId": "localhost", "descriptor": { - "exec": "java -Dport=%p -jar ../${artifactId}/target/${artifactId}-fat.jar -Dhttp.port=%p embed_postgres=true" + "exec": "java -Dport=%p -jar ../${artifactId}/target/${artifactId}-fat.jar -Dhttp.port=%p" } } From 317f47452f0a61221d3be94e5e9a61ac5d884e72 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Tue, 19 Mar 2019 10:25:54 -0400 Subject: [PATCH 13/17] Correct permission names as per FOLIO convention --- descriptors/ModuleDescriptor-template.json | 74 +++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index f82a4c9a0..c2a1721fa 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -10,62 +10,62 @@ { "methods": ["GET"], "pathPattern": "/invoicing/invoices", - "permissionsRequired": ["invoicing.invoice.collection.get"] + "permissionsRequired": ["invoice.invoices.collection.get"] }, { "methods": ["POST"], "pathPattern": "/invoicing/invoices", - "permissionsRequired": ["invoicing.invoice.item.post"] + "permissionsRequired": ["invoice.invoices.item.post"] }, { "methods": ["GET"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.invoice.item.get"] + "permissionsRequired": ["invoice.invoices.item.get"] }, { "methods": ["PUT"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.invoice.item.put"] + "permissionsRequired": ["invoice.invoices.item.put"] }, { "methods": ["DELETE"], "pathPattern": "/invoicing/invoices/{id}", - "permissionsRequired": ["invoicing.invoice.item.delete"] + "permissionsRequired": ["invoice.invoices.item.delete"] }, { "methods": ["GET"], "pathPattern": "/invoicing/invoice-lines", - "permissionsRequired": ["invoicing.invoice-lines.collection.get"] + "permissionsRequired": ["invoice.invoice-lines.collection.get"] }, { "methods": ["POST"], "pathPattern": "/invoicing/invoice-lines", - "permissionsRequired": ["invoicing.invoice-lines.item.post"] + "permissionsRequired": ["invoice.invoice-lines.item.post"] }, { "methods": ["GET"], "pathPattern": "/invoicing/invoice-lines/{id}", - "permissionsRequired": ["invoicing.invoice-lines.item.get"] + "permissionsRequired": ["invoice.invoice-lines.item.get"] }, { "methods": ["PUT"], "pathPattern": "/invoicing/invoice-lines/{id}", - "permissionsRequired": ["invoicing.invoice-lines.item.put"] + "permissionsRequired": ["invoice.invoice-lines.item.put"] }, { "methods": ["DELETE"], "pathPattern": "/invoicing/invoice-lines/{id}", - "permissionsRequired": ["invoicing.invoice-lines.item.delete"] + "permissionsRequired": ["invoice.invoice-lines.item.delete"] }, { "methods": ["GET"], "pathPattern": "/invoicing/invoice-number", - "permissionsRequired": ["invoicing.invoice-number.item.get"] + "permissionsRequired": ["invoice.invoice-number.item.get"] }, { "methods": ["POST"], "pathPattern": "/invoicing/invoice-number/validate", - "permissionsRequired": ["invoicing.invoice-number.item.post"] + "permissionsRequired": ["invoice.invoice-number.item.post"] } ] }, @@ -91,82 +91,82 @@ ], "permissionSets": [ { - "permissionName": "invoicing.invoice.collection.get", + "permissionName": "invoice.invoices.collection.get", "displayName": "Invoice - get collection of Invoice", "description": "Get collection of Invoice" }, { - "permissionName": "invoicing.invoice.item.get", + "permissionName": "invoice.invoices.item.get", "displayName": "Invoice - get an existing Invoice", "description": "Get an existing Invoice" }, { - "permissionName": "invoicing.invoice.item.post", + "permissionName": "invoice.invoices.item.post", "displayName": "Invoice - create a new Invoice", "description": "Create a new invoice" }, { - "permissionName": "invoicing.invoice.item.put", + "permissionName": "invoice.invoices.item.put", "displayName": "Invoice - modify invoice", "description": "Modify an existing Invoice" }, { - "permissionName": "invoicing.invoice.item.delete", + "permissionName": "invoice.invoices.item.delete", "displayName": "Invoice - delete an existing Invoice", "description": "Delete an existing Invoice" }, { - "permissionName": "invoicing.invoice-lines.collection.get", + "permissionName": "invoice.invoice-lines.collection.get", "displayName": "Invoice Line - get collection of Invoice lines", "description": "Get collection of Invoice lines" }, { - "permissionName": "invoicing.invoice-lines.item.get", + "permissionName": "invoice.invoice-lines.item.get", "displayName": "Invoice - get an existing Invoice line", "description": "Get an existing Invoice line" }, { - "permissionName": "invoicing.invoice-lines.item.post", + "permissionName": "invoice.invoice-lines.item.post", "displayName": "Invoice - create a new Invoice line", "description": "Create a new Invoice line" }, { - "permissionName": "invoicing.invoice-lines.item.put", + "permissionName": "invoice.invoice-lines.item.put", "displayName": "Invoice - modify an existing Invoice line", "description": "Modify an existing Invoice line" }, { - "permissionName": "invoicing.invoice-lines.item.delete", + "permissionName": "invoice.invoice-lines.item.delete", "displayName": "Invoice - delete an existing Invoice line", "description": "Delete an existing Invoice line" }, { - "permissionName": "invoicing.invoice-number.item.get", + "permissionName": "invoice.invoice-number.item.get", "displayName": "Invoice - generate a Invoice Number", "description": "Generate a Invoice Number" }, { - "permissionName": "invoicing.invoice-number.item.post", + "permissionName": "invoice.invoice-number.item.post", "displayName": "Invoice - validate a Invoice Number", "description": "Validate a Invoice Number" }, { - "permissionName": "invoicing.all", + "permissionName": "invoice.all", "displayName": "Invoice module - all permissions", "description": "Entire set of permissions needed to use the invoice module", "subPermissions": [ - "invoicing.invoice.collection.get", - "invoicing.invoice.item.get", - "invoicing.invoice.item.post", - "invoicing.invoice.item.put", - "invoicing.invoice.item.delete", - "invoicing.invoice-line.collection.get", - "invoicing.invoice-line.item.get", - "invoicing.invoice-line.item.post", - "invoicing.invoice-line.item.put", - "invoicing.invoice-line.item.delete", - "invoicing.invoice-number.item.get", - "invoicing.invoice-number.item.post" + "invoice.invoices.collection.get", + "invoice.invoices.item.get", + "invoice.invoices.item.post", + "invoice.invoices.item.put", + "invoice.invoices.item.delete", + "invoice.invoice-lines.collection.get", + "invoice.invoice-lines.item.get", + "invoice.invoice-lines.item.post", + "invoice.invoice-lines.item.put", + "invoice.invoice-lines.item.delete", + "invoice.invoice-number.item.get", + "invoice.invoice-number.item.post" ], "visible": false } From 8d8ca5283d4d70516821c89fd391c956bede48d3 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Tue, 19 Mar 2019 10:29:35 -0400 Subject: [PATCH 14/17] More naming convention changes --- descriptors/ModuleDescriptor-template.json | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index c2a1721fa..45dfec5a7 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -9,62 +9,62 @@ "handlers": [ { "methods": ["GET"], - "pathPattern": "/invoicing/invoices", + "pathPattern": "/invoice/invoices", "permissionsRequired": ["invoice.invoices.collection.get"] }, { "methods": ["POST"], - "pathPattern": "/invoicing/invoices", + "pathPattern": "/invoice/invoices", "permissionsRequired": ["invoice.invoices.item.post"] }, { "methods": ["GET"], - "pathPattern": "/invoicing/invoices/{id}", + "pathPattern": "/invoice/invoices/{id}", "permissionsRequired": ["invoice.invoices.item.get"] }, { "methods": ["PUT"], - "pathPattern": "/invoicing/invoices/{id}", + "pathPattern": "/invoice/invoices/{id}", "permissionsRequired": ["invoice.invoices.item.put"] }, { "methods": ["DELETE"], - "pathPattern": "/invoicing/invoices/{id}", + "pathPattern": "/invoice/invoices/{id}", "permissionsRequired": ["invoice.invoices.item.delete"] }, { "methods": ["GET"], - "pathPattern": "/invoicing/invoice-lines", + "pathPattern": "/invoice/invoice-lines", "permissionsRequired": ["invoice.invoice-lines.collection.get"] }, { "methods": ["POST"], - "pathPattern": "/invoicing/invoice-lines", + "pathPattern": "/invoice/invoice-lines", "permissionsRequired": ["invoice.invoice-lines.item.post"] }, { "methods": ["GET"], - "pathPattern": "/invoicing/invoice-lines/{id}", + "pathPattern": "/invoice/invoice-lines/{id}", "permissionsRequired": ["invoice.invoice-lines.item.get"] }, { "methods": ["PUT"], - "pathPattern": "/invoicing/invoice-lines/{id}", + "pathPattern": "/invoice/invoice-lines/{id}", "permissionsRequired": ["invoice.invoice-lines.item.put"] }, { "methods": ["DELETE"], - "pathPattern": "/invoicing/invoice-lines/{id}", + "pathPattern": "/invoice/invoice-lines/{id}", "permissionsRequired": ["invoice.invoice-lines.item.delete"] }, { "methods": ["GET"], - "pathPattern": "/invoicing/invoice-number", + "pathPattern": "/invoice/invoice-number", "permissionsRequired": ["invoice.invoice-number.item.get"] }, { "methods": ["POST"], - "pathPattern": "/invoicing/invoice-number/validate", + "pathPattern": "/invoice/invoice-number/validate", "permissionsRequired": ["invoice.invoice-number.item.post"] } ] From d9e04c4e51f349cfb30e21ced2ce505f5bb1653c Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Tue, 19 Mar 2019 10:51:58 -0400 Subject: [PATCH 15/17] More interface naming convention changes --- ramls/invoice.raml | 2 +- .../org/folio/rest/impl/InvoicesImpl.java | 66 +++++++++---------- .../java/org/folio/rest/imp/InvoicesTest.java | 12 ++-- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ramls/invoice.raml b/ramls/invoice.raml index cbd91913a..aa221bf70 100644 --- a/ramls/invoice.raml +++ b/ramls/invoice.raml @@ -30,7 +30,7 @@ resourceTypes: collection-item: !include raml-util/rtypes/item-collection.raml get-only: !include raml-util/rtypes/get-only.raml -/invoicing: +/invoice: /invoices: displayName: Invoice description: Manage Invoices diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index fc7573f4b..c65fd4bd5 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -1,105 +1,105 @@ package org.folio.rest.impl; -import io.vertx.core.AsyncResult; -import io.vertx.core.Context; -import io.vertx.core.Handler; +import static io.vertx.core.Future.succeededFuture; + +import java.util.Map; + +import javax.ws.rs.core.Response; import org.folio.rest.annotations.Validate; import org.folio.rest.jaxrs.model.Invoice; import org.folio.rest.jaxrs.model.InvoiceLine; -import org.folio.rest.jaxrs.resource.Invoicing; -import javax.ws.rs.core.Response; -import java.util.Map; - -import static io.vertx.core.Future.succeededFuture; +import io.vertx.core.AsyncResult; +import io.vertx.core.Context; +import io.vertx.core.Handler; -public class InvoicesImpl implements Invoicing { +public class InvoicesImpl implements org.folio.rest.jaxrs.resource.Invoice { private static final String NOT_SUPPORTED = "Not supported"; // To overcome sonarcloud warning @Validate @Override - public void postInvoicingInvoices(String lang, Invoice entity, Map okapiHeaders, + public void postInvoiceInvoices(String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(PostInvoiceInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void getInvoicingInvoices(int offset, int limit, String lang, Map okapiHeaders, + public void getInvoiceInvoices(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(GetInvoiceInvoicesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void getInvoicingInvoicesById(String id, String lang, Map okapiHeaders, + public void getInvoiceInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(GetInvoiceInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void putInvoicingInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, + public void putInvoiceInvoicesById(String id, String lang, Invoice entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(PutInvoiceInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void deleteInvoicingInvoicesById(String id, String lang, Map okapiHeaders, + public void deleteInvoiceInvoicesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(DeleteInvoiceInvoicesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void getInvoicingInvoiceLines(String lang, Map okapiHeaders, + public void getInvoiceInvoiceLines(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(GetInvoiceInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void postInvoicingInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, + public void postInvoiceInvoiceLines(String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(PostInvoiceInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void getInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, + public void getInvoiceInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(GetInvoiceInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void putInvoicingInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, + public void putInvoiceInvoiceLinesById(String id, String lang, InvoiceLine entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PutInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(PutInvoiceInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void deleteInvoicingInvoiceLinesById(String id, String lang, Map okapiHeaders, + public void deleteInvoiceInvoiceLinesById(String id, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(DeleteInvoicingInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(DeleteInvoiceInvoiceLinesByIdResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void getInvoicingInvoiceNumber(String lang, Map okapiHeaders, + public void getInvoiceInvoiceNumber(String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(GetInvoicingInvoiceNumberResponse.respond500WithTextPlain(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(GetInvoiceInvoiceNumberResponse.respond500WithTextPlain(NOT_SUPPORTED))); } @Validate @Override - public void postInvoicingInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, + public void postInvoiceInvoiceNumberValidate(String lang, Object entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - asyncResultHandler.handle(succeededFuture(PostInvoicingInvoiceNumberValidateResponse.respond500WithApplicationJson(NOT_SUPPORTED))); + asyncResultHandler.handle(succeededFuture(PostInvoiceInvoiceNumberValidateResponse.respond500WithApplicationJson(NOT_SUPPORTED))); } } diff --git a/src/test/java/org/folio/rest/imp/InvoicesTest.java b/src/test/java/org/folio/rest/imp/InvoicesTest.java index 968dd0f1a..e0ffc085e 100644 --- a/src/test/java/org/folio/rest/imp/InvoicesTest.java +++ b/src/test/java/org/folio/rest/imp/InvoicesTest.java @@ -36,12 +36,12 @@ public class InvoicesTest { private static final Logger logger = LoggerFactory.getLogger(InvoicesTest.class); - private static final String INVOICE_ID_PATH = "/invoicing/invoices/{id}"; - private static final String INVOICE_LINE_ID_PATH = "/invoicing/invoice-lines/{id}"; - private static final String INVOICE_PATH = "/invoicing/invoices"; - private static final String INVOICE_LINES_PATH = "/invoicing/invoice-lines"; - private static final String INVOICE_NUMBER_PATH = "/invoicing/invoice-number"; - private static final String INVOICE_NUMBER_VALIDATE_PATH = "/invoicing/invoice-number/validate"; + private static final String INVOICE_ID_PATH = "/invoice/invoices/{id}"; + private static final String INVOICE_LINE_ID_PATH = "/invoice/invoice-lines/{id}"; + private static final String INVOICE_PATH = "/invoice/invoices"; + private static final String INVOICE_LINES_PATH = "/invoice/invoice-lines"; + private static final String INVOICE_NUMBER_PATH = "/invoice/invoice-number"; + private static final String INVOICE_NUMBER_VALIDATE_PATH = "/invoice/invoice-number/validate"; private static final String INVOICE_SAMPLE_PATH = "invoice.json"; private static final String INVOICE_LINE_SAMPLE_PATH = "invoice_line.json"; private static final String ID = "id"; From 3ff8cb36c2bc9a4c9fc7d8465c1c76dbf444ba58 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Tue, 19 Mar 2019 12:54:55 -0400 Subject: [PATCH 16/17] Add pageable --- ramls/invoice.raml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ramls/invoice.raml b/ramls/invoice.raml index aa221bf70..fc0ee2d3b 100644 --- a/ramls/invoice.raml +++ b/ramls/invoice.raml @@ -70,7 +70,7 @@ resourceTypes: exampleItem: !include acq-models/mod-invoice-storage/examples/invoice_line.sample is: [validate] get: - is: [validate] + is: [ pageable, validate ] post: description: Post an invoice lines to corresponding invoice /{id}: From d0f48c14f19d471bba5659a86ee9606aac4d7858 Mon Sep 17 00:00:00 2001 From: javalkar-varun Date: Tue, 19 Mar 2019 12:59:58 -0400 Subject: [PATCH 17/17] Handle get after making pageable --- src/main/java/org/folio/rest/impl/InvoicesImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/folio/rest/impl/InvoicesImpl.java b/src/main/java/org/folio/rest/impl/InvoicesImpl.java index c65fd4bd5..fd8d728d4 100644 --- a/src/main/java/org/folio/rest/impl/InvoicesImpl.java +++ b/src/main/java/org/folio/rest/impl/InvoicesImpl.java @@ -56,7 +56,7 @@ public void deleteInvoiceInvoicesById(String id, String lang, Map okapiHeaders, + public void getInvoiceInvoiceLines(int offset, int limit, String lang, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { asyncResultHandler.handle(succeededFuture(GetInvoiceInvoiceLinesResponse.respond500WithTextPlain(NOT_SUPPORTED))); }