Skip to content

Commit

Permalink
more exhaustive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Jun 17, 2024
1 parent 870cbc5 commit 4ebfc0b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/test/java/org/folio/fqm/service/EntityTypeServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import org.junit.jupiter.api.Test;

import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down Expand Up @@ -79,8 +82,34 @@ void shouldGetEntityTypeSummaryForValidIds() {
verifyNoMoreInteractions(repo, localizationService);
}

@NullSource
@ValueSource(booleans = {false})
@ParameterizedTest
void testEntityTypeSummaryDoesNotIncludeInaccessibleWhenNotRequested(Boolean p) {
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
Set<UUID> ids = Set.of(id1, id2);
List<EntityTypeSummary> expectedSummary = List.of(new EntityTypeSummary().id(id2).label("label_02"));

when(repo.getEntityTypeSummaries(ids)).thenReturn(List.of(
new RawEntityTypeSummary(id1, "translation_label_01", List.of("perm1")),
new RawEntityTypeSummary(id2, "translation_label_02", List.of("perm2"))));
when(permissionsService.getUserPermissions()).thenReturn(Set.of("perm2"));
when(localizationService.getEntityTypeLabel("translation_label_02")).thenReturn("label_02");

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

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

verify(repo, times(1)).getEntityTypeSummaries(ids);

verify(localizationService, times(1)).getEntityTypeLabel("translation_label_02");

verifyNoMoreInteractions(repo, localizationService);
}

@Test
void testEntityTypeSummaryIncludesMissingPermissions() {
void testEntityTypeSummaryIncludesInaccessible() {
UUID id1 = UUID.randomUUID();
UUID id2 = UUID.randomUUID();
Set<UUID> ids = Set.of(id1, id2);
Expand Down

0 comments on commit 4ebfc0b

Please sign in to comment.