[CORD-2483] Mcast does not forward traffic to all the sinks

Rationale: if we add more than one sink a number
of sink add events are generated. For each event
we create a mcast path, right now we do not support
Mcast group editing. This means that a new nextobjective
will be created for each sink.

In particular, this patch enables the mcast group editing
to solve the following issue:

Sink1 arrives -> fwdObj A -> Next B (this has one output)
Sink2 arrives -> fwdObj A -> Next C (this has two outputs)

Next B and Next C shares a part of the chain. Reordering happens
during the creation of the Nexts:

Next C created -> flow A -> Group C
Next B created -> flow A -> Group B

Failure, traffic does not reach all the sinks. Other side effect is the
disalignment between SR app and flow/group because McastHandler believes
mcast group is associated to the Next C

It includes minor refactoring of the group handler

Change-Id: Ib59ba6b63ff411ed46ca8216677046a78cc92ac6
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
index 93730c7..bb215ae 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
@@ -804,9 +804,9 @@
         });
     }
 
-    private void createL3MulticastGroup(NextObjective nextObj, VlanId vlanId,
-                                        List<GroupInfo> groupInfos) {
+    private List<GroupBucket> createL3MulticastBucket(List<GroupInfo> groupInfos) {
         List<GroupBucket> l3McastBuckets = new ArrayList<>();
+        // For each inner group
         groupInfos.forEach(groupInfo -> {
             // Points to L3 interface group if there is one.
             // Otherwise points to L2 interface group directly.
@@ -817,6 +817,15 @@
             GroupBucket abucket = DefaultGroupBucket.createAllGroupBucket(ttb.build());
             l3McastBuckets.add(abucket);
         });
+        // Done return the new list of buckets
+        return l3McastBuckets;
+    }
+
+
+    private void createL3MulticastGroup(NextObjective nextObj, VlanId vlanId,
+                                        List<GroupInfo> groupInfos) {
+        // Let's create a new list mcast buckets
+        List<GroupBucket> l3McastBuckets = createL3MulticastBucket(groupInfos);
 
         int l3MulticastIndex = getNextAvailableIndex();
         int l3MulticastGroupId = L3_MULTICAST_TYPE |
@@ -1337,18 +1346,8 @@
                                              List<Deque<GroupKey>> allActiveKeys,
                                              List<GroupInfo> groupInfos,
                                              VlanId assignedVlan) {
-        // create the buckets to add to the outermost L3 Multicast group
-        List<GroupBucket> newBuckets = Lists.newArrayList();
-        groupInfos.forEach(groupInfo -> {
-            // Points to L3 interface group if there is one.
-            // Otherwise points to L2 interface group directly.
-            GroupDescription nextGroupDesc = (groupInfo.nextGroupDesc() != null) ?
-                    groupInfo.nextGroupDesc() : groupInfo.innerMostGroupDesc();
-            TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
-            treatmentBuilder.group(new GroupId(nextGroupDesc.givenGroupId()));
-            GroupBucket newBucket = DefaultGroupBucket.createAllGroupBucket(treatmentBuilder.build());
-            newBuckets.add(newBucket);
-        });
+        // Create the buckets to add to the outermost L3 Multicast group
+        List<GroupBucket> newBuckets = createL3MulticastBucket(groupInfos);
 
         // get the group being edited
         Group l3mcastGroup = retrieveTopLevelGroup(allActiveKeys, nextObj.id());