2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.vtnrsc.tenantnetwork;
18 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
20 import org.junit.Test;
21 import org.onosproject.vtnrsc.DefaultTenantNetwork;
22 import org.onosproject.vtnrsc.PhysicalNetwork;
23 import org.onosproject.vtnrsc.SegmentationId;
24 import org.onosproject.vtnrsc.TenantId;
25 import org.onosproject.vtnrsc.TenantNetwork;
26 import org.onosproject.vtnrsc.TenantNetworkId;
28 import com.google.common.testing.EqualsTester;
31 * Unit tests for DefaultNeutronNetwork class.
33 public class DefaultNeutronNetworkTest {
35 private String networkIdStr1 = "123";
36 private String networkIdStr2 = "234";
37 private String physicalNetworkStr = "1234";
38 private String tenantIdStr = "345";
39 private String segmentationIdStr = "1";
40 private String name = "456";
43 * Checks that the DefaultNeutronNetwork class is immutable.
46 public void testImmutability() {
47 assertThatClassIsImmutable(DefaultTenantNetwork.class);
51 * Checks the operation of equals() methods.
54 public void testEquality() {
55 TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr1);
56 TenantNetworkId networkid2 = TenantNetworkId.networkId(networkIdStr2);
57 PhysicalNetwork physicalNetwork = PhysicalNetwork
58 .physicalNetwork(physicalNetworkStr);
59 TenantId tenantId = TenantId.tenantId(tenantIdStr);
60 SegmentationId segmentationID = SegmentationId
61 .segmentationId(segmentationIdStr);
62 TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false,
63 TenantNetwork.State.ACTIVE,
64 false, tenantId, false,
65 TenantNetwork.Type.LOCAL,
68 TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false,
69 TenantNetwork.State.ACTIVE,
70 false, tenantId, false,
71 TenantNetwork.Type.LOCAL,
74 TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false,
75 TenantNetwork.State.ACTIVE,
76 false, tenantId, false,
77 TenantNetwork.Type.LOCAL,
80 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)