blob: 93edd8f61fa9020a3c490156256956e38f1aa8d8 [file] [log] [blame]
samueljcc7fa97bc2015-10-27 17:20:33 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samueljcc7fa97bc2015-10-27 17:20:33 -07003 *
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 Milkey6c1bac32015-11-13 14:40:40 -080016package org.onosproject.vtnrsc;
samueljcc7fa97bc2015-10-27 17:20:33 -070017
18import org.junit.Test;
samueljcc7fa97bc2015-10-27 17:20:33 -070019
20import com.google.common.testing.EqualsTester;
21
Ray Milkey6c1bac32015-11-13 14:40:40 -080022import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23
samueljcc7fa97bc2015-10-27 17:20:33 -070024/**
25 * Unit tests for DefaultNeutronNetwork class.
26 */
27public class DefaultNeutronNetworkTest {
28
29 private String networkIdStr1 = "123";
30 private String networkIdStr2 = "234";
31 private String physicalNetworkStr = "1234";
32 private String tenantIdStr = "345";
33 private String segmentationIdStr = "1";
34 private String name = "456";
35
36 /**
37 * Checks that the DefaultNeutronNetwork class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(DefaultTenantNetwork.class);
42 }
43
44 /**
45 * Checks the operation of equals() methods.
46 */
47 @Test
48 public void testEquality() {
49 TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr1);
50 TenantNetworkId networkid2 = TenantNetworkId.networkId(networkIdStr2);
51 PhysicalNetwork physicalNetwork = PhysicalNetwork
52 .physicalNetwork(physicalNetworkStr);
53 TenantId tenantId = TenantId.tenantId(tenantIdStr);
54 SegmentationId segmentationID = SegmentationId
55 .segmentationId(segmentationIdStr);
56 TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false,
57 TenantNetwork.State.ACTIVE,
58 false, tenantId, false,
59 TenantNetwork.Type.LOCAL,
60 physicalNetwork,
61 segmentationID);
62 TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false,
63 TenantNetwork.State.ACTIVE,
64 false, tenantId, false,
65 TenantNetwork.Type.LOCAL,
66 physicalNetwork,
67 segmentationID);
68 TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false,
69 TenantNetwork.State.ACTIVE,
70 false, tenantId, false,
71 TenantNetwork.Type.LOCAL,
72 physicalNetwork,
73 segmentationID);
74 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
75 .testEquals();
76 }
77}