Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add_gut_anatomogram
Browse files Browse the repository at this point in the history
  • Loading branch information
ke4 authored Oct 9, 2023
2 parents 5efbdd7 + 4839fdb commit 4d3c46d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import uk.ac.ebi.atlas.controllers.JsonExceptionHandlingController;
import uk.ac.ebi.atlas.experimentpage.markergenes.HighchartsHeatmapAdapter;

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Collection;

import static uk.ac.ebi.atlas.utils.GsonProvider.GSON;
Expand All @@ -33,8 +35,10 @@ public String getCellTypeMarkerGenes(
return GSON.toJson(
highchartsHeatmapAdapter.getMarkerGeneHeatmapDataSortedLexicographically(
experimentAccessions == null ?
multiexperimentCellTypeMarkerGenesService.getCellTypeMarkerGeneProfile(cellType) :
multiexperimentCellTypeMarkerGenesService.getCellTypeMarkerGeneProfile(
ImmutableSet.copyOf(experimentAccessions), cellType)));
URLDecoder.decode(cellType, StandardCharsets.UTF_8)) :
multiexperimentCellTypeMarkerGenesService.getCellTypeMarkerGeneProfile(
ImmutableSet.copyOf(experimentAccessions),
URLDecoder.decode(cellType, StandardCharsets.UTF_8))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import org.springframework.web.context.WebApplicationContext;
import uk.ac.ebi.atlas.configuration.TestConfig;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TEST_METHOD;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
Expand Down Expand Up @@ -56,9 +61,22 @@ void setUp() {
}

@Test
void returnsAValidJsonPayloadForAValidCellType() throws Exception {
void shouldReturnAValidJsonPayloadForAValidCellType() throws Exception {
this.mockMvc.perform(get("/json/cell-type-marker-genes/{cellType}", "cell cycle S phase")
.param("experimentAccession", "E-ENAD-53"))
.param("experimentAccession", "E-ENAD-53"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$[0].cellGroupValue", isA(String.class)))
.andExpect(jsonPath("$[0].value", isA(Number.class)))
.andExpect(jsonPath("$[0].cellGroupValueWhereMarker", isA(String.class)))
.andExpect(jsonPath("$[0].pValue", isA(Number.class)));
}

@Test
void shouldReturnAValidJsonPayloadForACellTypeContainingAForwardSlash() throws Exception {
final String encodedCellType = URLEncoder.encode("cell cycle G2/M phase", StandardCharsets.UTF_8);
this.mockMvc.perform(get("/json/cell-type-marker-genes/{cellType}", encodedCellType)
.param("experimentAccession", "E-ENAD-53"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$[0].cellGroupValue", isA(String.class)))
Expand All @@ -68,9 +86,11 @@ void returnsAValidJsonPayloadForAValidCellType() throws Exception {
}

@Test
void returnsEmptyPayloadForAnInvalidCellType() throws Exception {
void shouldReturnEmptyPayloadForAnInvalidCellType() throws Exception {
this.mockMvc.perform(get("/json/cell-type-marker-genes/{cellType}", "fooBar")
.param("experimentAccession", "E-CURD-4"))
.andExpect(status().isOk());
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", is(empty())));
}
}

0 comments on commit 4d3c46d

Please sign in to comment.