@Override
    public void performGroupOperation(DeviceId deviceId, GroupOperations groupOps) {
        final Dpid dpid = Dpid.dpid(deviceId.uri());
        OpenFlowSwitch sw = controller.getSwitch(dpid);
        for (GroupOperation groupOperation: groupOps.operations()) {
            if (sw == null) {
                log.error("SW {} is not found", dpid);
                return;
            }

            switch (groupOperation.groupType()) {
                case SELECT:
                case INDIRECT:
                case ALL:
                case FAILOVER:
                    break;
                case CLONE:
                default:
                    log.warn("Group type {} not supported, ignoring operation [{}]",
                             groupOperation.groupType(), groupOperation);
                    //  Next groupOperation.
                    continue;
            }

            final Long groupModXid = XID_COUNTER.getAndIncrement();
            GroupModBuilder builder = null;
            if (driverService == null) {
                builder = GroupModBuilder.builder(groupOperation.buckets(),
                                                groupOperation.groupId(),
                                                groupOperation.groupType(),
                                                sw.factory(),
                                                Optional.of(groupModXid));
            } else {
                builder = GroupModBuilder.builder(groupOperation.buckets(),
                                                  groupOperation.groupId(),
                                                  groupOperation.groupType(),
                                                  sw.factory(),
                                                  Optional.of(groupModXid),
                                                  Optional.of(driverService));
            }
            OFGroupMod groupMod = null;
            switch (groupOperation.opType()) {
                case ADD:
                    groupMod = builder.buildGroupAdd();
                    break;
                case MODIFY:
                    groupMod = builder.buildGroupMod();
                    break;
                case DELETE:
                    groupMod = builder.buildGroupDel();
                    break;
                default:
                    log.error("Unsupported Group operation");
                    return;
            }
            sw.sendMsg(groupMod);
            GroupId groudId = new GroupId(groupMod.getGroup().getGroupNumber());
            pendingGroupOperations.put(groudId, groupOperation);
            pendingXidMaps.put(groudId, groupModXid);
        }
     }
@Test
    public void addGroup() {

        GroupId groupId = new GroupId(1);

        List<GroupBucket> bucketList = Lists.newArrayList();
        TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
        builder.setOutput(PortNumber.portNumber(1));
        GroupBucket bucket =
                DefaultGroupBucket.createSelectGroupBucket(builder.build());
        bucketList.add(bucket);
        GroupBuckets buckets = new GroupBuckets(bucketList);

        List<GroupOperation> operationList = Lists.newArrayList();
        GroupOperation operation = GroupOperation.createAddGroupOperation(groupId,
                GroupDescription.Type.SELECT, buckets);
        operationList.add(operation);
        GroupOperations operations = new GroupOperations(operationList);

        provider.performGroupOperation(deviceId, operations);

        final Dpid dpid = Dpid.dpid(deviceId.uri());
        TestOpenFlowSwitch sw = (TestOpenFlowSwitch) controller.getSwitch(dpid);
        assertNotNull("Switch should not be nul", sw);
        assertNotNull("OFGroupMsg should not be null", sw.msg);

    }