diff --git a/uniprotkb-rest/src/test/java/org/uniprot/api/uniprotkb/controller/UniProtKBSearchControllerIT.java b/uniprotkb-rest/src/test/java/org/uniprot/api/uniprotkb/controller/UniProtKBSearchControllerIT.java index 94106de5f..0e96b6a3e 100644 --- a/uniprotkb-rest/src/test/java/org/uniprot/api/uniprotkb/controller/UniProtKBSearchControllerIT.java +++ b/uniprotkb-rest/src/test/java/org/uniprot/api/uniprotkb/controller/UniProtKBSearchControllerIT.java @@ -2159,6 +2159,31 @@ void searchWhitelistInvalidVGNCIdDefaultSearch() throws Exception { "$.messages.*", contains("'VGNC' is not a valid search field"))); } + @Test + void testSearchByChebi() throws Exception { + saveEntry(SaveScenario.SEARCH_ALL_FIELDS); + // when + ResultActions response = + getMockMvc() + .perform( + MockMvcRequestBuilders.get(SEARCH_RESOURCE) + .param("query", "chebi:search") + .header( + HttpHeaders.ACCEPT, + MediaType.APPLICATION_JSON_VALUE)); + response.andDo(MockMvcResultHandlers.print()) + .andExpect(MockMvcResultMatchers.status().is(HttpStatus.OK.value())) + .andExpect( + MockMvcResultMatchers.header() + .string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.jsonPath("$.results.size()", is(1))) + .andExpect( + MockMvcResultMatchers.jsonPath( + "$.results[0].primaryAccession", is("P00001"))); + // then + + } + @Override protected String getSearchRequestPath() { return SEARCH_RESOURCE; @@ -2297,7 +2322,7 @@ protected void saveEntry(SaveScenario saveContext) { doc.commentMap.put("cc_bpcp_temp_dependence_exp", Collections.singleton("Search All")); doc.inchikey.add("Search All"); doc.rheaIds.add("Search All"); - doc.chebi.add("Search All"); + doc.chebi.addAll(Set.of("Search All", "CHEBI:12345")); doc.cofactorChebi.add("Search All"); doc.commentMap.put("cc_cofactor_chebi_exp", Collections.singleton("Search All")); doc.cofactorNote.add("Search All");