diff --git a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/v4/TerminologyRestControllerIT.java b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/v4/TerminologyRestControllerIT.java index 2c6f52d..d9f52e9 100644 --- a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/v4/TerminologyRestControllerIT.java +++ b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/v4/TerminologyRestControllerIT.java @@ -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()); @@ -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") @@ -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(); }