Committed by
Gerrit Code Review
[ONOS-3229]Add the junit test code of TenantId
Change-Id: Ib5bd6a6c76fa11d3da7b50727c97ee6d4503c136
Showing
2 changed files
with
81 additions
and
0 deletions
... | @@ -37,4 +37,21 @@ | ... | @@ -37,4 +37,21 @@ |
37 | <module>vtnweb</module> | 37 | <module>vtnweb</module> |
38 | <module>app</module> | 38 | <module>app</module> |
39 | </modules> | 39 | </modules> |
40 | + <dependencies> | ||
41 | + <dependency> | ||
42 | + <groupId>org.onosproject</groupId> | ||
43 | + <artifactId>onlab-junit</artifactId> | ||
44 | + <scope>test</scope> | ||
45 | + </dependency> | ||
46 | + <dependency> | ||
47 | + <groupId>com.google.guava</groupId> | ||
48 | + <artifactId>guava-testlib</artifactId> | ||
49 | + <scope>test</scope> | ||
50 | + </dependency> | ||
51 | + <dependency> | ||
52 | + <groupId>org.easymock</groupId> | ||
53 | + <artifactId>easymock</artifactId> | ||
54 | + <scope>test</scope> | ||
55 | + </dependency> | ||
56 | + </dependencies> | ||
40 | </project> | 57 | </project> | ... | ... |
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.hamcrest.MatcherAssert.assertThat; | ||
19 | +import static org.hamcrest.Matchers.is; | ||
20 | +import static org.hamcrest.Matchers.notNullValue; | ||
21 | +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | ||
22 | + | ||
23 | +import org.junit.Test; | ||
24 | +import org.onosproject.vtnrsc.TenantId; | ||
25 | + | ||
26 | +import com.google.common.testing.EqualsTester; | ||
27 | + | ||
28 | +/** | ||
29 | + * Unit tests for TenantId class. | ||
30 | + */ | ||
31 | +public class TenantIdTest { | ||
32 | + | ||
33 | + final TenantId tenantId1 = TenantId.tenantId("1"); | ||
34 | + final TenantId sameAsTenantId1 = TenantId.tenantId("1"); | ||
35 | + final TenantId tenantId2 = TenantId.tenantId("2"); | ||
36 | + | ||
37 | + /** | ||
38 | + * Checks that the TenantId class is immutable. | ||
39 | + */ | ||
40 | + @Test | ||
41 | + public void testImmutability() { | ||
42 | + assertThatClassIsImmutable(TenantId.class); | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * Checks the operation of equals() methods. | ||
47 | + */ | ||
48 | + @Test | ||
49 | + public void testEquals() { | ||
50 | + new EqualsTester().addEqualityGroup(tenantId1, sameAsTenantId1).addEqualityGroup(tenantId2) | ||
51 | + .testEquals(); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Checks the construction of a TenantId object. | ||
56 | + */ | ||
57 | + @Test | ||
58 | + public void testConstruction() { | ||
59 | + final String tenantIdValue = "s"; | ||
60 | + final TenantId tenantId = TenantId.tenantId(tenantIdValue); | ||
61 | + assertThat(tenantId, is(notNullValue())); | ||
62 | + assertThat(tenantId.tenantId(), is(tenantIdValue)); | ||
63 | + } | ||
64 | +} |
-
Please register or login to post a comment