Skip to content

Commit

Permalink
provide search support by chebi name and synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshadab committed Dec 18, 2024
1 parent f2442dd commit 27a357c
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 27a357c

Please sign in to comment.