UT-Part 6 with overall coverage upto 45%

Change-Id: I4960bae8429ae34d88a2f98f288f72d582f9e788
diff --git a/internal/pkg/controller/controller_test.go b/internal/pkg/controller/controller_test.go
index 2c4b993..235bffe 100644
--- a/internal/pkg/controller/controller_test.go
+++ b/internal/pkg/controller/controller_test.go
@@ -23,6 +23,7 @@
 	"voltha-go-controller/internal/pkg/intf"
 	"voltha-go-controller/internal/pkg/of"
 	"voltha-go-controller/internal/pkg/tasks"
+	"voltha-go-controller/internal/pkg/util"
 	"voltha-go-controller/internal/pkg/vpagent"
 	"voltha-go-controller/internal/test/mocks"
 
@@ -946,7 +947,7 @@
 	type args struct {
 		device string
 	}
-	rebootInProgressDevices := map[string]string{}
+	rebootInProgressdevices := map[string]string{}
 	device := &Device{
 		ctx: context.Background(),
 		ID:  "SDX6320031",
@@ -976,7 +977,7 @@
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			v := &VoltController{
-				rebootInProgressDevices: rebootInProgressDevices,
+				rebootInProgressDevices: rebootInProgressdevices,
 				devices:                 dev,
 			}
 			switch tt.name {
@@ -997,12 +998,12 @@
 	type args struct {
 		device string
 	}
-	rebootInProgressDevices := map[string]string{}
+	rebootInProgressdevices := map[string]string{}
 	device := &Device{
 		ctx: context.Background(),
 		ID:  "SDX6320031",
 	}
-	rebootInProgressDevices["SDX6320031"] = "done"
+	rebootInProgressdevices["SDX6320031"] = "done"
 	dev := map[string]*Device{}
 	dev["SDX6320031"] = device
 	tests := []struct {
@@ -1021,7 +1022,7 @@
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			v := &VoltController{
-				rebootInProgressDevices: rebootInProgressDevices,
+				rebootInProgressDevices: rebootInProgressdevices,
 				devices:                 dev,
 			}
 			if got := v.ReSetRebootInProgressForDevice(tt.args.device); got != tt.want {
@@ -1030,3 +1031,201 @@
 		})
 	}
 }
+
+func TestVoltController_IsBlockedDevice(t *testing.T) {
+	type args struct {
+		deviceserialNumber string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		{
+			name: "IsBlockedDevice",
+			args: args{
+				deviceserialNumber: "SDX6320031",
+			},
+			want: false,
+		},
+		{
+			name: "deviceserialNumber",
+			args: args{
+				deviceserialNumber: "SDX6320031",
+			},
+			want: false,
+		},
+		{
+			name: "AddBlockeddevices",
+			args: args{
+				deviceserialNumber: "SDX6320031",
+			},
+			want: false,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			v := &VoltController{
+				BlockedDeviceList: util.NewConcurrentMap(),
+			}
+			switch tt.name {
+			case "IsBlockedDevice":
+				if got := v.IsBlockedDevice(tt.args.deviceserialNumber); got != tt.want {
+					t.Errorf("VoltController.IsBlockedDevice() = %v, want %v", got, tt.want)
+				}
+			case "deviceserialNumber":
+				v.DelBlockedDevices(tt.args.deviceserialNumber)
+			case "AddBlockeddevices":
+				v.AddBlockedDevices(tt.args.deviceserialNumber)
+			}
+		})
+	}
+}
+
+func TestVoltController_SetDeviceTableSyncDuration(t *testing.T) {
+	type args struct {
+		duration int
+	}
+	tests := []struct {
+		name string
+		args args
+	}{
+		{
+			name: "SetDeviceTableSyncDuration",
+			args: args{
+				duration: 1,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			v := &VoltController{}
+			switch tt.name {
+			case "SetDeviceTableSyncDuration":
+				v.SetDeviceTableSyncDuration(tt.args.duration)
+				v.GetDeviceTableSyncDuration()
+			}
+		})
+	}
+}
+
+func TestVoltController_IsRebootInProgressForDevice(t *testing.T) {
+	type args struct {
+		device string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		{
+			name: "SetDeviceTableSyncDuration",
+			args: args{
+				device: "SDX6320031",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			v := &VoltController{}
+			if got := v.IsRebootInProgressForDevice(tt.args.device); got != tt.want {
+				t.Errorf("VoltController.IsRebootInProgressForDevice() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestVoltController_GroupUpdate(t *testing.T) {
+	type args struct {
+		port   string
+		device string
+		group  *of.Group
+	}
+	portsByName := map[string]*DevicePort{}
+	portsByName["SDX6320031-1"] = &DevicePort{
+		Name: "SDX6320031-1",
+		ID:   256,
+	}
+	device := &Device{
+		ctx:         context.Background(),
+		ID:          "SDX6320031",
+		groups:      sync.Map{},
+		PortsByName: portsByName,
+	}
+	dev := map[string]*Device{}
+	dev["SDX6320031"] = device
+	grp := &of.Group{
+		Device:  "SDX6320031",
+		GroupID: uint32(256),
+		State:   1,
+		SetVlan: of.VlanAny,
+	}
+	dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+	db = dbintf
+	dbintf.EXPECT().PutGroup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
+	tests := []struct {
+		name    string
+		args    args
+		wantErr bool
+	}{
+		{
+			name: "GroupUpdate",
+			args: args{
+				port:   "SDX6320031-1",
+				device: "SDX6320031",
+				group:  grp,
+			},
+			wantErr: false,
+		},
+		{
+			name: "DeviceNOtFound_Error",
+			args: args{
+				device: "SDX632003134",
+			},
+			wantErr: true,
+		},
+		{
+			name: "PortNOtFound_Error",
+			args: args{
+				device: "SDX6320031",
+				port:   "SDX632003134",
+			},
+			wantErr: true,
+		},
+		{
+			name: "ContextNill_Error",
+			args: args{
+				device: "SDX6320031",
+				port:   "SDX6320031-1",
+			},
+			wantErr: true,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			switch tt.name {
+			case "GroupUpdate", "DeviceNOtFound_Error", "PortNOtFound_Error":
+				v := &VoltController{
+					devices: dev,
+				}
+				if err := v.GroupUpdate(tt.args.port, tt.args.device, tt.args.group); (err != nil) != tt.wantErr {
+					t.Errorf("VoltController.GroupUpdate() error = %v, wantErr %v", err, tt.wantErr)
+				}
+			case "ContextNill_Error":
+				device := &Device{
+					ID:          "SDX6320031",
+					groups:      sync.Map{},
+					PortsByName: portsByName,
+				}
+				dev := map[string]*Device{}
+				dev["SDX6320031"] = device
+				v := &VoltController{
+					devices: dev,
+				}
+				if err := v.GroupUpdate(tt.args.port, tt.args.device, tt.args.group); (err != nil) != tt.wantErr {
+					t.Errorf("VoltController.GroupUpdate() error = %v, wantErr %v", err, tt.wantErr)
+				}
+			}
+		})
+	}
+}