[VOL-2235] Mocks and interfaces for rw-core

This update consists of mocks that are used by the rw-core
during unit testing.  It also includes interfaces used for unit
tests.

Change-Id: I20ca1455c358113c3aa897acc6355e0ddbc614b7
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
new file mode 100644
index 0000000..a510e58
--- /dev/null
+++ b/rw_core/mocks/adapter.go
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
+	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
+	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+func macAddressToUint32Array(mac string) []uint32 {
+	slist := strings.Split(mac, ":")
+	result := make([]uint32, len(slist))
+	var err error
+	var tmp int64
+	for index, val := range slist {
+		if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
+			return []uint32{1, 2, 3, 4, 5, 6}
+		}
+		result[index] = uint32(tmp)
+	}
+	return result
+}
+
+type Adapter struct {
+	coreProxy adapterif.CoreProxy
+	devices   sync.Map
+}
+
+func NewAdapter(cp adapterif.CoreProxy) *Adapter {
+	return &Adapter{
+		coreProxy: cp,
+	}
+}
+
+func (ta *Adapter) storeDevice(d *voltha.Device) {
+	if d != nil {
+		ta.devices.Store(d.Id, d)
+	}
+}
+
+func (ta *Adapter) deleteDevice(id string) {
+	ta.devices.Delete(id)
+}
+
+func (ta *Adapter) getDevice(id string) *voltha.Device {
+	if val, ok := ta.devices.Load(id); ok && val != nil {
+		if device, ok := val.(*voltha.Device); ok {
+			return device
+		}
+	}
+	return nil
+}
+
+func (ta *Adapter) updateDevice(d *voltha.Device) error {
+	if d != nil {
+		if _, ok := ta.devices.LoadOrStore(d.Id, d); !ok {
+			return status.Errorf(codes.Internal, "error updating device %s", d.Id)
+		}
+	}
+	return nil
+}
+
+func (ta *Adapter) Adapter_descriptor() error {
+	return nil
+}
+func (ta *Adapter) Device_types() (*voltha.DeviceTypes, error) {
+	return nil, nil
+}
+func (ta *Adapter) Health() (*voltha.HealthStatus, error) {
+	return nil, nil
+}
+func (ta *Adapter) Adopt_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Reconcile_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Abandon_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Disable_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Reenable_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Reboot_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Self_test_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Delete_device(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Get_device_details(device *voltha.Device) error {
+	return nil
+}
+
+func (ta *Adapter) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
+	return nil
+}
+
+func (ta *Adapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
+	return nil
+}
+func (ta *Adapter) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
+	return nil
+}
+
+func (ta *Adapter) Receive_packet_out(deviceId string, egress_port_no int, msg *of.OfpPacketOut) error {
+	return nil
+}
+
+func (ta *Adapter) Suppress_alarm(filter *voltha.AlarmFilter) error {
+	return nil
+}
+
+func (ta *Adapter) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
+	return nil
+}
+
+func (ta *Adapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+	return &ic.SwitchCapability{
+		Desc: &of.OfpDesc{
+			HwDesc:    "adapter_mock",
+			SwDesc:    "adapter_mock",
+			SerialNum: "000000000",
+		},
+		SwitchFeatures: &of.OfpSwitchFeatures{
+			NBuffers: 256,
+			NTables:  2,
+			Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS |
+				of.OfpCapabilities_OFPC_TABLE_STATS |
+				of.OfpCapabilities_OFPC_PORT_STATS |
+				of.OfpCapabilities_OFPC_GROUP_STATS),
+		},
+	}, nil
+}
+
+func (ta *Adapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+	capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	return &ic.PortCapability{
+		Port: &voltha.LogicalPort{
+			OfpPort: &of.OfpPort{
+				HwAddr:     macAddressToUint32Array("11:11:33:44:55:66"),
+				Config:     0,
+				State:      uint32(of.OfpPortState_OFPPS_LIVE),
+				Curr:       capability,
+				Advertised: capability,
+				Peer:       capability,
+				CurrSpeed:  uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+			},
+			DeviceId:     device.Id,
+			DevicePortNo: uint32(port_no),
+		},
+	}, nil
+}
+
+func (ta *Adapter) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+	return nil
+}
+
+func (ta *Adapter) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
+
+func (ta *Adapter) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
+
+func (ta *Adapter) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
+
+func (ta *Adapter) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
+
+func (ta *Adapter) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
new file mode 100644
index 0000000..89f6c20
--- /dev/null
+++ b/rw_core/mocks/adapter_olt.go
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"context"
+	"fmt"
+	"github.com/gogo/protobuf/proto"
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
+	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
+	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+	"strings"
+)
+
+const (
+	numONUPerOLT = 4
+)
+
+type OLTAdapter struct {
+	Adapter
+}
+
+func NewOLTAdapter(cp adapterif.CoreProxy) *OLTAdapter {
+	a := &OLTAdapter{}
+	a.coreProxy = cp
+	return a
+}
+
+func (oltA *OLTAdapter) Adopt_device(device *voltha.Device) error {
+	go func() {
+		d := proto.Clone(device).(*voltha.Device)
+		d.Root = true
+		d.Vendor = "olt_adapter_mock"
+		d.Model = "go-mock"
+		d.SerialNumber = com.GetRandomSerialNumber()
+		d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
+		oltA.storeDevice(d)
+		if res := oltA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
+			log.Fatalf("deviceUpdate-failed-%s", res)
+		}
+		nniPort := &voltha.Port{
+			PortNo:     2,
+			Label:      fmt.Sprintf("nni-%d", 2),
+			Type:       voltha.Port_ETHERNET_NNI,
+			OperStatus: voltha.OperStatus_ACTIVE,
+		}
+		var err error
+		if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, nniPort); err != nil {
+			log.Fatalf("PortCreated-failed-%s", err)
+		}
+
+		ponPort := &voltha.Port{
+			PortNo:     1,
+			Label:      fmt.Sprintf("pon-%d", 1),
+			Type:       voltha.Port_PON_OLT,
+			OperStatus: voltha.OperStatus_ACTIVE,
+		}
+		if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+			log.Fatalf("PortCreated-failed-%s", err)
+		}
+
+		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		d.OperStatus = voltha.OperStatus_ACTIVE
+
+		if err = oltA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
+			log.Fatalf("Device-state-update-failed-%s", err)
+		}
+
+		//Get the latest device data from the Core
+		if d, err = oltA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
+			log.Fatalf("getting-device-failed-%s", err)
+		}
+
+		if err = oltA.updateDevice(d); err != nil {
+			log.Fatalf("saving-device-failed-%s", err)
+		}
+
+		// Register Child devices
+		initialUniPortNo := 100
+		for i := 0; i < numONUPerOLT; i++ {
+			go func(seqNo int) {
+				if _, err := oltA.coreProxy.ChildDeviceDetected(
+					context.TODO(),
+					d.Id,
+					1,
+					"onu_adapter_mock",
+					initialUniPortNo+seqNo,
+					"onu_adapter_mock",
+					com.GetRandomSerialNumber(),
+					int64(seqNo)); err != nil {
+					log.Fatalf("failure-sending-child-device-%s", err)
+				}
+			}(i)
+		}
+	}()
+	return nil
+}
+
+func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+	if d := oltA.getDevice(device.Id); d == nil {
+		log.Fatalf("device-not-found-%s", device.Id)
+	}
+	return &ic.SwitchCapability{
+		Desc: &of.OfpDesc{
+			HwDesc:    "olt_adapter_mock",
+			SwDesc:    "olt_adapter_mock",
+			SerialNum: "12345678",
+		},
+		SwitchFeatures: &of.OfpSwitchFeatures{
+			NBuffers: 256,
+			NTables:  2,
+			Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS |
+				of.OfpCapabilities_OFPC_TABLE_STATS |
+				of.OfpCapabilities_OFPC_PORT_STATS |
+				of.OfpCapabilities_OFPC_GROUP_STATS),
+		},
+	}, nil
+}
+
+func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+	if d := oltA.getDevice(device.Id); d == nil {
+		log.Fatalf("device-not-found-%s", device.Id)
+	}
+	capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	return &ic.PortCapability{
+		Port: &voltha.LogicalPort{
+			OfpPort: &of.OfpPort{
+				HwAddr:     macAddressToUint32Array("11:22:33:44:55:66"),
+				Config:     0,
+				State:      uint32(of.OfpPortState_OFPPS_LIVE),
+				Curr:       capability,
+				Advertised: capability,
+				Peer:       capability,
+				CurrSpeed:  uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+			},
+			DeviceId:     device.Id,
+			DevicePortNo: uint32(port_no),
+		},
+	}, nil
+}
+
+func (oltA *OLTAdapter) GetNumONUPerOLT() int {
+	return numONUPerOLT
+}
+
+func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error {
+	go func() {
+		if d := oltA.getDevice(device.Id); d == nil {
+			log.Fatalf("device-not-found-%s", device.Id)
+		}
+
+		cloned := proto.Clone(device).(*voltha.Device)
+		// Update the all ports state on that device to disable
+		if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+			log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+
+		//Update the device state
+		cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
+		cloned.OperStatus = voltha.OperStatus_UNKNOWN
+
+		if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+
+		if err := oltA.updateDevice(cloned); err != nil {
+			log.Fatalf("saving-device-failed-%s", err)
+		}
+
+		// Tell the Core that all child devices have been disabled (by default it's an action already taken by the Core
+		if err := oltA.coreProxy.ChildDevicesLost(context.TODO(), cloned.Id); err != nil {
+			log.Fatalf("lost-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+	}()
+	return nil
+}
+
+func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error {
+	go func() {
+		if d := oltA.getDevice(device.Id); d == nil {
+			log.Fatalf("device-not-found-%s", device.Id)
+		}
+
+		cloned := proto.Clone(device).(*voltha.Device)
+		// Update the all ports state on that device to enable
+		if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+			log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+
+		//Update the device state
+		cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		cloned.OperStatus = voltha.OperStatus_ACTIVE
+
+		if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+
+		// Tell the Core that all child devices have been enabled
+		if err := oltA.coreProxy.ChildDevicesDetected(context.TODO(), cloned.Id); err != nil {
+			log.Fatalf("detection-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+	}()
+	return nil
+}
diff --git a/rw_core/mocks/adapter_olt_test.go b/rw_core/mocks/adapter_olt_test.go
new file mode 100644
index 0000000..6d61e1f
--- /dev/null
+++ b/rw_core/mocks/adapter_olt_test.go
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters"
+	"testing"
+)
+
+func TestOLTAdapterImplementsIAdapter(t *testing.T) {
+	adapter := NewOLTAdapter(nil)
+
+	if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
+		t.Error("OLT adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
+	}
+}
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
new file mode 100644
index 0000000..66a3538
--- /dev/null
+++ b/rw_core/mocks/adapter_onu.go
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"context"
+	"fmt"
+	"github.com/gogo/protobuf/proto"
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
+	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
+	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+	"strings"
+)
+
+type ONUAdapter struct {
+	coreProxy adapterif.CoreProxy
+	Adapter
+}
+
+func NewONUAdapter(cp adapterif.CoreProxy) *ONUAdapter {
+	a := &ONUAdapter{}
+	a.coreProxy = cp
+	return a
+}
+
+func (onuA *ONUAdapter) Adopt_device(device *voltha.Device) error {
+	go func() {
+		d := proto.Clone(device).(*voltha.Device)
+		d.Root = false
+		d.Vendor = "onu_adapter_mock"
+		d.Model = "go-mock"
+		d.SerialNumber = com.GetRandomSerialNumber()
+		d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
+		onuA.storeDevice(d)
+		if res := onuA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
+			log.Fatalf("deviceUpdate-failed-%s", res)
+		}
+		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		d.OperStatus = voltha.OperStatus_DISCOVERED
+
+		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed-%s", err)
+		}
+
+		uniPortNo := uint32(2)
+		if device.ProxyAddress != nil {
+			if device.ProxyAddress.ChannelId != 0 {
+				uniPortNo = device.ProxyAddress.ChannelId
+			}
+		}
+
+		uniPort := &voltha.Port{
+			PortNo:     uniPortNo,
+			Label:      fmt.Sprintf("uni-%d", uniPortNo),
+			Type:       voltha.Port_ETHERNET_UNI,
+			OperStatus: voltha.OperStatus_ACTIVE,
+		}
+		var err error
+		if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, uniPort); err != nil {
+			log.Fatalf("PortCreated-failed-%s", err)
+		}
+
+		ponPortNo := uint32(1)
+		if device.ParentPortNo != 0 {
+			ponPortNo = device.ParentPortNo
+		}
+
+		ponPort := &voltha.Port{
+			PortNo:     ponPortNo,
+			Label:      fmt.Sprintf("pon-%d", ponPortNo),
+			Type:       voltha.Port_PON_ONU,
+			OperStatus: voltha.OperStatus_ACTIVE,
+			Peers: []*voltha.Port_PeerPort{{DeviceId: d.ParentId, // Peer device  is OLT
+				PortNo: uniPortNo}}, // Peer port is UNI port
+		}
+		if err := onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+			log.Fatalf("PortCreated-failed-%s", err)
+		}
+
+		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		d.OperStatus = voltha.OperStatus_ACTIVE
+
+		if err = onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed-%s", err)
+		}
+		//Get the latest device data from the Core
+		if d, err = onuA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
+			log.Fatalf("getting-device-failed-%s", err)
+		}
+
+		if err = onuA.updateDevice(d); err != nil {
+			log.Fatalf("saving-device-failed-%s", err)
+		}
+	}()
+	return nil
+}
+
+func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+	if d := onuA.getDevice(device.Id); d == nil {
+		log.Fatalf("device-not-found-%s", device.Id)
+	}
+	capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	return &ic.PortCapability{
+		Port: &voltha.LogicalPort{
+			OfpPort: &of.OfpPort{
+				HwAddr:     macAddressToUint32Array("12:12:12:12:12:12"),
+				Config:     0,
+				State:      uint32(of.OfpPortState_OFPPS_LIVE),
+				Curr:       capability,
+				Advertised: capability,
+				Peer:       capability,
+				CurrSpeed:  uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+			},
+			DeviceId:     device.Id,
+			DevicePortNo: uint32(port_no),
+		},
+	}, nil
+}
+
+func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error {
+	go func() {
+		if d := onuA.getDevice(device.Id); d == nil {
+			log.Fatalf("device-not-found-%s", device.Id)
+		}
+		cloned := proto.Clone(device).(*voltha.Device)
+		// Update the all ports state on that device to disable
+		if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+			log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+		//Update the device state
+		cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
+		cloned.OperStatus = voltha.OperStatus_UNKNOWN
+
+		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+		if err := onuA.updateDevice(cloned); err != nil {
+			log.Fatalf("saving-device-failed-%s", err)
+		}
+	}()
+	return nil
+}
+
+func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error {
+	go func() {
+		if d := onuA.getDevice(device.Id); d == nil {
+			log.Fatalf("device-not-found-%s", device.Id)
+		}
+
+		cloned := proto.Clone(device).(*voltha.Device)
+		// Update the all ports state on that device to enable
+		if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+			log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+
+		//Update the device state
+		cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		cloned.OperStatus = voltha.OperStatus_ACTIVE
+
+		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		}
+		if err := onuA.updateDevice(cloned); err != nil {
+			log.Fatalf("saving-device-failed-%s", err)
+		}
+	}()
+	return nil
+}
diff --git a/rw_core/mocks/adapter_onu_test.go b/rw_core/mocks/adapter_onu_test.go
new file mode 100644
index 0000000..748815a
--- /dev/null
+++ b/rw_core/mocks/adapter_onu_test.go
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters"
+	"testing"
+)
+
+func TestONUAdapterImplementsIAdapter(t *testing.T) {
+	adapter := NewONUAdapter(nil)
+
+	if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
+		t.Error("ONU adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
+	}
+}
diff --git a/rw_core/mocks/adapter_test.go b/rw_core/mocks/adapter_test.go
new file mode 100644
index 0000000..bc18cb5
--- /dev/null
+++ b/rw_core/mocks/adapter_test.go
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-lib-go/v2/pkg/adapters"
+	"testing"
+)
+
+func TestAdapterImplementsIAdapter(t *testing.T) {
+	adapter := NewAdapter(nil)
+
+	if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
+		t.Error("adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
+	}
+}
diff --git a/rw_core/mocks/common_test.go b/rw_core/mocks/common_test.go
new file mode 100644
index 0000000..1ff5700
--- /dev/null
+++ b/rw_core/mocks/common_test.go
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+)
+
+const (
+	logLevel = log.FatalLevel
+)
+
+// Unit test initialization. This init() function handles all unit tests in
+// the current directory.
+func init() {
+	// Setup this package so that it's log level can be modified at run time
+	_, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+	if err != nil {
+		panic(err)
+	}
+}
diff --git a/rw_core/mocks/device_manager.go b/rw_core/mocks/device_manager.go
new file mode 100644
index 0000000..c8bf1ca
--- /dev/null
+++ b/rw_core/mocks/device_manager.go
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"context"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+)
+
+type DeviceManager struct {
+}
+
+func (dm *DeviceManager) GetDevice(deviceId string) (*voltha.Device, error) {
+	return nil, nil
+}
+func (dm *DeviceManager) IsRootDevice(deviceId string) (bool, error) {
+	return false, nil
+}
+
+func (dm *DeviceManager) NotifyInvalidTransition(pcDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) SetAdminStateToEnable(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) CreateLogicalDevice(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) SetupUNILogicalPorts(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) DisableAllChildDevices(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) DeleteLogicalDevice(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) DeleteLogicalPorts(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) DeleteAllChildDevices(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) RunPostDeviceDelete(cDevice *voltha.Device) error {
+	return nil
+}
+
+func (dm *DeviceManager) ListDevices() (*voltha.Devices, error) {
+	return nil, nil
+}
+
+func (dm *DeviceManager) ListDeviceIds() (*voltha.IDs, error) {
+	return nil, nil
+}
+
+func (dm *DeviceManager) ReconcileDevices(ctx context.Context, ids *voltha.IDs, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) CreateDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) EnableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) DisableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) RebootDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) DeleteDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) StopManagingDevice(id string) {
+}
+
+func (dm *DeviceManager) DownloadImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) ActivateImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) RevertImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) UpdateImageDownload(deviceId string, img *voltha.ImageDownload) error {
+	return nil
+}
+
+func (dm *DeviceManager) SimulateAlarm(ctx context.Context, simulatereq *voltha.SimulateAlarmRequest, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, nil
+}
+
+func (dm *DeviceManager) ListImageDownloads(ctx context.Context, deviceId string) (*voltha.ImageDownloads, error) {
+	return nil, nil
+}
+
+func (dm *DeviceManager) UpdatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs, ch chan interface{}) {
+}
+
+func (dm *DeviceManager) ListPmConfigs(ctx context.Context, deviceId string) (*voltha.PmConfigs, error) {
+	return nil, nil
+}
+
+func (dm *DeviceManager) DeletePeerPorts(fromDeviceId string, deviceId string) error {
+	return nil
+}
+
+func (dm *DeviceManager) ProcessTransition(previous *voltha.Device, current *voltha.Device) error {
+	return nil
+}
diff --git a/rw_core/mocks/device_manager_test.go b/rw_core/mocks/device_manager_test.go
new file mode 100644
index 0000000..ab2226b
--- /dev/null
+++ b/rw_core/mocks/device_manager_test.go
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019-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
+
+import (
+	"github.com/opencord/voltha-go/rw_core/coreIf"
+	"testing"
+)
+
+func TestDeviceManagerImplementsDeviceManagerIf(t *testing.T) {
+	deviceMgr := &DeviceManager{}
+
+	if _, ok := interface{}(deviceMgr).(coreIf.DeviceManager); !ok {
+		t.Error("Device manager does not implement the coreIf.DeviceManager interface")
+	}
+}