MicroarrayExperimentFactory implements ExperimentFactory<MicroarrayExperiment> { @Override public MicroarrayExperiment create(ExperimentDTO experimentDTO, ExperimentDesign experimentDesign, IdfParserOutput idfParserOutput) { String experimentAccession = experimentDTO.getExperimentAccession(); MicroarrayExperimentConfiguration experimentConfiguration = configurationTrader.getMicroarrayExperimentConfiguration(experimentAccession); return new MicroarrayExperiment( experimentDTO.getExperimentType(), experimentAccession, experimentDTO.getLastUpdate(), experimentConfiguration.getContrastAndAnnotationPairs(), idfParserOutput.getTitle(), speciesFactory.create(experimentDTO.getSpecies()), experimentDesign, experimentDTO.getPubmedIds(), experimentDTO.getDois(), experimentConfiguration .getArrayDesignAccessions() .stream() .map(arrayDesignDAO::getArrayDesign) .collect(Collectors.toList()) ); } MicroarrayExperimentFactory(ConfigurationTrader configurationTrader,
                                       SpeciesFactory speciesFactory,
                                       ArrayDesignDao arrayDesignDAO); @Override MicroarrayExperiment create(ExperimentDTO experimentDTO,
                                       ExperimentDesign experimentDesign,
                                       IdfParserOutput idfParserOutput);  }
@Test public void testLoad() { MicroarrayExperiment microarrayExperiment = subject.create(experimentDTOMock, experimentDesignMock, idfParserOutputMock); assertThat(microarrayExperiment.getAccession(), is(ACCESSION)); assertThat(microarrayExperiment.getArrayDesignAccessions(), hasItem(ARRAYDESIGN_ID)); assertThat(microarrayExperiment.getSpecies(), is(SPECIES)); assertThat(microarrayExperiment.getExperimentDesign(), is(experimentDesignMock)); assertThat(microarrayExperiment.getArrayDesignNames(), hasItem(ARRAYDESIGN_NAME)); }
@Test public void idfTitleOverridesDatabaseTitleInExperimentDescription() { when(idfParserOutputMock.getTitle()).thenReturn("IDF title"); when(experimentDTOMock.getTitle()).thenReturn("DTO title"); Assert.assertThat( subject.create(experimentDTOMock, experimentDesignMock, idfParserOutputMock), hasProperty("description", Is.is("IDF title"))); }