RichFactorGroup { public static boolean isSubgroup(FactorGroup moreSpecificGroup, FactorGroup moreGeneralGroup) { for (Factor factor: moreGeneralGroup) { if (!moreSpecificGroup.factorOfType(factor.getType()).equals(factor)) { return false; } } return true; } RichFactorGroup(FactorGroup factorGroup); Set<OntologyTerm> getOntologyTerms(); String asUrlEncodedJson(); static Set<String> typesWithCommonValues(Iterable<FactorGroup> factorGroups); static List<String> filterOutTypesWithCommonValues(List<String> types, Iterable<FactorGroup> factorGroups); static boolean isSubgroup(FactorGroup moreSpecificGroup, FactorGroup moreGeneralGroup);  }
@Test public void isSubgroup() { FactorGroup generalGroup = new FactorSet().add(new Factor("T1", "v1")); FactorGroup moreSpecificGroup = new FactorSet().add(new Factor("T1", "v1")).add(new Factor("T2", "v2")); FactorGroup differentSpecificGroup = new FactorSet().add(new Factor("T1", "different value")).add(new Factor("T2", "v2")); assertThat(RichFactorGroup.isSubgroup(moreSpecificGroup, generalGroup), is(true)); assertThat(RichFactorGroup.isSubgroup(differentSpecificGroup, generalGroup), is(false)); assertThat(RichFactorGroup.isSubgroup(generalGroup, generalGroup), is(true)); assertThat(RichFactorGroup.isSubgroup(moreSpecificGroup, new FactorSet()), is(true)); assertThat(RichFactorGroup.isSubgroup(differentSpecificGroup, new FactorSet()), is(true)); }