diff --git a/backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java b/backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java index 906960cab4c00a92253aac5b7f2dd0b6eaca4435..cc3b1b85cccec18f4c32149885acbffe0ba690dc 100644 --- a/backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java +++ b/backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java @@ -39,10 +39,13 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo /** * Controller used to display a germplasm card based on its ID. + * Note that this controller is mapped to the /germplasm path in addition to + * the canonical /germplasms path in order to still honor legacy URLs used + * in external applications * @author JB Nizet */ @Controller("webGermplasmController") -@RequestMapping("/germplasms") +@RequestMapping({"/germplasms", "/germplasm"}) public class GermplasmController { private final GermplasmRepository germplasmRepository; diff --git a/backend/src/test/java/fr/inra/urgi/faidare/web/germplasm/GermplasmControllerTest.java b/backend/src/test/java/fr/inra/urgi/faidare/web/germplasm/GermplasmControllerTest.java index ab1ff169d33248f6a7255e607e781c5cfef6872a..d7967b5956c3ed5827e446f292e95d8ed80c63c3 100644 --- a/backend/src/test/java/fr/inra/urgi/faidare/web/germplasm/GermplasmControllerTest.java +++ b/backend/src/test/java/fr/inra/urgi/faidare/web/germplasm/GermplasmControllerTest.java @@ -160,6 +160,18 @@ public class GermplasmControllerTest { verify(mockGermplasmRepository).find(argThat(criteriaMatcher)); } + @Test + void shouldSupportLegacyPath() throws Exception { + PaginatedList<GermplasmVO> puiList = new PaginatedList<>(null, Collections.singletonList(germplasm)); + when(mockGermplasmRepository.find(any())).thenReturn(puiList); + + mockMvc.perform(get("/germplasm").param("pui", germplasm.getGermplasmPUI())) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) + .andExpect(htmlContent().hasTitle("Germplasm: BLE BARBU DU ROUSSILLON")) + .andExpect(htmlContent().endsCorrectly()); + } + @Test void shouldGenerateSitemap() throws Exception { List<GermplasmSitemapVO> germplasms = Arrays.asList(