blob: 8271b51c4421b8297c386a76aefbaa3ab221f17a [file] [log] [blame]
samueljcc67b85a92015-10-27 17:21:15 -07001/*
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 */
16package org.onosproject.vtnrsc.tenantnetwork;
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.TenantNetworkId;
25
26import com.google.common.testing.EqualsTester;
27
28/**
29 * Unit tests for TenantNetworkId class.
30 */
31public class TenantNetworkIdTest {
32
33 final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
34 final TenantNetworkId sameAsnetworkId1 = TenantNetworkId.networkId("1");
35 final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
36
37 /**
38 * Checks that the TenantNetworkId class is immutable.
39 */
40 @Test
41 public void testImmutability() {
42 assertThatClassIsImmutable(TenantNetworkId.class);
43 }
44
45 /**
46 * Checks the operation of equals() methods.
47 */
48 @Test
49 public void testEquals() {
50 new EqualsTester().addEqualityGroup(networkId1, sameAsnetworkId1)
51 .addEqualityGroup(networkId2).testEquals();
52 }
53
54 /**
55 * Checks the construction of a TenantNetworkId object.
56 */
57 @Test
58 public void testConstruction() {
59 final String networkIdValue = "s";
60 final TenantNetworkId networkId = TenantNetworkId.networkId(networkIdValue);
61 assertThat(networkId, is(notNullValue()));
62 assertThat(networkId.networkId(), is(networkIdValue));
63 }
64}