[ONOS-2225] Add codecs with unit test for FlowObjective REST API

* Add codec for FilteringObjective
* Add codec for ForwardingObjective
* Add codec for NextObjective

Change-Id: I715aa7f1969697468692459052fd27cc65ca2363
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/ForwardingObjectiveJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/ForwardingObjectiveJsonMatcher.java
new file mode 100644
index 0000000..9c9054b
--- /dev/null
+++ b/core/common/src/test/java/org/onosproject/codec/impl/ForwardingObjectiveJsonMatcher.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.codec.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.onosproject.net.flowobjective.ForwardingObjective;
+
+/**
+ * Hamcrest matcher for forwardingObjective.
+ */
+public final class ForwardingObjectiveJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> {
+
+    final ForwardingObjective forwardingObjective;
+
+    private ForwardingObjectiveJsonMatcher(ForwardingObjective forwardingObjective) {
+        this.forwardingObjective = forwardingObjective;
+    }
+
+    @Override
+    protected boolean matchesSafely(JsonNode jsonForwardingObj, Description description) {
+
+        ObjectiveJsonMatcher.matchesObjective(forwardingObjective).matchesSafely(jsonForwardingObj);
+
+        // check id
+        int jsonId = jsonForwardingObj.get("id").asInt();
+        int id = forwardingObjective.id();
+        if (jsonId != id) {
+            description.appendText("id was " + jsonId);
+            return false;
+        }
+
+        // check nextId
+        int jsonNextId = jsonForwardingObj.get("nextId").asInt();
+        int nextId = forwardingObjective.nextId();
+        if (jsonNextId != nextId) {
+            description.appendText("nextId was " + jsonNextId);
+            return false;
+        }
+
+        // check flag
+        String jsonFlag = jsonForwardingObj.get("flag").asText();
+        String flag = forwardingObjective.flag().toString();
+        if (!jsonFlag.equals(flag)) {
+            description.appendText("flag was " + jsonFlag);
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(forwardingObjective.toString());
+    }
+
+    /**
+     * Factory to allocate a forwardingObjective matcher.
+     *
+     * @param forwardingObjective forwardingObjective object we are looking for
+     * @return matcher
+     */
+    public static ForwardingObjectiveJsonMatcher matchesForwardingObjective(ForwardingObjective forwardingObjective) {
+        return new ForwardingObjectiveJsonMatcher(forwardingObjective);
+    }
+}