blob: 5661cb9b1fda263a9300af4ce4397feedeef80db [file] [log] [blame]
Brian Stanke0e5c94e2016-03-08 11:20:04 -05001/*
2 * Copyright 2016 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.incubator.net.virtual;
18
19import com.google.common.testing.EqualsTester;
20import org.junit.Test;
21import org.onosproject.incubator.net.tunnel.TunnelId;
22import org.onosproject.net.ConnectPoint;
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.PortNumber;
25
26import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
27
28/**
29 * Test of the default virtual link model entity.
30 */
31public class DefaultVirtualLinkTest {
32 final String deviceIdValue1 = "DEVICE_ID1";
33 final String deviceIdValue2 = "DEVICE_ID2";
34
35 /**
36 * Checks that the DefaultVirtualLink class is immutable.
37 */
38 @Test
39 public void testImmutability() {
40 assertThatClassIsImmutable(DefaultVirtualLink.class);
41 }
42
43 @Test
44 public void testEquality() {
45 DefaultVirtualDevice device1 =
46 new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
47 DefaultVirtualDevice device2 =
48 new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue2));
49 ConnectPoint src = new ConnectPoint(device1.id(), PortNumber.portNumber(1));
50 ConnectPoint dst = new ConnectPoint(device2.id(), PortNumber.portNumber(2));
51
52 DefaultVirtualLink link1 = new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(0));
53 DefaultVirtualLink link2 = new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(0));
54 DefaultVirtualLink link3 = new DefaultVirtualLink(NetworkId.networkId(0), src, dst, TunnelId.valueOf(1));
55 DefaultVirtualLink link4 = new DefaultVirtualLink(NetworkId.networkId(1), src, dst, TunnelId.valueOf(0));
56
57 new EqualsTester().addEqualityGroup(link1, link2).addEqualityGroup(link3)
58 .addEqualityGroup(link4).testEquals();
59 }
60}