Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -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.DefaultLink; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.net.provider.ProviderId; |
| 26 | import org.onosproject.ui.model.AbstractUiModelTest; |
| 27 | |
| 28 | import static org.junit.Assert.assertEquals; |
| 29 | import static org.onosproject.net.DeviceId.deviceId; |
| 30 | import static org.onosproject.net.PortNumber.portNumber; |
| 31 | |
| 32 | /** |
| 33 | * Unit tests for {@link UiLinkId}. |
| 34 | */ |
| 35 | public class UiLinkIdTest extends AbstractUiModelTest { |
| 36 | |
| 37 | |
| 38 | private static final ProviderId PROVIDER_ID = ProviderId.NONE; |
| 39 | |
| 40 | private static final DeviceId DEV_X = deviceId("device-X"); |
| 41 | private static final DeviceId DEV_Y = deviceId("device-Y"); |
| 42 | private static final PortNumber P1 = portNumber(1); |
| 43 | private static final PortNumber P2 = portNumber(2); |
| 44 | |
| 45 | private static final ConnectPoint CP_X = new ConnectPoint(DEV_X, P1); |
| 46 | private static final ConnectPoint CP_Y = new ConnectPoint(DEV_Y, P2); |
| 47 | |
| 48 | private static final Link LINK_X_TO_Y = DefaultLink.builder() |
| 49 | .providerId(ProviderId.NONE) |
| 50 | .src(CP_X) |
| 51 | .dst(CP_Y) |
| 52 | .type(Link.Type.DIRECT) |
| 53 | .build(); |
| 54 | |
| 55 | private static final Link LINK_Y_TO_X = DefaultLink.builder() |
| 56 | .providerId(ProviderId.NONE) |
| 57 | .src(CP_Y) |
| 58 | .dst(CP_X) |
| 59 | .type(Link.Type.DIRECT) |
| 60 | .build(); |
| 61 | |
| 62 | |
| 63 | @Test |
| 64 | public void canonical() { |
| 65 | title("canonical"); |
| 66 | UiLinkId one = UiLinkId.uiLinkId(LINK_X_TO_Y); |
| 67 | UiLinkId two = UiLinkId.uiLinkId(LINK_Y_TO_X); |
| 68 | print("link one: %s", one); |
| 69 | print("link two: %s", two); |
| 70 | assertEquals("not equiv", one, two); |
| 71 | } |
| 72 | } |