blob: 15b3870ec1029de434344e166d9b5333ed331857 [file] [log] [blame]
Simon Hunt642bc452016-05-04 19:34:45 -07001/*
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
17package org.onosproject.ui.model;
18
19import org.onosproject.cluster.ClusterService;
20import org.onosproject.cluster.ClusterServiceAdapter;
21import org.onosproject.cluster.ControllerNode;
22import org.onosproject.cluster.NodeId;
23import org.onosproject.mastership.MastershipService;
24import org.onosproject.net.device.DeviceService;
25import org.onosproject.net.flow.FlowRuleService;
26import org.onosproject.net.host.HostService;
27import org.onosproject.net.intent.IntentService;
28import org.onosproject.net.link.LinkService;
29import org.onosproject.net.region.RegionService;
30import org.onosproject.ui.AbstractUiTest;
Simon Hunt4f4ffc32016-08-03 18:30:47 -070031import org.onosproject.ui.UiTopoLayoutService;
Simon Hunt642bc452016-05-04 19:34:45 -070032
33/**
34 * Base class for UI model unit tests.
35 */
36public 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 Hunt4f4ffc32016-08-03 18:30:47 -070046 public UiTopoLayoutService layout() {
47 return null;
48 }
49
50 @Override
Simon Hunt642bc452016-05-04 19:34:45 -070051 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}