blob: 22510b246e79b29721aef2c8162175ee00b180b3 [file] [log] [blame]
jiangrui72d343a2015-11-11 18:00:16 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jiangrui72d343a2015-11-11 18:00:16 +08003 *
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 */
16package org.onosproject.vtnrsc.floatingip;
17
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.notNullValue;
21import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
22
23import org.junit.Test;
24import org.onosproject.vtnrsc.FloatingIpId;
25
26import com.google.common.testing.EqualsTester;
27
28/**
29 * Unit tests for FloatingIpId class.
30 */
31public class FloatingIpIdTest {
32 private String floatingIpIdStr1 = "5fb63824-4d5c-4b85-9f2f-ebb93c9ce3df";
33 private String floatingIpIdStr2 = "fa44f585-fe02-40d3-afe7-d1d7e5782c99";
34
35 /**
36 * Checks that the FloatingIpId class is immutable.
37 */
38 @Test
39 public void testImmutability() {
40 assertThatClassIsImmutable(FloatingIpId.class);
41 }
42
43 /**
44 * Checks the operation of equals() methods.
45 */
46 @Test
47 public void testEquals() {
48 FloatingIpId id1 = FloatingIpId.of(floatingIpIdStr1);
49 FloatingIpId id2 = FloatingIpId.of(floatingIpIdStr1);
50 FloatingIpId id3 = FloatingIpId.of(floatingIpIdStr2);
51 new EqualsTester().addEqualityGroup(id1, id2).addEqualityGroup(id3)
52 .testEquals();
53 }
54
55 /**
56 * Checks the construction of a FloatingIpId object.
57 */
58 @Test
59 public void testConstruction() {
60 final FloatingIpId id = FloatingIpId.of(floatingIpIdStr1);
61 assertThat(id, is(notNullValue()));
62 assertThat(id.floatingIpId().toString(), is(floatingIpIdStr1));
63 }
64}