blob: ac6193ee971e94bf98370f09c7ea5e823063eb19 [file] [log] [blame]
Mahesh Poojary Huawei4d2d5372015-11-05 13:29:15 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Mahesh Poojary Huawei4d2d5372015-11-05 13:29:15 +05303 *
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 java.util.UUID;
19
20import org.junit.Test;
21
22import com.google.common.testing.EqualsTester;
Mahesh Poojary Huawei4d2d5372015-11-05 13:29:15 +053023
24import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.is;
26import static org.hamcrest.Matchers.notNullValue;
27import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
28
Mahesh Poojary Huawei4d2d5372015-11-05 13:29:15 +053029/**
30 * Unit tests for PortChainId class.
31 */
32public class PortChainIdTest {
33
34 final PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
35 final PortChainId sameAsPortChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
36 final PortChainId portChainId2 = PortChainId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
37
38 /**
39 * Checks that the PortChainId class is immutable.
40 */
41 @Test
42 public void testImmutability() {
43 assertThatClassIsImmutable(PortChainId.class);
44 }
45
46 /**
47 * Checks the operation of equals() methods.
48 */
49 @Test
50 public void testEquals() {
51 new EqualsTester().addEqualityGroup(portChainId1, sameAsPortChainId1).addEqualityGroup(portChainId2)
52 .testEquals();
53 }
54
55 /**
56 * Checks the construction of a PortChainId object.
57 */
58 @Test
59 public void testConstruction() {
60 final String portChainIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
61 final PortChainId portChainId = PortChainId.of(portChainIdValue);
62 assertThat(portChainId, is(notNullValue()));
63 assertThat(portChainId.value(), is(UUID.fromString(portChainIdValue)));
64 }
65}