VOL-2640 Restructure openolt-adapter repo to best practices

Change-Id: Icead31e8ecb82ec75a22e66361fbf83f80136589
diff --git a/pkg/mocks/mockAdapterProxy.go b/pkg/mocks/mockAdapterProxy.go
new file mode 100644
index 0000000..817e675
--- /dev/null
+++ b/pkg/mocks/mockAdapterProxy.go
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"context"
+	"errors"
+
+	"github.com/golang/protobuf/proto"
+	"github.com/opencord/voltha-protos/v3/go/inter_container"
+)
+
+// MockAdapterProxy mocks the AdapterProxy interface.
+type MockAdapterProxy struct {
+}
+
+// SendInterAdapterMessage mocks SendInterAdapterMessage function.
+func (ma *MockAdapterProxy) SendInterAdapterMessage(ctx context.Context,
+	msg proto.Message,
+	msgType inter_container.InterAdapterMessageType_Types,
+	fromAdapter string,
+	toAdapter string,
+	toDeviceID string,
+	proxyDeviceID string,
+	messageID string) error {
+	if toDeviceID == "" {
+		return errors.New("no deviceid")
+	}
+	return nil
+}
diff --git a/pkg/mocks/mockCoreProxy.go b/pkg/mocks/mockCoreProxy.go
new file mode 100644
index 0000000..9c99599
--- /dev/null
+++ b/pkg/mocks/mockCoreProxy.go
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"context"
+	"errors"
+	"fmt"
+
+	"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
+	"github.com/opencord/voltha-protos/v3/go/voltha"
+)
+
+// MockCoreProxy mocks the CoreProxy interface
+type MockCoreProxy struct {
+	// Values to be used in test can reside inside this structure
+	// TODO store relevant info in this, use this info for negative and positive tests
+	Devices map[string]*voltha.Device
+}
+
+// UpdateCoreReference mock updatesCoreReference
+func (mcp *MockCoreProxy) UpdateCoreReference(deviceID string, coreReference string) {
+	panic("implement me")
+}
+
+// DeleteCoreReference mock DeleteCoreReference function
+func (mcp *MockCoreProxy) DeleteCoreReference(deviceID string) {
+	panic("implement me")
+}
+
+// GetCoreTopic implements mock GetCoreTopic
+func (mcp *MockCoreProxy) GetCoreTopic(deviceID string) kafka.Topic {
+	panic("implement me")
+}
+
+// GetAdapterTopic implements mock GetAdapterTopic
+func (mcp *MockCoreProxy) GetAdapterTopic(args ...string) kafka.Topic {
+	panic("implement me")
+}
+
+// RegisterAdapter implements mock RegisterAdapter
+func (mcp *MockCoreProxy) RegisterAdapter(ctx context.Context, adapter *voltha.Adapter,
+	deviceTypes *voltha.DeviceTypes) error {
+	if ctx == nil || adapter == nil || deviceTypes == nil {
+		return errors.New("registerAdapter func parameters cannot be nil")
+	}
+	return nil
+}
+
+// DeviceUpdate implements mock DeviceUpdate
+func (mcp *MockCoreProxy) DeviceUpdate(ctx context.Context, device *voltha.Device) error {
+	if device.Id == "" {
+		return errors.New("no Device")
+	}
+	return nil
+}
+
+// PortCreated implements mock PortCreated
+func (mcp *MockCoreProxy) PortCreated(ctx context.Context, deviceID string, port *voltha.Port) error {
+	if deviceID == "" {
+		return errors.New("no deviceID")
+	}
+	if port.Type > 7 {
+		return errors.New("invalid porttype")
+	}
+	return nil
+}
+
+// PortsStateUpdate implements mock PortsStateUpdate
+func (mcp *MockCoreProxy) PortsStateUpdate(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types) error {
+	if deviceID == "" {
+		return errors.New("no Device")
+	}
+	return nil
+}
+
+// DeleteAllPorts implements mock DeleteAllPorts
+func (mcp *MockCoreProxy) DeleteAllPorts(ctx context.Context, deviceID string) error {
+	if deviceID == "" {
+		return errors.New("no Device id")
+	}
+	return nil
+}
+
+// DeviceStateUpdate implements mock DeviceStateUpdate
+func (mcp *MockCoreProxy) DeviceStateUpdate(ctx context.Context, deviceID string,
+	connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
+	if deviceID == "" {
+		return errors.New("no Device id")
+	}
+	return nil
+}
+
+// ChildDeviceDetected implements mock ChildDeviceDetected
+func (mcp *MockCoreProxy) ChildDeviceDetected(ctx context.Context, parentdeviceID string, parentPortNo int,
+	childDeviceType string, channelID int, vendorID string, serialNumber string, onuID int64) (*voltha.Device, error) {
+	if parentdeviceID == "" {
+		return nil, errors.New("no deviceID")
+	}
+	return nil, nil
+}
+
+// ChildDevicesLost implements mock ChildDevicesLost.
+func (mcp *MockCoreProxy) ChildDevicesLost(ctx context.Context, parentdeviceID string) error {
+	//panic("implement me")
+	if parentdeviceID == "" {
+		return errors.New("no device id")
+	}
+	return nil
+}
+
+// ChildDevicesDetected implements mock ChildDevicesDetecte
+func (mcp *MockCoreProxy) ChildDevicesDetected(ctx context.Context, parentdeviceID string) error {
+	if parentdeviceID == "" {
+		return errors.New("no device id")
+	}
+	return nil
+}
+
+// GetDevice implements mock GetDevice
+func (mcp *MockCoreProxy) GetDevice(ctx context.Context, parentdeviceID string, deviceID string) (*voltha.Device, error) {
+	if parentdeviceID == "" || deviceID == "" {
+		return &voltha.Device{}, errors.New("no deviceID")
+	}
+	for k, v := range mcp.Devices {
+		if k == "olt" {
+			return v, nil
+		}
+	}
+	return nil, errors.New("device detection failed")
+}
+
+// GetChildDevice implements mock GetChildDevice
+func (mcp *MockCoreProxy) GetChildDevice(ctx context.Context, parentdeviceID string, kwargs map[string]interface{}) (*voltha.Device, error) {
+
+	if parentdeviceID == "" {
+		return nil, errors.New("device detection failed")
+	}
+	onuID := kwargs["onu_id"]
+	var onuDevice *voltha.Device
+	for _, val := range mcp.Devices {
+		if val.GetId() == fmt.Sprintf("%v", onuID) {
+			onuDevice = val
+			break
+		}
+	}
+	if onuDevice != nil {
+		return onuDevice, nil
+	}
+	//return &voltha.Device{}, nil
+	return nil, errors.New("device detection failed")
+}
+
+// GetChildDevices implements mock GetChildDevices
+func (mcp *MockCoreProxy) GetChildDevices(ctx context.Context, parentdeviceID string) (*voltha.Devices, error) {
+	if parentdeviceID == "" {
+		return nil, errors.New("no deviceID")
+	}
+	onuDevices := make([]*voltha.Device, 0)
+
+	for _, val := range mcp.Devices {
+		if val != nil {
+			onuDevices = append(onuDevices, val)
+		}
+	}
+
+	deviceList := &voltha.Devices{Items: onuDevices}
+	if len(deviceList.Items) > 0 {
+		return deviceList, nil
+	}
+	return nil, errors.New("device detection failed")
+}
+
+// SendPacketIn  implements mock SendPacketIn
+func (mcp *MockCoreProxy) SendPacketIn(ctx context.Context, deviceID string, port uint32, pktPayload []byte) error {
+	if deviceID == "" {
+		return errors.New("no Device ID")
+	}
+	return nil
+}
+
+// DeviceReasonUpdate  implements mock SendPacketIn
+func (mcp *MockCoreProxy) DeviceReasonUpdate(ctx context.Context, deviceID string, reason string) error {
+	if deviceID == "" {
+		return errors.New("no Device ID")
+	}
+	return nil
+}
+
+// DevicePMConfigUpdate implements mock DevicePMConfigUpdate
+func (mcp *MockCoreProxy) DevicePMConfigUpdate(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
+	return nil
+}
+
+// PortStateUpdate implements mock PortStateUpdate
+func (mcp *MockCoreProxy) PortStateUpdate(ctx context.Context, deviceID string, pType voltha.Port_PortType, portNo uint32,
+	operStatus voltha.OperStatus_Types) error {
+	if deviceID == "" {
+		return errors.New("no Device")
+	}
+	return nil
+}
diff --git a/pkg/mocks/mockEventproxy.go b/pkg/mocks/mockEventproxy.go
new file mode 100644
index 0000000..d2621ab
--- /dev/null
+++ b/pkg/mocks/mockEventproxy.go
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"errors"
+
+	"github.com/opencord/voltha-protos/v3/go/voltha"
+)
+
+// MockEventProxy for mocking EventProxyIntf
+type MockEventProxy struct {
+}
+
+// SendDeviceEvent mocks the SendDeviceEvent function
+func (me *MockEventProxy) SendDeviceEvent(deviceEvent *voltha.DeviceEvent, category voltha.EventCategory_Types,
+	subCategory voltha.EventSubCategory_Types, raisedTs int64) error {
+	if raisedTs == 0 {
+		return errors.New("raisedTS cannot be zero")
+	}
+	return nil
+}
+
+// SendKpiEvent mocks the SendKpiEvent function
+func (me *MockEventProxy) SendKpiEvent(id string, deviceEvent *voltha.KpiEvent2, category voltha.EventCategory_Types,
+	subCategory voltha.EventSubCategory_Types, raisedTs int64) error {
+	if raisedTs == 0 {
+		return errors.New("raisedTS cannot be zero")
+	}
+	return nil
+}
diff --git a/pkg/mocks/mockKVClient.go b/pkg/mocks/mockKVClient.go
new file mode 100644
index 0000000..f686ec1
--- /dev/null
+++ b/pkg/mocks/mockKVClient.go
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"strconv"
+	"strings"
+	"time"
+
+	"github.com/opencord/voltha-lib-go/v3/pkg/log"
+	"github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
+
+	"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
+	ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
+	openolt "github.com/opencord/voltha-protos/v3/go/openolt"
+)
+
+const (
+	// MeterConfig meter to extarct meter
+	MeterConfig = "meter_id"
+	// TpIDPathSuffix to extract Techprofile
+	TpIDPathSuffix = "tp_id"
+	// FlowIDpool to extract Flow ids
+	FlowIDpool = "flow_id_pool"
+	// FlowIDs to extract flow_ids
+	FlowIDs = "flow_ids"
+	// FlowIDInfo  to extract flowId info
+	FlowIDInfo = "flow_id_info"
+	// GemportIDs to gemport_ids
+	GemportIDs = "gemport_ids"
+	// AllocIDs to extract alloc_ids
+	AllocIDs = "alloc_ids"
+	//FlowGroup flow_groups/<flow_group_id>
+	FlowGroup = "flow_groups"
+	//FlowGroupCached flow_groups_cached/<flow_group_id>
+	FlowGroupCached = "flow_groups_cached"
+)
+
+// MockKVClient mocks the AdapterProxy interface.
+type MockKVClient struct {
+}
+
+// List mock function implementation for KVClient
+func (kvclient *MockKVClient) List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error) {
+	if key != "" {
+		maps := make(map[string]*kvstore.KVPair)
+		maps[key] = &kvstore.KVPair{Key: key}
+		return maps, nil
+	}
+	return nil, errors.New("key didn't find")
+}
+
+// Get mock function implementation for KVClient
+func (kvclient *MockKVClient) Get(ctx context.Context, key string) (*kvstore.KVPair, error) {
+	log.Debugw("Warning Warning Warning: Get of MockKVClient called", log.Fields{"key": key})
+	if key != "" {
+		log.Debug("Warning Key Not Blank")
+		if strings.Contains(key, "meter_id/{0,62,8}/{upstream}") {
+			meterConfig := ofp.OfpMeterConfig{
+				Flags:   0,
+				MeterId: 1,
+			}
+			str, _ := json.Marshal(meterConfig)
+			return kvstore.NewKVPair(key, string(str), "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, MeterConfig) {
+			var bands []*ofp.OfpMeterBandHeader
+			bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DSCP_REMARK,
+				Rate: 1024, Data: &ofp.OfpMeterBandHeader_DscpRemark{DscpRemark: &ofp.OfpMeterBandDscpRemark{PrecLevel: 2}}})
+
+			bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DSCP_REMARK,
+				Rate: 1024, Data: &ofp.OfpMeterBandHeader_DscpRemark{DscpRemark: &ofp.OfpMeterBandDscpRemark{PrecLevel: 3}}})
+
+			sep := strings.Split(key, "/")[1]
+			val, _ := strconv.ParseInt(strings.Split(sep, ",")[1], 10, 32)
+			if uint32(val) > 1 {
+				meterConfig := &ofp.OfpMeterConfig{MeterId: uint32(val), Bands: bands}
+				str, _ := json.Marshal(meterConfig)
+
+				return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+			}
+
+			if strings.Contains(key, "meter_id/{1,1,1}/{downstream}") {
+
+				band1 := &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 1000, BurstSize: 5000}
+				band2 := &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 2000, BurstSize: 5000}
+				bands := []*ofp.OfpMeterBandHeader{band1, band2}
+				ofpMeterConfig := &ofp.OfpMeterConfig{Flags: 1, MeterId: 1, Bands: bands}
+				str, _ := json.Marshal(ofpMeterConfig)
+				return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+			}
+			if uint32(val) == 1 {
+				return nil, nil
+			}
+			return nil, errors.New("invalid meter")
+		}
+		if strings.Contains(key, TpIDPathSuffix) {
+			str, _ := json.Marshal(64)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, FlowIDpool) {
+			log.Debug("Error Error Error Key:", FlowIDpool)
+			data := make(map[string]interface{})
+			data["pool"] = "1024"
+			data["start_idx"] = 1
+			data["end_idx"] = 1024
+			str, _ := json.Marshal(data)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, FlowIDs) {
+			data := []uint32{1, 2}
+			log.Debug("Error Error Error Key:", FlowIDs)
+			str, _ := json.Marshal(data)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, FlowIDInfo) {
+
+			data := []resourcemanager.FlowInfo{
+				{
+					Flow:            &openolt.Flow{FlowId: 1, OnuId: 1, UniId: 1, GemportId: 1},
+					FlowStoreCookie: uint64(48132224281636694),
+					LogicalFlowID:   1,
+				},
+			}
+			log.Debug("Error Error Error Key:", FlowIDs)
+			str, _ := json.Marshal(data)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, GemportIDs) {
+			log.Debug("Error Error Error Key:", GemportIDs)
+			str, _ := json.Marshal(1)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, AllocIDs) {
+			log.Debug("Error Error Error Key:", AllocIDs)
+			str, _ := json.Marshal(1)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+		if strings.Contains(key, FlowGroup) || strings.Contains(key, FlowGroupCached) {
+			log.Debug("Error Error Error Key:", FlowGroup)
+			groupInfo := resourcemanager.GroupInfo{
+				GroupID:  2,
+				OutPorts: []uint32{1},
+			}
+			str, _ := json.Marshal(&groupInfo)
+			return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil
+		}
+
+		maps := make(map[string]*kvstore.KVPair)
+		maps[key] = &kvstore.KVPair{Key: key}
+		return maps[key], nil
+	}
+	return nil, errors.New("key didn't find")
+}
+
+// Put mock function implementation for KVClient
+func (kvclient *MockKVClient) Put(ctx context.Context, key string, value interface{}) error {
+	if key != "" {
+
+		return nil
+	}
+	return errors.New("key didn't find")
+}
+
+// Delete mock function implementation for KVClient
+func (kvclient *MockKVClient) Delete(ctx context.Context, key string) error {
+	if key == "" {
+		return errors.New("key didn't find")
+	}
+	return nil
+}
+
+// Reserve mock function implementation for KVClient
+func (kvclient *MockKVClient) Reserve(ctx context.Context, key string, value interface{}, ttl int64) (interface{}, error) {
+	if key != "" {
+		maps := make(map[string]*kvstore.KVPair)
+		maps[key] = &kvstore.KVPair{Key: key}
+		return maps[key], nil
+	}
+	return nil, errors.New("key didn't find")
+}
+
+// ReleaseReservation mock function implementation for KVClient
+func (kvclient *MockKVClient) ReleaseReservation(ctx context.Context, key string) error {
+	// return nil
+	if key == "" {
+		return errors.New("key didn't find")
+	}
+	return nil
+}
+
+// ReleaseAllReservations mock function implementation for KVClient
+func (kvclient *MockKVClient) ReleaseAllReservations(ctx context.Context) error {
+	return nil
+}
+
+// RenewReservation mock function implementation for KVClient
+func (kvclient *MockKVClient) RenewReservation(ctx context.Context, key string) error {
+	// return nil
+	if key == "" {
+		return errors.New("key didn't find")
+	}
+	return nil
+}
+
+// Watch mock function implementation for KVClient
+func (kvclient *MockKVClient) Watch(ctx context.Context, key string, withPrefix bool) chan *kvstore.Event {
+	return nil
+	// if key == "" {
+	// 	return nil
+	// }
+	// return &kvstore.Event{EventType: 1, Key: key}
+}
+
+// AcquireLock mock function implementation for KVClient
+func (kvclient *MockKVClient) AcquireLock(ctx context.Context, lockName string, timeout int) error {
+	return nil
+}
+
+// ReleaseLock mock function implementation for KVClient
+func (kvclient *MockKVClient) ReleaseLock(lockName string) error {
+	return nil
+}
+
+// IsConnectionUp mock function implementation for KVClient
+func (kvclient *MockKVClient) IsConnectionUp(ctx context.Context) bool {
+	// timeout in second
+	t, _ := ctx.Deadline()
+	if t.Second()-time.Now().Second() < 1 {
+		return false
+	}
+	return true
+}
+
+// CloseWatch mock function implementation for KVClient
+func (kvclient *MockKVClient) CloseWatch(key string, ch chan *kvstore.Event) {
+}
+
+// Close mock function implementation for KVClient
+func (kvclient *MockKVClient) Close() {
+}
diff --git a/pkg/mocks/mockOpenOltClient.go b/pkg/mocks/mockOpenOltClient.go
new file mode 100644
index 0000000..652f959
--- /dev/null
+++ b/pkg/mocks/mockOpenOltClient.go
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"context"
+	"errors"
+	"io"
+
+	openolt "github.com/opencord/voltha-protos/v3/go/openolt"
+	tech_profile "github.com/opencord/voltha-protos/v3/go/tech_profile"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/metadata"
+)
+
+// MockOpenoltClient mock struct for OpenoltClient.
+type MockOpenoltClient struct {
+	counter int
+}
+
+// DisableOlt mocks the DisableOlt function of Openoltclient.
+func (ooc *MockOpenoltClient) DisableOlt(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	//return &openolt.Empty{}, nil
+	if ooc.counter == 0 {
+		ooc.counter++
+		return &openolt.Empty{}, nil
+	}
+	return nil, errors.New("disableOlt failed")
+}
+
+// ReenableOlt mocks the ReenableOlt function of Openoltclient.
+func (ooc *MockOpenoltClient) ReenableOlt(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	if ooc.counter == 0 {
+		ooc.counter++
+		return &openolt.Empty{}, nil
+	}
+	return nil, errors.New("reenable olt failed")
+}
+
+// ActivateOnu mocks the ActivateOnu function of Openoltclient.
+func (ooc *MockOpenoltClient) ActivateOnu(ctx context.Context, in *openolt.Onu, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	if in == nil {
+		return nil, errors.New("invalid onuId")
+	}
+	return &openolt.Empty{}, nil
+}
+
+// DeactivateOnu mocks the DeactivateOnu function of Openoltclient.
+func (ooc *MockOpenoltClient) DeactivateOnu(ctx context.Context, in *openolt.Onu, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// DeleteOnu mocks the DeleteOnu function of Openoltclient.
+func (ooc *MockOpenoltClient) DeleteOnu(ctx context.Context, in *openolt.Onu, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// OmciMsgOut mocks the OmciMsgOut function of Openoltclient.
+func (ooc *MockOpenoltClient) OmciMsgOut(ctx context.Context, in *openolt.OmciMsg, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	if in == nil {
+		return nil, errors.New("invalid Omci Msg")
+	}
+	return &openolt.Empty{}, nil
+}
+
+// OnuPacketOut mocks the OnuPacketOut function of Openoltclient.
+func (ooc *MockOpenoltClient) OnuPacketOut(ctx context.Context, in *openolt.OnuPacket, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// UplinkPacketOut mocks the UplinkPacketOut function of Openoltclient.
+func (ooc *MockOpenoltClient) UplinkPacketOut(ctx context.Context, in *openolt.UplinkPacket, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// FlowAdd mocks the FlowAdd function of Openoltclient.
+func (ooc *MockOpenoltClient) FlowAdd(ctx context.Context, in *openolt.Flow, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// FlowRemove mocks the FlowRemove function of Openoltclient.
+func (ooc *MockOpenoltClient) FlowRemove(ctx context.Context, in *openolt.Flow, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// HeartbeatCheck mocks the HeartbeatCheck function of Openoltclient.
+func (ooc *MockOpenoltClient) HeartbeatCheck(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.Heartbeat, error) {
+	return nil, nil
+}
+
+// EnablePonIf mocks the EnablePonIf function of Openoltclient.
+func (ooc *MockOpenoltClient) EnablePonIf(ctx context.Context, in *openolt.Interface, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// DisablePonIf mocks the DisablePonIf function of Openoltclient.
+func (ooc *MockOpenoltClient) DisablePonIf(ctx context.Context, in *openolt.Interface, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// GetDeviceInfo mocks the GetDeviceInfo function of Openoltclient.
+func (ooc *MockOpenoltClient) GetDeviceInfo(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.DeviceInfo, error) {
+	if ooc.counter == 0 {
+		ooc.counter++
+		deviceInfo := &openolt.DeviceInfo{Vendor: "Openolt", Model: "1.0", HardwareVersion: "1.0", FirmwareVersion: "1.0", DeviceId: "olt", DeviceSerialNumber: "olt"}
+		return deviceInfo, nil
+	}
+	if ooc.counter == 1 {
+		ooc.counter++
+		deviceInfo := &openolt.DeviceInfo{Vendor: "Openolt", Model: "1.0", HardwareVersion: "1.0", FirmwareVersion: "1.0", DeviceId: "", DeviceSerialNumber: "olt"}
+		return deviceInfo, nil
+	}
+	if ooc.counter == 2 {
+		ooc.counter++
+		return nil, nil
+	}
+
+	return nil, errors.New("device info not found")
+}
+
+// Reboot mocks the Reboot function of Openoltclient.
+func (ooc *MockOpenoltClient) Reboot(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	if ooc.counter == 0 {
+		ooc.counter++
+		return &openolt.Empty{}, nil
+	}
+	return nil, errors.New("reboot failed")
+}
+
+// CollectStatistics mocks the CollectStatistics function of Openoltclient.
+func (ooc *MockOpenoltClient) CollectStatistics(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// CreateTrafficSchedulers mocks the CreateTrafficSchedulers function of Openoltclient.
+func (ooc *MockOpenoltClient) CreateTrafficSchedulers(ctx context.Context, in *tech_profile.TrafficSchedulers, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// RemoveTrafficSchedulers mocks the RemoveTrafficSchedulers function of Openoltclient.
+func (ooc *MockOpenoltClient) RemoveTrafficSchedulers(ctx context.Context, in *tech_profile.TrafficSchedulers, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// CreateTrafficQueues mocks the CreateTrafficQueues function of Openoltclient.
+func (ooc *MockOpenoltClient) CreateTrafficQueues(ctx context.Context, in *tech_profile.TrafficQueues, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// RemoveTrafficQueues mocks the RemoveTrafficQueues function of Openoltclient.
+func (ooc *MockOpenoltClient) RemoveTrafficQueues(ctx context.Context, in *tech_profile.TrafficQueues, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
+
+// EnableIndication mocks the EnableIndication function of Openoltclient.
+func (ooc *MockOpenoltClient) EnableIndication(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (openolt.Openolt_EnableIndicationClient, error) {
+	if ooc.counter < 2 {
+		ooc.counter++
+		mockInd := &mockOpenoltEnableIndicationClient{0}
+		return mockInd, nil
+	}
+	if ooc.counter == 2 {
+		ooc.counter++
+		return nil, nil
+	}
+	return nil, errors.New("invalid method invocation")
+}
+
+type mockOpenoltEnableIndicationClient struct {
+	count int
+}
+
+func (mock *mockOpenoltEnableIndicationClient) Recv() (*openolt.Indication, error) {
+	if mock.count == 0 {
+		mock.count = mock.count + 1
+		indi := &openolt.Indication{Data: &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: "Down"}}}
+		return indi, nil
+	}
+	if mock.count == 1 {
+		mock.count = mock.count + 1
+		return nil, errors.New("error, while processing indication")
+	}
+
+	return nil, io.EOF
+}
+
+func (mock *mockOpenoltEnableIndicationClient) Header() (metadata.MD, error) {
+	return nil, nil
+}
+
+func (mock *mockOpenoltEnableIndicationClient) Trailer() metadata.MD {
+	return nil
+}
+
+func (mock *mockOpenoltEnableIndicationClient) CloseSend() error {
+	return nil
+}
+
+func (mock *mockOpenoltEnableIndicationClient) Context() context.Context {
+	return context.Background()
+}
+
+func (mock *mockOpenoltEnableIndicationClient) SendMsg(m interface{}) error {
+	return nil
+}
+
+func (mock *mockOpenoltEnableIndicationClient) RecvMsg(m interface{}) error {
+	return nil
+}
+
+// PerformGroupOperation mocks the PerformGroupOperation function of Openoltclient.
+func (ooc *MockOpenoltClient) PerformGroupOperation(ctx context.Context, in *openolt.Group, opts ...grpc.CallOption) (*openolt.Empty, error) {
+	return &openolt.Empty{}, nil
+}
diff --git a/pkg/mocks/mockTechprofile.go b/pkg/mocks/mockTechprofile.go
new file mode 100644
index 0000000..1ad57f1
--- /dev/null
+++ b/pkg/mocks/mockTechprofile.go
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//Package mocks provides the mocks for openolt-adapter.
+package mocks
+
+import (
+	"context"
+	"github.com/opencord/voltha-lib-go/v3/pkg/db"
+	"github.com/opencord/voltha-lib-go/v3/pkg/log"
+	tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
+	tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile"
+)
+
+// MockTechProfile mock struct for OpenoltClient.
+type MockTechProfile struct {
+	TpID uint32
+}
+
+// SetKVClient to mock techprofile SetKVClient method
+func (m MockTechProfile) SetKVClient() *db.Backend {
+	return &db.Backend{Client: &MockKVClient{}}
+}
+
+// GetTechProfileInstanceKVPath to mock techprofile GetTechProfileInstanceKVPath method
+func (m MockTechProfile) GetTechProfileInstanceKVPath(techProfiletblID uint32, uniPortName string) string {
+	return ""
+
+}
+
+// GetTPInstanceFromKVStore to mock techprofile GetTPInstanceFromKVStore method
+func (m MockTechProfile) GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (*tp.TechProfile, error) {
+	log.Debug("Warning Warning Warning: GetTPInstanceFromKVStore")
+	return nil, nil
+
+}
+
+// CreateTechProfInstance to mock techprofile CreateTechProfInstance method
+func (m MockTechProfile) CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (*tp.TechProfile, error) {
+
+	return &tp.TechProfile{
+		Name:                           "mock-tech-profile",
+		SubscriberIdentifier:           "257",
+		ProfileType:                    "mock",
+		Version:                        0,
+		NumGemPorts:                    2,
+		UpstreamGemPortAttributeList:   nil,
+		DownstreamGemPortAttributeList: nil,
+	}, nil
+
+}
+
+// DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method
+func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error {
+	return nil
+}
+
+// GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method
+func (m MockTechProfile) GetprotoBufParamValue(paramType string, paramKey string) int32 {
+	return 0
+
+}
+
+// GetUsScheduler to mock techprofile GetUsScheduler method
+func (m MockTechProfile) GetUsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
+	return &tp_pb.SchedulerConfig{}, nil
+
+}
+
+// GetDsScheduler to mock techprofile GetDsScheduler method
+func (m MockTechProfile) GetDsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
+	return &tp_pb.SchedulerConfig{}, nil
+}
+
+// GetTrafficScheduler to mock techprofile GetTrafficScheduler method
+func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig,
+	ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler {
+	return &tp_pb.TrafficScheduler{}
+
+}
+
+// GetTrafficQueues to mock techprofile GetTrafficQueues method
+func (m MockTechProfile) GetTrafficQueues(tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) {
+	return []*tp_pb.TrafficQueue{{}}, nil
+}
+
+// GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method
+func (m MockTechProfile) GetMulticastTrafficQueues(tp *tp.TechProfile) []*tp_pb.TrafficQueue {
+	return []*tp_pb.TrafficQueue{{}}
+}
+
+// GetGemportIDForPbit to mock techprofile GetGemportIDForPbit method
+func (m MockTechProfile) GetGemportIDForPbit(tp *tp.TechProfile, Dir tp_pb.Direction, pbit uint32) uint32 {
+	return 0
+}
+
+// FindAllTpInstances to mock techprofile FindAllTpInstances method
+func (m MockTechProfile) FindAllTpInstances(ctx context.Context, techProfiletblID uint32, ponIntf uint32, onuID uint32) []tp.TechProfile {
+	return []tp.TechProfile{}
+}