blob: d10ca7101977196c591bd07df700dd70adf02afa [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Sean Condonfae8e662016-12-15 10:25:13 +00003 *
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
Sean Condonfae8e662016-12-15 10:25:13 +000018import org.onosproject.core.ApplicationId;
19import org.onosproject.core.CoreService;
20import org.onosproject.core.DefaultApplicationId;
21import org.onosproject.core.IdGenerator;
22import org.onosproject.core.Version;
23import org.onosproject.net.intent.MockIdGenerator;
24
Thomas Vachuska2048c1f2017-05-10 19:32:22 -070025import java.util.HashSet;
26import java.util.Set;
27
Sean Condonfae8e662016-12-15 10:25:13 +000028public 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");
Sean Condonfae8e662016-12-15 10:25:13 +000038 }
39
40 @Override
41 public Version version() {
42 return version;
43 }
44
45 @Override
46 public Set<ApplicationId> getAppIds() {
47 return appIds;
48 }
49
50 @Override
51 public ApplicationId getAppId(Short id) {
52 for (ApplicationId appId:appIds) {
53 if (appId.id() == id.shortValue()) {
54 return appId;
55 }
56 }
57 return null;
58 }
59
60 @Override
61 public ApplicationId getAppId(String name) {
62 for (ApplicationId appId:appIds) {
63 if (appId.name().equalsIgnoreCase(name)) {
64 return appId;
65 }
66 }
67 return null;
68 }
69
70 @Override
71 public ApplicationId registerApplication(String name) {
72 ApplicationId appId = new DefaultApplicationId(101, name);
73 appIds.add(appId);
74 return appId;
75 }
76
77 @Override
78 public ApplicationId registerApplication(String name, Runnable preDeactivate) {
79 // TODO Auto-generated method stub
80 return null;
81 }
82
83 @Override
84 public IdGenerator getIdGenerator(String topic) {
Thomas Vachuska2048c1f2017-05-10 19:32:22 -070085 return MockIdGenerator.INSTANCE;
Sean Condonfae8e662016-12-15 10:25:13 +000086 }
87
88}