blob: bde6015855f28e90c8267284426b36a2339bc1fb [file] [log] [blame]
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuskabf916ea2015-05-20 18:24:34 -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 */
16
17package org.onosproject.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080018
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.is;
21import static org.hamcrest.Matchers.notNullValue;
22import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23
24import org.junit.Test;
25
26import com.google.common.testing.EqualsTester;
27
28/**
29 * Unit tests for tunnel id class.
30 */
31public class TunnelIdTest {
32
Brian Stanke9a108972016-04-11 15:25:17 -040033 final TunnelId tunnelId1 = TunnelId.valueOf("1");
34 final TunnelId sameAstunnelId1 = TunnelId.valueOf("1");
35 final TunnelId tunnelId2 = TunnelId.valueOf("2");
jcc4a20a5f2015-04-30 15:43:39 +080036
37 /**
38 * Checks that the TunnelId class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42 assertThatClassIsImmutable(TunnelId.class);
43 }
44
45 /**
46 * Checks the operation of equals(), hashCode() and toString() methods.
47 */
48 @Test
49 public void testEquals() {
50 new EqualsTester()
51 .addEqualityGroup(tunnelId1, sameAstunnelId1)
52 .addEqualityGroup(tunnelId2)
53 .testEquals();
54 }
55
56 /**
57 * Checks the construction of a FlowId object.
58 */
59 @Test
60 public void testConstruction() {
Brian Stanke9a108972016-04-11 15:25:17 -040061 final String tunnelIdValue = "7777";
jcc4a20a5f2015-04-30 15:43:39 +080062 final TunnelId tunnelId = TunnelId.valueOf(tunnelIdValue);
63 assertThat(tunnelId, is(notNullValue()));
64 assertThat(tunnelId.id(), is(tunnelIdValue));
65 }
66}