2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.vtnrsc.tenantnetwork;
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue;
21 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23 import org.junit.Test;
24 import org.onosproject.vtnrsc.SegmentationId;
26 import com.google.common.testing.EqualsTester;
29 * Unit tests for SegmentationId class.
31 public class SegmentationIdTest {
33 final SegmentationId segmentationID1 = SegmentationId.segmentationId("1");
34 final SegmentationId sameAsSegmentationID1 = SegmentationId.segmentationId("1");
35 final SegmentationId segmentationID2 = SegmentationId.segmentationId("2");
38 * Checks that the SegmentationId class is immutable.
41 public void testImmutability() {
42 assertThatClassIsImmutable(SegmentationId.class);
46 * Checks the operation of equals() methods.
49 public void testEquals() {
50 new EqualsTester().addEqualityGroup(segmentationID1, sameAsSegmentationID1)
51 .addEqualityGroup(segmentationID2).testEquals();
55 * Checks the construction of a segmentationId object.
58 public void testConstruction() {
59 final String segmentationIdValue = "s";
60 final SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdValue);
61 assertThat(segmentationId, is(notNullValue()));
62 assertThat(segmentationId.segmentationId(), is(segmentationIdValue));