Skip to content

Commit

Permalink
Fix default plot type and it's parameterisation null check code issues (
Browse files Browse the repository at this point in the history
#341)

* Fix default plot type and it's parameterisation null pointer exception and pull cell plot methods from the DB to use

* Improve code

* Add null fix test coverage

* Add curly braces to else condition

* Fetch plot methods from the test DB

* Update submodule

* Refactor variable name

* Bump atlas-web-core

* Remove JDBCUtils injection and related code

* Bump atlas-web-core submodule
  • Loading branch information
upendrakumbham authored Oct 17, 2023
1 parent 8923733 commit 5924024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
Expand Down Expand Up @@ -157,21 +157,17 @@ void returnEmptyResultIfThereIsNoDefaultPlotMethodAndParameterisation() {
}

@Test
void throwsNullPointerExceptionIfHardCodedTestMethodIsNotSameAsDBMethod() {
var tsne = randomAlphabetic(10);
var umap = randomAlphabetic(10);
void defaultResultedPlotMethodMatchesWithDBPlotMethods() {
var experimentAccession = RandomDataTestUtils.generateRandomExperimentAccession();

when(cellPlotDaoMock.fetchDefaultPlotMethodWithParameterisation(experimentAccession))
.thenReturn(ImmutableMap.of(umap.toUpperCase(),
.thenReturn(ImmutableMap.of("UMAP",
List.of(new Gson().fromJson("{\"n_neighbors\": 15}", JsonObject.class)),
tsne,
"t-SNE",
List.of(new Gson().fromJson("{\"perplexity\": 20}", JsonObject.class))));

assertThrows(NullPointerException.class, () -> {
//We are passing method 'umap' which is small letters, But DB has capilized method 'UMAP'
//This gives null List as MAP fetches from the DB, MAP keys are case-sensitive.
subject.fetchDefaultPlotMethodWithParameterisation(experimentAccession)
.get(umap).getAsJsonObject();
});
assertTrue(subject.fetchDefaultPlotMethodWithParameterisation(experimentAccession)
.keySet()
.contains("t-SNE"));
}
}
2 changes: 1 addition & 1 deletion atlas-web-core

0 comments on commit 5924024

Please sign in to comment.