adding support of WCMP weights to Next Objective

Change-Id: Id8f9a4222d0d9d98995f727dbfbf467ab2104468
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveCodecTest.java
index 355209f..fb4f1e8 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveCodecTest.java
@@ -26,7 +26,9 @@
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flowobjective.DefaultNextObjective;
+import org.onosproject.net.flowobjective.DefaultNextTreatment;
 import org.onosproject.net.flowobjective.NextObjective;
+import org.onosproject.net.flowobjective.NextTreatment;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -70,6 +72,7 @@
     public void testNextObjectiveEncode() {
 
         TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
+        NextTreatment nextTreatment = DefaultNextTreatment.of(treatment, 5);
 
         NextObjective nextObj = DefaultNextObjective.builder()
                 .makePermanent()
@@ -77,7 +80,7 @@
                 .fromApp(APP_ID)
                 .withPriority(60)
                 .withId(5)
-                .addTreatment(treatment)
+                .addTreatment(nextTreatment)
                 .add();
 
         ObjectNode nextObjJson = nextObjectiveCodec.encode(nextObj, context);
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveJsonMatcher.java
index bb86771..cdf4da9 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveJsonMatcher.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/NextObjectiveJsonMatcher.java
@@ -16,9 +16,13 @@
 package org.onosproject.codec.impl;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.hamcrest.Description;
 import org.hamcrest.TypeSafeDiagnosingMatcher;
 import org.onosproject.net.flowobjective.NextObjective;
+import org.onosproject.net.flowobjective.NextTreatment;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Hamcrest matcher for nextObjective.
@@ -58,6 +62,22 @@
             return false;
         }
 
+        // check the weight
+        boolean result = true;
+        List<NextTreatment> nt = new ArrayList(nextObjective.nextTreatments());
+        for (int i = 0; i < jsonTreatments.size(); i++) {
+            ObjectNode jsonTreatment = jsonTreatments.path(i).isObject() &&
+                    !jsonTreatments.path(i).isNull() ? (ObjectNode) jsonTreatments.path(i) : null;
+            int jsonWeight = jsonTreatment.get("weight").asInt();
+            if (jsonWeight != nt.get(i).weight()) {
+                description.appendText("weight of NextTreatment with index " + i + " was " + jsonWeight);
+                result = false;
+            }
+        }
+        if (!result) {
+            return false;
+        }
+
         // TODO: need to check the content of treatment collection
 
         // TODO: need to check the content of selector instance