ConditionsCollector { public Stream<Condition> getConditions(BaselineExperiment experiment) { ImmutableSetMultimap<String, String> assayAccession2OntologyTerms = mapAssayAccessionsToOntologyTerms(experiment.getExperimentDesign()); return experiment.getDataColumnDescriptors().stream() .flatMap(assayGroup -> assayGroup.assaysAnalyzedForThisDataColumn().stream() .map(assayAccession -> new Condition( experiment.getAccession(), assayGroup.getId(), collectAssayProperties( experiment, assayAccession, assayAccession2OntologyTerms.get(assayAccession))))); } ConditionsCollector(EfoLookupService efoLookupService); Stream<Condition> getConditions(BaselineExperiment experiment); Stream<DifferentialCondition> getConditions(DifferentialExperiment experiment);  }
@Test void baselineConditions() { assertThat(subject.getConditions(baselineExperimentMock)) .flatExtracting("values") .containsExactlyInAnyOrderElementsOf( ImmutableList.<String>builder() .addAll(expandedOntologyTerms.values()) .addAll( factorValues.values().stream() .flatMap(headerValueMap -> headerValueMap.values().stream()) .collect(toSet())) .addAll( sampleCharacteristics.values().stream() .flatMap(headerValueMap -> headerValueMap.values().stream()) .collect(toSet())) .build()); }
@Test void differentialConditions() { assertThat(subject.getConditions(differentialExperimentMock)) .flatExtracting("values") .containsExactlyInAnyOrderElementsOf( ImmutableList.<String>builder() .addAll( testAssayGroup.assaysAnalyzedForThisDataColumn().stream() .flatMap(assayId -> ImmutableSet.<String>builder() .addAll(expandedOntologyTerms.get(assayId)) .addAll(factorValues.get(assayId).values()) .addAll(sampleCharacteristics.get(assayId).values()) .build() .stream()) .collect(toList())) .addAll( referenceAssayGroup.assaysAnalyzedForThisDataColumn().stream() .flatMap(assayId -> ImmutableSet.<String>builder() .addAll(expandedOntologyTerms.get(assayId)) .addAll(factorValues.get(assayId).values()) .addAll(sampleCharacteristics.get(assayId).values()) .build() .stream()) .collect(toList())) .build()); }