Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-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 | |
| 17 | package org.onosproject.ui.model; |
| 18 | |
| 19 | import org.onosproject.cluster.ClusterService; |
| 20 | import org.onosproject.cluster.ClusterServiceAdapter; |
| 21 | import org.onosproject.cluster.ControllerNode; |
| 22 | import org.onosproject.cluster.NodeId; |
| 23 | import org.onosproject.mastership.MastershipService; |
| 24 | import org.onosproject.net.device.DeviceService; |
| 25 | import org.onosproject.net.flow.FlowRuleService; |
| 26 | import org.onosproject.net.host.HostService; |
| 27 | import org.onosproject.net.intent.IntentService; |
| 28 | import org.onosproject.net.link.LinkService; |
| 29 | import org.onosproject.net.region.RegionService; |
| 30 | import org.onosproject.ui.AbstractUiTest; |
Simon Hunt | 4f4ffc3 | 2016-08-03 18:30:47 -0700 | [diff] [blame] | 31 | import org.onosproject.ui.UiTopoLayoutService; |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Base class for UI model unit tests. |
| 35 | */ |
| 36 | public class AbstractUiModelTest extends AbstractUiTest { |
| 37 | |
| 38 | /** |
| 39 | * Returns canned results. |
| 40 | * At some future point, we may make this "programmable", so that |
| 41 | * it returns certain values based on element IDs etc. |
| 42 | */ |
| 43 | protected static final ServiceBundle MOCK_SERVICES = |
| 44 | new ServiceBundle() { |
| 45 | @Override |
Simon Hunt | 4f4ffc3 | 2016-08-03 18:30:47 -0700 | [diff] [blame] | 46 | public UiTopoLayoutService layout() { |
| 47 | return null; |
| 48 | } |
| 49 | |
| 50 | @Override |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 51 | public ClusterService cluster() { |
| 52 | return MOCK_CLUSTER; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public MastershipService mastership() { |
| 57 | return null; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public RegionService region() { |
| 62 | return null; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public DeviceService device() { |
| 67 | return null; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public LinkService link() { |
| 72 | return null; |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public HostService host() { |
| 77 | return null; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public IntentService intent() { |
| 82 | return null; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public FlowRuleService flow() { |
| 87 | return null; |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | private static final ClusterService MOCK_CLUSTER = new MockClusterService(); |
| 92 | |
| 93 | |
| 94 | private static class MockClusterService extends ClusterServiceAdapter { |
| 95 | @Override |
| 96 | public ControllerNode.State getState(NodeId nodeId) { |
| 97 | // For now, a hardcoded state of ACTIVE (but not READY) |
| 98 | // irrespective of the node ID. |
| 99 | return ControllerNode.State.ACTIVE; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | } |