Committed by
Gerrit Code Review
Merge "Unit tests for FlowId class."
Showing
2 changed files
with
66 additions
and
1 deletions
... | @@ -26,7 +26,7 @@ public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, | ... | @@ -26,7 +26,7 @@ public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, |
26 | 26 | ||
27 | private final long time; | 27 | private final long time; |
28 | private final T type; | 28 | private final T type; |
29 | - private S subject; | 29 | + private final S subject; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Creates an event of a given type and for the specified subject and the | 32 | * Creates an event of a given type and for the specified subject and the | ... | ... |
1 | +/* | ||
2 | + * Copyright 2014 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.onlab.onos.net.flow; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | + | ||
20 | +import com.google.common.testing.EqualsTester; | ||
21 | + | ||
22 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
23 | +import static org.hamcrest.Matchers.is; | ||
24 | +import static org.hamcrest.Matchers.notNullValue; | ||
25 | +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; | ||
26 | + | ||
27 | +/** | ||
28 | + * Unit tests for flow id class. | ||
29 | + */ | ||
30 | +public class FlowIdTest { | ||
31 | + | ||
32 | + final FlowId flowId1 = FlowId.valueOf(1); | ||
33 | + final FlowId sameAsFlowId1 = FlowId.valueOf(1); | ||
34 | + final FlowId flowId2 = FlowId.valueOf(2); | ||
35 | + | ||
36 | + /** | ||
37 | + * Checks that the DefaultFlowRule class is immutable. | ||
38 | + */ | ||
39 | + @Test | ||
40 | + public void testImmutability() { | ||
41 | + assertThatClassIsImmutable(FlowId.class); | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Checks the operation of equals(), hashCode and toString() methods. | ||
46 | + */ | ||
47 | + @Test | ||
48 | + public void testEquals() { | ||
49 | + new EqualsTester() | ||
50 | + .addEqualityGroup(flowId1, sameAsFlowId1) | ||
51 | + .addEqualityGroup(flowId2) | ||
52 | + .testEquals(); | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Checks the construction of a FlowId object. | ||
57 | + */ | ||
58 | + @Test | ||
59 | + public void testConstruction() { | ||
60 | + final long flowIdValue = 7777L; | ||
61 | + final FlowId flowId = FlowId.valueOf(flowIdValue); | ||
62 | + assertThat(flowId, is(notNullValue())); | ||
63 | + assertThat(flowId.value(), is(flowIdValue)); | ||
64 | + } | ||
65 | +} |
-
Please register or login to post a comment