BaselineExperimentAssayGroupsLines implements Iterable<String[]> { @Nonnull @Override public Iterator<String[]> iterator() { return assayGroupsDetails.stream().map(list -> list.toArray(new String[0])).iterator(); } BaselineExperimentAssayGroupsLines(BaselineExperiment experiment); @Nonnull @Override Iterator<String[]> iterator();  }
@Test public void lines() { ExperimentDesign experimentDesign = new ExperimentDesign(); SampleCharacteristic sampleCharacteristic1 = SampleCharacteristic.create(SAMPLE_HEADER, SAMPLE_VALUE1, SAMPLE_ONTOLOGY_TERM1); SampleCharacteristic sampleCharacteristic2 = SampleCharacteristic.create(SAMPLE_HEADER, SAMPLE_VALUE2, SAMPLE_ONTOLOGY_TERM2); experimentDesign.putSampleCharacteristic(ASSAY1, SAMPLE_HEADER, sampleCharacteristic1); experimentDesign.putFactor(ASSAY1, FACTOR_HEADER, FACTOR_VALUE1, FACTOR_ONTOLOGY_TERM1); experimentDesign.putSampleCharacteristic(ASSAY2, SAMPLE_HEADER, sampleCharacteristic2); experimentDesign.putFactor(ASSAY2, FACTOR_HEADER, FACTOR_VALUE2, FACTOR_ONTOLOGY_TERM2); experimentDesign.putSampleCharacteristic(ASSAY3, SAMPLE_HEADER, SAMPLE_VALUE3); experimentDesign.putFactor(ASSAY3, FACTOR_HEADER, FACTOR_VALUE3); when(baselineExperiment.getAccession()).thenReturn(EXPERIMENT_ACCESSION); when(baselineExperiment.getDataColumnDescriptors()).thenReturn(ImmutableList.of(ASSAY_GROUP1, ASSAY_GROUP2, ASSAY_GROUP3)); when(baselineExperiment.getExperimentDesign()).thenReturn(experimentDesign); BaselineExperimentAssayGroupsLines subject = new BaselineExperimentAssayGroupsLines(baselineExperiment); Iterator<String[]> lines = subject.iterator(); subject.forEach(line -> LOGGER.info( Arrays.stream(line) .map(field -> wrap(field, "\"")) .map(field -> isBlank(field) ? "\"\"" : field) .collect(joining(",")))); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G1, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE1, HTTP_OBO + SAMPLE_ONTOLOGY_ID1})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G1, FACTOR, FACTOR_HEADER, FACTOR_VALUE1, HTTP_OBO + FACTOR_ONTOLOGY_ID1})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G2, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE2, SAMPLE_ONTOLOGY_ID2})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G2, FACTOR, FACTOR_HEADER, FACTOR_VALUE2, FACTOR_ONTOLOGY_ID2})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G3, CHARACTERISTIC, SAMPLE_HEADER, SAMPLE_VALUE3, ""})); assertThat( lines.next(), is(new String[] { EXPERIMENT_ACCESSION, G3, FACTOR, FACTOR_HEADER, FACTOR_VALUE3, ""})); }