Skip to content

Commit

Permalink
Merge branch 'develop' into 374-experiments-default-plot-option-is-no…
Browse files Browse the repository at this point in the history
…t-correctly-displayed-in-scxa
  • Loading branch information
lingyun1010 authored Feb 28, 2024
2 parents a1c0fa1 + 092fea1 commit 5c2a8bc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package uk.ac.ebi.atlas.configuration;

import com.google.common.collect.ImmutableSet;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import uk.ac.ebi.atlas.hcalandingpage.HcaHumanExperimentDao;
import uk.ac.ebi.atlas.hcalandingpage.HcaHumanExperimentService;
import uk.ac.ebi.atlas.solr.cloud.SolrCloudCollectionProxyFactory;
import uk.ac.ebi.atlas.trader.ExperimentTrader;

import java.util.Set;

@Configuration
// Enabling component scanning will also load BasePathsConfig, JdbcConfig and SolrConfig, so just using this class as
// application context is enough in integration tests. It’s important to exclude CacheConfig, otherwise Spring will
// complain if you want to inject classes such as ScxaExperimentTrader, since a proxy will be injected instead! As an
// exercise, remove CacheConfig.class and run tests in ScxaExperimentTraderIT.
@ComponentScan(basePackages = "uk.ac.ebi.atlas",
excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE,
value = {AppConfig.class, CacheConfig.class}))
public class TestConfigForHCA extends TestConfig {

private static final String INVALID_CHARACTERISTIC_VALUE = "foo";
private static final String VALID_CHARACTERISTIC_VALUE = "pancreas";

private static final ImmutableSet<String> ALL_ACCESSION_IDS =
ImmutableSet.of("E-CURD-4", "E-EHCA-2", "E-GEOD-71585", "E-GEOD-81547", "E-GEOD-99058", "E-MTAB-5061",
"E-ENAD-53");

@Bean
public HcaHumanExperimentDao hcaHumanExperimentDao(SolrCloudCollectionProxyFactory solrCloudCollectionProxyFactory) {

return new HcaHumanExperimentDao(solrCloudCollectionProxyFactory) {

@Override
public ImmutableSet<String> fetchExperimentAccessions(String characteristicName,
Set<String> characteristicValues) {
if (characteristicValues.contains(INVALID_CHARACTERISTIC_VALUE)) {
return ImmutableSet.of();
} else if(characteristicValues.contains(VALID_CHARACTERISTIC_VALUE)) {
return ImmutableSet.of("E-MTAB-5061");
} else {
return ALL_ACCESSION_IDS;
}
}
};
}

@Bean
public HcaHumanExperimentService hcaHumanExperimentService(ExperimentTrader experimentTrader,
HcaHumanExperimentDao hcaHumanExperimentDao) {
return new HcaHumanExperimentService(experimentTrader, hcaHumanExperimentDao);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

import javax.inject.Inject;
import javax.sql.DataSource;
import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestConfig.class)
@WebAppConfiguration
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class IdfParserIT {
class IdfParserForSingleCellIT {
@Inject
private DataSource dataSource;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
Expand All @@ -16,7 +17,7 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import uk.ac.ebi.atlas.configuration.TestConfig;
import uk.ac.ebi.atlas.configuration.TestConfigForHCA;

import javax.inject.Inject;
import javax.sql.DataSource;
Expand All @@ -26,9 +27,9 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@ExtendWith(SpringExtension.class)
@ExtendWith({MockitoExtension.class, SpringExtension.class})
@WebAppConfiguration
@ContextConfiguration(classes = TestConfig.class)
@ContextConfiguration(classes = TestConfigForHCA.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class HcaHumanExperimentsControllerWIT {
@Inject
Expand Down

0 comments on commit 5c2a8bc

Please sign in to comment.