Skip to content

Commit

Permalink
#382 - Change display and translations structure for criteria and con…
Browse files Browse the repository at this point in the history
…cepts

- fix TerminologyRestControllerIT
  • Loading branch information
michael-82 committed Jan 15, 2025
1 parent d9df917 commit f520310
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,23 @@ public void testSearchOntologyItemsCriteriaQuery_failsOnUnauthorized() throws Ex
@Test
@WithMockUser(roles = "DATAPORTAL_TEST_USER")
public void testGetOntologyItemRelationsByHash_succeeds() throws Exception {
var dummyOntologyItemRelations = createDummyOntologyItemRelations();
doReturn(dummyOntologyItemRelations).when(terminologyEsService).getRelationEntryByHash(any(String.class));
var dummyRelationEntry = createDummyRelationEntry();
doReturn(dummyRelationEntry).when(terminologyEsService).getRelationEntryByHash(any(String.class));

mockMvc.perform(get(URI.create(PATH_API + PATH_TERMINOLOGY + "/entry/abc/relations")).with(csrf()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.children[0].contextualizedTermcodeHash").value(dummyOntologyItemRelations.children().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.children[0].name").value(dummyOntologyItemRelations.children().stream().toList().get(0).name()))
.andExpect(jsonPath("$.parents[0].contextualizedTermcodeHash").value(dummyOntologyItemRelations.parents().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.parents[0].name").value(dummyOntologyItemRelations.parents().stream().toList().get(0).name()))
.andExpect(jsonPath("$.relatedTerms[0].contextualizedTermcodeHash").value(dummyOntologyItemRelations.relatedTerms().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.relatedTerms[0].name").value(dummyOntologyItemRelations.relatedTerms().stream().toList().get(0).name()));
.andExpect(jsonPath("$.children[0].contextualizedTermcodeHash").value(dummyRelationEntry.children().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.children[0].name").value(dummyRelationEntry.children().stream().toList().get(0).name()))
.andExpect(jsonPath("$.parents[0].contextualizedTermcodeHash").value(dummyRelationEntry.parents().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.parents[0].name").value(dummyRelationEntry.parents().stream().toList().get(0).name()))
.andExpect(jsonPath("$.relatedTerms[0].contextualizedTermcodeHash").value(dummyRelationEntry.relatedTerms().stream().toList().get(0).contextualizedTermcodeHash()))
.andExpect(jsonPath("$.relatedTerms[0].name").value(dummyRelationEntry.relatedTerms().stream().toList().get(0).name()));
}

@Test
public void testGetOntologyItemRelationsByHash_failsOnUnauthorized() throws Exception {
var dummyOntologyItemRelations = createDummyOntologyItemRelations();
doReturn(dummyOntologyItemRelations).when(terminologyEsService).getRelationEntryByHash(any(String.class));
var dummyRelationEntry = createDummyRelationEntry();
doReturn(dummyRelationEntry).when(terminologyEsService).getRelationEntryByHash(any(String.class));

mockMvc.perform(get(URI.create(PATH_API + PATH_TERMINOLOGY + "/entry/abc/relations")).with(csrf()))
.andExpect(status().isUnauthorized());
Expand Down Expand Up @@ -271,6 +271,14 @@ private EsSearchResultEntry createDummyEsSearchResultEntry() {
.build();
}

private Display createDummyDisplay() {
return Display.builder()
.original("some-name")
.deDe("Some German Name")
.enUs("Some English Name")
.build();
}

private DisplayEntry createDummyDisplayEntry() {
return DisplayEntry.builder()
.original("some-name")
Expand All @@ -285,11 +293,16 @@ private LocalizedValue createDummyLocalizedValue() {
.build();
}

private RelationEntry createDummyRelationEntry() {
return RelationEntry.of(createDummyOntologyItemRelations());
}

private OntologyItemRelationsDocument createDummyOntologyItemRelations() {
return OntologyItemRelationsDocument.builder()
.relatedTerms(List.of(createDummyRelative()))
.parents(List.of(createDummyRelative()))
.children(List.of(createDummyRelative()))
.display(createDummyDisplay())
.build();
}

Expand Down

0 comments on commit f520310

Please sign in to comment.