blob: 545d1d442e007ae9d96ced15581b8d0847a8f3c2 [file] [log] [blame]
samueljcccb9cf932015-10-27 17:18:32 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcccb9cf932015-10-27 17:18:32 -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;
samueljcccb9cf932015-10-27 17:18:32 -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
samueljcccb9cf932015-10-27 17:18:32 -070027/**
28 * Unit tests for SegmentationId class.
29 */
30public class SegmentationIdTest {
31
32 final SegmentationId segmentationID1 = SegmentationId.segmentationId("1");
33 final SegmentationId sameAsSegmentationID1 = SegmentationId.segmentationId("1");
34 final SegmentationId segmentationID2 = SegmentationId.segmentationId("2");
35
36 /**
37 * Checks that the SegmentationId class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(SegmentationId.class);
42 }
43
44 /**
45 * Checks the operation of equals() methods.
46 */
47 @Test
48 public void testEquals() {
49 new EqualsTester().addEqualityGroup(segmentationID1, sameAsSegmentationID1)
50 .addEqualityGroup(segmentationID2).testEquals();
51 }
52
53 /**
54 * Checks the construction of a segmentationId object.
55 */
56 @Test
57 public void testConstruction() {
58 final String segmentationIdValue = "s";
59 final SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdValue);
60 assertThat(segmentationId, is(notNullValue()));
61 assertThat(segmentationId.segmentationId(), is(segmentationIdValue));
62 }
63}