blob: 9bc521db23059d663171ae6b854b4fb5e2db3103 [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;
Yoonseon Han6c603892016-09-01 11:52:21 -070021import org.onosproject.net.ConnectPoint;
Brian Stanke0e5c94e2016-03-08 11:20:04 -050022import org.onosproject.net.PortNumber;
Brian Stanke7a81b532016-06-14 15:43:51 -040023import org.onosproject.net.TestDeviceParams;
Brian Stanke0e5c94e2016-03-08 11:20:04 -050024
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26
27/**
28 * Test of the default virtual port model entity.
29 */
Brian Stanke7a81b532016-06-14 15:43:51 -040030public class DefaultVirtualPortTest extends TestDeviceParams {
Brian Stanke0e5c94e2016-03-08 11:20:04 -050031 /**
32 * Checks that the DefaultVirtualPort class is immutable.
33 */
34 @Test
35 public void testImmutability() {
36 assertThatClassIsImmutable(DefaultVirtualPort.class);
37 }
38
39 @Test
40 public void testEquality() {
41 DefaultVirtualDevice device1 =
Brian Stanke7a81b532016-06-14 15:43:51 -040042 new DefaultVirtualDevice(NetworkId.networkId(0), DID1);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050043 DefaultVirtualDevice device2 =
Brian Stanke7a81b532016-06-14 15:43:51 -040044 new DefaultVirtualDevice(NetworkId.networkId(0), DID2);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050045
Yoonseon Han6c603892016-09-01 11:52:21 -070046 ConnectPoint cpA = new ConnectPoint(device1.id(), PortNumber.portNumber(1));
47 ConnectPoint cpB = new ConnectPoint(device1.id(), PortNumber.portNumber(2));
48 ConnectPoint cpC = new ConnectPoint(device2.id(), PortNumber.portNumber(2));
Brian Stanke0e5c94e2016-03-08 11:20:04 -050049
50 DefaultVirtualPort port1 =
Yoonseon Han6c603892016-09-01 11:52:21 -070051 new DefaultVirtualPort(NetworkId.networkId(0), device1,
52 PortNumber.portNumber(1), cpA);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050053 DefaultVirtualPort port2 =
Yoonseon Han6c603892016-09-01 11:52:21 -070054 new DefaultVirtualPort(NetworkId.networkId(0), device1,
55 PortNumber.portNumber(1), cpA);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050056 DefaultVirtualPort port3 =
Yoonseon Han6c603892016-09-01 11:52:21 -070057 new DefaultVirtualPort(NetworkId.networkId(0), device1,
58 PortNumber.portNumber(2), cpB);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050059 DefaultVirtualPort port4 =
Yoonseon Han6c603892016-09-01 11:52:21 -070060 new DefaultVirtualPort(NetworkId.networkId(1), device2,
61 PortNumber.portNumber(2), cpC);
Brian Stanke0e5c94e2016-03-08 11:20:04 -050062
63
64 new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3)
65 .addEqualityGroup(port4).testEquals();
66 }
67}