blob: 6b83e3acfa68f14ae2750bb53b1288311b3b9e52 [file] [log] [blame]
Brian Stanke0e5c94e2016-03-08 11:20:04 -05001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Brian Stanke0e5c94e2016-03-08 11:20:04 -05003 *
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;
Brian Stanke0e5c94e2016-03-08 11:20:04 -050022import org.onosproject.net.Port;
23import org.onosproject.net.PortNumber;
Brian Stanke7a81b532016-06-14 15:43:51 -040024import org.onosproject.net.TestDeviceParams;
Brian Stanke0e5c94e2016-03-08 11:20:04 -050025
26import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
27
28/**
29 * Test of the default virtual port model entity.
30 */
Brian Stanke7a81b532016-06-14 15:43:51 -040031public class DefaultVirtualPortTest extends TestDeviceParams {
Brian Stanke0e5c94e2016-03-08 11:20:04 -050032
33 /**
34 * Checks that the DefaultVirtualPort class is immutable.
35 */
36 @Test
37 public void testImmutability() {
38 assertThatClassIsImmutable(DefaultVirtualPort.class);
39 }
40
41 @Test
42 public void testEquality() {
43 DefaultVirtualDevice device1 =
Brian Stanke7a81b532016-06-14 15:43:51 -040044 new DefaultVirtualDevice(NetworkId.networkId(0), DID1);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050045 DefaultVirtualDevice device2 =
Brian Stanke7a81b532016-06-14 15:43:51 -040046 new DefaultVirtualDevice(NetworkId.networkId(0), DID2);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050047
48 Port portA = new DefaultPort(device1, PortNumber.portNumber(1), true);
49 Port portB = new DefaultPort(device1, PortNumber.portNumber(2), true);
50 Port portC = new DefaultPort(device2, PortNumber.portNumber(2), true);
51
52 DefaultVirtualPort port1 =
53 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
54 DefaultVirtualPort port2 =
55 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
56 DefaultVirtualPort port3 =
57 new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(2), portB);
58 DefaultVirtualPort port4 =
59 new DefaultVirtualPort(NetworkId.networkId(1), device2, PortNumber.portNumber(2), portC);
60
61
62 new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3)
63 .addEqualityGroup(port4).testEquals();
64 }
65}