Switch to MD-SAL APIs
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowPluginBulkGroupTransactionProvider.java
index f352a7d7b65f758b44f63c27e4abf8a5f4b71ae1..e183029cf8509f69ad3e5ad76b5fe40db4cd91f2 100644 (file)
@@ -5,23 +5,19 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.test;
 
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
@@ -85,7 +81,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@@ -100,40 +95,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.M
-
+@SuppressWarnings("checkstyle:MethodName")
 public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvider {
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkGroupTransactionProvider.class);
-    private NodeBuilder testNode;
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
     private final BundleContext ctx;
-    private ProviderContext pc;
-    private FlowBuilder testFlow;
     private final String originalFlowName = "Foo";
     private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
-    private Registration listener1Reg;
-    private Registration listener2Reg;
-    private Group testGroup;
-    private Group testGroup2;
     private Node testNode12;
     private final String originalGroupName = "Foo";
-    private static NotificationService notificationService;
+    private final NotificationService notificationService;
 
-    public OpenflowPluginBulkGroupTransactionProvider(BundleContext ctx) {
+    public OpenflowPluginBulkGroupTransactionProvider(DataBroker dataBroker, NotificationService notificationService,
+            BundleContext ctx) {
+        this.dataBroker = dataBroker;
+        this.notificationService = notificationService;
         this.ctx = ctx;
     }
 
-    public void onSessionInitiated(ProviderContext session) {
-        pc = session;
-        notificationService = session.getSALService(NotificationService.class);
-        listener2Reg = notificationService.registerNotificationListener(nodeErrorListener);
-        dataBroker = session.getSALService(DataBroker.class);
+    public void init() {
+        notificationService.registerNotificationListener(nodeErrorListener);
         ctx.registerService(CommandProvider.class.getName(), this, null);
         createTestFlow(createTestNode(null), null, null);
     }
@@ -142,18 +128,17 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         if (nodeId == null) {
             nodeId = OpenflowpluginTestActivator.NODE_ID;
         }
-        NodeRef nodeOne = createNodeRef(nodeId);
         NodeBuilder builder = new NodeBuilder();
         builder.setId(new NodeId(nodeId));
-        builder.setKey(new NodeKey(builder.getId()));
-        testNode = builder;
+        builder.withKey(new NodeKey(builder.getId()));
         return builder;
     }
 
-    private static NodeRef createNodeRef(String string) {
-        NodeKey key = new NodeKey(new NodeId(string));
-        InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
-        return new NodeRef(path);
+    private void createTestNode() {
+        NodeBuilder builder = new NodeBuilder();
+        builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
+        builder.withKey(new NodeKey(builder.getId()));
+        testNode12 = builder.build();
     }
 
     @Override
@@ -161,9 +146,6 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         return "No help";
     }
 
-    /**
-     * @return
-     */
     private static MatchBuilder createMatch1() {
         MatchBuilder match = new MatchBuilder();
         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
@@ -180,9 +162,6 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         return match;
     }
 
-    /**
-     * @return
-     */
     private static InstructionsBuilder createDecNwTtlInstructions() {
         DecNwTtlBuilder ta = new DecNwTtlBuilder();
         DecNwTtl decNwTtl = ta.build();
@@ -190,7 +169,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
 
         // Add our drop action to a list
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         actionList.add(ab.build());
 
         // Create an Apply Action
@@ -200,20 +179,17 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         // Wrap our Apply Action in an Instruction
         InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-        ib.setKey(new InstructionKey(0));
+        ib.withKey(new InstructionKey(0));
         ib.setOrder(0);
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
-    /**
-     * @return
-     */
     private static MatchBuilder createMatch2() {
         MatchBuilder match = new MatchBuilder();
         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
@@ -230,9 +206,6 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         return match;
     }
 
-    /**
-     * @return
-     */
     private static MatchBuilder createMatch3() {
         MatchBuilder match = new MatchBuilder();
         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
@@ -251,7 +224,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
 
         // Add our drop action to a list
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         actionList.add(ab.build());
 
         // Create an Apply Action
@@ -264,18 +237,13 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
     private static MatchBuilder createEthernetMatch() {
-        MatchBuilder match = new MatchBuilder();
-
-        byte[] mask1 = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0};
-        byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0};
-
         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
         // match
         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
@@ -297,14 +265,12 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         // ethsrc.setMask(mask2);
 
         ethmatch.setEthernetSource(ethsrc.build());
+        MatchBuilder match = new MatchBuilder();
         match.setEthernetMatch(ethmatch.build());
         return match;
 
     }
 
-    /**
-     * @return
-     */
     private static InstructionsBuilder createMeterInstructions() {
 
         MeterBuilder aab = new MeterBuilder();
@@ -315,7 +281,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -323,7 +289,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
     private static InstructionsBuilder createAppyActionInstruction() {
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         ActionBuilder ab = new ActionBuilder();
         ControllerActionBuilder controller = new ControllerActionBuilder();
         controller.setMaxLength(5);
@@ -339,7 +305,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -347,12 +313,12 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
     private static InstructionsBuilder createAppyActionInstruction7() {
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         ActionBuilder ab = new ActionBuilder();
 
         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
-        VlanId a = new VlanId(4012);
-        vl.setVlanId(a);
+        VlanId vlanId = new VlanId(4012);
+        vl.setVlanId(vlanId);
         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
         actionList.add(ab.build());
         // Create an Apply Action
@@ -365,7 +331,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -373,7 +339,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
     private static InstructionsBuilder createAppyActionInstruction21() {
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         ActionBuilder ab = new ActionBuilder();
 
         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
@@ -390,7 +356,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -398,7 +364,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
     private static InstructionsBuilder createAppyActionInstruction2() {
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         ActionBuilder ab = new ActionBuilder();
 
         PushMplsActionBuilder push = new PushMplsActionBuilder();
@@ -415,7 +381,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -423,7 +389,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
     private static InstructionsBuilder createAppyActionInstruction3() {
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         ActionBuilder ab = new ActionBuilder();
 
         PushPbbActionBuilder pbb = new PushPbbActionBuilder();
@@ -440,7 +406,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -456,7 +422,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -543,7 +509,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
                 LOG.warn("flow type not understood: {}", flowType);
         }
 
-        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
         if (null == flow.isBarrier()) {
             flow.setBarrier(Boolean.FALSE);
         }
@@ -565,18 +531,21 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         // flow
         flow.setOutPort(outputPort);
 
-        flow.setKey(key);
+        flow.withKey(key);
         flow.setPriority(2);
         flow.setFlowName(originalFlowName + "X" + flowType);
-        testFlow = flow;
         return flow;
     }
 
     private short getTableId(String tableId) {
         short table = 2;
+        if (tableId == null) {
+            return table;
+        }
+
         try {
             table = Short.parseShort(tableId);
-        } catch (Exception ex) {
+        } catch (NumberFormatException ex) {
             // ignore exception and continue with default value
         }
 
@@ -617,16 +586,15 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
                 GroupBuilder group7 = createTestGroup("a3", "g1", "add", "6");
                 writeGroup(ci, group6.build(), group7.build());
                 break;
-
+            default:
+                break;
         }
-
     }
 
     private void createUserNode(String nodeRef) {
-        NodeRef nodeOne = createNodeRef(nodeRef);
         NodeBuilder builder = new NodeBuilder();
         builder.setId(new NodeId(nodeRef));
-        builder.setKey(new NodeKey(builder.getId()));
+        builder.withKey(new NodeKey(builder.getId()));
         testNode12 = builder.build();
     }
 
@@ -663,19 +631,13 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
                 GroupBuilder group7 = createTestGroup("a29", "g1", "modify", "6");
                 writeGroup(ci, group6.build(), group7.build());
                 break;
+            default:
+                break;
         }
     }
 
     private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
-    }
-
-    private void createTestNode() {
-        NodeRef nodeOne = createNodeRef(OpenflowpluginTestActivator.NODE_ID);
-        NodeBuilder builder = new NodeBuilder();
-        builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
-        builder.setKey(new NodeKey(builder.getId()));
-        testNode12 = builder.build();
+        return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
     }
 
     public void _removeGroups(CommandInterpreter ci) {
@@ -732,29 +694,28 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
                 GroupBuilder group15 = createTestGroup("a29", "g1", "modify", "6");
                 writeGroup(ci, group14.build(), group15.build());
                 break;
-
+            default:
+                break;
         }
-
     }
 
     private void writeGroup(final CommandInterpreter ci, Group group, Group group1) {
         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
 
         InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
                 .child(Group.class, new GroupKey(group.getGroupId()));
         modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
         modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true);
 
         InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
                 .child(Group.class, new GroupKey(group1.getGroupId()));
         modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
         modification.merge(LogicalDatastoreType.CONFIGURATION, path2, group1, true);
-        CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
-        Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+        modification.commit().addCallback(new FutureCallback<Object>() {
             @Override
-            public void onSuccess(Void aVoid) {
+            public void onSuccess(Object notUsed) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
@@ -762,25 +723,24 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
             public void onFailure(Throwable throwable) {
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
-        });
+        }, MoreExecutors.directExecutor());
     }
 
     private void deleteGroup(final CommandInterpreter ci, Group group, Group group1) {
         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
         InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
                 .child(Group.class, new GroupKey(group.getGroupId()));
         modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
         modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
         InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
+                .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
                 .child(Group.class, new GroupKey(group1.getGroupId()));
         modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
         modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
-        CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
-        Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+        modification.commit().addCallback(new FutureCallback<Object>() {
             @Override
-            public void onSuccess(Void aVoid) {
+            public void onSuccess(Object notUsed) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
@@ -788,31 +748,25 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
             public void onFailure(Throwable throwable) {
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
-        });
+        }, MoreExecutors.directExecutor());
     }
 
-    private GroupBuilder createTestGroup(String actiontype, String type, String mod, String iD) {
+    private GroupBuilder createTestGroup(String actionType, String groupType, String groupmod, String strId) {
         // Sample data , committing to DataStore
 
-        String GroupType = type;
-        String ActionType = actiontype;
-        String Groupmod = mod;
-
-        long id = Long.parseLong(iD);
-        GroupKey key = new GroupKey(new GroupId(id));
         GroupBuilder group = new GroupBuilder();
         BucketBuilder bucket = new BucketBuilder();
         bucket.setBucketId(new BucketId((long) 12));
-        bucket.setKey(new BucketKey(new BucketId((long) 12)));
+        bucket.withKey(new BucketKey(new BucketId((long) 12)));
 
-        if (GroupType == null) {
-            GroupType = "g1";
+        if (groupType == null) {
+            groupType = "g1";
         }
-        if (ActionType == null) {
-            ActionType = "a1";
+        if (actionType == null) {
+            actionType = "a1";
         }
 
-        switch (GroupType) {
+        switch (groupType) {
             case "g1":
                 group.setGroupType(GroupTypes.GroupSelect);
                 break;
@@ -825,9 +779,11 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
             case "g4":
                 group.setGroupType(GroupTypes.GroupFf);
                 break;
+            default:
+                break;
         }
 
-        switch (ActionType) {
+        switch (actionType) {
             case "a1":
                 bucket.setAction(createPopVlanAction());
                 break;
@@ -844,8 +800,6 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
                 bucket.setAction(createPopPbbAction());
                 break;
             case "a6":
-                bucket.setAction(createPushPbbAction());
-                break;
             case "a7":
                 bucket.setAction(createPushPbbAction());
                 break;
@@ -864,10 +818,11 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
             case "a29":
                 bucket.setAction(createNonAppyPushVlanAction());
                 break;
-
+            default:
+                break;
         }
 
-        if (Groupmod == "add") {
+        if ("add".equals(groupmod)) {
             bucket.setWatchGroup((long) 14);
             bucket.setWatchPort((long) 1234);
             bucket.setWeight(50);
@@ -876,17 +831,19 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
             bucket.setWatchPort((long) 134);
             bucket.setWeight(30);
         }
-        group.setKey(key);
+
+        long id = Long.parseLong(strId);
+        GroupKey key = new GroupKey(new GroupId(id));
+        group.withKey(key);
         // group.setInstall(false);
         group.setGroupId(new GroupId(id));
         group.setGroupName(originalGroupName);
         group.setBarrier(false);
         BucketsBuilder value = new BucketsBuilder();
-        List<Bucket> value1 = new ArrayList<Bucket>();
+        List<Bucket> value1 = new ArrayList<>();
         value1.add(bucket.build());
         value.setBucket(value1);
         group.setBuckets(value.build());
-        testGroup = group.build();
         return group;
     }
 
@@ -894,8 +851,8 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         PopVlanActionBuilder vlanAction = new PopVlanActionBuilder();
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(vlanAction.build()).build());
-        action.setKey(new ActionKey(0));
-        List<Action> actions = new ArrayList<Action>();
+        action.withKey(new ActionKey(0));
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -903,11 +860,11 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
     private List<Action> createPushVlanAction() {
         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
         vlan.setEthernetType(0x8100);
-        VlanId v = new VlanId(2);
-        vlan.setVlanId(v);
+        VlanId vlanId = new VlanId(2);
+        vlan.setVlanId(vlanId);
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -917,7 +874,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         push.setEthernetType(0x8847);
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -927,7 +884,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         popMplsActionBuilder.setEthernetType(0XB);
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -936,7 +893,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -946,7 +903,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         pbb.setEthernetType(0x88E7);
         ActionBuilder action = new ActionBuilder();
         action.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -955,7 +912,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
         ActionBuilder action = new ActionBuilder();
         action.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -964,7 +921,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
         ActionBuilder action = new ActionBuilder();
         action.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -973,7 +930,7 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
         ActionBuilder action = new ActionBuilder();
         action.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
-        List<Action> actions = new ArrayList<Action>();
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
@@ -985,24 +942,24 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid
         groupActionB.setGroup("0");
         ActionBuilder action = new ActionBuilder();
         action.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
-        action.setKey(new ActionKey(0));
-        List<Action> actions = new ArrayList<Action>();
+        action.withKey(new ActionKey(0));
+        List<Action> actions = new ArrayList<>();
         actions.add(action.build());
         return actions;
     }
 
     private static List<Action> createNonAppyPushVlanAction() {
 
-        List<Action> actionList = new ArrayList<Action>();
         ActionBuilder ab = new ActionBuilder();
 
         GroupActionBuilder groupActionB = new GroupActionBuilder();
         groupActionB.setGroupId(1L);
         groupActionB.setGroup("0");
         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
+
+        List<Action> actionList = new ArrayList<>();
         actionList.add(ab.build());
 
         return actionList;
     }
-
 }