// Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
// 
// 	public void accept(TestCaseVisitor<O> visitor);
// 
// 	public Set<Semantics> getApplicableSemantics();
// 
// 	public String getIdentifier();
// 
// 	public Set<URI> getImportedOntologies();
// 
// 	public String getImportedOntology(URI uri, SerializationFormat format);
// 
// 	public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
// 
// 	public Set<Semantics> getNotApplicableSemantics();
// 
// 	public Set<SyntaxConstraint> getSatisfiedConstraints();
// 
// 	public Status getStatus();
// 
// 	public Set<SyntaxConstraint> getUnsatisfiedConstraints();
// 
// 	public URI getURI();
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
// 
// 	public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
// 
// 	/**
// 	 * Test a {@link TestCase} against a condition
// 	 * 
// 	 * @param testcase
// 	 *            The {@link TestCase} to evaluate
// 	 * @return <code>true</code> if the filter condition accepts the test case,
// 	 *         <code>false</code> otherwise
// 	 */
// 	public boolean accepts(TestCase testcase);
// 
// 	/**
// 	 * Filter condition which accepts all test cases. Useful as a default
// 	 * condition.
// 	 */
// 	public final FilterCondition	ACCEPT_ALL	= new FilterCondition() {
// 													public boolean accepts(TestCase testcase) {
// 														return true;
// 													}
// 												};
// }


import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;
package com.clarkparsia.owlwg;





/**
 * <p>
 * Title: Test Collection
 * </p>
 * <p>
 * Description: Converts an ontology containing test case descriptions into an
 * iterable collection of {@link TestCase} objects
 * </p>
 * <p>
 * Copyright: Copyright &copy; 2009
 * </p>
 * <p>
 * Company: Clark & Parsia, LLC. <a
 * href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
 * </p>
 * 
 * @author Mike Smith &lt;msmith@clarkparsia.com&gt;
 */
public class TestCollection<O> implements Iterable<TestCase<O>> {

	private final Map<OWLIndividual, TestCase<O>>	cases;

	public TestCollection(TestCaseFactory<O> factory, OWLOntology o) {
		this( factory, o, FilterCondition.ACCEPT_ALL );
	}

	public TestCollection(TestCaseFactory<O> factory, OWLOntology o, FilterCondition filter) {
		if( factory == null )
			throw new NullPointerException();

		if( filter == null )
			throw new NullPointerException();

		cases = new HashMap<OWLIndividual, TestCase<O>>();
		Set<OWLClassAssertionAxiom> axioms;

		axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
		if( axioms != null ) {
			for( OWLClassAssertionAxiom ax : axioms ) {
				final OWLIndividual i = ax.getIndividual();
				final PositiveEntailmentTest<O> t = factory.getPositiveEntailmentTestCase( o, i );
				if( filter.accepts( t ) )
// Path: core/src/com/clarkparsia/owlwg/testcase/ConsistencyTest.java
// public interface ConsistencyTest<O> extends PremisedTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/InconsistencyTest.java
// public interface InconsistencyTest<O> extends PremisedTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/PositiveEntailmentTest.java
// public interface PositiveEntailmentTest<O> extends EntailmentTest<O> {
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCase.java
// public interface TestCase<O> {
// 
// 	public void accept(TestCaseVisitor<O> visitor);
// 
// 	public Set<Semantics> getApplicableSemantics();
// 
// 	public String getIdentifier();
// 
// 	public Set<URI> getImportedOntologies();
// 
// 	public String getImportedOntology(URI uri, SerializationFormat format);
// 
// 	public Set<SerializationFormat> getImportedOntologyFormats(URI uri);
// 
// 	public Set<Semantics> getNotApplicableSemantics();
// 
// 	public Set<SyntaxConstraint> getSatisfiedConstraints();
// 
// 	public Status getStatus();
// 
// 	public Set<SyntaxConstraint> getUnsatisfiedConstraints();
// 
// 	public URI getURI();
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/TestCaseFactory.java
// public interface TestCaseFactory<O> {
// 
// 	public ConsistencyTest<O> getConsistencyTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public InconsistencyTest<O> getInconsistencyTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public PositiveEntailmentTest<O> getPositiveEntailmentTestCase(OWLOntology o, OWLIndividual i);
// 
// 	public NegativeEntailmentTest<O> getNegativeEntailmentTestCase(OWLOntology o, OWLIndividual i);
// }
// 
// Path: core/src/com/clarkparsia/owlwg/testcase/filter/FilterCondition.java
// public interface FilterCondition {
// 
// 	/**
// 	 * Test a {@link TestCase} against a condition
// 	 * 
// 	 * @param testcase
// 	 *            The {@link TestCase} to evaluate
// 	 * @return <code>true</code> if the filter condition accepts the test case,
// 	 *         <code>false</code> otherwise
// 	 */
// 	public boolean accepts(TestCase testcase);
// 
// 	/**
// 	 * Filter condition which accepts all test cases. Useful as a default
// 	 * condition.
// 	 */
// 	public final FilterCondition	ACCEPT_ALL	= new FilterCondition() {
// 													public boolean accepts(TestCase testcase) {
// 														return true;
// 													}
// 												};
// }


// Path: core/src/com/clarkparsia/owlwg/TestCollection.java
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.CONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.INCONSISTENCY_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.NEGATIVE_ENTAILMENT_TEST;
import static com.clarkparsia.owlwg.testcase.TestVocabulary.Class.POSITIVE_ENTAILMENT_TEST;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import com.clarkparsia.owlwg.testcase.ConsistencyTest;
import com.clarkparsia.owlwg.testcase.InconsistencyTest;
import com.clarkparsia.owlwg.testcase.NegativeEntailmentTest;
import com.clarkparsia.owlwg.testcase.PositiveEntailmentTest;
import com.clarkparsia.owlwg.testcase.TestCase;
import com.clarkparsia.owlwg.testcase.TestCaseFactory;
import com.clarkparsia.owlwg.testcase.filter.FilterCondition;

package com.clarkparsia.owlwg;





/**
 * <p>
 * Title: Test Collection
 * </p>
 * <p>
 * Description: Converts an ontology containing test case descriptions into an
 * iterable collection of {@link TestCase} objects
 * </p>
 * <p>
 * Copyright: Copyright &copy; 2009
 * </p>
 * <p>
 * Company: Clark & Parsia, LLC. <a
 * href="http://clarkparsia.com/"/>http://clarkparsia.com/</a>
 * </p>
 * 
 * @author Mike Smith &lt;msmith@clarkparsia.com&gt;
 */
public class TestCollection<O> implements Iterable<TestCase<O>> {

	private final Map<OWLIndividual, TestCase<O>>	cases;

	public TestCollection(TestCaseFactory<O> factory, OWLOntology o) {
		this( factory, o, FilterCondition.ACCEPT_ALL );
	}

	public TestCollection(TestCaseFactory<O> factory, OWLOntology o, FilterCondition filter) {
		if( factory == null )
			throw new NullPointerException();

		if( filter == null )
			throw new NullPointerException();

		cases = new HashMap<OWLIndividual, TestCase<O>>();
		Set<OWLClassAssertionAxiom> axioms;

		axioms = o.getClassAssertionAxioms( POSITIVE_ENTAILMENT_TEST.getOWLClass() );
		if( axioms != null ) {
			for( OWLClassAssertionAxiom ax : axioms ) {
				final OWLIndividual i = ax.getIndividual();
				final PositiveEntailmentTest<O> t = factory.getPositiveEntailmentTestCase( o, i );
				if( filter.accepts( t ) )
					cases.put( i, t );