Simon Hunt | c13082f | 2016-08-03 21:20:23 -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 | |
| 19 | import org.junit.Test; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DefaultEdgeLink; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.EdgeLink; |
| 24 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.ui.model.AbstractUiModelTest; |
| 26 | |
| 27 | import static org.junit.Assert.assertEquals; |
| 28 | |
| 29 | /** |
| 30 | * Unit tests for {@link UiEdgeLink}. |
| 31 | */ |
| 32 | public class UiEdgeLinkTest extends AbstractUiModelTest { |
| 33 | |
| 34 | private static final String PHANTOM_HOST_ID = "00:00:00:00:00:00/None"; |
Simon Hunt | b7fd080 | 2016-10-27 12:21:40 -0700 | [diff] [blame] | 35 | private static final String S_D1 = "dev-1"; |
| 36 | private static final String S_P8 = "8"; |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 37 | |
| 38 | private static final DeviceId DEV = DeviceId.deviceId("dev-1"); |
| 39 | private static final PortNumber P8 = PortNumber.portNumber(8); |
| 40 | private static final ConnectPoint CP = new ConnectPoint(DEV, P8); |
| 41 | |
| 42 | private static final EdgeLink EDGE_LINK = |
| 43 | DefaultEdgeLink.createEdgeLink(CP, true); |
| 44 | |
| 45 | @Test |
| 46 | public void basic() { |
| 47 | title("basic"); |
| 48 | UiLinkId id = UiLinkId.uiLinkId(EDGE_LINK); |
| 49 | UiEdgeLink link = new UiEdgeLink(null, id); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 50 | print(link); |
| 51 | print(link.endPointA()); |
Simon Hunt | b7fd080 | 2016-10-27 12:21:40 -0700 | [diff] [blame] | 52 | print(link.endPortA()); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 53 | print(link.endPointB()); |
Simon Hunt | b7fd080 | 2016-10-27 12:21:40 -0700 | [diff] [blame] | 54 | print(link.endPortB()); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 55 | |
| 56 | assertEquals("bad end point A", PHANTOM_HOST_ID, link.endPointA()); |
Simon Hunt | b7fd080 | 2016-10-27 12:21:40 -0700 | [diff] [blame] | 57 | assertEquals("bad end port A", null, link.endPortA()); |
| 58 | |
| 59 | assertEquals("bad end point B", S_D1, link.endPointB()); |
| 60 | assertEquals("bad end port B", S_P8, link.endPortB()); |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 61 | } |
| 62 | } |