001: /*
002: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package org.mandarax.kernel.validation;
020:
021: import org.mandarax.kernel.*;
022:
023: /**
024: * Test case that can be used to validate a knowledge base.
025: * Modelled after JUnit test cases, although this interface does not depend on JUnit.
026: * A reference implementation based on JUnit is provided as well.
027: * <p>
028: * The test case can validate the following:
029: * <ol>
030: * <li>whether a ground query yields true or false</li>
031: * <li>the expected variable replacements in a query containing variables</li>
032: * <li>the number of expected results</li>
033: * </ol>
034: * @author <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich</A>
035: * @version 3.4 <7 March 05>
036: * @since 3.4
037: */
038: public interface TestCase extends PropertiesSupport {
039:
040: // public constants representing policies how assumptions should be integrated into the kb
041: // ON_TOP can be used in conjunction with the ExtendedKnowledgeBase that has an API to give
042: // clause sets top priority
043: public static final int ON_TOP = 0;
044: public static final int AT_BOTTOM = 1;
045:
046: /**
047: * Prepares the test case.
048: */
049: public void prepare() throws Exception;
050:
051: /**
052: * Releases the test case.
053: */
054: public void release() throws Exception;
055:
056: /**
057: * Execute the test case.
058: */
059: public abstract void execute() throws Exception;
060:
061: /**
062: * Get the assumptions.
063: * @return Returns the assumptions.
064: */
065: public ClauseSet[] getAssumptions();
066:
067: /**
068: * Set the assumptions.
069: * @param assumptions The assumptions to set.
070: */
071: public void setAssumptions(ClauseSet[] assumptions);
072:
073: /**
074: * Get the test knowledge base.
075: * @return Returns the kb.
076: */
077: public KnowledgeBase getKb();
078:
079: /**
080: * Set the test knowledge base.
081: * @param kb The kb to set.
082: */
083: public void setKb(KnowledgeBase kb);
084:
085: /**
086: * Set the test query.
087: * @return Returns the query.
088: */
089: public Query getQuery();
090:
091: /**
092: * Set the test query.
093: * @param query The query to set.
094: */
095: public void setQuery(Query query);
096:
097: /**
098: * @return Returns the expectedNumberOfResults.
099: */
100: public int getExpectedNumberOfResults();
101:
102: /**
103: * @param expectedNumberOfResults The expectedNumberOfResults to set.
104: */
105: public void setExpectedNumberOfResults(int expectedNumberOfResults);
106:
107: /**
108: * Get an array of maps containing variable term -> constant term mapping expected in the result
109: * at this position.
110: * Can be null indicating that this condition will not be checked in this test case.
111: * @return Returns the expectedReplacements.
112: */
113: public java.util.Map[] getExpectedReplacements();
114:
115: /**
116: * Set an array of maps containing variable term -> constant term mapping expected in the result
117: * at this position.
118: * Can be null indicating that this condition will not be checked in this test case.
119: * @param expectedReplacements The expectedReplacements to set.
120: */
121: public void setExpectedReplacements(
122: java.util.Map[] expectedReplacements);
123:
124: /**
125: * Indicates whether a test case must yield true.
126: * Only used if the query is ground (does not have variables).
127: * @return Returns the mustBeTrue.
128: */
129: public boolean isMustBeTrue();
130:
131: /**
132: * Sets whether a test case must yield true.
133: * Only used if the query is ground (does not have variables).
134: * @param mustBeTrue The mustBeTrue to set.
135: */
136: public void setMustBeTrue(boolean mustBeTrue);
137:
138: /**
139: * Set the policy to add an assumption.
140: * @param policy the (encoded) policy = one of the constants defined in TestCase
141: */
142: public void setPolicyToAddAssumptionsToKB(int policy);
143:
144: /**
145: * Get the policy to add an assumption.
146: * @return an integer, the (encoded) policy = one of the constants defined in TestCase
147: */
148: public int getPolicyToAddAssumptionsToKB();
149:
150: }
|