diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json
index 7177d5015..42ce32ec1 100644
--- a/descriptors/ModuleDescriptor-template.json
+++ b/descriptors/ModuleDescriptor-template.json
@@ -665,6 +665,31 @@
}
]
},
+ {
+ "id": "wrapper-pieces",
+ "version": "1.0",
+ "handlers": [
+ {
+ "methods": ["GET"],
+ "pathPattern": "/orders/wrapper-pieces",
+ "permissionsRequired": ["orders.wrapper-pieces.collection.get"],
+ "modulePermissions": [
+ "orders-storage.wrapper-pieces.collection.get",
+ "orders-storage.settings.collection.get",
+ "consortia.user-tenants.collection.get",
+ "user-tenants.collection.get"
+ ]
+ },
+ {
+ "methods": ["GET"],
+ "pathPattern": "/orders/wrapper-pieces/{id}",
+ "permissionsRequired": ["orders.wrapper-pieces.item.get"],
+ "modulePermissions": [
+ "orders-storage.wrapper-pieces.item.get"
+ ]
+ }
+ ]
+ },
{
"id": "acquisition-methods",
"version": "1.0",
@@ -1263,6 +1288,10 @@
"id": "orders-storage.pieces",
"version": "5.0"
},
+ {
+ "id": "orders-storage.wrapper-pieces",
+ "version": "1.0"
+ },
{
"id": "orders-storage.receiving-history",
"version": "4.0"
@@ -1615,6 +1644,25 @@
"orders.piece-requests.collection.get"
]
},
+ {
+ "permissionName" : "orders.wrapper-pieces.collection.get",
+ "displayName" : "orders.wrapper-pieces-collection get",
+ "description" : "Get a collection of wrapper pieces"
+ },
+ {
+ "permissionName" : "orders.wrapper-pieces.item.get",
+ "displayName" : "orders.wrapper-pieces-item get",
+ "description" : "Fetch a wrapper piece"
+ },
+ {
+ "permissionName" : "orders.wrapper-pieces.all",
+ "displayName" : "All orders wrapper pieces perms",
+ "description" : "All permissions for the orders-wrapper-pieces",
+ "subPermissions" : [
+ "orders.wrapper-pieces.collection.get",
+ "orders.wrapper-pieces.item.get"
+ ]
+ },
{
"permissionName" : "orders.acquisition-methods.collection.get",
"displayName" : "acquisition-methods-collection get",
@@ -2077,6 +2125,7 @@
"orders.expect.collection.post",
"orders.receiving-history.collection.get",
"orders.pieces.all",
+ "orders.wrapper-pieces.all",
"orders.acquisitions-units-assignments.all",
"orders.order-templates.all",
"orders.titles.all",
diff --git a/ramls/acq-models b/ramls/acq-models
index 494a65e44..e401fec3e 160000
--- a/ramls/acq-models
+++ b/ramls/acq-models
@@ -1 +1 @@
-Subproject commit 494a65e44f01d3ad01dcc46947587d81ca955083
+Subproject commit e401fec3e8084596c7b638e737567adc30acb6f2
diff --git a/ramls/wrapper-pieces.raml b/ramls/wrapper-pieces.raml
new file mode 100644
index 000000000..13d180e25
--- /dev/null
+++ b/ramls/wrapper-pieces.raml
@@ -0,0 +1,46 @@
+#%RAML 1.0
+title: "Wrapper Pieces"
+baseUri: https://github.com/folio-org/mod-orders
+version: v4
+
+documentation:
+ - title: "Wrapper Pieces"
+ content: Read API to manage Wrapper Pieces.
+
+types:
+ errors: !include raml-util/schemas/errors.schema
+ wrapper_piece: !include acq-models/mod-orders-storage/schemas/wrapper_piece.json
+ wrapper_piece_collection: !include acq-models/mod-orders-storage/schemas/wrapper_piece_collection.json
+ 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:
+ orderable: !include raml-util/traits/orderable.raml
+ pageable: !include raml-util/traits/pageable.raml
+ searchable: !include raml-util/traits/searchable.raml
+
+resourceTypes:
+ collection-get: !include raml-util/rtypes/collection-get.raml
+ collection-item-get: !include raml-util/rtypes/item-collection-get-with-json-response.raml
+
+/orders/wrapper-pieces:
+ type:
+ collection-get:
+ exampleCollection: !include acq-models/mod-orders-storage/examples/wrapper_piece_collection.sample
+ schemaCollection: wrapper_piece_collection
+ get:
+ description: Get list of Wrapper Pieces
+ is: [
+ searchable: {description: "with valid searchable fields: for example code", example: "[\"code\", \"MEDGRANT\", \"=\"]"},
+ pageable
+ ]
+ /{id}:
+ uriParameters:
+ id:
+ description: The UUID of a Wrapper Piece
+ type: UUID
+ type:
+ collection-item-get:
+ exampleItem: !include acq-models/mod-orders-storage/examples/wrapper_piece_get.sample
+ schema: wrapper_piece
diff --git a/src/main/java/org/folio/config/ApplicationConfig.java b/src/main/java/org/folio/config/ApplicationConfig.java
index 7ee11cb1f..a5b70c357 100644
--- a/src/main/java/org/folio/config/ApplicationConfig.java
+++ b/src/main/java/org/folio/config/ApplicationConfig.java
@@ -95,6 +95,7 @@
import org.folio.service.orders.lines.update.instance.WithHoldingOrderLineUpdateInstanceStrategy;
import org.folio.service.orders.lines.update.instance.WithoutHoldingOrderLineUpdateInstanceStrategy;
import org.folio.service.organization.OrganizationService;
+import org.folio.service.pieces.WrapperPieceStorageService;
import org.folio.service.pieces.PieceChangeReceiptStatusPublisher;
import org.folio.service.pieces.PieceDeleteInventoryService;
import org.folio.service.pieces.ItemRecreateInventoryService;
@@ -530,6 +531,14 @@ PieceStorageService pieceStorageService(ConsortiumConfigurationService consortiu
return new PieceStorageService(consortiumConfigurationService, consortiumUserTenantsRetriever, settingsRetriever, restClient);
}
+ @Bean
+ WrapperPieceStorageService wrapperPieceStorageService(ConsortiumConfigurationService consortiumConfigurationService,
+ ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever,
+ SettingsRetriever settingsRetriever,
+ RestClient restClient) {
+ return new WrapperPieceStorageService(consortiumConfigurationService, consortiumUserTenantsRetriever, settingsRetriever, restClient);
+ }
+
@Bean
PieceService piecesService(PieceChangeReceiptStatusPublisher receiptStatusPublisher) {
return new PieceService(receiptStatusPublisher);
diff --git a/src/main/java/org/folio/orders/utils/ResourcePathResolver.java b/src/main/java/org/folio/orders/utils/ResourcePathResolver.java
index 64f197063..1e42e2b94 100644
--- a/src/main/java/org/folio/orders/utils/ResourcePathResolver.java
+++ b/src/main/java/org/folio/orders/utils/ResourcePathResolver.java
@@ -27,6 +27,7 @@ private ResourcePathResolver() {
public static final String PURCHASE_ORDER_STORAGE = "purchaseOrder";
public static final String PIECES_STORAGE = "pieces";
public static final String PIECES_STORAGE_BATCH = "pieces-batch";
+ public static final String WRAPPER_PIECES_STORAGE = "wrapper-pieces";
public static final String ORGANIZATION_STORAGE = "organizations";
public static final String RECEIVING_HISTORY = "receiving-history";
public static final String RECEIPT_STATUS = "receiptStatus";
@@ -81,6 +82,7 @@ private ResourcePathResolver() {
apis.put(PURCHASE_ORDER_STORAGE, "/orders-storage/purchase-orders");
apis.put(PIECES_STORAGE, "/orders-storage/pieces");
apis.put(PIECES_STORAGE_BATCH, "/orders-storage/pieces-batch");
+ apis.put(WRAPPER_PIECES_STORAGE, "/orders-storage/wrapper-pieces");
apis.put(ORGANIZATION_STORAGE, "/organizations-storage/organizations");
apis.put(RECEIVING_HISTORY, "/orders-storage/receiving-history");
apis.put(PO_LINE_NUMBER, "/orders-storage/po-line-number");
diff --git a/src/main/java/org/folio/rest/impl/WrapperPiecesAPI.java b/src/main/java/org/folio/rest/impl/WrapperPiecesAPI.java
new file mode 100644
index 000000000..e9feb95c8
--- /dev/null
+++ b/src/main/java/org/folio/rest/impl/WrapperPiecesAPI.java
@@ -0,0 +1,44 @@
+package org.folio.rest.impl;
+
+import io.vertx.core.AsyncResult;
+import io.vertx.core.Context;
+import io.vertx.core.Handler;
+import io.vertx.core.Vertx;
+import lombok.extern.log4j.Log4j2;
+import org.folio.rest.core.models.RequestContext;
+import org.folio.rest.jaxrs.resource.OrdersWrapperPieces;
+import org.folio.service.pieces.WrapperPieceStorageService;
+import org.folio.spring.SpringContextUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.ws.rs.core.Response;
+import java.util.Map;
+
+import static io.vertx.core.Future.succeededFuture;
+
+@Log4j2
+public class WrapperPiecesAPI extends BaseApi implements OrdersWrapperPieces {
+
+ @Autowired
+ private WrapperPieceStorageService wrapperPieceStorageService;
+
+ public WrapperPiecesAPI() {
+ SpringContextUtil.autowireDependencies(this, Vertx.currentContext());
+ }
+
+ @Override
+ public void getOrdersWrapperPieces(String query, String totalRecords, int offset, int limit,
+ Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) {
+ wrapperPieceStorageService.getWrapperPieces(limit, offset, query, new RequestContext(vertxContext, okapiHeaders))
+ .onSuccess(wrapperPieces -> asyncResultHandler.handle(succeededFuture(buildOkResponse(wrapperPieces))))
+ .onFailure(fail -> handleErrorResponse(asyncResultHandler, fail));
+ }
+
+ @Override
+ public void getOrdersWrapperPiecesById(String id, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+ wrapperPieceStorageService.getWrapperPieceById(id, new RequestContext(vertxContext, okapiHeaders))
+ .onSuccess(wrapperPiece -> asyncResultHandler.handle(succeededFuture(buildOkResponse(wrapperPiece))))
+ .onFailure(fail -> handleErrorResponse(asyncResultHandler, fail));
+ }
+}
diff --git a/src/main/java/org/folio/service/pieces/PieceStorageService.java b/src/main/java/org/folio/service/pieces/PieceStorageService.java
index 979e5414e..3ac8af737 100644
--- a/src/main/java/org/folio/service/pieces/PieceStorageService.java
+++ b/src/main/java/org/folio/service/pieces/PieceStorageService.java
@@ -46,9 +46,11 @@ public class PieceStorageService {
private final ConsortiumConfigurationService consortiumConfigurationService;
private final ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever;
private final SettingsRetriever settingsRetriever;
- private final RestClient restClient;
+ protected final RestClient restClient;
- public PieceStorageService(ConsortiumConfigurationService consortiumConfigurationService, ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever, SettingsRetriever settingsRetriever, RestClient restClient) {
+ public PieceStorageService(ConsortiumConfigurationService consortiumConfigurationService,
+ ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever,
+ SettingsRetriever settingsRetriever, RestClient restClient) {
this.consortiumConfigurationService = consortiumConfigurationService;
this.consortiumUserTenantsRetriever = consortiumUserTenantsRetriever;
this.settingsRetriever = settingsRetriever;
@@ -146,7 +148,7 @@ public Future getAllPieces(int limit, int offset, String query,
return restClient.get(requestEntry, PieceCollection.class, requestContext);
}
- private Future> getUserTenantsIfNeeded(RequestContext requestContext) {
+ protected Future> getUserTenantsIfNeeded(RequestContext requestContext) {
return consortiumConfigurationService.getConsortiumConfiguration(requestContext)
.compose(consortiumConfiguration -> {
if (consortiumConfiguration.isEmpty()) {
diff --git a/src/main/java/org/folio/service/pieces/WrapperPieceStorageService.java b/src/main/java/org/folio/service/pieces/WrapperPieceStorageService.java
new file mode 100644
index 000000000..b3128b106
--- /dev/null
+++ b/src/main/java/org/folio/service/pieces/WrapperPieceStorageService.java
@@ -0,0 +1,45 @@
+package org.folio.service.pieces;
+
+import io.vertx.core.Future;
+import lombok.extern.log4j.Log4j2;
+import org.folio.rest.core.RestClient;
+import org.folio.rest.core.models.RequestContext;
+import org.folio.rest.core.models.RequestEntry;
+import org.folio.rest.jaxrs.model.WrapperPiece;
+import org.folio.rest.jaxrs.model.WrapperPieceCollection;
+import org.folio.service.consortium.ConsortiumConfigurationService;
+import org.folio.service.consortium.ConsortiumUserTenantsRetriever;
+import org.folio.service.settings.SettingsRetriever;
+
+import static org.folio.orders.utils.ResourcePathResolver.WRAPPER_PIECES_STORAGE;
+import static org.folio.orders.utils.ResourcePathResolver.resourcesPath;
+
+@Log4j2
+public class WrapperPieceStorageService extends PieceStorageService {
+
+ private static final String WRAPPER_PIECES_STORAGE_ENDPOINT = resourcesPath(WRAPPER_PIECES_STORAGE);
+ private static final String WRAPPER_PIECES_STORAGE_BY_ID_ENDPOINT = WRAPPER_PIECES_STORAGE_ENDPOINT + "/{id}";
+
+ public WrapperPieceStorageService(ConsortiumConfigurationService consortiumConfigurationService,
+ ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever,
+ SettingsRetriever settingsRetriever, RestClient restClient) {
+ super(consortiumConfigurationService, consortiumUserTenantsRetriever, settingsRetriever, restClient);
+ }
+
+ public Future getWrapperPieces(int limit, int offset, String query, RequestContext requestContext) {
+ return getUserTenantsIfNeeded(requestContext)
+ .map(userTenants -> getQueryForUserTenants(userTenants, query))
+ .compose(cql -> getAllWrapperPieces(limit, offset, cql, requestContext));
+ }
+
+ private Future getAllWrapperPieces(int limit, int offset, String query, RequestContext requestContext) {
+ log.debug("getAllWrapperPieces:: limit: {}, offset: {}, query: {}", limit, offset, query);
+ var requestEntry = new RequestEntry(WRAPPER_PIECES_STORAGE_ENDPOINT).withQuery(query).withOffset(offset).withLimit(limit);
+ return restClient.get(requestEntry, WrapperPieceCollection.class, requestContext);
+ }
+
+ public Future getWrapperPieceById(String pieceId, RequestContext requestContext) {
+ var requestEntry = new RequestEntry(WRAPPER_PIECES_STORAGE_BY_ID_ENDPOINT).withId(pieceId);
+ return restClient.get(requestEntry, WrapperPiece.class, requestContext);
+ }
+}
diff --git a/src/test/java/org/folio/ApiTestSuite.java b/src/test/java/org/folio/ApiTestSuite.java
index 62a9acd20..73b3500a5 100644
--- a/src/test/java/org/folio/ApiTestSuite.java
+++ b/src/test/java/org/folio/ApiTestSuite.java
@@ -39,6 +39,7 @@
import org.folio.rest.impl.ReceivingHistoryApiTest;
import org.folio.rest.impl.RoutingListsApiTest;
import org.folio.rest.impl.TitlesApiTest;
+import org.folio.rest.impl.WrapperPiecesAPITest;
import org.folio.rest.impl.crud.ConfigurationCrudTest;
import org.folio.rest.impl.protection.LinesProtectionTest;
import org.folio.rest.impl.protection.OrdersProtectionTest;
@@ -99,6 +100,7 @@
import org.folio.service.pieces.PieceUpdateInventoryServiceTest;
import org.folio.service.pieces.PieceUtilTest;
import org.folio.service.pieces.PiecesClaimingServiceTest;
+import org.folio.service.pieces.WrapperPieceStorageServiceTest;
import org.folio.service.pieces.flows.BasePieceFlowHolderBuilderTest;
import org.folio.service.pieces.flows.DefaultPieceFlowsValidatorTest;
import org.folio.service.pieces.flows.create.PieceCreateFlowInventoryManagerTest;
@@ -560,4 +562,12 @@ class PiecesClaimingServiceNested extends PiecesClaimingServiceTest {
@Nested
class PieceUtilTestNested extends PieceUtilTest {
}
+
+ @Nested
+ class WrapperPieceStorageServiceTestNested extends WrapperPieceStorageServiceTest {
+ }
+
+ @Nested
+ class WrapperPiecesAPITestNested extends WrapperPiecesAPITest {
+ }
}
diff --git a/src/test/java/org/folio/RestTestUtils.java b/src/test/java/org/folio/RestTestUtils.java
index 292ccd411..2aae8df2c 100644
--- a/src/test/java/org/folio/RestTestUtils.java
+++ b/src/test/java/org/folio/RestTestUtils.java
@@ -34,23 +34,23 @@
public class RestTestUtils {
- public static Response verifyPostResponse(String url, String body, Headers headers, String
- expectedContentType, int expectedCode) {
+ public static Response verifyPostResponse(String url, String body, Headers headers,
+ String expectedContentType, int expectedCode) {
Response response = RestAssured
- .with()
- .header(X_OKAPI_URL)
- .header(X_OKAPI_TOKEN)
- .headers(headers)
- .contentType(APPLICATION_JSON)
- .body(body)
- .post(url)
- .then()
- .log()
- .all()
- .statusCode(expectedCode)
- .contentType(expectedContentType)
- .extract()
- .response();
+ .with()
+ .header(X_OKAPI_URL)
+ .header(X_OKAPI_TOKEN)
+ .headers(headers)
+ .contentType(APPLICATION_JSON)
+ .body(body)
+ .post(url)
+ .then()
+ .log()
+ .all()
+ .statusCode(expectedCode)
+ .contentType(expectedContentType)
+ .extract()
+ .response();
// Verify no messages sent via event bus on POST (except receiving/check-in/claiming)
if (!(url.startsWith(ORDERS_RECEIVING_ENDPOINT)
@@ -62,7 +62,8 @@ public static Response verifyPostResponse(String url, String body, Headers heade
return response;
}
- public static Response verifyPostResponseWithQueryParams(String url, String body, Map queryParams, Headers headers, String
+ public static Response verifyPostResponseWithQueryParams(String url, String body, Map queryParams,
+ Headers headers, String
expectedContentType, int expectedCode) {
Response response = RestAssured
.with()
@@ -99,18 +100,18 @@ public static Response verifyPut(String url, String body, String expectedContent
public static Response verifyPut(String url, String body, Headers headers, String expectedContentType, int expectedCode) {
Response response = RestAssured
- .with()
- .header(X_OKAPI_TOKEN)
- .header(X_OKAPI_URL)
- .headers(headers)
- .body(body)
- .contentType(APPLICATION_JSON)
- .put(url)
- .then()
- .statusCode(expectedCode)
- .contentType(expectedContentType)
- .extract()
- .response();
+ .with()
+ .header(X_OKAPI_TOKEN)
+ .header(X_OKAPI_URL)
+ .headers(headers)
+ .body(body)
+ .contentType(APPLICATION_JSON)
+ .put(url)
+ .then()
+ .statusCode(expectedCode)
+ .contentType(expectedContentType)
+ .extract()
+ .response();
// Verify no messages sent via event bus on PUT if there is an error
if (expectedCode != 204) {
@@ -123,20 +124,21 @@ public static Response verifyPut(String url, String body, Headers headers, Strin
public static Response verifyPatch(String url, String body, String expectedContentType, int expectedCode) {
return verifyPatch(url, body, prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), expectedContentType, expectedCode);
}
+
public static Response verifyPatch(String url, String body, Headers headers, String expectedContentType, int expectedCode) {
Response response = RestAssured
- .with()
- .header(X_OKAPI_TOKEN)
- .header(X_OKAPI_URL)
- .headers(headers)
- .body(body)
- .contentType(APPLICATION_JSON)
- .patch(url)
- .then()
- .statusCode(expectedCode)
- .contentType(expectedContentType)
- .extract()
- .response();
+ .with()
+ .header(X_OKAPI_TOKEN)
+ .header(X_OKAPI_URL)
+ .headers(headers)
+ .body(body)
+ .contentType(APPLICATION_JSON)
+ .patch(url)
+ .then()
+ .statusCode(expectedCode)
+ .contentType(expectedContentType)
+ .extract()
+ .response();
// Verify no messages sent via event bus
if (expectedCode != 204) {
@@ -158,15 +160,15 @@ public static Response verifyGet(String url, String expectedContentType, int exp
public static Response verifyGet(String url, Headers headers, String expectedContentType, int expectedCode) {
return RestAssured
- .with()
- .header(X_OKAPI_URL)
- .headers(headers)
- .get(url)
- .then()
- .statusCode(expectedCode)
- .contentType(expectedContentType)
- .extract()
- .response();
+ .with()
+ .header(X_OKAPI_URL)
+ .headers(headers)
+ .get(url)
+ .then()
+ .statusCode(expectedCode)
+ .contentType(expectedContentType)
+ .extract()
+ .response();
}
public static T verifySuccessGet(String url, Class clazz) {
@@ -178,21 +180,21 @@ public static T verifySuccessGet(String url, Class clazz, String tenant)
}
public static Response verifyDeleteResponse(String url, String expectedContentType, int expectedCode) {
- Headers headers = prepareHeaders(NON_EXIST_CONFIG_X_OKAPI_TENANT);
+ Headers headers = prepareHeaders(NON_EXIST_CONFIG_X_OKAPI_TENANT);
return verifyDeleteResponse(url, headers, expectedContentType, expectedCode);
}
public static Response verifyDeleteResponse(String url, Headers headers, String expectedContentType, int expectedCode) {
Response response = RestAssured
- .with()
- .header(X_OKAPI_URL)
- .headers(headers)
- .delete(url)
- .then()
- .statusCode(expectedCode)
- .contentType(expectedContentType)
- .extract()
- .response();
+ .with()
+ .header(X_OKAPI_URL)
+ .headers(headers)
+ .delete(url)
+ .then()
+ .statusCode(expectedCode)
+ .contentType(expectedContentType)
+ .extract()
+ .response();
// Verify no messages sent via event bus
HandlersTestHelper.verifyOrderStatusUpdateEvent(0);
@@ -207,20 +209,19 @@ public static void checkPreventProtectedFieldsModificationRule(String path, Json
compPOParser.setValueAt(m.getKey(), m.getValue());
}
Errors errors = verifyPut(String.format(path, compPO.getString("id")), compPOJson, "", HttpStatus.HTTP_BAD_REQUEST.toInt())
- .as(Errors.class);
+ .as(Errors.class);
// Only one error expected
assertThat(errors.getErrors(), hasSize(1));
- Error error = errors.getErrors()
- .get(0);
+ Error error = errors.getErrors().get(0);
assertThat(error.getCode(), equalTo(PROHIBITED_FIELD_CHANGING.getCode()));
Object[] failedFieldNames = getModifiedProtectedFields(error);
Object[] expected = updatedFields.keySet()
- .stream()
- .map(fieldName -> fieldName.replace(COMPOSITE_PO_LINES_PREFIX, StringUtils.EMPTY))
- .toArray();
+ .stream()
+ .map(fieldName -> fieldName.replace(COMPOSITE_PO_LINES_PREFIX, StringUtils.EMPTY))
+ .toArray();
assertThat(failedFieldNames.length, is(expected.length));
assertThat(expected, Matchers.arrayContainingInAnyOrder(failedFieldNames));
}
diff --git a/src/test/java/org/folio/TestConstants.java b/src/test/java/org/folio/TestConstants.java
index d258b7b7a..7ad51ba14 100644
--- a/src/test/java/org/folio/TestConstants.java
+++ b/src/test/java/org/folio/TestConstants.java
@@ -23,6 +23,7 @@ private TestConstants() {}
public static final String ORDERS_BIND_ENDPOINT = "/orders/bind-pieces";
public static final String ORDERS_BIND_ID_ENDPOINT = "/orders/bind-pieces/%s";
public static final String PIECES_CLAIMING_ENDPOINT = "/pieces/claim";
+ public static final String WRAPPER_PIECES_ENDPOINT = "/orders/wrapper-pieces";
public static final String PO_LINE_NUMBER_VALUE = "1";
public static final String BAD_QUERY = "unprocessableQuery";
diff --git a/src/test/java/org/folio/rest/impl/MockServer.java b/src/test/java/org/folio/rest/impl/MockServer.java
index 53e3bbb1b..bfca261bd 100644
--- a/src/test/java/org/folio/rest/impl/MockServer.java
+++ b/src/test/java/org/folio/rest/impl/MockServer.java
@@ -91,6 +91,7 @@
import static org.folio.orders.utils.ResourcePathResolver.TITLES;
import static org.folio.orders.utils.ResourcePathResolver.TRANSACTIONS_ENDPOINT;
import static org.folio.orders.utils.ResourcePathResolver.USER_TENANTS_ENDPOINT;
+import static org.folio.orders.utils.ResourcePathResolver.WRAPPER_PIECES_STORAGE;
import static org.folio.orders.utils.ResourcePathResolver.resourceByIdPath;
import static org.folio.orders.utils.ResourcePathResolver.resourcesPath;
import static org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT;
@@ -128,6 +129,7 @@
import static org.folio.service.inventory.InventoryManagerTest.ONLY_NEW_HOLDING_EXIST_ID;
import io.vertx.core.MultiMap;
+
import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.time.Instant;
@@ -335,8 +337,10 @@ public class MockServer {
public static final String CONSISTENT_ECS_PURCHASE_ORDER_ID_ELECTRONIC = "01c8d44a-dc73-4bca-a4d1-ef28bdfb9275";
public static final String CONSISTENT_ECS_PURCHASE_ORDER_ID_PHYSICAL_SINGLE_ITEM = "b25f8ef6-04c4-4290-8531-9bbcefeb8c11";
public static final String CONSISTENT_ECS_PURCHASE_ORDER_ID_PHYSICAL_MULTIPLE_ITEMS = "0c9a0e56-3518-4f0c-bfbb-98cc47b07f6c";
- public static final String MOCKDATA_LOCATIONS_JSON = "mockdata/locations/locations.json";
- public static final String MOCKDATA_MATERIAL_TYPES_JSON = "mockdata/material-types/material-types.json";
+ public static final String MOCK_DATA_LOCATIONS_JSON = "mockdata/locations/locations.json";
+ public static final String MOCK_DATA_MATERIAL_TYPES_JSON = "mockdata/material-types/material-types.json";
+ public static final String MOCK_DATA_WRAPPER_PIECES_JSON = "mockdata/wrapper-pieces/wrapper-pieces.json";
+ public static final String MOCK_DATA_WRAPPER_PIECES_BY_ID_JSON = "mockdata/wrapper-pieces/wrapper-pieces-by-id.json";
public static Table> serverRqRs = HashBasedTable.create();
public static HashMap> serverRqQueries = new HashMap<>();
@@ -376,10 +380,9 @@ public void start() throws InterruptedException, ExecutionException, TimeoutExce
HttpServer server = vertx.createHttpServer();
Promise deploymentComplete = Promise.promise();
server.requestHandler(defineRoutes()).listen(port, result -> {
- if(result.succeeded()) {
+ if (result.succeeded()) {
deploymentComplete.complete(result.result());
- }
- else {
+ } else {
deploymentComplete.fail(result.cause());
}
});
@@ -509,6 +512,7 @@ static List getInstanceTypesSearches() {
public static List getAcqUnitsSearches() {
return getCollectionRecords(getRqRsEntries(HttpMethod.GET, ACQUISITIONS_UNITS));
}
+
public static List getAcqUnitsRetrievals() {
return getRecordsByIds(getRqRsEntries(HttpMethod.GET, ACQUISITIONS_UNITS));
}
@@ -678,8 +682,10 @@ private Router defineRoutes() {
router.get("/data-import-profiles/jobProfileSnapshots/:id").handler(this::handleGetJobProfileSnapshotById);
router.get("/change-manager/jobExecutions/:id").handler(this::handleGetJobExecutionById);
router.get("/organizations/organizations").handler(this::handleGetOrganizations);
- router.get("/locations").handler(ctx -> handleGetJsonResource(ctx, MOCKDATA_LOCATIONS_JSON));
- router.get("/material-types").handler(ctx -> handleGetJsonResource(ctx, MOCKDATA_MATERIAL_TYPES_JSON));
+ router.get("/locations").handler(ctx -> handleGetJsonResource(ctx, MOCK_DATA_LOCATIONS_JSON));
+ router.get("/material-types").handler(ctx -> handleGetJsonResource(ctx, MOCK_DATA_MATERIAL_TYPES_JSON));
+ router.get(resourcesPath(WRAPPER_PIECES_STORAGE)).handler(ctx -> handleGetJsonResource(ctx, MOCK_DATA_WRAPPER_PIECES_JSON));
+ router.get(resourcesPath(WRAPPER_PIECES_STORAGE) + "/:id").handler(ctx -> handleGetJsonResource(ctx, MOCK_DATA_WRAPPER_PIECES_BY_ID_JSON));
// PUT
router.put(resourcePath(PURCHASE_ORDER_STORAGE)).handler(ctx -> handlePutGenericSubObj(ctx, PURCHASE_ORDER_STORAGE));
router.put(resourcePath(PO_LINES_STORAGE)).handler(ctx -> handlePutGenericSubObj(ctx, PO_LINES_STORAGE));
@@ -820,12 +826,11 @@ private void handleGetFundById(RoutingContext ctx) {
FundCollection funds = getFundsByIds(Collections.singletonList(id))
.mapTo(FundCollection.class);
- if (funds.getTotalRecords() == 0){
+ if (funds.getTotalRecords() == 0) {
serverResponse(ctx, 404, APPLICATION_JSON, id);
- }
- else {
+ } else {
JsonObject fund = new JsonObject()
- .put("fund",JsonObject.mapFrom(funds.getFunds().get(0)))
+ .put("fund", JsonObject.mapFrom(funds.getFunds().get(0)))
.put("groupIds", new JsonArray());
addServerRqRsData(HttpMethod.GET, FUNDS, fund);
@@ -981,7 +986,7 @@ private void handleGetCurrentFiscalYearByLedgerId(RoutingContext ctx) {
serverResponse(ctx, 500, APPLICATION_JSON, INTERNAL_SERVER_ERROR.getReasonPhrase());
} else if (ID_DOES_NOT_EXIST.equals(id)) {
serverResponse(ctx, 404, APPLICATION_JSON, id);
- } else if(id.equals("133a7916-f05e-4df4-8f7f-09eb2a7076d1")) {
+ } else if (id.equals("133a7916-f05e-4df4-8f7f-09eb2a7076d1")) {
FiscalYear fiscalYear = new FiscalYear();
fiscalYear.setId("ac2164c7-ba3d-1bc2-a12c-e35ceccbfaf2");
fiscalYear.setCode("test2020");
@@ -990,7 +995,7 @@ private void handleGetCurrentFiscalYearByLedgerId(RoutingContext ctx) {
fiscalYear.setPeriodStart(Date.from(Instant.now().minus(365, DAYS)));
fiscalYear.setPeriodEnd(Date.from(Instant.now().plus(365, DAYS)));
serverResponse(ctx, 200, APPLICATION_JSON, JsonObject.mapFrom(fiscalYear).encodePrettily());
- } else {
+ } else {
FiscalYear fiscalYear = new FiscalYear();
fiscalYear.setId(UUID.randomUUID().toString());
fiscalYear.setCode("test2020");
@@ -1003,7 +1008,7 @@ private void handleGetCurrentFiscalYearByLedgerId(RoutingContext ctx) {
}
private void handleGetPoLineNumber(RoutingContext ctx) {
- if(PO_NUMBER_ERROR_TENANT.equals(ctx.request().getHeader(OKAPI_HEADER_TENANT))) {
+ if (PO_NUMBER_ERROR_TENANT.equals(ctx.request().getHeader(OKAPI_HEADER_TENANT))) {
ctx.response()
.setStatusCode(500)
.putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
@@ -1114,14 +1119,14 @@ private void handleGetHoldingsRecords(RoutingContext ctx) {
.filter(holding -> holding.getString("permanentLocationId").equals(OLD_LOCATION_ID))
.collect(toList());
holdings = new JsonObject().put("holdingsRecords", new JsonArray(holdingsList));
- } else if (queryParam.contains(OLD_LOCATION_ID) && !queryParam.contains(NON_EXISTED_NEW_HOLDING_ID)) {
+ } else if (queryParam.contains(OLD_LOCATION_ID) && !queryParam.contains(NON_EXISTED_NEW_HOLDING_ID)) {
List holdingsList = new JsonObject(getMockData(HOLDINGS_OLD_NEW_PATH)).getJsonArray("holdingsRecords").stream()
.map(o -> ((JsonObject) o))
.filter(holding -> holding.getString("permanentLocationId").equals(OLD_LOCATION_ID)
|| !holding.getString("permanentLocationId").equals(NON_EXISTED_NEW_HOLDING_ID))
.collect(toList());
holdings = new JsonObject().put("holdingsRecords", new JsonArray(holdingsList));
- } else {
+ } else {
holdings = new JsonObject().put("holdingsRecords", new JsonArray());
}
if (queryParam.contains(NEW_LOCATION_ID) && queryParam.contains(ONLY_NEW_HOLDING_EXIST_ID)) {
@@ -1177,7 +1182,7 @@ private JsonObject getHoldingsByIds(List holdingIds) {
.map(holdingId -> new JsonObject(mockData).getJsonArray("holdingsRecords").getJsonObject(0).put(ID, holdingId))
.toList();
} catch (IOException e) {
- holdingRecords = Collections.emptyList();
+ holdingRecords = Collections.emptyList();
}
}
@@ -1255,7 +1260,7 @@ private void handleGetInventoryItemRecords(RoutingContext ctx) {
int lineIndex = query.indexOf(ITEM_PURCHASE_ORDER_LINE_IDENTIFIER) + ITEM_PURCHASE_ORDER_LINE_IDENTIFIER.length() + 2;
String purchaseOrderLineIdentifier = query.substring(lineIndex, lineIndex + 36);
int holdingIndex = query.indexOf(ITEM_HOLDINGS_RECORD_ID) + ITEM_HOLDINGS_RECORD_ID.length() + 2;
- String holdingsRecordId = query.substring(holdingIndex, holdingIndex + 36);
+ String holdingsRecordId = query.substring(holdingIndex, holdingIndex + 36);
final Iterator