samueljcc | 67b85a9 | 2015-10-27 17:21:15 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
samueljcc | 67b85a9 | 2015-10-27 17:21:15 -0700 | [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 | */ |
Ray Milkey | 6c1bac3 | 2015-11-13 14:40:40 -0800 | [diff] [blame] | 16 | package org.onosproject.vtnrsc; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | |
| 20 | import com.google.common.testing.EqualsTester; |
samueljcc | 67b85a9 | 2015-10-27 17:21:15 -0700 | [diff] [blame] | 21 | |
| 22 | import static org.hamcrest.MatcherAssert.assertThat; |
| 23 | import static org.hamcrest.Matchers.is; |
| 24 | import static org.hamcrest.Matchers.notNullValue; |
| 25 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 26 | |
samueljcc | 67b85a9 | 2015-10-27 17:21:15 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Unit tests for TenantNetworkId class. |
| 29 | */ |
| 30 | public class TenantNetworkIdTest { |
| 31 | |
| 32 | final TenantNetworkId networkId1 = TenantNetworkId.networkId("1"); |
| 33 | final TenantNetworkId sameAsnetworkId1 = TenantNetworkId.networkId("1"); |
| 34 | final TenantNetworkId networkId2 = TenantNetworkId.networkId("2"); |
| 35 | |
| 36 | /** |
| 37 | * Checks that the TenantNetworkId class is immutable. |
| 38 | */ |
| 39 | @Test |
| 40 | public void testImmutability() { |
| 41 | assertThatClassIsImmutable(TenantNetworkId.class); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Checks the operation of equals() methods. |
| 46 | */ |
| 47 | @Test |
| 48 | public void testEquals() { |
| 49 | new EqualsTester().addEqualityGroup(networkId1, sameAsnetworkId1) |
| 50 | .addEqualityGroup(networkId2).testEquals(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Checks the construction of a TenantNetworkId object. |
| 55 | */ |
| 56 | @Test |
| 57 | public void testConstruction() { |
| 58 | final String networkIdValue = "s"; |
| 59 | final TenantNetworkId networkId = TenantNetworkId.networkId(networkIdValue); |
| 60 | assertThat(networkId, is(notNullValue())); |
| 61 | assertThat(networkId.networkId(), is(networkIdValue)); |
| 62 | } |
| 63 | } |