blob: 4a71661c6d14a6c6b0d81691b88c20d54e7ce7f0 [file] [log] [blame]
Takahiro Suzukid7bf8202020-12-17 20:21:59 +09001/*
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
23 "github.com/opencord/voltha-lib-go/v3/pkg/db"
24 tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
25 tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile"
26)
27
28// MockTechProfile mock struct for OpenoltClient.
29type MockTechProfile struct {
30 TpID uint32
31}
32
33// SetKVClient to mock techprofile SetKVClient method
34func (m MockTechProfile) SetKVClient(ctx context.Context) *db.Backend {
35 return &db.Backend{Client: &MockKVClient{}}
36}
37
38// GetTechProfileInstanceKVPath to mock techprofile GetTechProfileInstanceKVPath method
39func (m MockTechProfile) GetTechProfileInstanceKVPath(ctx context.Context, techProfiletblID uint32, uniPortName string) string {
40 return ""
41
42}
43
44// GetTPInstanceFromKVStore to mock techprofile GetTPInstanceFromKVStore method
45func (m MockTechProfile) GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (interface{}, error) {
46 logger.Debug(ctx, "Warning Warning Warning: GetTPInstanceFromKVStore")
47 return nil, nil
48
49}
50
51// CreateTechProfInstance to mock techprofile CreateTechProfInstance method
52func (m MockTechProfile) CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (interface{}, error) {
53
54 if techProfiletblID == 64 {
55 return &tp.TechProfile{
56 Name: "mock-tech-profile",
57 SubscriberIdentifier: "257",
58 ProfileType: "mock",
59 Version: 0,
60 NumGemPorts: 2,
61 UpstreamGemPortAttributeList: nil,
62 DownstreamGemPortAttributeList: nil,
63 }, nil
64 } else if techProfiletblID == 65 {
65 return &tp.EponProfile{
66 Name: "mock-epon-profile",
67 SubscriberIdentifier: "257",
68 ProfileType: "mock",
69 Version: 0,
70 NumGemPorts: 2,
71 UpstreamQueueAttributeList: nil,
72 DownstreamQueueAttributeList: nil,
73 }, nil
74 } else {
75 return nil, nil
76 }
77
78}
79
80// DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method
81func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error {
82 return nil
83}
84
85// GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method
86func (m MockTechProfile) GetprotoBufParamValue(ctx context.Context, paramType string, paramKey string) int32 {
87 return 0
88
89}
90
91// GetUsScheduler to mock techprofile GetUsScheduler method
92func (m MockTechProfile) GetUsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
93 return &tp_pb.SchedulerConfig{}, nil
94
95}
96
97// GetDsScheduler to mock techprofile GetDsScheduler method
98func (m MockTechProfile) GetDsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
99 return &tp_pb.SchedulerConfig{}, nil
100}
101
102// GetTrafficScheduler to mock techprofile GetTrafficScheduler method
103func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig,
104 ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler {
105 return &tp_pb.TrafficScheduler{}
106
107}
108
109// GetTrafficQueues to mock techprofile GetTrafficQueues method
110func (m MockTechProfile) GetTrafficQueues(ctx context.Context, tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) {
111 return []*tp_pb.TrafficQueue{{}}, nil
112}
113
114// GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method
115func (m MockTechProfile) GetMulticastTrafficQueues(ctx context.Context, tp *tp.TechProfile) []*tp_pb.TrafficQueue {
116 return []*tp_pb.TrafficQueue{{}}
117}
118
119// GetGemportIDForPbit to mock techprofile GetGemportIDForPbit method
120func (m MockTechProfile) GetGemportIDForPbit(ctx context.Context, tp interface{}, Dir tp_pb.Direction, pbit uint32) uint32 {
121 return 0
122}
123
124// FindAllTpInstances to mock techprofile FindAllTpInstances method
125func (m MockTechProfile) FindAllTpInstances(ctx context.Context, techProfiletblID uint32, ponIntf uint32, onuID uint32) interface{} {
126 return []tp.TechProfile{}
127}