blob: 6abf628bde560cd781e321c46c71d2a720f4e9da [file] [log] [blame]
kdarapu381c6902019-07-31 18:23:16 +05301/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//Package mocks provides the mocks for openolt-adapter.
18package mocks
19
20import (
21 "context"
22 "errors"
23
24 "github.com/opencord/voltha-go/kafka"
25 "github.com/opencord/voltha-protos/go/voltha"
26)
27
28// MockCoreProxy mocks the CoreProxy interface
29type MockCoreProxy struct {
30 // Values to be used in test can reside inside this structure
31 // TODO store relevant info in this, use this info for negative and positive tests
32}
33
34// UpdateCoreReference mock updatesCoreReference
35func (mp *MockCoreProxy) UpdateCoreReference(deviceID string, coreReference string) {
36 panic("implement me")
37}
38
39// DeleteCoreReference mock DeleteCoreReference function
40func (mp *MockCoreProxy) DeleteCoreReference(deviceID string) {
41 panic("implement me")
42}
43
44// GetCoreTopic implements mock GetCoreTopic
45func (mp *MockCoreProxy) GetCoreTopic(deviceID string) kafka.Topic {
46 panic("implement me")
47}
48
49// GetAdapterTopic implements mock GetAdapterTopic
50func (mp *MockCoreProxy) GetAdapterTopic(args ...string) kafka.Topic {
51 panic("implement me")
52}
53
54// RegisterAdapter implements mock RegisterAdapter
55func (mp *MockCoreProxy) RegisterAdapter(ctx context.Context, adapter *voltha.Adapter,
56 deviceTypes *voltha.DeviceTypes) error {
57 if ctx == nil || adapter == nil || deviceTypes == nil {
58
59 return errors.New("registerAdapter func parameters cannot be nil")
60 }
61 return nil
62
63}
64
65// DeviceUpdate implements mock DeviceUpdate
66func (mp *MockCoreProxy) DeviceUpdate(ctx context.Context, device *voltha.Device) error {
67 panic("implement me")
68}
69
70// PortCreated implements mock PortCreated
71func (mp *MockCoreProxy) PortCreated(ctx context.Context, deviceID string, port *voltha.Port) error {
72 panic("implement me")
73}
74
75// PortsStateUpdate implements mock PortsStateUpdate
76func (mp *MockCoreProxy) PortsStateUpdate(ctx context.Context, deviceID string, operStatus voltha.OperStatus_OperStatus) error {
77 panic("implement me")
78}
79
80// DeleteAllPorts implements mock DeleteAllPorts
81func (mp *MockCoreProxy) DeleteAllPorts(ctx context.Context, deviceID string) error {
82 panic("implement me")
83}
84
85// DeviceStateUpdate implements mock DeviceStateUpdate
86func (mp *MockCoreProxy) DeviceStateUpdate(ctx context.Context, deviceID string,
87 connStatus voltha.ConnectStatus_ConnectStatus, operStatus voltha.OperStatus_OperStatus) error {
88 panic("implement me")
89}
90
91// ChildDeviceDetected implements mock ChildDeviceDetected
92func (mp *MockCoreProxy) ChildDeviceDetected(ctx context.Context, parentDeviceID string, parentPortNo int,
93 childDeviceType string, channelID int, vendorID string, serialNumber string, onuID int64) (*voltha.Device, error) {
94 panic("implement me")
95}
96
97// ChildDevicesLost implements mock ChildDevicesLost
98func (mp *MockCoreProxy) ChildDevicesLost(ctx context.Context, parentDeviceID string) error {
99 panic("implement me")
100}
101
102// ChildDevicesDetected implements mock ChildDevicesDetecte
103func (mp *MockCoreProxy) ChildDevicesDetected(ctx context.Context, parentDeviceID string) error {
104 panic("implement me")
105}
106
107// GetDevice implements mock GetDevice
108func (mp *MockCoreProxy) GetDevice(ctx context.Context, parentDeviceID string, deviceID string) (*voltha.Device, error) {
109 if parentDeviceID != "" {
110 return &voltha.Device{}, nil
111 }
112 return nil, errors.New("device detection failed")
113}
114
115// GetChildDevice implements mock GetChildDevice
116func (mp *MockCoreProxy) GetChildDevice(ctx context.Context, parentDeviceID string, kwargs map[string]interface{}) (*voltha.Device, error) {
117 if parentDeviceID != "" {
118 return &voltha.Device{}, nil
119 }
120 return nil, errors.New("device detection failed")
121}
122
123// GetChildDevices implements mock GetChildDevices
124func (mp *MockCoreProxy) GetChildDevices(ctx context.Context, parentDeviceID string) (*voltha.Devices, error) {
125 if parentDeviceID != "" {
126 return &voltha.Devices{}, nil
127 }
128 return nil, errors.New("device detection failed")
129}
130
131// SendPacketIn implements mock SendPacketIn
132func (mp *MockCoreProxy) SendPacketIn(ctx context.Context, deviceID string, port uint32, pktPayload []byte) error {
133 panic("implement me")
134}