FactorGroupingService { JsonArray groupOrganismPartOntologyTerms(Collection<OntologyTerm> ontologyTermsInAllFactors) { JsonArray result = new JsonArray(); groupingAsJson( organismPartGroupingService.getOrgansGrouping(ontologyTermsInAllFactors), "Organs", "Organ") .ifPresent(result::add); groupingAsJson( organismPartGroupingService.getAnatomicalSystemsGrouping(ontologyTermsInAllFactors), "Anatomical Systems", "Anatomical system") .ifPresent(result::add); return result; } FactorGroupingService(OrganismPartGroupingService organismPartGroupingService); JsonArray group(String defaultQueryFactorType,
                           Collection<FactorAcrossExperiments> factorsAcrossExperiments);  }
@Test public void noResultsNoFactorGrouping() { when(organismPartGroupingService.getAnatomicalSystemsGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of()); when(organismPartGroupingService.getOrgansGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of()); assertThat( subject.groupOrganismPartOntologyTerms(ontologyTermsAcrossExperiments), is(new JsonArray())); }
@Test public void noOntologyTermsNoFactorGrouping() { when(organismPartGroupingService.getAnatomicalSystemsGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of(ColumnGroup.create("", ""), ImmutableSet.of())); when(organismPartGroupingService.getOrgansGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of()); assertThat( subject.groupOrganismPartOntologyTerms(ontologyTermsAcrossExperiments), is(new JsonArray())); }
@Test public void ontologyTermsGivesFactorGrouping() { when(organismPartGroupingService.getAnatomicalSystemsGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of(ColumnGroup.create("", ""), ImmutableSet.of(OntologyTerm.create("")))); when(organismPartGroupingService.getOrgansGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of()); assertThat( subject.groupOrganismPartOntologyTerms(ontologyTermsAcrossExperiments).size(), is(1)); }
@Test public void ontologyTermsGivesFactorGrouping2() { when(organismPartGroupingService.getAnatomicalSystemsGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of(ColumnGroup.create("", ""), ImmutableSet.of(OntologyTerm.create("")))); when(organismPartGroupingService.getOrgansGrouping(ontologyTermsAcrossExperiments)) .thenReturn(ImmutableMap.of(ColumnGroup.create("", ""), ImmutableSet.of(OntologyTerm.create("")))); assertThat( subject.groupOrganismPartOntologyTerms(ontologyTermsAcrossExperiments).size(), is(2)); }