Skip to content

Commit

Permalink
fix(browse-contributors-subjects): Fix title count when on central te…
Browse files Browse the repository at this point in the history
…nant (#576)

- Count only shared instances for subject/contributor when on central tenant

Closes: MSEARCH-745
(cherry picked from commit 7b4d410)
  • Loading branch information
viacheslavkol committed May 3, 2024
1 parent 70c5cb9 commit 6dbcdc0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ public <T> Set<InstanceSubResource> filterSubResourcesForConsortium(
var subResources = subResourceExtractor.apply(resource);
var contextTenantId = folioExecutionContext.getTenantId();
var centralTenantId = consortiumTenantService.getCentralTenant(contextTenantId);
if (centralTenantId.isEmpty() || contextTenantId.equals(centralTenantId.get())) {
if (centralTenantId.isEmpty()) {
return subResources;
} else if (contextTenantId.equals(centralTenantId.get())) {
return subResources.stream()
.filter(InstanceSubResource::getShared)
.collect(Collectors.toSet());
}

var sharedFilter = getBrowseSharedFilter(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,21 @@ void filterSubResourcesForConsortium_positive_notConsortiumTenant() {
assertThat(actual).isEqualTo(resource.getInstances());
}

@Test
void filterSubResourcesForConsortium_positive_centralTenant() {
when(context.getTenantId()).thenReturn(CENTRAL_TENANT_ID);
when(tenantService.getCentralTenant(CENTRAL_TENANT_ID)).thenReturn(Optional.of(CENTRAL_TENANT_ID));

var browseContext = browseContext(null, null);
var resource = new SubjectResource();
resource.setInstances(subResources());

var actual = consortiumSearchHelper.filterSubResourcesForConsortium(browseContext, resource,
SubjectResource::getInstances);

assertThat(actual).hasSize(2);
}

@Test
void filterSubResourcesForConsortium_positive_memberTenant() {
when(context.getTenantId()).thenReturn(TENANT_ID);
Expand Down

0 comments on commit 6dbcdc0

Please sign in to comment.