BaselineRequestContext extends RequestContext<AssayGroup, U, BaselineExperiment, BaselineRequestPreferences<U>> implements BaselineProfileStreamOptions<U> { @Override public String displayNameForColumn(AssayGroup assayGroup) { return Optional.ofNullable(displayNamePerSelectedAssayGroup.get().get(assayGroup)) .orElse(assayGroup.getId()); } BaselineRequestContext(BaselineRequestPreferences<U> requestPreferences, BaselineExperiment experiment); @Override String displayNameForColumn(AssayGroup assayGroup); @Override U getExpressionUnit();  }
@Test public void singleFactorExperimentHasSimpleLabels() { String defaultQueryFactorType = "defaultQueryFactorType"; AssayGroup ag1 = AssayGroupFactory.create("g1", "run11"); AssayGroup ag2 = AssayGroupFactory.create("g2", "run21"); List<AssayGroup> assayGroups = ImmutableList.of(ag1, ag2); ExperimentDesign experimentDesign = mock(ExperimentDesign.class); FactorSet factors1 = new FactorSet(); factors1.add(new Factor(defaultQueryFactorType, "name for g1")); when(experimentDesign.getFactors("run11")).thenReturn(factors1); FactorSet factors2 = new FactorSet(); factors2.add(new Factor(defaultQueryFactorType, "name for g2")); when(experimentDesign.getFactors("run21")).thenReturn(factors2); BaselineRequestContext<ExpressionUnit.Absolute.Rna> subject = new BaselineRequestContext<>( BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment(experimentDesign, assayGroups)); assertThat(subject.displayNameForColumn(ag1), (is("name for g1"))); assertThat(subject.displayNameForColumn(ag2), (is("name for g2"))); }
@Test public void multiFactorExperimentWhereDisplayedColumnsShareAFactorShowsOnlyTheDifferentPart() { String defaultQueryFactorType = "defaultQueryFactorType"; String otherType = "otherQueryFactorType"; AssayGroup ag1 = AssayGroupFactory.create("g1", "run11"); AssayGroup ag2 = AssayGroupFactory.create("g2", "run21"); List<AssayGroup> assayGroups = ImmutableList.of(ag1, ag2); ExperimentDesign experimentDesign = mock(ExperimentDesign.class); FactorSet factors1 = new FactorSet(); factors1.add(new Factor(defaultQueryFactorType, "name for g1")); factors1.add(new Factor(otherType, "otherTypeValue")); when(experimentDesign.getFactors("run11")).thenReturn(factors1); FactorSet factors2 = new FactorSet(); factors2.add(new Factor(defaultQueryFactorType, "name for g2")); factors2.add(new Factor(otherType, "otherTypeValue")); when(experimentDesign.getFactors("run21")).thenReturn(factors2); BaselineRequestContext<ExpressionUnit.Absolute.Rna> subject = new BaselineRequestContext<>( BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment(experimentDesign, assayGroups)); assertThat(subject.displayNameForColumn(ag1), (is("name for g1"))); assertThat(subject.displayNameForColumn(ag2), (is("name for g2"))); }
@Test public void whenViewIsAllFlatAndAllFactorsDifferWeShowThemInPrescribedOrder() { String defaultQueryFactorType = "defaultQueryFactorType"; String otherType = "otherQueryFactorType"; Collection<Factor> defaultFactorValues = ImmutableSet.of(new Factor(otherType, "defaultValueForOtherType")); List<String> prescribedOrderOfFilters = ImmutableList.of(defaultQueryFactorType, otherType); AssayGroup ag1 = AssayGroupFactory.create("g1", "run11"); AssayGroup ag2 = AssayGroupFactory.create("g2", "run21"); List<AssayGroup> assayGroups = ImmutableList.of(ag1, ag2); ExperimentDesign experimentDesign = mock(ExperimentDesign.class); FactorSet factors1 = new FactorSet(); factors1.add(new Factor(defaultQueryFactorType, "name for g1")); factors1.add(new Factor(otherType, "other type value 1")); when(experimentDesign.getFactors("run11")).thenReturn(factors1); FactorSet factors2 = new FactorSet(); factors2.add(new Factor(defaultQueryFactorType, "name for g2")); factors2.add(new Factor(otherType, "other type value 2")); when(experimentDesign.getFactors("run21")).thenReturn(factors2); BaselineRequestContext<ExpressionUnit.Absolute.Rna> subject = new BaselineRequestContext<>(BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment( experimentDesign, assayGroups, ExperimentDisplayDefaults.create(defaultFactorValues, prescribedOrderOfFilters, false))); assertThat(subject.displayNameForColumn(ag1), (is("name for g1, other type value 1"))); assertThat(subject.displayNameForColumn(ag2), (is("name for g2, other type value 2"))); subject = new BaselineRequestContext<>(BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment( experimentDesign, assayGroups, ExperimentDisplayDefaults.create( defaultFactorValues, Lists.reverse(prescribedOrderOfFilters), false))); assertThat(subject.displayNameForColumn(ag1), (is("other type value 1, name for g1"))); assertThat(subject.displayNameForColumn(ag2), (is("other type value 2, name for g2"))); }
@Test public void whenSomeTypesAreTheSameAcrossTheSetTheyDoNotGoIntoTheName() { String defaultQueryFactorType = "defaultQueryFactorType"; String otherType = "otherQueryFactorType"; Collection<Factor> defaultFactorValues = ImmutableSet.of(new Factor(otherType, "defaultValueForOtherType")); List<String> prescribedOrderOfFilters = ImmutableList.of(defaultQueryFactorType, otherType); AssayGroup ag1 = AssayGroupFactory.create("g1", "run11"); AssayGroup ag2 = AssayGroupFactory.create("g2", "run21"); List<AssayGroup> assayGroups = ImmutableList.of(ag1, ag2); ExperimentDesign experimentDesign = mock(ExperimentDesign.class); FactorSet factors1 = new FactorSet(); factors1.add(new Factor(defaultQueryFactorType, "name for g1")); factors1.add(new Factor(otherType, "other type value")); when(experimentDesign.getFactors("run11")).thenReturn(factors1); FactorSet factors2 = new FactorSet(); factors2.add(new Factor(defaultQueryFactorType, "name for g2")); factors2.add(new Factor(otherType, "other type value")); when(experimentDesign.getFactors("run21")).thenReturn(factors2); BaselineRequestContext<ExpressionUnit.Absolute.Rna> subject = new BaselineRequestContext<>( BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment( experimentDesign, assayGroups, ExperimentDisplayDefaults.create(defaultFactorValues, prescribedOrderOfFilters, false))); assertThat(subject.displayNameForColumn(ag1), (is("name for g1"))); assertThat(subject.displayNameForColumn(ag2), (is("name for g2"))); subject = new BaselineRequestContext<>(BaselineRequestPreferencesTest.get(), MockExperiment.createBaselineExperiment( experimentDesign, assayGroups, ExperimentDisplayDefaults.create( defaultFactorValues, Lists.reverse(prescribedOrderOfFilters), false))); assertThat(subject.displayNameForColumn(ag1), (is("name for g1"))); assertThat(subject.displayNameForColumn(ag2), (is("name for g2"))); }