From bb39dc5009f3446c3e1b0e8aa5ff85b4a608109e Mon Sep 17 00:00:00 2001 From: saba_zedginidze Date: Mon, 26 Aug 2024 16:50:39 +0400 Subject: [PATCH] [MODINVSTOR-1243] Attempt increase coverage --- .../java/org/folio/inventory/resources/TenantItems.java | 2 +- src/test/java/api/items/TenantItemApiTests.java | 3 +-- src/test/java/api/support/ApiRoot.java | 6 ++++++ src/test/java/support/fakes/FakeOkapi.java | 9 +++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/folio/inventory/resources/TenantItems.java b/src/main/java/org/folio/inventory/resources/TenantItems.java index abafbbf0e..eb0df011f 100644 --- a/src/main/java/org/folio/inventory/resources/TenantItems.java +++ b/src/main/java/org/folio/inventory/resources/TenantItems.java @@ -38,7 +38,7 @@ public class TenantItems extends AbstractInventoryResource { private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass()); - public static final String TENANT_ITEMS_PATH = "/inventory/tenant-items"; + private static final String TENANT_ITEMS_PATH = "/inventory/tenant-items"; public static final String ITEMS_FIELD = "items"; public static final String TOTAL_RECORDS_FIELD = "totalRecords"; diff --git a/src/test/java/api/items/TenantItemApiTests.java b/src/test/java/api/items/TenantItemApiTests.java index 6c2ff9d0e..a22741006 100644 --- a/src/test/java/api/items/TenantItemApiTests.java +++ b/src/test/java/api/items/TenantItemApiTests.java @@ -6,7 +6,6 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.folio.inventory.resources.TenantItems.ITEMS_FIELD; -import static org.folio.inventory.resources.TenantItems.TENANT_ITEMS_PATH; import static org.folio.inventory.resources.TenantItems.TOTAL_RECORDS_FIELD; import static org.folio.inventory.support.ItemUtil.ID; @@ -52,7 +51,7 @@ public void testTenantItemsGetFromDifferentTenants() throws MalformedURLExceptio CONSORTIA_TENANT_ID, consortiumItem.getString(ID), COLLEGE_TENANT_ID, collegeItem.getString(ID) )); - var response = okapiClient.post(TENANT_ITEMS_PATH, JsonObject.mapFrom(tenantItemPariCollection)) + var response = okapiClient.post(ApiRoot.tenantItems(), JsonObject.mapFrom(tenantItemPariCollection)) .toCompletableFuture().get(5, TimeUnit.SECONDS); assertThat(response.getStatusCode()).isEqualTo(200); var items = extractItems(response, 2); diff --git a/src/test/java/api/support/ApiRoot.java b/src/test/java/api/support/ApiRoot.java index aa1373cc1..cac7fc07f 100644 --- a/src/test/java/api/support/ApiRoot.java +++ b/src/test/java/api/support/ApiRoot.java @@ -71,6 +71,12 @@ public static URL items(String query) return new URL(String.format("%s/items?%s", inventory(), query)); } + public static URL tenantItems() + throws MalformedURLException { + + return new URL(String.format("%s/tenant-items", inventory())); + } + public static String isbn() { return String.format("%s/isbn", ApiTestSuite.apiRoot()); } diff --git a/src/test/java/support/fakes/FakeOkapi.java b/src/test/java/support/fakes/FakeOkapi.java index ae75b0210..542a7b1bd 100644 --- a/src/test/java/support/fakes/FakeOkapi.java +++ b/src/test/java/support/fakes/FakeOkapi.java @@ -29,6 +29,7 @@ public void start(Promise startFuture) { registerFakeHoldingStorageModule(router); registerFakeAuthorityStorageModule(router); registerFakeItemsStorageModule(router); + registerFakeTenantItemsStorageModule(router); registerFakeMaterialTypesModule(router); registerFakeLoanTypesModule(router); registerFakeLocationsModule(router); @@ -171,6 +172,14 @@ private void registerFakeItemsStorageModule(Router router) { .create().register(router); } + private void registerFakeTenantItemsStorageModule(Router router) { + new FakeStorageModuleBuilder() + .withRecordName("tenantItem") + .withRootPath("/inventory/tenant-items") + .withCollectionPropertyName("items") + .create().register(router); + } + private void registerFakeMaterialTypesModule(Router router) { new FakeStorageModuleBuilder()