Skip to content

Commit

Permalink
[MODORDERS-1006] Change to meet coding convention rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Apr 8, 2024
1 parent b6d8aed commit 6c7191a
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 102 deletions.
15 changes: 8 additions & 7 deletions ramls/routing-lists.raml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]

17 changes: 9 additions & 8 deletions src/main/java/org/folio/rest/impl/RoutingListsAPI.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -66,8 +67,7 @@ public Future<RoutingList> getRoutingList(String rListId, RequestContext request
public Future<Void> 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());
Expand All @@ -91,9 +91,9 @@ public Future<RoutingList> createRoutingList(RoutingList routingList, RequestCon

public Future<RoutingListCollection> 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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Error> validateRoutingList(RoutingListCollection rListExisting, PoLine poLine) {
Expand Down
65 changes: 33 additions & 32 deletions src/test/java/org/folio/rest/impl/RoutingListsApiTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";
Expand Down

0 comments on commit 6c7191a

Please sign in to comment.