Implement a setter and a getter of the conflict detection policy for flow manager.

- Currently, the flow manager accepts FREE policy only.
- This work is a part of ONOS-1759.

Change-Id: I20fb9288ca5ab60577c573cb9aaa5aa1583ded1d
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
index a1ca35e..0d56ad3 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
@@ -15,6 +15,15 @@
  * TODO: Make all methods thread-safe
  */
 public class FlowManagerModule implements IFlowManagerService {
+    private ConflictDetectionPolicy conflictDetectionPolicy;
+
+    /**
+     * Constructor.
+     */
+    public FlowManagerModule() {
+        this.conflictDetectionPolicy = ConflictDetectionPolicy.FREE;
+    }
+
     @Override
     public boolean addFlow(IFlow flow) {
         BatchOperation<IFlow> ops = new BatchOperation<IFlow>();
@@ -56,14 +65,17 @@
 
     @Override
     public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) {
-        // TODO Auto-generated method stub
-
+        if (policy == ConflictDetectionPolicy.FREE) {
+            conflictDetectionPolicy = policy;
+        } else {
+            throw new UnsupportedOperationException(
+                    policy.toString() + " is not supported.");
+        }
     }
 
     @Override
     public ConflictDetectionPolicy getConflictDetectionPolicy() {
-        // TODO Auto-generated method stub
-        return null;
+        return conflictDetectionPolicy;
     }
 
     @Override
diff --git a/src/test/java/net/onrc/onos/core/flowmanager/FlowManagerModuleTest.java b/src/test/java/net/onrc/onos/core/flowmanager/FlowManagerModuleTest.java
new file mode 100644
index 0000000..3467812
--- /dev/null
+++ b/src/test/java/net/onrc/onos/core/flowmanager/FlowManagerModuleTest.java
@@ -0,0 +1,51 @@
+package net.onrc.onos.core.flowmanager;
+
+import static org.junit.Assert.assertEquals;
+import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class FlowManagerModuleTest {
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    /**
+     * Checks the default conflict detection policy is the FREE policy, and
+     * the other policies are not supported.
+     */
+    @Test
+    public void testConflictDetectionPolicy() {
+        FlowManagerModule flowManager = new FlowManagerModule();
+        assertEquals(ConflictDetectionPolicy.FREE,
+                flowManager.getConflictDetectionPolicy());
+
+        flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.FREE);
+        assertEquals(ConflictDetectionPolicy.FREE,
+                flowManager.getConflictDetectionPolicy());
+
+        thrown.expect(UnsupportedOperationException.class);
+        thrown.expectMessage("LOOSE is not supported.");
+        flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.LOOSE);
+        assertEquals(ConflictDetectionPolicy.FREE,
+                flowManager.getConflictDetectionPolicy());
+
+        thrown.expect(UnsupportedOperationException.class);
+        thrown.expectMessage("STRICT is not supported.");
+        flowManager.setConflictDetectionPolicy(ConflictDetectionPolicy.STRICT);
+        assertEquals(ConflictDetectionPolicy.FREE,
+                flowManager.getConflictDetectionPolicy());
+    }
+
+}