blob: 97a5480907bd194beba5bf23e3c3b8b78f3e3661 [file] [log] [blame]
Simon Huntc13082f2016-08-03 21:20:23 -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.topo;
18
19import org.junit.Test;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DefaultEdgeLink;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.EdgeLink;
24import org.onosproject.net.PortNumber;
25import org.onosproject.ui.model.AbstractUiModelTest;
26
27import static org.junit.Assert.assertEquals;
28
29/**
30 * Unit tests for {@link UiEdgeLink}.
31 */
32public class UiEdgeLinkTest extends AbstractUiModelTest {
33
34 private static final String PHANTOM_HOST_ID = "00:00:00:00:00:00/None";
Simon Huntb7fd0802016-10-27 12:21:40 -070035 private static final String S_D1 = "dev-1";
36 private static final String S_P8 = "8";
Simon Huntc13082f2016-08-03 21:20:23 -070037
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 Huntc13082f2016-08-03 21:20:23 -070050 print(link);
51 print(link.endPointA());
Simon Huntb7fd0802016-10-27 12:21:40 -070052 print(link.endPortA());
Simon Huntc13082f2016-08-03 21:20:23 -070053 print(link.endPointB());
Simon Huntb7fd0802016-10-27 12:21:40 -070054 print(link.endPortB());
Simon Huntc13082f2016-08-03 21:20:23 -070055
56 assertEquals("bad end point A", PHANTOM_HOST_ID, link.endPointA());
Simon Huntb7fd0802016-10-27 12:21:40 -070057 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 Huntc13082f2016-08-03 21:20:23 -070061 }
62}