VOL-1838 Unit test cases for golang openolt adapter device_handler.go
1.Mocked AdapterproxyIntf and coreproxyIntf Interfaces for unit test cases.
2. Added few unit testcases for the device_handler.go functions
Change-Id: I793d94055d2c0480e614e918c064df51cdf0b0ae
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index 52e4afd..95bc170 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -33,7 +33,7 @@
"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/ptypes"
- com "github.com/opencord/voltha-go/adapters/common"
+ "github.com/opencord/voltha-go/adapters/adapterif"
"github.com/opencord/voltha-go/common/log"
rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
"github.com/opencord/voltha-protos/go/common"
@@ -51,15 +51,19 @@
MaxTimeOutInMs = 500
)
+func init() {
+ _, _ = log.AddPackage(log.JSON, log.DebugLevel, nil)
+}
+
//DeviceHandler will interact with the OLT device.
type DeviceHandler struct {
deviceID string
deviceType string
adminState string
device *voltha.Device
- coreProxy *com.CoreProxy
- AdapterProxy *com.AdapterProxy
- EventProxy *com.EventProxy
+ coreProxy adapterif.CoreProxy
+ AdapterProxy adapterif.AdapterProxy
+ EventProxy adapterif.EventProxy
openOLT *OpenOLT
exitChannel chan int
lockDevice sync.RWMutex
@@ -97,7 +101,7 @@
}
//NewDeviceHandler creates a new device handler
-func NewDeviceHandler(cp *com.CoreProxy, ap *com.AdapterProxy, ep *com.EventProxy, device *voltha.Device, adapter *OpenOLT) *DeviceHandler {
+func NewDeviceHandler(cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, device *voltha.Device, adapter *OpenOLT) *DeviceHandler {
var dh DeviceHandler
dh.coreProxy = cp
dh.AdapterProxy = ap