diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json
index 09620fc64..a5069c693 100644
--- a/descriptors/ModuleDescriptor-template.json
+++ b/descriptors/ModuleDescriptor-template.json
@@ -108,6 +108,44 @@
}
]
},
+ {
+ "id": "circulation-settings-storage",
+ "version": "1.0",
+ "handlers": [
+ {
+ "methods": ["GET"],
+ "pathPattern": "/circulation-settings-storage/circulation-settings",
+ "permissionsRequired": [
+ "circulation-storage.circulation-settings.collection.get"
+ ]
+ },
+ {
+ "methods": ["GET"],
+ "pathPattern": "/circulation-settings-storage/circulation-settings/{id}",
+ "permissionsRequired": [
+ "circulation-storage.circulation-settings.item.get"
+ ]
+ }, {
+ "methods": ["PUT"],
+ "pathPattern": "/circulation-settings-storage/circulation-settings/{id}",
+ "permissionsRequired": [
+ "circulation-storage.circulation-settings.item.put"
+ ]
+ }, {
+ "methods": ["POST"],
+ "pathPattern": "/circulation-settings-storage/circulation-settings",
+ "permissionsRequired": [
+ "circulation-storage.circulation-settings.item.post"
+ ]
+ }, {
+ "methods": ["DELETE"],
+ "pathPattern": "/circulation-settings-storage/circulation-settings/{id}",
+ "permissionsRequired": [
+ "circulation-storage.circulation-settings.item.delete"
+ ]
+ }
+ ]
+ },
{
"id": "loan-policy-storage",
"version": "2.3",
@@ -974,6 +1012,31 @@
"displayName": "Circulation storage - get expired session patron ids collection",
"description": "Get expired session patron ids collection from storage"
},
+ {
+ "permissionName": "circulation-storage.circulation-settings.collection.get",
+ "displayName": "Circulation storage - get circulation settings collection",
+ "description": "Get circulation settings collection from storage"
+ },
+ {
+ "permissionName": "circulation-storage.circulation-settings.item.get",
+ "displayName": "Circulation storage - get circulation setting by id",
+ "description": "Get circulation setting by id from storage"
+ },
+ {
+ "permissionName": "circulation-storage.circulation-settings.item.post",
+ "displayName": "Circulation storage - create circulation setting",
+ "description": "Create circulation setting in storage"
+ },
+ {
+ "permissionName": "circulation-storage.circulation-settings.item.put",
+ "displayName": "Circulation storage - update circulation setting by id",
+ "description": "Update circulation setting by id"
+ },
+ {
+ "permissionName": "circulation-storage.circulation-settings.item.delete",
+ "displayName": "Circulation storage - delete circulation setting by id",
+ "description": "Delete circulation setting by id"
+ },
{
"permissionName": "circulation-storage.all",
"displayName": "Circulation storage module - all permissions",
@@ -1065,7 +1128,12 @@
"checkout-lock-storage.checkout-locks.item.post",
"checkout-lock-storage.checkout-locks.item.delete",
"checkout-lock-storage.checkout-locks.item.get",
- "checkout-lock-storage.checkout-locks.collection.get"
+ "checkout-lock-storage.checkout-locks.collection.get",
+ "circulation-storage.circulation-settings.collection.get",
+ "circulation-storage.circulation-settings.item.get",
+ "circulation-storage.circulation-settings.item.post",
+ "circulation-storage.circulation-settings.item.put",
+ "circulation-storage.circulation-settings.item.delete"
]
},
{
diff --git a/ramls/circulation-setting.json b/ramls/circulation-setting.json
new file mode 100644
index 000000000..0907442e8
--- /dev/null
+++ b/ramls/circulation-setting.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "Circulation Setting Schema",
+ "description": "Circulation setting",
+ "type": "object",
+ "properties": {
+ "id": {
+ "description": "ID of the circulation setting",
+ "type": "string",
+ "$ref": "raml-util/schemas/uuid.schema"
+ },
+ "name": {
+ "description": "Circulation setting name",
+ "type": "string"
+ },
+ "value": {
+ "description": "Circulation setting",
+ "type": "object",
+ "additionalProperties": true
+ },
+ "metadata": {
+ "description": "Metadata about creation and changes, provided by the server (client should not provide)",
+ "type": "object",
+ "$ref": "raml-util/schemas/metadata.schema"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "id",
+ "name",
+ "value"
+ ]
+}
diff --git a/ramls/circulation-settings-storage.raml b/ramls/circulation-settings-storage.raml
new file mode 100644
index 000000000..7f87a73e9
--- /dev/null
+++ b/ramls/circulation-settings-storage.raml
@@ -0,0 +1,106 @@
+#%RAML 1.0
+title: Circulation Settings Storage
+version: v1.0
+protocols: [ HTTP, HTTPS ]
+baseUri: http://localhost:9130
+
+documentation:
+ - title: Circulation Settings Storage API
+ content: Storage for circulation settings
+
+traits:
+ language: !include raml-util/traits/language.raml
+ pageable: !include raml-util/traits/pageable.raml
+ searchable: !include raml-util/traits/searchable.raml
+ validate: !include raml-util/traits/validation.raml
+
+types:
+ circulation-setting: !include circulation-setting.json
+ circulation-settings: !include circulation-settings.json
+ errors: !include raml-util/schemas/errors.schema
+ parameters: !include raml-util/schemas/parameters.schema
+
+resourceTypes:
+ collection: !include raml-util/rtypes/collection.raml
+ collection-item: !include raml-util/rtypes/item-collection.raml
+
+/circulation-settings-storage:
+ /circulation-settings:
+ type:
+ collection:
+ exampleCollection: !include examples/circulation-settings.json
+ exampleItem: !include examples/circulation-setting.json
+ schemaCollection: circulation-settings
+ schemaItem: circulation-setting
+ post:
+ is: [validate]
+ description: Create a new circulation setting
+ body:
+ application/json:
+ type: circulation-setting
+ responses:
+ 201:
+ description: "Circulation setting has been created"
+ body:
+ application/json:
+ type: circulation-setting
+ 500:
+ description: "Internal server error"
+ body:
+ text/plain:
+ example: "Internal server error"
+ get:
+ is: [validate, pageable, searchable: { description: "with valid searchable fields", example: "id=497f6eca-6276-4993-bfeb-98cbbbba8f79" }]
+ description: Get all circulation settings
+ responses:
+ 200:
+ description: "Circulation settings successfully retreived"
+ body:
+ application/json:
+ type: circulation-settings
+ 500:
+ description: "Internal server error"
+ body:
+ text/plain:
+ example: "Internal server error"
+ /{circulationSettingsId}:
+ type:
+ collection-item:
+ exampleItem: !include examples/circulation-setting.json
+ schema: circulation-setting
+ get:
+ responses:
+ 200:
+ description: "Circulation setting successfully retreived"
+ body:
+ application/json:
+ type: circulation-setting
+ 500:
+ description: "Internal server error"
+ body:
+ text/plain:
+ example: "Internal server error"
+ put:
+ is: [ validate ]
+ body:
+ application/json:
+ type: circulation-setting
+ responses:
+ 204:
+ description: "Circulation settings have been saved."
+ 500:
+ description: "Internal server error"
+ body:
+ text/plain:
+ example: "Internal server error"
+ delete:
+ is: [ validate ]
+ responses:
+ 204:
+ description: "Circulation settings deleted"
+ 500:
+ description: "Internal server error"
+ body:
+ text/plain:
+ example: "Internal server error"
+
diff --git a/ramls/circulation-settings.json b/ramls/circulation-settings.json
new file mode 100644
index 000000000..99173df7b
--- /dev/null
+++ b/ramls/circulation-settings.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "Collection of Circulation settings",
+ "type": "object",
+ "properties": {
+ "circulationSettings": {
+ "description": "List of circulation settings",
+ "id": "circulationSettings",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "$ref": "circulation-setting.json"
+ }
+ },
+ "totalRecords": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "circulationSettings",
+ "totalRecords"
+ ]
+}
diff --git a/ramls/examples/circulation-setting.json b/ramls/examples/circulation-setting.json
new file mode 100644
index 000000000..35f0aba43
--- /dev/null
+++ b/ramls/examples/circulation-setting.json
@@ -0,0 +1,7 @@
+{
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f09",
+ "name": "Sample settings",
+ "value": {
+ "org.folio.circulation.settings": "true"
+ }
+}
diff --git a/ramls/examples/circulation-settings.json b/ramls/examples/circulation-settings.json
new file mode 100644
index 000000000..b9b7a9c8b
--- /dev/null
+++ b/ramls/examples/circulation-settings.json
@@ -0,0 +1,12 @@
+{
+ "circulationSettings": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f09",
+ "name": "Sample settings",
+ "value": {
+ "org.folio.circulation.settings": "true"
+ }
+ }
+ ],
+ "totalRecords": 1
+}
diff --git a/src/main/java/org/folio/persist/CirculationSettingsRepository.java b/src/main/java/org/folio/persist/CirculationSettingsRepository.java
new file mode 100644
index 000000000..fd0f9757f
--- /dev/null
+++ b/src/main/java/org/folio/persist/CirculationSettingsRepository.java
@@ -0,0 +1,22 @@
+package org.folio.persist;
+
+import static org.folio.rest.persist.PgUtil.postgresClient;
+import static org.folio.support.ModuleConstants.CIRCULATION_SETTINGS_TABLE;
+
+import java.util.Map;
+
+import org.folio.rest.jaxrs.model.CirculationSetting;
+
+import io.vertx.core.Context;
+
+public class CirculationSettingsRepository
+ extends AbstractRepository {
+
+ public CirculationSettingsRepository(Context context, Map okapiHeaders) {
+
+ super(postgresClient(context, okapiHeaders), CIRCULATION_SETTINGS_TABLE,
+ CirculationSetting.class);
+ }
+
+}
diff --git a/src/main/java/org/folio/rest/impl/CirculationSettingsAPI.java b/src/main/java/org/folio/rest/impl/CirculationSettingsAPI.java
new file mode 100644
index 000000000..07e05a95f
--- /dev/null
+++ b/src/main/java/org/folio/rest/impl/CirculationSettingsAPI.java
@@ -0,0 +1,67 @@
+package org.folio.rest.impl;
+
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.folio.rest.jaxrs.model.CirculationSetting;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage;
+import org.folio.service.CirculationSettingsService;
+
+import io.vertx.core.AsyncResult;
+import io.vertx.core.Context;
+import io.vertx.core.Handler;
+
+public class CirculationSettingsAPI implements CirculationSettingsStorage {
+
+ @Override
+ public void postCirculationSettingsStorageCirculationSettings(String lang,
+ CirculationSetting circulationSettings, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
+ new CirculationSettingsService(vertxContext, okapiHeaders)
+ .create(circulationSettings)
+ .onComplete(asyncResultHandler);
+ }
+
+ @Override
+ public void getCirculationSettingsStorageCirculationSettings(int offset,
+ int limit, String query, String lang, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
+ new CirculationSettingsService(vertxContext, okapiHeaders)
+ .getAll(offset, limit, query)
+ .onComplete(asyncResultHandler);
+ }
+
+ @Override
+ public void getCirculationSettingsStorageCirculationSettingsByCirculationSettingsId(
+ String circulationSettingsId, String lang, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
+ new CirculationSettingsService(vertxContext, okapiHeaders)
+ .findById(circulationSettingsId)
+ .onComplete(asyncResultHandler);
+ }
+
+ @Override
+ public void putCirculationSettingsStorageCirculationSettingsByCirculationSettingsId(
+ String circulationSettingsId, String lang, CirculationSetting entity,
+ Map okapiHeaders, Handler> asyncResultHandler,
+ Context vertxContext) {
+
+ new CirculationSettingsService(vertxContext, okapiHeaders)
+ .update(circulationSettingsId, entity)
+ .onComplete(asyncResultHandler);
+ }
+
+ @Override
+ public void deleteCirculationSettingsStorageCirculationSettingsByCirculationSettingsId(
+ String circulationSettingsId, String lang, Map okapiHeaders,
+ Handler> asyncResultHandler, Context vertxContext) {
+
+ new CirculationSettingsService(vertxContext, okapiHeaders)
+ .delete(circulationSettingsId)
+ .onComplete(asyncResultHandler);
+ }
+}
diff --git a/src/main/java/org/folio/rest/impl/TenantRefAPI.java b/src/main/java/org/folio/rest/impl/TenantRefAPI.java
index af808b14d..bca5f474a 100644
--- a/src/main/java/org/folio/rest/impl/TenantRefAPI.java
+++ b/src/main/java/org/folio/rest/impl/TenantRefAPI.java
@@ -58,7 +58,9 @@ Future loadData(TenantAttributes attributes, String tenantId,
.add("cancellation-reason-storage/cancellation-reasons")
.withKey(SAMPLE_KEY).withLead(SAMPLE_LEAD)
.add("loans", "loan-storage/loans")
- .add("requests", "request-storage/requests");
+ .add("requests", "request-storage/requests")
+ .add("circulation-settings-storage/circulation-settings");
+
tl.perform(attributes, headers, vertx, res -> {
if (res.failed()) {
diff --git a/src/main/java/org/folio/service/CirculationSettingsService.java b/src/main/java/org/folio/service/CirculationSettingsService.java
new file mode 100644
index 000000000..a0c950074
--- /dev/null
+++ b/src/main/java/org/folio/service/CirculationSettingsService.java
@@ -0,0 +1,70 @@
+package org.folio.service;
+
+import static org.folio.service.event.EntityChangedEventPublisherFactory.circulationSettingsEventPublisher;
+import static org.folio.support.ModuleConstants.CIRCULATION_SETTINGS_TABLE;
+
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.folio.persist.CirculationSettingsRepository;
+import org.folio.rest.jaxrs.model.CirculationSetting;
+import org.folio.rest.jaxrs.model.CirculationSettings;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage.DeleteCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage.GetCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage.GetCirculationSettingsStorageCirculationSettingsResponse;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage.PostCirculationSettingsStorageCirculationSettingsResponse;
+import org.folio.rest.jaxrs.resource.CirculationSettingsStorage.PutCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse;
+import org.folio.rest.persist.PgUtil;
+import org.folio.service.event.EntityChangedEventPublisher;
+
+import io.vertx.core.Context;
+import io.vertx.core.Future;
+
+public class CirculationSettingsService {
+
+ private final Context vertxContext;
+ private final Map okapiHeaders;
+ private final CirculationSettingsRepository repository;
+ private final EntityChangedEventPublisher eventPublisher;
+
+ public CirculationSettingsService(Context vertxContext, Map okapiHeaders) {
+ this.vertxContext = vertxContext;
+ this.okapiHeaders = okapiHeaders;
+ this.repository = new CirculationSettingsRepository(vertxContext, okapiHeaders);
+ this.eventPublisher = circulationSettingsEventPublisher(vertxContext, okapiHeaders);
+ }
+
+ public Future getAll(int offset, int limit, String query) {
+ return PgUtil.get(CIRCULATION_SETTINGS_TABLE, CirculationSetting.class,
+ CirculationSettings.class,
+ query, offset, limit, okapiHeaders, vertxContext,
+ GetCirculationSettingsStorageCirculationSettingsResponse.class);
+ }
+
+ public Future create(CirculationSetting circulationSetting) {
+ return PgUtil.post(CIRCULATION_SETTINGS_TABLE, circulationSetting, okapiHeaders, vertxContext,
+ PostCirculationSettingsStorageCirculationSettingsResponse.class)
+ .compose(eventPublisher.publishCreated());
+ }
+
+ public Future findById(String circulationSettingsId) {
+ return PgUtil.getById(CIRCULATION_SETTINGS_TABLE, CirculationSetting.class,
+ circulationSettingsId, okapiHeaders, vertxContext,
+ GetCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse.class);
+ }
+
+ public Future update(String circulationSettingsId, CirculationSetting circulationSetting) {
+ return PgUtil.put(CIRCULATION_SETTINGS_TABLE, circulationSetting, circulationSettingsId, okapiHeaders, vertxContext,
+ PutCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse.class)
+ .compose(eventPublisher.publishUpdated(circulationSetting));
+ }
+
+ public Future delete(String circulationSettingsId) {
+ return repository.getById(circulationSettingsId).compose (
+ circulationSetting -> PgUtil.deleteById(CIRCULATION_SETTINGS_TABLE, circulationSettingsId, okapiHeaders, vertxContext,
+ DeleteCirculationSettingsStorageCirculationSettingsByCirculationSettingsIdResponse.class)
+ .compose(eventPublisher.publishRemoved(circulationSetting))
+ );
+ }
+}
diff --git a/src/main/java/org/folio/service/event/EntityChangedEventPublisherFactory.java b/src/main/java/org/folio/service/event/EntityChangedEventPublisherFactory.java
index c8aaecd78..54eccfe90 100644
--- a/src/main/java/org/folio/service/event/EntityChangedEventPublisherFactory.java
+++ b/src/main/java/org/folio/service/event/EntityChangedEventPublisherFactory.java
@@ -2,6 +2,7 @@
import static org.folio.rest.tools.utils.TenantTool.tenantId;
import static org.folio.support.kafka.topic.CirculationStorageKafkaTopic.CHECK_IN;
+import static org.folio.support.kafka.topic.CirculationStorageKafkaTopic.CIRCULATION_SETTINGS;
import static org.folio.support.kafka.topic.CirculationStorageKafkaTopic.LOAN;
import static org.folio.support.kafka.topic.CirculationStorageKafkaTopic.REQUEST;
import static org.folio.support.kafka.topic.CirculationStorageKafkaTopic.RULES;
@@ -10,10 +11,12 @@
import org.folio.persist.CheckInRepository;
import org.folio.persist.CirculationRulesRepository;
+import org.folio.persist.CirculationSettingsRepository;
import org.folio.persist.LoanRepository;
import org.folio.persist.RequestRepository;
import org.folio.rest.jaxrs.model.CheckIn;
import org.folio.rest.jaxrs.model.CirculationRules;
+import org.folio.rest.jaxrs.model.CirculationSetting;
import org.folio.rest.jaxrs.model.Loan;
import org.folio.rest.jaxrs.model.Request;
@@ -74,4 +77,15 @@ public static EntityChangedEventPublisher circulationR
new CirculationRulesRepository(vertxContext, okapiHeaders));
}
+ public static EntityChangedEventPublisher circulationSettingsEventPublisher(
+ Context vertxContext, Map okapiHeaders) {
+
+ return new EntityChangedEventPublisher<>(okapiHeaders, CirculationSetting::getId, NULL_ID,
+ new EntityChangedEventFactory<>(),
+ new DomainEventPublisher<>(vertxContext,
+ CIRCULATION_SETTINGS.fullTopicName(tenantId(okapiHeaders)),
+ FailureHandler.noOperation()),
+ new CirculationSettingsRepository(vertxContext, okapiHeaders));
+ }
+
}
diff --git a/src/main/java/org/folio/support/ModuleConstants.java b/src/main/java/org/folio/support/ModuleConstants.java
index 2bb2ab639..ba92fd1ee 100644
--- a/src/main/java/org/folio/support/ModuleConstants.java
+++ b/src/main/java/org/folio/support/ModuleConstants.java
@@ -15,6 +15,8 @@ public class ModuleConstants {
public static final String LOAN_TABLE = "loan";
public static final String OPEN_LOAN_STATUS = "Open";
public static final String REQUEST_TABLE = "request";
+ public static final String CIRCULATION_SETTINGS_TABLE =
+ "circulation_settings";
public static final Class REQUEST_CLASS = Request.class;
public static final String CHECKIN_TABLE = "check_in";
public static final Class CHECKIN_CLASS = CheckIn.class;
diff --git a/src/main/java/org/folio/support/kafka/topic/CirculationStorageKafkaTopic.java b/src/main/java/org/folio/support/kafka/topic/CirculationStorageKafkaTopic.java
index a8889f554..0f4ec85b3 100644
--- a/src/main/java/org/folio/support/kafka/topic/CirculationStorageKafkaTopic.java
+++ b/src/main/java/org/folio/support/kafka/topic/CirculationStorageKafkaTopic.java
@@ -4,6 +4,7 @@
public enum CirculationStorageKafkaTopic implements KafkaTopic {
REQUEST("request", 10),
+ CIRCULATION_SETTINGS("circulation-settings", 10),
LOAN("loan", 10),
CHECK_IN("check-in", 10),
RULES("rules", 10);
diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json
index 180723cca..5ad434893 100644
--- a/src/main/resources/templates/db_scripts/schema.json
+++ b/src/main/resources/templates/db_scripts/schema.json
@@ -151,6 +151,11 @@
}
]
},
+ {
+ "tableName": "circulation_settings",
+ "withMetadata": true,
+ "withAuditing": false
+ },
{
"tableName": "request",
"withMetadata": true,
diff --git a/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java b/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java
new file mode 100644
index 000000000..5ec12cba3
--- /dev/null
+++ b/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java
@@ -0,0 +1,75 @@
+package org.folio.rest.api;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.junit.MatcherAssert.assertThat;
+
+import java.net.MalformedURLException;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.folio.rest.support.ApiTests;
+import org.folio.rest.support.http.AssertingRecordClient;
+import org.folio.rest.support.http.InterfaceUrls;
+import org.junit.Test;
+
+import io.vertx.core.json.JsonObject;
+
+public class CirculationSettingsAPITest extends ApiTests {
+
+ private final AssertingRecordClient circulationSettingsClient =
+ new AssertingRecordClient(
+ client, StorageTestSuite.TENANT_ID, InterfaceUrls::circulationSettingsUrl,
+ "circulation-settings");
+
+ @Test
+ public void canCreateAndRetrieveCirculationSettings() throws MalformedURLException,
+ ExecutionException, InterruptedException, TimeoutException {
+
+ String id = UUID.randomUUID().toString();
+ JsonObject circulationSettingsJson = getCirculationSetting(id);
+ JsonObject circulationSettingsResponse =
+ circulationSettingsClient.create(circulationSettingsJson).getJson();
+ JsonObject circulationSettingsById = circulationSettingsClient.getById(id).getJson();
+
+ assertThat(circulationSettingsResponse.getString("id"), is(id));
+ assertThat(circulationSettingsById.getString("id"), is(id));
+ assertThat(circulationSettingsById.getJsonObject("value"), is(
+ circulationSettingsJson.getJsonObject("value")));
+ }
+
+ @Test
+ public void canUpdateCirculationSettings() throws MalformedURLException,
+ ExecutionException, InterruptedException, TimeoutException {
+
+ String id = UUID.randomUUID().toString();
+ JsonObject circulationSettingsJson = getCirculationSetting(id);
+ circulationSettingsClient.create(circulationSettingsJson).getJson();
+ circulationSettingsClient.attemptPutById(
+ circulationSettingsJson.put("value", new JsonObject().put("sample", "DONE")));
+ JsonObject updatedCirculationSettings = circulationSettingsClient.getById(id).getJson();
+
+ assertThat(updatedCirculationSettings.getString("id"), is(id));
+ assertThat(updatedCirculationSettings.getJsonObject("value"), is(
+ circulationSettingsJson.getJsonObject("value")));
+ }
+
+ @Test
+ public void canDeleteCirculationSettings() throws MalformedURLException,
+ ExecutionException, InterruptedException, TimeoutException {
+
+ UUID id = UUID.randomUUID();
+ circulationSettingsClient.create(getCirculationSetting(id.toString())).getJson();
+ circulationSettingsClient.deleteById(id);
+ var deletedCirculationSettings = circulationSettingsClient.attemptGetById(id);
+ assertThat(deletedCirculationSettings.getStatusCode(), is(404));
+ }
+
+ private JsonObject getCirculationSetting(String id) {
+ return new JsonObject()
+ .put("id", id)
+ .put("name", "sample")
+ .put("value", new JsonObject().put("sample", "OK"));
+ }
+
+}
diff --git a/src/test/java/org/folio/rest/api/StorageTestSuite.java b/src/test/java/org/folio/rest/api/StorageTestSuite.java
index ffe473bc5..bf9dbb708 100644
--- a/src/test/java/org/folio/rest/api/StorageTestSuite.java
+++ b/src/test/java/org/folio/rest/api/StorageTestSuite.java
@@ -81,7 +81,8 @@
TlrFeatureToggleJobAPITest.class,
ActualCostRecordAPITest.class,
EventConsumerVerticleTest.class,
- CheckOutLockAPITest.class
+ CheckOutLockAPITest.class,
+ CirculationSettingsAPITest.class
})
public class StorageTestSuite {
diff --git a/src/test/java/org/folio/rest/support/http/InterfaceUrls.java b/src/test/java/org/folio/rest/support/http/InterfaceUrls.java
index 0eacef610..a60caef57 100644
--- a/src/test/java/org/folio/rest/support/http/InterfaceUrls.java
+++ b/src/test/java/org/folio/rest/support/http/InterfaceUrls.java
@@ -48,4 +48,8 @@ public static URL checkOutStorageUrl(String subPath) throws MalformedURLExceptio
return storageUrl("/check-out-lock-storage" + subPath);
}
+ public static URL circulationSettingsUrl(String subPath) throws MalformedURLException {
+ return storageUrl("/circulation-settings-storage/circulation-settings" + subPath);
+ }
+
}
diff --git a/src/test/java/org/folio/service/kafka/topic/KafkaAdminClientServiceTest.java b/src/test/java/org/folio/service/kafka/topic/KafkaAdminClientServiceTest.java
index 66edb8ee0..e5b63c190 100644
--- a/src/test/java/org/folio/service/kafka/topic/KafkaAdminClientServiceTest.java
+++ b/src/test/java/org/folio/service/kafka/topic/KafkaAdminClientServiceTest.java
@@ -42,7 +42,8 @@ public class KafkaAdminClientServiceTest {
"folio.foo-tenant.circulation.request",
"folio.foo-tenant.circulation.loan",
"folio.foo-tenant.circulation.check-in",
- "folio.foo-tenant.circulation.rules"
+ "folio.foo-tenant.circulation.rules",
+ "folio.foo-tenant.circulation.circulation-settings"
);
private KafkaAdminClient mockClient;