blob: 134577acc20bb8b5e7aa0961f0b46ed18c0fb21b [file] [log] [blame]
bobzhou1aaecbd2015-10-31 17:41:34 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
bobzhou1aaecbd2015-10-31 17:41:34 +08003 *
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;
bobzhou1aaecbd2015-10-31 17:41:34 +080021
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
bobzhou1aaecbd2015-10-31 17:41:34 +080027/**
28 * Unit tests for RouterId class.
29 */
30public class RouterIdTest {
31 final RouterId routerId1 = RouterId.valueOf("1");
32 final RouterId sameAsRouterId1 = RouterId.valueOf("1");
33 final RouterId routerId2 = RouterId.valueOf("2");
34
35 /**
36 * Checks that the RouterId class is immutable.
37 */
38 @Test
39 public void testImmutability() {
40 assertThatClassIsImmutable(RouterId.class);
41 }
42
43 /**
44 * Checks the operation of equals() methods.
45 */
46 @Test
47 public void testEquals() {
48 new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2)
49 .testEquals();
50 }
51
52 /**
53 * Checks the construction of a RouterId object.
54 */
55 @Test
56 public void testConstruction() {
57 final String routerIdValue = "s";
58 final RouterId routerId = RouterId.valueOf(routerIdValue);
59 assertThat(routerId, is(notNullValue()));
60 assertThat(routerId.routerId(), is(routerIdValue));
61 }
62}