samueljcc | 7fa97bc | 2015-10-27 17:20:33 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
Ray Milkey | 6c1bac3 | 2015-11-13 14:40:40 -0800 | [diff] [blame] | 16 | package org.onosproject.vtnrsc; |
samueljcc | 7fa97bc | 2015-10-27 17:20:33 -0700 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
samueljcc | 7fa97bc | 2015-10-27 17:20:33 -0700 | [diff] [blame] | 19 | |
| 20 | import com.google.common.testing.EqualsTester; |
| 21 | |
Ray Milkey | 6c1bac3 | 2015-11-13 14:40:40 -0800 | [diff] [blame] | 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 23 | |
samueljcc | 7fa97bc | 2015-10-27 17:20:33 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Unit tests for DefaultNeutronNetwork class. |
| 26 | */ |
| 27 | public 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 | } |