f176089ebcfb890ddef79f3ccecd919cc317090e
[onosfw.git] /
1 /*
2  * Copyright 2015 Open Networking Laboratory
3  *
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 package org.onosproject.vtnrsc.portpair;
17
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;
22
23 import org.junit.Test;
24 import org.onosproject.vtnrsc.PortPairId;
25
26 import com.google.common.testing.EqualsTester;
27 import java.util.UUID;
28
29 /**
30  * Unit tests for PortPairId class.
31  */
32 public class PortPairIdTest {
33
34     final PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
35     final PortPairId sameAsPortPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
36     final PortPairId portPairId2 = PortPairId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
37
38     /**
39      * Checks that the PortPairId class is immutable.
40      */
41     @Test
42     public void testImmutability() {
43         assertThatClassIsImmutable(PortPairId.class);
44     }
45
46     /**
47      * Checks the operation of equals() methods.
48      */
49     @Test
50     public void testEquals() {
51         new EqualsTester().addEqualityGroup(portPairId1, sameAsPortPairId1).addEqualityGroup(portPairId2).testEquals();
52     }
53
54     /**
55      * Checks the construction of a PortPairId object.
56      */
57     @Test
58     public void testConstruction() {
59         final String portPairIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
60         final PortPairId portPairId = PortPairId.of(portPairIdValue);
61         assertThat(portPairId, is(notNullValue()));
62         assertThat(portPairId.value(), is(UUID.fromString(portPairIdValue)));
63     }
64 }