Skip to content

Commit

Permalink
[MODINVSTOR-1243] Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Aug 27, 2024
1 parent cbd0c78 commit d135a4e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions ramls/tenantItemPair.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ramls/tenantItemPairCollection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/folio/inventory/resources/TenantItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/api/items/TenantItemApiTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -94,10 +94,10 @@ private List<JsonObject> extractItems(Response itemsResponse, int expected) {
return items;
}

private TenantItemPairCollection constructTenantItemPairCollection(Map<String, String> itemToTenantIds) {
private TenantItemPairCollection constructTenantItemPairCollection(Map<String, String> 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());
}

Expand Down

0 comments on commit d135a4e

Please sign in to comment.