From d135a4e257e4fd4b5d8ba587ed7fa42759de2513 Mon Sep 17 00:00:00 2001 From: saba_zedginidze Date: Tue, 27 Aug 2024 16:46:21 +0400 Subject: [PATCH] [MODINVSTOR-1243] Fix typo --- ramls/tenantItemPair.json | 8 ++++---- ramls/tenantItemPairCollection.json | 2 +- .../org/folio/inventory/resources/TenantItems.java | 3 +-- src/test/java/api/items/TenantItemApiTests.java | 10 +++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ramls/tenantItemPair.json b/ramls/tenantItemPair.json index 5f84d2ffe..0573be0e8 100644 --- a/ramls/tenantItemPair.json +++ b/ramls/tenantItemPair.json @@ -3,14 +3,14 @@ "description": "Pair of item and tenant IDs", "type": "object", "properties": { + "tenantId": { + "type": "string", + "description": "Unique ID of the tenant where the item is located" + }, "itemId": { "type": "string", "description": "Unique ID (UUID) of the item", "$ref": "uuid.json" - }, - "tenantId": { - "type": "string", - "description": "Unique ID of the tenant where the item is located" } }, "additionalProperties": false, diff --git a/ramls/tenantItemPairCollection.json b/ramls/tenantItemPairCollection.json index f5d34aef0..390c7063a 100644 --- a/ramls/tenantItemPairCollection.json +++ b/ramls/tenantItemPairCollection.json @@ -5,7 +5,7 @@ "properties": { "tenantItemPairs": { "type": "array", - "description": "Unique ID (UUID) of the item", + "description": "Pairs of tenantId and itemId", "items": { "type": "object", "$ref": "tenantItemPair.json" diff --git a/src/main/java/org/folio/inventory/resources/TenantItems.java b/src/main/java/org/folio/inventory/resources/TenantItems.java index 400d66f0e..8a151a16e 100644 --- a/src/main/java/org/folio/inventory/resources/TenantItems.java +++ b/src/main/java/org/folio/inventory/resources/TenantItems.java @@ -19,7 +19,6 @@ import org.folio.TenantItemPair; import org.folio.TenantItemPairCollection; import org.folio.inventory.common.WebContext; -import org.folio.inventory.storage.Storage; import org.folio.inventory.storage.external.CollectionResourceClient; import org.folio.inventory.support.JsonArrayHelper; import org.folio.inventory.support.http.client.OkapiHttpClient; @@ -62,7 +61,7 @@ public void register(Router router) { private void getItemsFromTenants(RoutingContext routingContext) { var getItemsFutures = routingContext.body().asPojo(TenantItemPairCollection.class) .getTenantItemPairs().stream() - .collect(groupingBy(TenantItemPair::getTenantId, mapping(TenantItemPair::getTenantId, toList()))) + .collect(groupingBy(TenantItemPair::getTenantId, mapping(TenantItemPair::getItemId, toList()))) .entrySet().stream() .map(tenantToItems -> getItemsWithTenantId(tenantToItems.getKey(), tenantToItems.getValue(), routingContext)) .toList(); diff --git a/src/test/java/api/items/TenantItemApiTests.java b/src/test/java/api/items/TenantItemApiTests.java index 5ad802f62..9c2c39a79 100644 --- a/src/test/java/api/items/TenantItemApiTests.java +++ b/src/test/java/api/items/TenantItemApiTests.java @@ -49,12 +49,12 @@ public void testTenantItemsGetFromDifferentTenants() throws MalformedURLExceptio assertThat(consortiumItem.getString(ID)).matches(consortiumItemId.toString()); assertThat(collegeItem.getString(ID)).matches(collegeItemId.toString()); - var tenantItemPariCollection = constructTenantItemPairCollection(Map.of( + var tenantItemPairCollection = constructTenantItemPairCollection(Map.of( CONSORTIA_TENANT_ID, consortiumItem.getString(ID), COLLEGE_TENANT_ID, collegeItem.getString(ID) )); - var response = okapiClient.post(ApiRoot.tenantItems(), JsonObject.mapFrom(tenantItemPariCollection)) + var response = okapiClient.post(ApiRoot.tenantItems(), JsonObject.mapFrom(tenantItemPairCollection)) .toCompletableFuture().get(5, TimeUnit.SECONDS); assertThat(response.getStatusCode()).isEqualTo(200); @@ -94,10 +94,10 @@ private List extractItems(Response itemsResponse, int expected) { return items; } - private TenantItemPairCollection constructTenantItemPairCollection(Map itemToTenantIds) { + private TenantItemPairCollection constructTenantItemPairCollection(Map tenantsToItemIds) { return new TenantItemPairCollection() - .withTenantItemPairs(itemToTenantIds.entrySet().stream() - .map(pair -> new TenantItemPair().withItemId(pair.getKey()).withTenantId(pair.getValue())) + .withTenantItemPairs(tenantsToItemIds.entrySet().stream() + .map(pair -> new TenantItemPair().withTenantId(pair.getKey()).withItemId(pair.getValue())) .toList()); }