ExperimentDesignFile extends CanStreamSupplier<E> { public Collection<ExternallyAvailableContent> get(final E experiment) { return Collections.singleton( new ExternallyAvailableContent( makeUri("experiment-design"), ExternallyAvailableContent.Description.create( "icon-experiment-design", "Experiment Design (tsv)"), streamFile(experiment.getAccession() + "-experiment-design.tsv", new Function<Writer, Void>() { @Nullable @Override public Void apply(@Nullable Writer writer) { writeLines(experiment.getAccession(), getAnalysedRowsAccessions(experiment), writer); return null; } }) ) ); } private  ExperimentDesignFile(DataFileHub dataFileHub); @Override ExternallyAvailableContent.ContentType contentType(); static String makeUrl(String experimentAccession, String accessKey); Collection<ExternallyAvailableContent> get(final E experiment);  }
@Test public void hasOnlyOneContentItem() { assertThat(baselineExperimentDesignFile.get(baselineExperiment), hasSize(1)); assertThat(differentialMicroarrayExperimentDesignFile.get(differentialMicroarrayExperiment), hasSize(1)); assertThat(differentialRnaSeqExperimentDesignFile.get(differentialRnaSeqExperiment), hasSize(1)); }
@Test public void lookingGood() throws Exception { fileHub.addExperimentDesignFile( "E-FOOBAR", ImmutableList.of( new String[]{"Run", "Sample Characteristic[foo]", "Sample Charactersitic Ontology Term[foo]"}, new String[]{"assay1", "bar", "http: new String[]{"assay2", "bar", "http: new String[]{"assay3", "bar", "http: new String[]{"assay4", "bar", "http: new String[]{"assay5", "bar", "http: ) ); when(baselineExperiment.getAccession()).thenReturn("E-FOOBAR"); when(baselineExperiment.getDataColumnDescriptors()).thenReturn(ImmutableList.of( AssayGroupFactory.create( "g1", "assay1", "assay2", "assay3"), new AssayGroup( "g2", ImmutableSet.of(new BiologicalReplicate("t1", ImmutableSet.of("assay4", "assay5")))))); ExternallyAvailableContent externallyAvailableContent = baselineExperimentDesignFile.get(baselineExperiment).iterator().next(); externallyAvailableContent.stream.apply(httpServletResponse); assertThat(httpServletResponse.getContentAsString(), is(equalTo( "Run\tSample Characteristic[foo]\tSample Charactersitic Ontology Term[foo]\tAnalysed\n" + "assay1\tbar\thttp: "assay2\tbar\thttp: "assay3\tbar\thttp: "assay4\tbar\thttp: "assay5\tbar\thttp: }