jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
jiangrui | 72d343a | 2015-11-11 18:00:16 +0800 | [diff] [blame] | 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.floatingip; |
| 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.FloatingIpId; |
| 25 | |
| 26 | import com.google.common.testing.EqualsTester; |
| 27 | |
| 28 | /** |
| 29 | * Unit tests for FloatingIpId class. |
| 30 | */ |
| 31 | public 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 | } |