blob: 785900b0dcabc25d82cbce1ad45225e924d328bf [file] [log] [blame]
Ray Milkey85267002016-11-16 11:06:35 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Ray Milkey85267002016-11-16 11:06:35 -08003 *
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 */
Avantika-Huawei9e848e82016-09-01 12:12:42 +053016package org.onosproject.pcelabelstore.util;
17
18import java.util.HashMap;
19import java.util.Map;
20import java.util.Set;
21
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.config.Config;
24import org.onosproject.net.config.ConfigApplyDelegate;
25import org.onosproject.net.config.ConfigFactory;
26import org.onosproject.net.config.NetworkConfigListener;
27import org.onosproject.net.config.NetworkConfigRegistry;
28import org.onosproject.net.config.NetworkConfigService;
29import org.onosproject.net.config.SubjectFactory;
30import org.onosproject.pcep.api.DeviceCapability;
31
32import com.fasterxml.jackson.databind.JsonNode;
33import com.fasterxml.jackson.databind.ObjectMapper;
34import com.fasterxml.jackson.databind.node.JsonNodeFactory;
35import com.fasterxml.jackson.databind.node.ObjectNode;
36
37/* Mock test for network config registry. */
38public class MockNetConfigRegistryAdapter implements NetworkConfigService, NetworkConfigRegistry {
39 private ConfigFactory cfgFactory;
40 private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
41
42 @Override
43 public void registerConfigFactory(ConfigFactory configFactory) {
44 cfgFactory = configFactory;
45 }
46
47 @Override
48 public void unregisterConfigFactory(ConfigFactory configFactory) {
49 cfgFactory = null;
50 }
51
52 @Override
53 public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
54 if (configClass == DeviceCapability.class) {
55 DeviceCapability devCap = new DeviceCapability();
56 classConfig.put((DeviceId) subject, devCap);
57
58 JsonNode node = new ObjectNode(new MockJsonNode());
59 ObjectMapper mapper = new ObjectMapper();
60 ConfigApplyDelegate delegate = new InternalApplyDelegate();
61 devCap.init((DeviceId) subject, null, node, mapper, delegate);
62 return (C) devCap;
63 }
64
65 return null;
66 }
67
68 @Override
69 public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
70 classConfig.remove(subject);
71 }
72
73 @Override
74 public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
75 if (configClass == DeviceCapability.class) {
76 return (C) classConfig.get(subject);
77 }
78 return null;
79 }
80
81 private class MockJsonNode extends JsonNodeFactory {
82 }
83
84 // Auxiliary delegate to receive notifications about changes applied to
85 // the network configuration - by the apps.
86 private class InternalApplyDelegate implements ConfigApplyDelegate {
87 @Override
88 public void onApply(Config config) {
89 //configs.put(config.subject(), config.node());
90 }
91 }
92
93 @Override
94 public void addListener(NetworkConfigListener listener) {
95 // TODO Auto-generated method stub
96
97 }
98
99 @Override
100 public void removeListener(NetworkConfigListener listener) {
101 // TODO Auto-generated method stub
102
103 }
104
105 @Override
106 public Set<ConfigFactory> getConfigFactories() {
107 // TODO Auto-generated method stub
108 return null;
109 }
110
111 @Override
112 public <S, C extends Config<S>> Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass) {
113 // TODO Auto-generated method stub
114 return null;
115 }
116
117 @Override
118 public <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass) {
119 // TODO Auto-generated method stub
120 return null;
121 }
122
123 @Override
124 public Set<Class> getSubjectClasses() {
125 // TODO Auto-generated method stub
126 return null;
127 }
128
129 @Override
130 public SubjectFactory getSubjectFactory(String subjectClassKey) {
131 // TODO Auto-generated method stub
132 return null;
133 }
134
135 @Override
136 public SubjectFactory getSubjectFactory(Class subjectClass) {
137 // TODO Auto-generated method stub
138 return null;
139 }
140
141 @Override
142 public Class<? extends Config> getConfigClass(String subjectClassKey, String configKey) {
143 // TODO Auto-generated method stub
144 return null;
145 }
146
147 @Override
148 public <S> Set<S> getSubjects(Class<S> subjectClass) {
149 // TODO Auto-generated method stub
150 return null;
151 }
152
153 @Override
154 public <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass) {
155 // TODO Auto-generated method stub
156 return null;
157 }
158
159 @Override
160 public <S> Set<? extends Config<S>> getConfigs(S subject) {
161 // TODO Auto-generated method stub
162 return null;
163 }
164
165 @Override
166 public <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass, JsonNode json) {
167 // TODO Auto-generated method stub
168 return null;
169 }
170
171 @Override
172 public <S, C extends Config<S>> C applyConfig(String subjectClassKey, S subject, String configKey, JsonNode json) {
173 // TODO Auto-generated method stub
174 return null;
175 }
176
177 @Override
178 public <S> void removeConfig(String subjectClassKey, S subject, String configKey) {
179 // TODO Auto-generated method stub
180
181 }
182
183 @Override
184 public <S> void removeConfig(S subject) {
185 // TODO Auto-generated method stub
186
187 }
188
189 @Override
190 public <S> void removeConfig() {
191 // TODO Auto-generated method stub
192
193 }
194}