Commit 697e6f1a authored by Jean-Baptiste Nizet's avatar Jean-Baptiste Nizet
Browse files

feat: support legacy path for germplasm card

parent d35cead5
...@@ -39,10 +39,13 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo ...@@ -39,10 +39,13 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
/** /**
* Controller used to display a germplasm card based on its ID. * 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 * @author JB Nizet
*/ */
@Controller("webGermplasmController") @Controller("webGermplasmController")
@RequestMapping("/germplasms") @RequestMapping({"/germplasms", "/germplasm"})
public class GermplasmController { public class GermplasmController {
private final GermplasmRepository germplasmRepository; private final GermplasmRepository germplasmRepository;
......
...@@ -160,6 +160,18 @@ public class GermplasmControllerTest { ...@@ -160,6 +160,18 @@ public class GermplasmControllerTest {
verify(mockGermplasmRepository).find(argThat(criteriaMatcher)); 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 @Test
void shouldGenerateSitemap() throws Exception { void shouldGenerateSitemap() throws Exception {
List<GermplasmSitemapVO> germplasms = Arrays.asList( List<GermplasmSitemapVO> germplasms = Arrays.asList(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment