Add unit test code for ErrorIntent and IntentOperation class.
Change-Id: Id87e1b01b8aeed25c1e8e87e947d1cf864571388
diff --git a/src/test/java/net/onrc/onos/intent/ErrorIntentTest.java b/src/test/java/net/onrc/onos/intent/ErrorIntentTest.java
new file mode 100644
index 0000000..c10b9b5
--- /dev/null
+++ b/src/test/java/net/onrc/onos/intent/ErrorIntentTest.java
@@ -0,0 +1,38 @@
+package net.onrc.onos.intent;
+
+import static org.junit.Assert.*;
+import net.onrc.onos.intent.ErrorIntent.ErrorType;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for the ErrorIntent class.
+ * @author Toshio Koide (t-koide@onlab.us)
+ */
+public class ErrorIntentTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test the result of executing constructor of the ErrorIntent class.
+ * This test checks the fields of id, errorType, message and parentIntent.
+ */
+ @Test
+ public void testCreate() {
+ Intent parentIntent = new Intent("1");
+ ErrorIntent errorIntent = new ErrorIntent(ErrorType.PATH_NOT_FOUND, "path not found", parentIntent);
+
+ assertEquals("1", errorIntent.getId());
+ assertEquals(ErrorType.PATH_NOT_FOUND, errorIntent.errorType);
+ assertEquals("path not found", errorIntent.message);
+ assertEquals(parentIntent, errorIntent.parentIntent);
+ }
+}
diff --git a/src/test/java/net/onrc/onos/intent/IntentOperationTest.java b/src/test/java/net/onrc/onos/intent/IntentOperationTest.java
new file mode 100644
index 0000000..807f5ba
--- /dev/null
+++ b/src/test/java/net/onrc/onos/intent/IntentOperationTest.java
@@ -0,0 +1,41 @@
+package net.onrc.onos.intent;
+
+import static org.junit.Assert.*;
+import net.onrc.onos.intent.IntentOperation.Operator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for the IntentOperation class.
+ * @author Toshio Koide (t-koide@onlab.us)
+ */
+public class IntentOperationTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test the result of executing constructor of the IntentOperation class.
+ * This test checks the id field and the operator field.
+ */
+ @Test
+ public void testCreate() {
+ IntentOperation op1 = new IntentOperation(Operator.ADD, new Intent("1"));
+ IntentOperation op2 = new IntentOperation(Operator.REMOVE, new Intent("2"));
+ IntentOperation op3 = new IntentOperation(Operator.ERROR, new Intent("3"));
+
+ assertEquals("1", op1.intent.getId());
+ assertEquals(Operator.ADD, op1.operator);
+ assertEquals("2", op2.intent.getId());
+ assertEquals(Operator.REMOVE, op2.operator);
+ assertEquals("3", op3.intent.getId());
+ assertEquals(Operator.ERROR, op3.operator);
+ }
+}