Committed by
Ray Milkey
[ONOS-3232] Add the junit test code of DefaultNeutronNetwork
Change-Id: I17bcc5410fe701cce551f59643e324d59bff1674
Showing
1 changed file
with
83 additions
and
0 deletions
apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java
0 → 100644
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 | + */ | ||
16 | +package org.onosproject.vtnrsc.tenantnetwork; | ||
17 | + | ||
18 | +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | ||
19 | + | ||
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; | ||
27 | + | ||
28 | +import com.google.common.testing.EqualsTester; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit tests for DefaultNeutronNetwork class. | ||
32 | + */ | ||
33 | +public class DefaultNeutronNetworkTest { | ||
34 | + | ||
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"; | ||
41 | + | ||
42 | + /** | ||
43 | + * Checks that the DefaultNeutronNetwork class is immutable. | ||
44 | + */ | ||
45 | + @Test | ||
46 | + public void testImmutability() { | ||
47 | + assertThatClassIsImmutable(DefaultTenantNetwork.class); | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * Checks the operation of equals() methods. | ||
52 | + */ | ||
53 | + @Test | ||
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, | ||
66 | + physicalNetwork, | ||
67 | + segmentationID); | ||
68 | + TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false, | ||
69 | + TenantNetwork.State.ACTIVE, | ||
70 | + false, tenantId, false, | ||
71 | + TenantNetwork.Type.LOCAL, | ||
72 | + physicalNetwork, | ||
73 | + segmentationID); | ||
74 | + TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false, | ||
75 | + TenantNetwork.State.ACTIVE, | ||
76 | + false, tenantId, false, | ||
77 | + TenantNetwork.Type.LOCAL, | ||
78 | + physicalNetwork, | ||
79 | + segmentationID); | ||
80 | + new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) | ||
81 | + .testEquals(); | ||
82 | + } | ||
83 | +} |
-
Please register or login to post a comment