Skip to content

Commit

Permalink
[Bugfix] Alternative view refactoring (#183)
Browse files Browse the repository at this point in the history
* Fix test runners

* Upgrade Mockito to 5.2.0

* Add ontology related files to the local Docker env

* Remove large experiments from local env

* Implement ExperimentCellCountDao interface

* Remove experiment design tab from the experiment page

* Remove unused stubbing

* Add null check

* Adjust test to code changes that happened in February 2022

Unfortunately test code was not adjusted when the `download` endpoint has been changed in February 2022 and probably the tests were not executed before the PR as merged. :-(

* Add back E-MTAB-5214 to the experiment's fixtures

* Add E-MTAB-5555 as a private experiment

* Fix experiment fixture for GxaExperimentCrudIT

* Remove E-MTAB-5200 from the small-experiment-fixture.sql as we don't have it local

* Fix DASFeaturesControllerWIT's featuresURLGeneWithoutExpressions method

* Add temporary folders to .gitignore

* Fix port related issue for gradle task

* New section - How to add a private experiment into our local env

* Add known build issue to the README.md

* Improve the README.md

* Fix anchor in the README

* Change property source to git.properties

git.properties is being generated by the plugin

* Define folder name to git.properties

* Remove the definition of the folder for git.properties

* Change the path and name of the generated git props file

* Refactor how we handle the alternative views of an experiment

* Update with the latest atlas-web-core module
  • Loading branch information
ke4 authored Apr 10, 2024
1 parent 347c425 commit 786a91f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ public Experiment getExperiment(String experimentAccession) {
+ ": experiment type " + experimentDto.getExperimentType() + " is not supported");
}
}

@Override
public String getExperimentType(String experimentAccession) {
return experimentCrudDao.getExperimentType(experimentAccession);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,22 @@ void baselineProteomicsDiaExperiments() {
.isInstanceOf(BaselineExperiment.class)
.hasNoNullFieldsOrProperties();
}

@Test
void whenExperimentDoesNotExists_ThrowsException() {
assertThatExceptionOfType(ResourceNotFoundException.class)
.isThrownBy(
() -> subject.getExperimentType(
jdbcUtils.fetchRandomExperimentAccession() + "_NOT_EXIST")
);
}

@Test
void whenExperimentExists_thenReturnsExperimentType() {
var experimentAccession = jdbcUtils.fetchRandomExperimentAccession();
var originalExperimentType = jdbcUtils.fetchExperimentTypeByAccession(experimentAccession);
var experimentType = subject.getExperimentType(experimentAccession);

assertThat(experimentType).isEqualTo(originalExperimentType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.ac.ebi.atlas.controllers.ResourceNotFoundException;
import uk.ac.ebi.atlas.experimentimport.ExperimentCrudDao;
import uk.ac.ebi.atlas.experimentimport.ExperimentDto;
import uk.ac.ebi.atlas.experimentimport.idf.IdfParser;
import uk.ac.ebi.atlas.experimentimport.idf.IdfParserOutput;
import uk.ac.ebi.atlas.model.experiment.ExperimentDesign;
import uk.ac.ebi.atlas.model.experiment.ExperimentType;
import uk.ac.ebi.atlas.trader.factory.BaselineExperimentFactory;
import uk.ac.ebi.atlas.trader.factory.MicroarrayExperimentFactory;
import uk.ac.ebi.atlas.trader.factory.ProteomicsDifferentialExperimentFactory;
Expand All @@ -24,6 +26,8 @@
import java.util.concurrent.ThreadLocalRandom;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.when;
import static uk.ac.ebi.atlas.model.experiment.ExperimentType.SINGLE_CELL_RNASEQ_MRNA_BASELINE;
Expand Down Expand Up @@ -59,6 +63,9 @@ class GxaExperimentRepositoryTest {

private GxaExperimentRepository subject;

private String experimentAccession;
private ExperimentDto experimentDto;

@BeforeEach
void setUp() {
subject =
Expand All @@ -70,23 +77,25 @@ void setUp() {
rnaSeqDifferentialExperimentFactoryMock,
microarrayExperimentFactoryMock,
proteomicsDifferentialExperimentFactoryMock);

experimentAccession = generateRandomExperimentAccession();
experimentDto = new ExperimentDto(
experimentAccession,
SINGLE_CELL_RNASEQ_MRNA_BASELINE,
generateRandomSpecies().getName(),
ImmutableList.of(generateRandomPubmedId()),
ImmutableList.of(generateRandomDoi()),
new Timestamp(new Date().getTime()),
new Timestamp(new Date().getTime()),
RNG.nextBoolean(),
UUID.randomUUID().toString());

}

@Test
void cannotBuildNonBulkExperiments() {
var experimentAccession = generateRandomExperimentAccession();

when(experimentCrudDaoMock.readExperiment(experimentAccession))
.thenReturn(new ExperimentDto(
experimentAccession,
SINGLE_CELL_RNASEQ_MRNA_BASELINE,
generateRandomSpecies().getName(),
ImmutableList.of(generateRandomPubmedId()),
ImmutableList.of(generateRandomDoi()),
new Timestamp(new Date().getTime()),
new Timestamp(new Date().getTime()),
RNG.nextBoolean(),
UUID.randomUUID().toString()));
.thenReturn(experimentDto);

when(experimentDesignParserMock.parse(experimentAccession))
.thenReturn(new ExperimentDesign());
Expand All @@ -102,4 +111,30 @@ void cannotBuildNonBulkExperiments() {
assertThatIllegalArgumentException()
.isThrownBy(() -> subject.getExperiment(experimentAccession));
}

@Test
void whenExperimentDoesNotExists_ThrowsException() {
var experimentAccession = generateRandomExperimentAccession();

when(experimentCrudDaoMock.getExperimentType(experimentAccession))
.thenThrow(ResourceNotFoundException.class);

assertThatExceptionOfType(ResourceNotFoundException.class)
.isThrownBy(
() -> subject.getExperimentType(experimentAccession)
);
}

@Test
void whenExperimentExists_thenReturnsExperimentType() {
final String originalExperimentType = experimentDto.getExperimentType().name();

when(experimentCrudDaoMock.getExperimentType(experimentAccession))
.thenReturn(originalExperimentType);

var experimentType = subject.getExperimentType(experimentAccession);

assertThat(experimentType).isEqualTo(originalExperimentType);
assertThat(ExperimentType.valueOf(experimentType)).isEqualTo(experimentDto.getExperimentType());
}
}

0 comments on commit 786a91f

Please sign in to comment.