Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 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.incubator.net.virtual; |
| 18 | |
| 19 | import com.google.common.testing.EqualsTester; |
| 20 | import org.junit.Test; |
| 21 | import org.onosproject.net.DefaultPort; |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 22 | import org.onosproject.net.Port; |
| 23 | import org.onosproject.net.PortNumber; |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 24 | import org.onosproject.net.TestDeviceParams; |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 25 | |
| 26 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 27 | |
| 28 | /** |
| 29 | * Test of the default virtual port model entity. |
| 30 | */ |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 31 | public class DefaultVirtualPortTest extends TestDeviceParams { |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 32 | |
| 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 Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 44 | new DefaultVirtualDevice(NetworkId.networkId(0), DID1); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 45 | DefaultVirtualDevice device2 = |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 46 | new DefaultVirtualDevice(NetworkId.networkId(0), DID2); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 47 | |
| 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 | } |