[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/core/adapter_proxy.go b/rw_core/core/adapter_proxy.go
index 3143b60..b986a0e 100755
--- a/rw_core/core/adapter_proxy.go
+++ b/rw_core/core/adapter_proxy.go
@@ -101,7 +101,7 @@
 	// Use a device specific topic as we are the only core handling requests for this device
 	//replyToTopic := kafka.CreateSubTopic(ap.kafkaICProxy.DefaultTopic.Name, device.Id)
 	replyToTopic := ap.getCoreTopic()
-	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, device.Id, args...)
+	success, result := ap.kafkaICProxy.InvokeRPC(ctx, rpc, &toTopic, &replyToTopic, true, device.Id, args...)
 	log.Debugw("DisableDevice-response", log.Fields{"deviceId": device.Id, "success": success})
 	return unPackResponse(rpc, device.Id, success, result)
 }
diff --git a/rw_core/core/adapter_proxy_test.go b/rw_core/core/adapter_proxy_test.go
new file mode 100755
index 0000000..e6e0ecb
--- /dev/null
+++ b/rw_core/core/adapter_proxy_test.go
@@ -0,0 +1,216 @@
+/*
+ * 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 core
+
+import (
+	"context"
+	"crypto/rand"
+	cm "github.com/opencord/voltha-go/rw_core/mocks"
+	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
+	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
+	lm "github.com/opencord/voltha-lib-go/v2/pkg/mocks"
+	of "github.com/opencord/voltha-protos/v2/go/openflow_13"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"
+	"testing"
+	"time"
+)
+
+const (
+	coreName       = "rw_core"
+	adapterName    = "adapter_mock"
+	coreInstanceId = "1000"
+)
+
+var (
+	coreKafkaICProxy    *kafka.InterContainerProxy
+	adapterKafkaICProxy *kafka.InterContainerProxy
+	kc                  kafka.Client
+	adapterReqHandler   *com.RequestHandlerProxy
+	adapter             *cm.Adapter
+)
+
+func init() {
+	if _, err := log.SetDefaultLogger(log.JSON, 0, log.Fields{"instanceId": coreInstanceId}); err != nil {
+		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+	}
+	// Set the log level to Warning
+	log.SetAllLogLevel(2)
+
+	var err error
+
+	// Create the KV client
+	kc = lm.NewKafkaClient()
+
+	// Setup core inter-container proxy and core request handler
+	if coreKafkaICProxy, err = kafka.NewInterContainerProxy(
+		kafka.MsgClient(kc),
+		kafka.DefaultTopic(&kafka.Topic{Name: coreName})); err != nil || coreKafkaICProxy == nil {
+		log.Fatalw("Failure-creating-core-intercontainerProxy", log.Fields{"error": err})
+
+	}
+	if err := coreKafkaICProxy.Start(); err != nil {
+		log.Fatalw("Failure-starting-core-kafka-intercontainerProxy", log.Fields{"error": err})
+	}
+	if err := coreKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: coreName}, 0); err != nil {
+		log.Fatalw("Failure-subscribing-core-request-handler", log.Fields{"error": err})
+	}
+
+	// Setup adapter inter-container proxy and adapter request handler
+	adapterCoreProxy := com.NewCoreProxy(nil, adapterName, coreName)
+	adapter = cm.NewAdapter(adapterCoreProxy)
+	adapterReqHandler = com.NewRequestHandlerProxy(coreInstanceId, adapter, adapterCoreProxy)
+	if adapterKafkaICProxy, err = kafka.NewInterContainerProxy(
+		kafka.MsgClient(kc),
+		kafka.DefaultTopic(&kafka.Topic{Name: adapterName}),
+		kafka.RequestHandlerInterface(adapterReqHandler)); err != nil || adapterKafkaICProxy == nil {
+		log.Fatalw("Failure-creating-adapter-intercontainerProxy", log.Fields{"error": err})
+	}
+	if err = adapterKafkaICProxy.Start(); err != nil {
+		log.Fatalw("Failure-starting-adapter-kafka-intercontainerProxy", log.Fields{"error": err})
+	}
+	if err = adapterKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: adapterName}, 0); err != nil {
+		log.Fatalw("Failure-subscribing-adapter-request-handler", log.Fields{"error": err})
+	}
+}
+
+func getRandomBytes(size int) (bytes []byte, err error) {
+	bytes = make([]byte, size)
+	_, err = rand.Read(bytes)
+	return
+}
+
+func TestCreateAdapterProxy(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	assert.NotNil(t, ap)
+}
+
+func testSimpleRequests(t *testing.T) {
+	type simpleRequest func(context.Context, *voltha.Device) error
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	simpleRequests := []simpleRequest{
+		ap.AdoptDevice,
+		ap.DisableDevice,
+		ap.RebootDevice,
+		ap.DeleteDevice,
+		ap.ReconcileDevice,
+		ap.ReEnableDevice,
+	}
+	for _, f := range simpleRequests {
+		//Success
+		d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+		ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
+		err := f(ctx, d)
+		cancel()
+		assert.Nil(t, err)
+
+		//	Failure - invalid adapter
+		expectedError := status.Error(codes.Canceled, "context deadline exceeded")
+		d = &voltha.Device{Id: "deviceId", Adapter: "adapter_mock_1"}
+		ctx, cancel = context.WithTimeout(context.Background(), 20*time.Millisecond)
+		err = f(ctx, d)
+		cancel()
+		assert.NotNil(t, err)
+		assert.Equal(t, expectedError.Error(), err.Error())
+
+		// Failure - short timeout
+		expectedError = status.Error(codes.Canceled, "context deadline exceeded")
+		d = &voltha.Device{Id: "deviceId", Adapter: adapterName}
+		ctx, cancel = context.WithTimeout(context.Background(), 100*time.Nanosecond)
+		err = f(ctx, d)
+		cancel()
+		assert.NotNil(t, err)
+		assert.Equal(t, expectedError.Error(), err.Error())
+	}
+}
+
+func testGetSwitchCapabilityFromAdapter(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+	switchCap, err := ap.GetOfpDeviceInfo(ctx, d)
+	cancel()
+	assert.Nil(t, err)
+	assert.NotNil(t, switchCap)
+	expectedCap, _ := adapter.Get_ofp_device_info(d)
+	assert.Equal(t, switchCap.String(), expectedCap.String())
+}
+
+func testGetPortInfoFromAdapter(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+	portNo := uint32(1)
+	portInfo, err := ap.GetOfpPortInfo(ctx, d, portNo)
+	cancel()
+	assert.Nil(t, err)
+	assert.NotNil(t, portInfo)
+	expectedPortInfo, _ := adapter.Get_ofp_port_info(d, int64(portNo))
+	assert.Equal(t, portInfo.String(), expectedPortInfo.String())
+}
+
+func testPacketOut(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+	outPort := uint32(1)
+	packet, err := getRandomBytes(50)
+	assert.Nil(t, err)
+	err = ap.packetOut(adapterName, d.Id, outPort, &of.OfpPacketOut{Data: packet})
+	assert.Nil(t, err)
+}
+
+func testFlowUpdates(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+	err := ap.UpdateFlowsBulk(d, &voltha.Flows{}, &voltha.FlowGroups{}, &voltha.FlowMetadata{})
+	assert.Nil(t, err)
+	flowChanges := &voltha.FlowChanges{ToAdd: &voltha.Flows{Items: nil}, ToRemove: &voltha.Flows{Items: nil}}
+	groupChanges := &voltha.FlowGroupChanges{ToAdd: &voltha.FlowGroups{Items: nil}, ToRemove: &voltha.FlowGroups{Items: nil}, ToUpdate: &voltha.FlowGroups{Items: nil}}
+	err = ap.UpdateFlowsIncremental(d, flowChanges, groupChanges, &voltha.FlowMetadata{})
+	assert.Nil(t, err)
+}
+
+func testPmUpdates(t *testing.T) {
+	ap := NewAdapterProxy(coreKafkaICProxy, coreName)
+	d := &voltha.Device{Id: "deviceId", Adapter: adapterName}
+	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+	err := ap.UpdatePmConfigs(ctx, d, &voltha.PmConfigs{})
+	cancel()
+	assert.Nil(t, err)
+}
+
+func TestSuite(t *testing.T) {
+	//1. Test the simple requests first
+	testSimpleRequests(t)
+
+	//2.  Test get switch capability
+	testGetSwitchCapabilityFromAdapter(t)
+
+	//3.  Test get port info
+	testGetPortInfoFromAdapter(t)
+
+	//4. Test PacketOut
+	testPacketOut(t)
+
+	//	5. Test flow updates
+	testFlowUpdates(t)
+
+	//6. Pm configs
+	testPmUpdates(t)
+}
diff --git a/rw_core/core/common_test.go b/rw_core/core/common_test.go
new file mode 100644
index 0000000..6642a36
--- /dev/null
+++ b/rw_core/core/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 core
+
+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/core/device_state_transitions_test.go b/rw_core/core/device_state_transitions_test.go
index 33171ee..0e7b4b3 100644
--- a/rw_core/core/device_state_transitions_test.go
+++ b/rw_core/core/device_state_transitions_test.go
@@ -17,6 +17,7 @@
 
 import (
 	"github.com/opencord/voltha-go/rw_core/coreIf"
+	"github.com/opencord/voltha-go/rw_core/mocks"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
 	"github.com/stretchr/testify/assert"
@@ -28,60 +29,17 @@
 var tdm coreIf.DeviceManager
 
 type testDeviceManager struct {
+	mocks.DeviceManager
 }
 
 func newTestDeviceManager() *testDeviceManager {
 	return &testDeviceManager{}
 }
 
-func (tdm *testDeviceManager) GetDevice(string) (*voltha.Device, error) {
-	return nil, nil
-}
-
-func (tdm *testDeviceManager) IsRootDevice(string) (bool, error) {
-	return false, nil
-}
-
-func (tdm *testDeviceManager) NotifyInvalidTransition(pto *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) SetAdminStateToEnable(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) CreateLogicalDevice(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) SetupUNILogicalPorts(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DisableAllChildDevices(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteLogicalDevice(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteLogicalPorts(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteAllChildDevices(to *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) RunPostDeviceDelete(to *voltha.Device) error {
-	return nil
-}
-
 func init() {
-	log.AddPackage(log.JSON, log.WarnLevel, nil)
-	//log.UpdateAllLoggers(log.Fields{"instanceId": "device-state-transition"})
-	//log.SetAllLogLevel(log.DebugLevel)
+	if _, err := log.AddPackage(log.JSON, log.WarnLevel, nil); err != nil {
+		log.Fatal("failure-adding-package-core")
+	}
 	tdm = newTestDeviceManager()
 	transitionMap = NewTransitionMap(tdm)
 }
diff --git a/rw_core/coreIf/adapter_manager_if.go b/rw_core/coreIf/adapter_manager_if.go
new file mode 100644
index 0000000..b48852c
--- /dev/null
+++ b/rw_core/coreIf/adapter_manager_if.go
@@ -0,0 +1,28 @@
+/*
+ * 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 coreIf
+
+import (
+	"context"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+)
+
+type AdapterManager interface {
+	ListAdapters(ctx context.Context) (*voltha.Adapters, error)
+	GetAdapterName(deviceType string) (string, error)
+	GetDeviceType(deviceType string) *voltha.DeviceType
+	RegisterAdapter(adapter *voltha.Adapter, deviceTypes *voltha.DeviceTypes) *voltha.CoreInstance
+}
diff --git a/rw_core/coreIf/core_if.go b/rw_core/coreIf/core_if.go
new file mode 100644
index 0000000..bf9a661
--- /dev/null
+++ b/rw_core/coreIf/core_if.go
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+/*
+Defines a DeviceManager Interface - Used for unit testing of the flow decomposer only at this
+time.
+*/
+package coreIf
+
+import (
+	"context"
+	"github.com/opencord/voltha-go/db/model"
+	"github.com/opencord/voltha-go/rw_core/config"
+	"github.com/opencord/voltha-lib-go/v2/pkg/kafka"
+)
+
+type Core interface {
+	Start(ctx context.Context)
+	Stop(ctx context.Context)
+	GetKafkaInterContainerProxy() *kafka.InterContainerProxy
+	GetConfig() *config.RWCoreFlags
+	GetInstanceId() string
+	GetClusterDataProxy() *model.Proxy
+	GetAdapterManager() AdapterManager
+	StartGRPCService(ctx context.Context)
+	GetDeviceManager() DeviceManager
+	GetLogicalDeviceManager() LogicalDeviceManager
+	GetDeviceOwnerShip() DeviceOwnership
+}
diff --git a/rw_core/coreIf/device_ownership_if.go b/rw_core/coreIf/device_ownership_if.go
new file mode 100644
index 0000000..fb19097
--- /dev/null
+++ b/rw_core/coreIf/device_ownership_if.go
@@ -0,0 +1,28 @@
+/*
+ * 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 coreIf
+
+import (
+	"context"
+)
+
+type DeviceOwnership interface {
+	Start(ctx context.Context)
+	Stop(ctx context.Context)
+	OwnedByMe(id interface{}) (bool, error)
+	AbandonDevice(id string) error
+	GetAllDeviceIdsOwnedByMe() []string
+}
diff --git a/rw_core/coreIf/logical_device_manager_if.go b/rw_core/coreIf/logical_device_manager_if.go
new file mode 100644
index 0000000..a10a3c8
--- /dev/null
+++ b/rw_core/coreIf/logical_device_manager_if.go
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/*
+Defines a DeviceManager Interface - Used for unit testing of the flow decomposer only at this
+time.
+*/
+package coreIf
+
+import (
+	"context"
+	"github.com/opencord/voltha-protos/v2/go/openflow_13"
+	"github.com/opencord/voltha-protos/v2/go/voltha"
+)
+
+type LogicalDeviceManager interface {
+	GetLogicalPort(lPortId *voltha.LogicalPortId) (*voltha.LogicalPort, error)
+	EnableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{})
+	DisableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{})
+	UpdateFlowTable(ctx context.Context, id string, flow *openflow_13.OfpFlowMod, ch chan interface{})
+	UpdateMeterTable(ctx context.Context, id string, meter *openflow_13.OfpMeterMod, ch chan interface{})
+	UpdateGroupTable(ctx context.Context, id string, groupMod *openflow_13.OfpGroupMod, ch chan interface{})
+	GetLogicalDevice(id string) (*voltha.LogicalDevice, error)
+	ListManagedLogicalDevices() (*voltha.LogicalDevices, error)
+	ListLogicalDevices() (*voltha.LogicalDevices, error)
+	ListLogicalDeviceFlows(ctx context.Context, id string) (*openflow_13.Flows, error)
+	ListLogicalDeviceFlowGroups(ctx context.Context, id string) (*openflow_13.FlowGroups, error)
+	ListLogicalDevicePorts(ctx context.Context, id string) (*voltha.LogicalPorts, error)
+	ListLogicalDeviceMeters(ctx context.Context, id string) (*openflow_13.Meters, error)
+	PacketOut(packet *openflow_13.PacketOut) error
+}
diff --git a/rw_core/flow_decomposition/flow_decomposer_test.go b/rw_core/flow_decomposition/flow_decomposer_test.go
index f21f589..a24765e 100644
--- a/rw_core/flow_decomposition/flow_decomposer_test.go
+++ b/rw_core/flow_decomposition/flow_decomposer_test.go
@@ -18,6 +18,7 @@
 import (
 	"errors"
 	"github.com/opencord/voltha-go/rw_core/graph"
+	"github.com/opencord/voltha-go/rw_core/mocks"
 	fu "github.com/opencord/voltha-lib-go/v2/pkg/flows"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	ofp "github.com/opencord/voltha-protos/v2/go/openflow_13"
@@ -43,6 +44,7 @@
 }
 
 type testDeviceManager struct {
+	mocks.DeviceManager
 	devices map[string]*voltha.Device
 }
 
@@ -110,42 +112,6 @@
 	return false, errors.New("ABSENT.")
 }
 
-func (tdm *testDeviceManager) NotifyInvalidTransition(pcDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) SetAdminStateToEnable(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) CreateLogicalDevice(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) SetupUNILogicalPorts(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DisableAllChildDevices(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteLogicalDevice(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteLogicalPorts(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) DeleteAllChildDevices(cDevice *voltha.Device) error {
-	return nil
-}
-
-func (tdm *testDeviceManager) RunPostDeviceDelete(cDevice *voltha.Device) error {
-	return nil
-}
-
 type testFlowDecomposer struct {
 	dMgr         *testDeviceManager
 	logicalPorts map[uint32]*voltha.LogicalPort
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")
+	}
+}