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"; |
| 35 | private static final String D1_P8 = "dev-1/8"; |
| 36 | |
| 37 | private static final DeviceId DEV = DeviceId.deviceId("dev-1"); |
| 38 | private static final PortNumber P8 = PortNumber.portNumber(8); |
| 39 | private static final ConnectPoint CP = new ConnectPoint(DEV, P8); |
| 40 | |
| 41 | private static final EdgeLink EDGE_LINK = |
| 42 | DefaultEdgeLink.createEdgeLink(CP, true); |
| 43 | |
| 44 | @Test |
| 45 | public void basic() { |
| 46 | title("basic"); |
| 47 | UiLinkId id = UiLinkId.uiLinkId(EDGE_LINK); |
| 48 | UiEdgeLink link = new UiEdgeLink(null, id); |
| 49 | link.attachEdgeLink(EDGE_LINK); |
| 50 | print(link); |
| 51 | print(link.endPointA()); |
| 52 | print(link.endPointB()); |
| 53 | |
| 54 | assertEquals("bad end point A", PHANTOM_HOST_ID, link.endPointA()); |
| 55 | assertEquals("bad end point B", D1_P8, link.endPointB()); |
| 56 | } |
| 57 | } |