DefaultOntology implements Ontology { @Override public Iterator<Rule> iterator() { return this.map.values().iterator(); } DefaultOntology();  DefaultOntology(RuleSet rules);  DefaultOntology(CloseableIterator<Object> parser); @Override Set<String> getRuleNames(); @Override Rule getRule(String name); @Override Set<String> getNegativeConstraintNames(); @Override NegativeConstraint getNegativeConstraint(String name); @Override boolean add(Rule rule); @Override boolean addAll(Iterator<Rule> ruleIterator); @Override boolean addAll(CloseableIterator<Rule> ruleIterator); @Override boolean remove(Rule rule); @Override boolean removeAll(Iterator<Rule> ruleIterator); @Override boolean removeAll(CloseableIterator<Rule> ruleIterator); @Override boolean contains(Rule rule); @Override int size(); @Override Iterator<Rule> iterator(); @Override Set<Predicate> getVocabulary(); @Override boolean isEmpty();  }
@Test public void testIterator_empty() { Ontology onto = new DefaultOntology(); Iterator<Rule> it = onto.iterator(); Assert.assertFalse(it.hasNext()); }
@Test public void testIterator() { boolean isThereR1 = false; boolean isThereNoName = false; Ontology onto = new DefaultOntology(); onto.add(r1); onto.add(noName); Iterator<Rule> it = onto.iterator(); while(it.hasNext()) { Rule r = it.next(); if(r == r1 && !isThereR1) { isThereR1 = true; } else if(r == noName && !isThereNoName) { isThereNoName = true; } else { fail("Not wanted rule: " + r); } } Assert.assertTrue("isThereR1",isThereR1); Assert.assertTrue("isThereNoName",isThereNoName); }