diff --git a/ramls/routing-lists.raml b/ramls/routing-lists.raml index 9675563d2..922e4de34 100644 --- a/ramls/routing-lists.raml +++ b/ramls/routing-lists.raml @@ -69,13 +69,6 @@ resourceTypes: body: application/json: type: error - /{id}/template: - uriParameters: - id: - description: The UUID of a Title - type: UUID - get: - description: Execute mod-template-engine to process templates with replaced token placeholders [update] /{id}: uriParameters: id: @@ -86,3 +79,11 @@ resourceTypes: collection-item: exampleItem: !include acq-models/mod-orders-storage/examples/routing_list_get.sample schema: routing-list + /{id}/template: + uriParameters: + id: + description: The UUID of a Title + type: UUID + get: + description: Execute mod-template-engine to process templates with replaced token placeholders [update] + diff --git a/src/main/java/org/folio/rest/impl/RoutingListsAPI.java b/src/main/java/org/folio/rest/impl/RoutingListsAPI.java index bf333ebe5..c57a08f0a 100644 --- a/src/main/java/org/folio/rest/impl/RoutingListsAPI.java +++ b/src/main/java/org/folio/rest/impl/RoutingListsAPI.java @@ -1,9 +1,10 @@ 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 static io.vertx.core.Future.succeededFuture; + +import javax.ws.rs.core.Response; +import java.util.Map; + import org.folio.rest.annotations.Validate; import org.folio.rest.core.models.RequestContext; import org.folio.rest.jaxrs.model.RoutingList; @@ -12,10 +13,10 @@ 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; +import io.vertx.core.AsyncResult; +import io.vertx.core.Context; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; public class RoutingListsAPI extends BaseApi implements OrdersRoutingLists { diff --git a/src/main/java/org/folio/service/routinglists/RoutingListService.java b/src/main/java/org/folio/service/routinglists/RoutingListService.java index 8a98a20dd..6837354f2 100644 --- a/src/main/java/org/folio/service/routinglists/RoutingListService.java +++ b/src/main/java/org/folio/service/routinglists/RoutingListService.java @@ -1,7 +1,14 @@ package org.folio.service.routinglists; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; +import static org.folio.orders.utils.ResourcePathResolver.ORDER_SETTINGS; +import static org.folio.orders.utils.ResourcePathResolver.ROUTING_LISTS; +import static org.folio.orders.utils.ResourcePathResolver.TEMPLATE_REQUEST; +import static org.folio.orders.utils.ResourcePathResolver.resourcesPath; + +import java.util.Collections; +import java.util.List; +import java.util.UUID; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -25,14 +32,8 @@ import org.folio.service.orders.PurchaseOrderLineService; import org.folio.service.routinglists.validators.RoutingListValidatorUtil; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import static org.folio.orders.utils.ResourcePathResolver.ORDER_SETTINGS; -import static org.folio.orders.utils.ResourcePathResolver.ROUTING_LISTS; -import static org.folio.orders.utils.ResourcePathResolver.TEMPLATE_REQUEST; -import static org.folio.orders.utils.ResourcePathResolver.resourcesPath; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; public class RoutingListService { private static final Logger logger = LogManager.getLogger(RoutingListService.class); @@ -66,8 +67,7 @@ public Future getRoutingList(String rListId, RequestContext request public Future updateRoutingList(RoutingList routingList, RequestContext requestContext) { try { validateRoutingList(routingList, requestContext); - } - catch (HttpException e) { + } catch (HttpException e) { return Future.failedFuture(e); } RequestEntry requestEntry = new RequestEntry(ROUTING_LIST_BY_ID_ENDPOINT).withId(routingList.getId()); @@ -91,9 +91,9 @@ public Future createRoutingList(RoutingList routingList, RequestCon public Future getRoutingLists(int limit, int offset, String query, RequestContext requestContext) { RequestEntry requestEntry = new RequestEntry(ROUTING_LIST_ENDPOINT) - .withQuery(query) + .withLimit(limit) .withOffset(offset) - .withLimit(limit); + .withQuery(query); return restClient.get(requestEntry, RoutingListCollection.class, requestContext); } diff --git a/src/main/java/org/folio/service/routinglists/validators/RoutingListValidatorUtil.java b/src/main/java/org/folio/service/routinglists/validators/RoutingListValidatorUtil.java index 2aab85dbd..a94146eaa 100644 --- a/src/main/java/org/folio/service/routinglists/validators/RoutingListValidatorUtil.java +++ b/src/main/java/org/folio/service/routinglists/validators/RoutingListValidatorUtil.java @@ -1,14 +1,14 @@ package org.folio.service.routinglists.validators; +import java.util.ArrayList; +import java.util.List; + import org.folio.rest.core.exceptions.ErrorCodes; import org.folio.rest.jaxrs.model.Error; import org.folio.rest.jaxrs.model.Location; import org.folio.rest.jaxrs.model.PoLine; import org.folio.rest.jaxrs.model.RoutingListCollection; -import java.util.ArrayList; -import java.util.List; - public class RoutingListValidatorUtil { public static List validateRoutingList(RoutingListCollection rListExisting, PoLine poLine) { diff --git a/src/test/java/org/folio/rest/impl/RoutingListsApiTest.java b/src/test/java/org/folio/rest/impl/RoutingListsApiTest.java index 385403256..8a9c2ad27 100644 --- a/src/test/java/org/folio/rest/impl/RoutingListsApiTest.java +++ b/src/test/java/org/folio/rest/impl/RoutingListsApiTest.java @@ -1,37 +1,5 @@ package org.folio.rest.impl; -import io.vertx.core.Context; -import io.vertx.core.json.JsonObject; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.folio.ApiTestSuite; -import org.folio.HttpStatus; -import org.folio.rest.RestConstants; -import org.folio.rest.core.exceptions.ErrorCodes; -import org.folio.rest.core.exceptions.HttpException; -import org.folio.rest.core.models.RequestContext; -import org.folio.rest.jaxrs.model.RoutingList; -import org.folio.rest.jaxrs.model.RoutingListCollection; -import org.folio.rest.jaxrs.model.Error; -import org.folio.rest.jaxrs.model.Errors; -import org.folio.rest.jaxrs.model.PoLine; -import org.folio.service.routinglists.RoutingListService; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - import static io.vertx.core.Future.failedFuture; import static io.vertx.core.Future.succeededFuture; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; @@ -82,6 +50,39 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.folio.ApiTestSuite; +import org.folio.HttpStatus; +import org.folio.rest.RestConstants; +import org.folio.rest.core.exceptions.ErrorCodes; +import org.folio.rest.core.exceptions.HttpException; +import org.folio.rest.core.models.RequestContext; +import org.folio.rest.jaxrs.model.Error; +import org.folio.rest.jaxrs.model.Errors; +import org.folio.rest.jaxrs.model.PoLine; +import org.folio.rest.jaxrs.model.RoutingList; +import org.folio.rest.jaxrs.model.RoutingListCollection; +import org.folio.service.routinglists.RoutingListService; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; + +import io.vertx.core.Context; +import io.vertx.core.json.JsonObject; + public class RoutingListsApiTest { private static final Logger logger = LogManager.getLogger(); diff --git a/src/test/java/org/folio/service/routinglists/RoutingListServiceTest.java b/src/test/java/org/folio/service/routinglists/RoutingListServiceTest.java index 583a58405..30f4b6a85 100644 --- a/src/test/java/org/folio/service/routinglists/RoutingListServiceTest.java +++ b/src/test/java/org/folio/service/routinglists/RoutingListServiceTest.java @@ -1,15 +1,30 @@ package org.folio.service.routinglists; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.junit5.VertxExtension; -import io.vertx.junit5.VertxTestContext; +import static io.vertx.core.Future.succeededFuture; +import static org.folio.TestConstants.ROUTING_LIST_ID; +import static org.folio.TestUtils.getLocationPhysicalCopies; +import static org.folio.TestUtils.getMinimalContentPoLine; +import static org.folio.TestUtils.getMockAsJson; +import static org.folio.TestUtils.getMockData; +import static org.folio.rest.core.exceptions.ErrorCodes.INVALID_ROUTING_LIST_FOR_PO_LINE_FORMAT; +import static org.folio.rest.core.exceptions.ErrorCodes.ROUTING_LIST_LIMIT_REACHED_FOR_PO_LINE; +import static org.folio.rest.impl.MockServer.ROUTING_LISTS_MOCK_DATA_PATH; +import static org.folio.rest.impl.MockServer.USERS_MOCK_DATA_PATH; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + import org.folio.models.UserCollection; import org.folio.rest.acq.model.Setting; import org.folio.rest.acq.model.SettingCollection; import org.folio.rest.core.RestClient; -import org.folio.rest.core.exceptions.ErrorCodes; -import org.folio.rest.core.exceptions.HttpException; import org.folio.rest.core.models.RequestContext; import org.folio.rest.core.models.RequestEntry; import org.folio.rest.jaxrs.model.PoLine; @@ -25,27 +40,10 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import static io.vertx.core.Future.succeededFuture; -import static org.folio.TestConstants.ROUTING_LIST_ID; -import static org.folio.TestUtils.getLocationPhysicalCopies; -import static org.folio.TestUtils.getMinimalContentPoLine; -import static org.folio.TestUtils.getMockAsJson; -import static org.folio.TestUtils.getMockData; -import static org.folio.rest.core.exceptions.ErrorCodes.INVALID_ROUTING_LIST_FOR_PO_LINE_FORMAT; -import static org.folio.rest.core.exceptions.ErrorCodes.ROUTING_LIST_LIMIT_REACHED_FOR_PO_LINE; -import static org.folio.rest.impl.MockServer.ROUTING_LISTS_MOCK_DATA_PATH; -import static org.folio.rest.impl.MockServer.USERS_MOCK_DATA_PATH; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.junit5.VertxExtension; +import io.vertx.junit5.VertxTestContext; @ExtendWith(VertxExtension.class) public class RoutingListServiceTest { diff --git a/src/test/java/org/folio/service/routinglists/validators/RoutingListValidatorTest.java b/src/test/java/org/folio/service/routinglists/validators/RoutingListValidatorTest.java index 43f3c2b75..333d3bde5 100644 --- a/src/test/java/org/folio/service/routinglists/validators/RoutingListValidatorTest.java +++ b/src/test/java/org/folio/service/routinglists/validators/RoutingListValidatorTest.java @@ -1,16 +1,5 @@ package org.folio.service.routinglists.validators; -import org.folio.rest.jaxrs.model.Error; -import org.folio.rest.jaxrs.model.PoLine; -import org.folio.rest.jaxrs.model.RoutingList; -import org.folio.rest.jaxrs.model.RoutingListCollection; -import org.folio.service.routinglists.validators.RoutingListValidatorUtil; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - import static org.folio.TestUtils.getLocationPhysicalCopies; import static org.folio.TestUtils.getMinimalContentPoLine; import static org.folio.TestUtils.getMockAsJson; @@ -19,6 +8,16 @@ import static org.folio.rest.impl.MockServer.ROUTING_LISTS_MOCK_DATA_PATH; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.ArrayList; +import java.util.List; + +import org.folio.rest.jaxrs.model.Error; +import org.folio.rest.jaxrs.model.PoLine; +import org.folio.rest.jaxrs.model.RoutingList; +import org.folio.rest.jaxrs.model.RoutingListCollection; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + public class RoutingListValidatorTest { private static final String ROUTING_LIST_SAMPLE = ROUTING_LISTS_MOCK_DATA_PATH + "routing-list.json";