blob: 36b23624e2761f5b73b070ea64ac7f141735ecb9 [file] [log] [blame]
Ray Milkey506455f2014-11-12 13:18:35 -08001/*
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 */
16package org.onlab.onos.net.flow;
17
18import org.junit.Test;
19
20import com.google.common.testing.EqualsTester;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24import static org.hamcrest.Matchers.notNullValue;
25import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
26
27/**
28 * Unit tests for flow id class.
29 */
30public 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 /**
Ray Milkeyff517732014-12-01 10:40:14 -080037 * Checks that the FlowId class is immutable.
Ray Milkey506455f2014-11-12 13:18:35 -080038 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(FlowId.class);
42 }
43
44 /**
Ray Milkeyff517732014-12-01 10:40:14 -080045 * Checks the operation of equals(), hashCode() and toString() methods.
Ray Milkey506455f2014-11-12 13:18:35 -080046 */
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}