blob: 6838ef5b884994ce4d4a1f8128c3ae0fa33920af [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.net.DefaultPort;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.Port;
24import org.onosproject.net.PortNumber;
25
26import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
27
28/**
29 * Test of the default virtual port model entity.
30 */
31public class DefaultVirtualPortTest {
32 final String deviceIdValue1 = "DEVICE_ID1";
33 final String deviceIdValue2 = "DEVICE_ID2";
34
35 /**
36 * Checks that the DefaultVirtualPort class is immutable.
37 */
38 @Test
39 public void testImmutability() {
40 assertThatClassIsImmutable(DefaultVirtualPort.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
50 Port portA = new DefaultPort(device1, PortNumber.portNumber(1), true);
51 Port portB = new DefaultPort(device1, PortNumber.portNumber(2), true);
52 Port portC = new DefaultPort(device2, PortNumber.portNumber(2), true);
53
54 DefaultVirtualPort port1 =
55 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
56 DefaultVirtualPort port2 =
57 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
58 DefaultVirtualPort port3 =
59 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(2), portB);
60 DefaultVirtualPort port4 =
61 new DefaultVirtualPort(NetworkId.networkId(1), device2, PortNumber.portNumber(2), portC);
62
63
64 new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3)
65 .addEqualityGroup(port4).testEquals();
66 }
67}