Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.drivers.netconf; |
| 17 | |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.core.CoreService; |
| 20 | import org.onosproject.core.DefaultApplicationId; |
| 21 | import org.onosproject.core.IdGenerator; |
| 22 | import org.onosproject.core.Version; |
| 23 | import org.onosproject.net.intent.MockIdGenerator; |
| 24 | |
Thomas Vachuska | 2048c1f | 2017-05-10 19:32:22 -0700 | [diff] [blame] | 25 | import java.util.HashSet; |
| 26 | import java.util.Set; |
| 27 | |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 28 | public 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 Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 38 | } |
| 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 Vachuska | 2048c1f | 2017-05-10 19:32:22 -0700 | [diff] [blame] | 85 | return MockIdGenerator.INSTANCE; |
Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | } |