blob: d63c5e66a6b7ce89edab065b013c232fd0657630 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
2 * Copyright 2017-present 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 */
16package org.onosproject.drivers.netconf;
17
18import java.util.HashSet;
19import java.util.Set;
20
21import org.onosproject.core.ApplicationId;
22import org.onosproject.core.CoreService;
23import org.onosproject.core.DefaultApplicationId;
24import org.onosproject.core.IdGenerator;
25import org.onosproject.core.Version;
26import org.onosproject.net.intent.MockIdGenerator;
27
28public class MockCoreService implements CoreService {
29
30 private HashSet<ApplicationId> appIds;
31 private Version version;
32 private IdGenerator idGenerator;
33
34 public MockCoreService() {
35 appIds = new HashSet<ApplicationId>();
36 appIds.add(new DefaultApplicationId(101, "org.onosproject.drivers.netconf"));
37 version = Version.version(1, 1, "1", "1");
38 idGenerator = new MockIdGenerator();
39 }
40
41 @Override
42 public Version version() {
43 return version;
44 }
45
46 @Override
47 public Set<ApplicationId> getAppIds() {
48 return appIds;
49 }
50
51 @Override
52 public ApplicationId getAppId(Short id) {
53 for (ApplicationId appId:appIds) {
54 if (appId.id() == id.shortValue()) {
55 return appId;
56 }
57 }
58 return null;
59 }
60
61 @Override
62 public ApplicationId getAppId(String name) {
63 for (ApplicationId appId:appIds) {
64 if (appId.name().equalsIgnoreCase(name)) {
65 return appId;
66 }
67 }
68 return null;
69 }
70
71 @Override
72 public ApplicationId registerApplication(String name) {
73 ApplicationId appId = new DefaultApplicationId(101, name);
74 appIds.add(appId);
75 return appId;
76 }
77
78 @Override
79 public ApplicationId registerApplication(String name, Runnable preDeactivate) {
80 // TODO Auto-generated method stub
81 return null;
82 }
83
84 @Override
85 public IdGenerator getIdGenerator(String topic) {
86 return idGenerator;
87 }
88
89}