FactorSet implements FactorGroup { @Override public boolean containsOnlyOrganism() { return size() == 1 && factorOfType("ORGANISM") != null; } FactorSet(); private  FactorSet(Map<String, Factor> factorsByType); FactorSet add(Factor factor); @Override Iterator<Factor> iterator(); @Override Factor factorOfType(String type); @Override int compareTo(FactorGroup other); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); @Override List<Factor> without(Collection<Factor> factors); @Override FactorGroup withoutTypes(Collection<String> factorTypes); static FactorSet create(Map<String, String> factorValueByType); int size(); @Override boolean isEmpty(); @Override boolean containsOnlyOrganism(); final Map<String, Factor> factorsByType; }
@Test public void testDoesNotContainAnyOrganism() { assertThat(subject.containsOnlyOrganism(), is(false)); }
@Test public void testContainsOnlyOrganism() { FactorSet subjectContainsOnlyOrganism = new FactorSet(); assertThat(subjectContainsOnlyOrganism.containsOnlyOrganism(), is(false)); subjectContainsOnlyOrganism.add(new Factor("ORGANISM", "Homo sapiens")); assertThat(subjectContainsOnlyOrganism.containsOnlyOrganism(), is(true)); subjectContainsOnlyOrganism.add(new Factor("type1", "value1")); assertThat(subjectContainsOnlyOrganism.containsOnlyOrganism(), is(false)); }