aboutsummaryrefslogtreecommitdiff
path: root/rsTester/src/test
diff options
context:
space:
mode:
authorGravatar Benjamin Jones <bjones@galois.com>2012-11-12 17:34:28 -0800
committerGravatar Benjamin Jones <bjones@galois.com>2012-11-12 17:34:28 -0800
commit5d4e0e6e486982d3bcd9ee600c286714296d3816 (patch)
treeaf1772d12c55bfd6e74d811f7524e862158b8baf /rsTester/src/test
parent561cea3b871085e5d268118124a641c9d912f2f8 (diff)
added new unit test
Diffstat (limited to 'rsTester/src/test')
-rw-r--r--rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java52
1 files changed, 47 insertions, 5 deletions
diff --git a/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java b/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java
index d9fd3dc..8f69e82 100644
--- a/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java
+++ b/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java
@@ -24,26 +24,68 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
+/**
+ * Test parsing of RuleSet and Rule objects using the built-in parse methods
+ * of both classes.
+ * <p>
+ * Currently there are tests for parsing rule sets containing 0, 1, and 2
+ * rules.
+ *
+ */
public class RuleSetTest {
+
+ /**
+ * Test parsing a rule set containing no rules.
+ *
+ * @throws AssertionError
+ */
@Test
- public void testParseNoFns() {
+ public void testParseNoRule() {
testParse("the name", "a descr", "[]", new ArrayList<Rule>());
}
+ /**
+ * Test parsing a rule set containing one rule.
+ *
+ * @throws AssertionError
+ */
@Test
- public void testParseOneFn() {
+ public void testParseOneRule() {
String str = "[{'name':'a', 'description':'b', 'id':1, 'rule':function () {}}]";
List<Rule> rules = ImmutableList.of(new Rule("a", "b", "function () {}", 1));
testParse("the name", "a descr", str, rules);
}
+ /**
+ * Test parsing a rule set containing two distinct rules.
+ *
+ * @throws AssertionError
+ */
+ @Test
+ public void testParseTwoRule() {
+ String str = "[{'name':'a', 'description':'b', 'id':1, 'rule':function () {}},"
+ + " {'name':'c', 'description':'d', 'id':2, 'rule':function () {}}]";
+ List<Rule> rules = ImmutableList.of(new Rule("a", "b", "function () {}", 1),
+ new Rule("c", "d", "function () {}", 2));
+ testParse("the name", "a descr", str, rules);
+ }
+
+ /**
+ * Helper function for parsing unit tests.
+ * <p>
+ * testParse takes a String name, description, and list of rules and constructs
+ * a RuleSet object using RuleSet.parse. This object is compared to the given
+ * oracle.
+ *
+ * @param name name of the rule set
+ * @param desc description of the ruleset
+ * @param rules a string representing a list of rules
+ * @param rulesOracle list of Rule objects
+ */
private void testParse(String name, String desc, String rules, List<Rule> rulesOracle) {
RuleSet rs = RuleSet.parse("{ 'name': '" +name+"'" +
", 'description': '"+desc+"'" +