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.topo; |
| 18 | |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 19 | import org.junit.Before; |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.IpAddress; |
| 22 | import org.onosproject.cluster.ControllerNode; |
| 23 | import org.onosproject.cluster.DefaultControllerNode; |
| 24 | import org.onosproject.cluster.NodeId; |
| 25 | import org.onosproject.ui.model.AbstractUiModelTest; |
| 26 | |
| 27 | import static org.junit.Assert.assertEquals; |
| 28 | |
| 29 | /** |
| 30 | * Unit tests for {@link UiClusterMember}. |
| 31 | */ |
| 32 | public class UiClusterMemberTest extends AbstractUiModelTest { |
| 33 | |
| 34 | private static final NodeId NODE_ID = NodeId.nodeId("Node-1"); |
| 35 | private static final IpAddress NODE_IP = IpAddress.valueOf("1.2.3.4"); |
| 36 | |
| 37 | private static final ControllerNode CNODE_1 = |
| 38 | new DefaultControllerNode(NODE_ID, NODE_IP); |
| 39 | |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 40 | private UiTopology topo; |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 41 | private UiClusterMember member; |
| 42 | |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 43 | @Before |
| 44 | public void setUp() { |
| 45 | topo = new UiTopology(); |
| 46 | } |
| 47 | |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 48 | @Test |
| 49 | public void basic() { |
| 50 | title("basic"); |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 51 | member = new UiClusterMember(topo, CNODE_1); |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 52 | print(member); |
| 53 | |
| 54 | assertEquals("wrong id", NODE_ID, member.id()); |
| 55 | assertEquals("wrong IP", NODE_IP, member.ip()); |
| 56 | assertEquals("unex. online", false, member.isOnline()); |
| 57 | assertEquals("unex. ready", false, member.isReady()); |
| 58 | assertEquals("unex. device count", 0, member.deviceCount()); |
| 59 | } |
| 60 | } |