ExternallyViewableProfilesList { public JsonObject asJson() { JsonObject result = new JsonObject(); for (Map.Entry<String, String> e: profiles.properties().entrySet()) { result.addProperty(e.getKey(), e.getValue()); } JsonArray rows = new JsonArray(); for (P profile : profiles) { rows.add(convert(profile)); } result.add("rows", rows); return result; } ExternallyViewableProfilesList(GeneProfilesList<P> profiles,
                                          Function<P, URI> provideLinkToProfile,
                                          List<D> prescribedOrderOfColumns,
                                          Function<P, U> expressionUnitForProfile); static ExternallyViewableProfilesList<FactorAcrossExperiments, BaselineExperimentProfile, ExpressionUnit.Absolute> createForExperimentProfiles(SemanticQuery geneQuery,
                                BaselineExperimentProfilesList experimentProfiles,
                                List<FactorAcrossExperiments> dataColumns); JsonObject asJson();  }
@Test public void weCanSerializeDataForTheDifferentialPage() { Function<RnaSeqProfile, URI> provideLinkToProfile = o -> { try { return new URI("https: } catch (URISyntaxException e) { throw new RuntimeException(e); } }; AssayGroup g1 = AssayGroupFactory.create("g1", "run_11", "run_12", "run_13"); AssayGroup g2 = AssayGroupFactory.create("g2", "run_21", "run_22", "run_23", "run_24"); AssayGroup g3 = AssayGroupFactory.create("g3", "run_31", "run_32"); Contrast g1g2 = new Contrast("g1_g2", "", g1, g2, "first contrast"); Contrast g1g3 = new Contrast("g1_g3", "", g1, g3, "second contrast"); List<Contrast> factorsAcrossExperiments = ImmutableList.of(g1g2, g1g3); RnaSeqProfile p1 = new RnaSeqProfile("gene_1_id", "gene_1_name"); p1.add(g1g2, new DifferentialExpression(1000, 10)); p1.add(g1g3, new DifferentialExpression(2000, 20)); RnaSeqProfile p2 = new RnaSeqProfile("gene_2_id", "gene_2_name"); p2.add(g1g2, new DifferentialExpression(3000, 30)); DifferentialProfilesList<RnaSeqProfile> profiles = new DifferentialProfilesList<>(); profiles.add(p1); profiles.add(p2); JsonObject result = new ExternallyViewableProfilesList<>( profiles, provideLinkToProfile, factorsAcrossExperiments, rnaSeqProfile -> ExpressionUnit.Relative.FOLD_CHANGE).asJson(); assertThat(result.get("rows").getAsJsonArray().size(), is(ImmutableList.of(p1, p2).size())); for (JsonElement row: result.get("rows").getAsJsonArray()) { assertThat( row.getAsJsonObject().get("expressions").getAsJsonArray().size(), is(factorsAcrossExperiments.size())); } }