Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 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; |
| 17 | |
| 18 | import java.util.UUID; |
| 19 | |
| 20 | import org.junit.Test; |
| 21 | |
| 22 | import com.google.common.testing.EqualsTester; |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 23 | |
| 24 | import static org.hamcrest.MatcherAssert.assertThat; |
| 25 | import static org.hamcrest.Matchers.is; |
| 26 | import static org.hamcrest.Matchers.notNullValue; |
| 27 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 28 | |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 29 | /** |
| 30 | * Unit tests for FlowClassifierId class. |
| 31 | */ |
| 32 | public class FlowClassifierIdTest { |
| 33 | |
| 34 | final FlowClassifierId flowClassifierId1 = FlowClassifierId |
Mahesh Poojary Huawei | 321cc50 | 2015-11-03 13:23:32 +0530 | [diff] [blame] | 35 | .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 36 | final FlowClassifierId sameAsFlowClassifierId1 = FlowClassifierId |
Mahesh Poojary Huawei | 321cc50 | 2015-11-03 13:23:32 +0530 | [diff] [blame] | 37 | .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 38 | final FlowClassifierId flowClassifierId2 = FlowClassifierId |
Mahesh Poojary Huawei | 321cc50 | 2015-11-03 13:23:32 +0530 | [diff] [blame] | 39 | .of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Checks that the FlowClassifierId class is immutable. |
| 43 | */ |
| 44 | @Test |
| 45 | public void testImmutability() { |
| 46 | assertThatClassIsImmutable(FlowClassifierId.class); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Checks the operation of equals() methods. |
| 51 | */ |
| 52 | @Test |
| 53 | public void testEquals() { |
| 54 | new EqualsTester().addEqualityGroup(flowClassifierId1, sameAsFlowClassifierId1) |
| 55 | .addEqualityGroup(flowClassifierId2).testEquals(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Checks the construction of a FlowClassifierId object. |
| 60 | */ |
| 61 | @Test |
| 62 | public void testConstruction() { |
| 63 | final String flowClassifierIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; |
Mahesh Poojary Huawei | 321cc50 | 2015-11-03 13:23:32 +0530 | [diff] [blame] | 64 | final FlowClassifierId flowClassifierId = FlowClassifierId.of(flowClassifierIdValue); |
Mahesh Poojary Huawei | e39f49a | 2015-10-30 15:58:22 +0530 | [diff] [blame] | 65 | assertThat(flowClassifierId, is(notNullValue())); |
| 66 | assertThat(flowClassifierId.value(), is(UUID.fromString(flowClassifierIdValue))); |
| 67 | } |
| 68 | } |