blob: 2c9d6a96165099a81f8324f726abfaec0d6a5c74 [file] [log] [blame]
samueljcccfb93e62015-10-28 15:57:27 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcccfb93e62015-10-28 15:57:27 -07003 *
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 */
Ray Milkey6c1bac32015-11-13 14:40:40 -080016package org.onosproject.vtnrsc;
17
18import org.junit.Test;
19
20import com.google.common.testing.EqualsTester;
samueljcccfb93e62015-10-28 15:57:27 -070021
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24import static org.hamcrest.Matchers.notNullValue;
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26
samueljcccfb93e62015-10-28 15:57:27 -070027/**
28 * Unit tests for SubnetId class.
29 */
30public class SubnetIdTest {
31
32 final SubnetId subnetId1 = SubnetId.subnetId("1");
33 final SubnetId sameAsSubnetId1 = SubnetId.subnetId("1");
34 final SubnetId subnetId2 = SubnetId.subnetId("2");
35
36 /**
37 * Checks that the SubnetId class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(SubnetId.class);
42 }
43
44 /**
45 * Checks the operation of equals() methods.
46 */
47 @Test
48 public void testEquals() {
49 new EqualsTester().addEqualityGroup(subnetId1, sameAsSubnetId1).addEqualityGroup(subnetId2)
50 .testEquals();
51 }
52
53 /**
54 * Checks the construction of a SubnetId object.
55 */
56 @Test
57 public void testConstruction() {
58 final String subnetIdValue = "s";
59 final SubnetId subnetId = SubnetId.subnetId(subnetIdValue);
60 assertThat(subnetId, is(notNullValue()));
61 assertThat(subnetId.subnetId(), is(subnetIdValue));
62 }
63}