Skip to content

Commit

Permalink
MODORDERS-344 code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Aug 29, 2023
1 parent ff8777a commit 2b4295b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
19 changes: 6 additions & 13 deletions ramls/po-line-batch.raml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ baseUri: http://github.com/folio-org/mod-orders-storage
version: v9.3

documentation:
- title: PO Line
content: <b>This module implements the CRUD interface. This API is intended for internal use only. Please use the /orders/order-lines API provided by mod-orders instead.</b>
- title: PO Line batch
content: <b>This module implements the PO lines batch processing interface. This API is intended for internal use only.

types:
po-line-collection: !include acq-models/mod-orders-storage/schemas/po_line_collection.json
Expand All @@ -20,10 +20,10 @@ traits:


/orders-storage/po-lines-batch:
displayName: Finance release encumbrance
description: Finance release encumbrance APIs
displayName: Process list of PO lines in a batch
description: Process list of PO lines in a batch APIs
put:
description: "asd"
description: "Update the list of PO lines in a batch"
body:
application/json:
type: po-line-collection
Expand All @@ -32,12 +32,7 @@ traits:
value: !include acq-models/mod-orders-storage/examples/po_line_collection.sample
responses:
204:
description: "Item successfully updated"
404:
description: "Item with a given ID not found"
body:
text/plain:
example: "Bad request"
description: "Collection successfully updated"
400:
description: "Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response."
body:
Expand All @@ -48,5 +43,3 @@ traits:
body:
text/plain:
example: "internal server error, contact administrator"


62 changes: 62 additions & 0 deletions src/test/java/org/folio/rest/impl/PoLineBatchAPITest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.folio.rest.impl;

import static io.restassured.RestAssured.given;
import static org.folio.StorageTestSuite.storageUrl;
import static org.folio.rest.utils.TestEntities.PO_LINE;
import static org.folio.rest.utils.TestEntities.PURCHASE_ORDER;
import static org.folio.rest.utils.TestEntities.TITLES;

import java.net.MalformedURLException;
import java.util.UUID;

import org.apache.commons.lang3.tuple.Pair;
import org.folio.rest.jaxrs.model.PoLineCollection;
import org.folio.rest.utils.IsolatedTenant;
import org.folio.rest.utils.TestData;
import org.junit.jupiter.api.Test;

import io.restassured.http.ContentType;
import io.restassured.http.Headers;
import io.vertx.core.json.Json;

@IsolatedTenant
class PoLineBatchAPITest extends TestBase {

private static final String PO_LINES_BATCH_ENDPOINT = "/orders-storage/po-lines-batch";
@Test
void putOrdersStoragePoLinesBatchSuccess() throws MalformedURLException {
String userId = UUID.randomUUID().toString();
Headers headers = getDikuTenantHeaders(userId);

givenTestData(Pair.of(PURCHASE_ORDER, TestData.PurchaseOrder.DEFAULT),
Pair.of(PO_LINE, TestData.PoLine.DEFAULT),
Pair.of(TITLES, TestData.Title.DEFAULT));

String polinesAsString = Json.encode(new PoLineCollection().withTotalRecords(0));
given()
.headers(headers)
.contentType(ContentType.JSON)
.body(polinesAsString)
.put(storageUrl(PO_LINES_BATCH_ENDPOINT))
.then()
.statusCode(204);
}


@Test
void putOrdersStorageEmptyPoLinesBatch() throws MalformedURLException {
String userId = UUID.randomUUID().toString();
Headers headers = getDikuTenantHeaders(userId);

String polinesAsString = Json.encode(new PoLineCollection().withTotalRecords(0));

given()
.headers(headers)
.contentType(ContentType.JSON)
.body(polinesAsString)
.put(storageUrl(PO_LINES_BATCH_ENDPOINT))
.then()
.statusCode(204);
}

}

0 comments on commit 2b4295b

Please sign in to comment.