Implement serialization/deserialization feature for each Intent classes

Change-Id: I63db34914d8df76d5a000831da1e03e03383e62f
diff --git a/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java b/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java
new file mode 100644
index 0000000..8160ca8
--- /dev/null
+++ b/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java
@@ -0,0 +1,42 @@
+package net.onrc.onos.intent;
+
+import static org.junit.Assert.*;
+import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConstrainedShortestPathIntentTest {
+	NetworkGraph g;
+
+	@Before
+	public void setUp() throws Exception {
+		MockNetworkGraph graph = new MockNetworkGraph();
+		graph.createSampleTopology();
+		g = graph;
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void test() {
+		ConstrainedShortestPathIntent intent1 =
+				new ConstrainedShortestPathIntent(g, "1", 1L, 20L, 1L, 4L, 20L, 4L, 1000.0);
+
+		byte b[] = intent1.toBytes();
+
+		ConstrainedShortestPathIntent intent2 =
+				ConstrainedShortestPathIntent.fromBytes(g, b);
+
+		assertEquals("1", intent2.getId());
+		assertEquals(Long.valueOf(1), intent2.getSourcePort().getSwitch().getDpid());
+		assertEquals(Long.valueOf(20), intent2.getSourcePort().getNumber());
+		assertEquals(1L, intent2.getSourceMac().toLong());
+		assertEquals(Long.valueOf(4), intent2.getDestinationPort().getSwitch().getDpid());
+		assertEquals(Long.valueOf(20), intent2.getDestinationPort().getNumber());
+		assertEquals(4L, intent2.getDestinationMac().toLong());
+		assertEquals(Double.valueOf(1000.0), intent2.getBandwidth());
+	}
+}