Skip to content

Commit

Permalink
re
Browse files Browse the repository at this point in the history
  • Loading branch information
kjain110 committed Jan 23, 2025
1 parent fc53e52 commit c1d6299
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ void testSummaryIncludesAllEntityTypesIfRequested() throws Exception {
verifyNoMoreInteractions(entityTypeService);
}


@Test
void shouldReturnEmptyListWhenEntityTypeSummaryNotFound() throws Exception {
UUID id1 = UUID.randomUUID();
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,38 @@ void testEntityTypeSummaryDoesNotIncludeInaccessibleWhenNotRequested() {
verifyNoMoreInteractions(repo, localizationService);
}

@Test
void testEntityTypeSummaryIncludesAllWhenRequested() {
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
Set<UUID> ids = Set.of(id1, id2);

List<EntityTypeSummary> expectedSummary = List.of(
new EntityTypeSummary().id(id1).label("label_01"),
new EntityTypeSummary().id(id2).label("label_02")
);

when(repo.getEntityTypeDefinitions(ids, null)).thenReturn(Stream.of(
new EntityType(id1.toString(), "translation_label_01", true, true).requiredPermissions(List.of("perm1")), // Private entity
new EntityType(id2.toString(), "translation_label_02", true, false).requiredPermissions(List.of("perm2")) // Non-private entity
));

when(permissionsService.getUserPermissions()).thenReturn(Set.of("perm2", "perm1"));
when(permissionsService.getRequiredPermissions(any(EntityType.class)))
.then(invocationOnMock -> new HashSet<>(invocationOnMock.<EntityType>getArgument(0).getRequiredPermissions()));

when(localizationService.getEntityTypeLabel("translation_label_01")).thenReturn("label_01");
when(localizationService.getEntityTypeLabel("translation_label_02")).thenReturn("label_02");

List<EntityTypeSummary> actualSummary = entityTypeService.getEntityTypeSummary(ids, false, true);

assertEquals(expectedSummary, actualSummary, "Expected Summary should equal Actual Summary");

verify(repo, times(1)).getEntityTypeDefinitions(ids, null);
verify(localizationService, times(1)).getEntityTypeLabel("translation_label_01");
verify(localizationService, times(1)).getEntityTypeLabel("translation_label_02");
verifyNoMoreInteractions(repo, localizationService);
}

@Test
void testEntityTypeSummaryIncludesInaccessible() {
Expand Down

0 comments on commit c1d6299

Please sign in to comment.