blob: b99e7e61c4ce2ffbcc52b8ff86a3c8374504bceb [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.DeviceId;
22
23import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
24
25/**
26 * Test of the default virtual device model entity.
27 */
28public class DefaultVirtualDeviceTest {
29 final String deviceIdValue1 = "DEVICE_ID1";
30 final String deviceIdValue2 = "DEVICE_ID2";
31
32 /**
33 * Checks that the DefaultVirtualDevice class is immutable.
34 */
35 @Test
36 public void testImmutability() {
37 assertThatClassIsImmutable(DefaultVirtualDevice.class);
38 }
39
40 @Test
41 public void testEquality() {
42 DefaultVirtualDevice device1 =
43 new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
44 DefaultVirtualDevice device2 =
45 new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
46 DefaultVirtualDevice device3 =
47 new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue2));
48 DefaultVirtualDevice device4 =
49 new DefaultVirtualDevice(NetworkId.networkId(1), DeviceId.deviceId(deviceIdValue1));
50
51 new EqualsTester().addEqualityGroup(device1, device2).addEqualityGroup(device3)
52 .addEqualityGroup(device4).testEquals();
53 }
54}