Committed by
Gerrit Code Review
[ONOS-3163] Stub on PortPairManager and PortPairGroupManager
Change-Id: I3c68d3c154212d7677fd6c41dec95ec331b68427
Showing
2 changed files
with
178 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
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 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.concurrent.ConcurrentMap; | ||
19 | +import java.util.concurrent.ConcurrentHashMap; | ||
20 | +import java.util.Collections; | ||
21 | + | ||
22 | +import org.onosproject.vtnrsc.PortPairGroup; | ||
23 | +import org.onosproject.vtnrsc.PortPairGroupId; | ||
24 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; | ||
25 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | ||
26 | + | ||
27 | +/** | ||
28 | + * Provides implementation of the portPairGroupService. | ||
29 | + */ | ||
30 | +public class PortPairGroupManagerTestImpl implements PortPairGroupService { | ||
31 | + | ||
32 | + private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>(); | ||
33 | + | ||
34 | + @Override | ||
35 | + public boolean exists(PortPairGroupId portPairGroupId) { | ||
36 | + return portPairGroupStore.containsKey(portPairGroupId); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public int getPortPairGroupCount() { | ||
41 | + return portPairGroupStore.size(); | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public Iterable<PortPairGroup> getPortPairGroups() { | ||
46 | + return Collections.unmodifiableCollection(portPairGroupStore.values()); | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId) { | ||
51 | + return portPairGroupStore.get(portPairGroupId); | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public boolean createPortPairGroup(PortPairGroup portPairGroup) { | ||
56 | + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); | ||
57 | + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { | ||
58 | + return false; | ||
59 | + } | ||
60 | + return true; | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean updatePortPairGroup(PortPairGroup portPairGroup) { | ||
65 | + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); | ||
70 | + | ||
71 | + if (!portPairGroup.equals(portPairGroupStore.get(portPairGroup.portPairGroupId()))) { | ||
72 | + return false; | ||
73 | + } | ||
74 | + return true; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public boolean removePortPairGroup(PortPairGroupId portPairGroupId) { | ||
79 | + return true; | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void addListener(PortPairGroupListener listener) { | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void removeListener(PortPairGroupListener listener) { | ||
88 | + } | ||
89 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
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 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.concurrent.ConcurrentMap; | ||
19 | +import java.util.concurrent.ConcurrentHashMap; | ||
20 | +import java.util.Collections; | ||
21 | + | ||
22 | +import org.onosproject.vtnrsc.PortPair; | ||
23 | +import org.onosproject.vtnrsc.PortPairId; | ||
24 | +import org.onosproject.vtnrsc.portpair.PortPairListener; | ||
25 | +import org.onosproject.vtnrsc.portpair.PortPairService; | ||
26 | + | ||
27 | +/** | ||
28 | + * Provides implementation of the portPairService. | ||
29 | + */ | ||
30 | +public class PortPairManagerTestImpl implements PortPairService { | ||
31 | + | ||
32 | + private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>(); | ||
33 | + | ||
34 | + @Override | ||
35 | + public boolean exists(PortPairId portPairId) { | ||
36 | + return portPairStore.containsKey(portPairId); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public int getPortPairCount() { | ||
41 | + return portPairStore.size(); | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public Iterable<PortPair> getPortPairs() { | ||
46 | + return Collections.unmodifiableCollection(portPairStore.values()); | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public PortPair getPortPair(PortPairId portPairId) { | ||
51 | + return portPairStore.get(portPairId); | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public boolean createPortPair(PortPair portPair) { | ||
56 | + portPairStore.put(portPair.portPairId(), portPair); | ||
57 | + if (!portPairStore.containsKey(portPair.portPairId())) { | ||
58 | + return false; | ||
59 | + } | ||
60 | + return true; | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean updatePortPair(PortPair portPair) { | ||
65 | + if (!portPairStore.containsKey(portPair.portPairId())) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + portPairStore.put(portPair.portPairId(), portPair); | ||
70 | + | ||
71 | + if (!portPair.equals(portPairStore.get(portPair.portPairId()))) { | ||
72 | + return false; | ||
73 | + } | ||
74 | + return true; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public boolean removePortPair(PortPairId portPairId) { | ||
79 | + return true; | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void addListener(PortPairListener listener) { | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void removeListener(PortPairListener listener) { | ||
88 | + } | ||
89 | +} |
-
Please register or login to post a comment