Brian Stanke | aa6211a | 2016-02-04 18:22:54 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Brian Stanke | aa6211a | 2016-02-04 18:22:54 -0500 | [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 | */ |
| 16 | |
Claudine Chiu | 31ad527 | 2016-02-17 20:56:24 +0000 | [diff] [blame] | 17 | package org.onosproject.net.key; |
Brian Stanke | aa6211a | 2016-02-04 18:22:54 -0500 | [diff] [blame] | 18 | |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.junit.Assert.*; |
| 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 23 | |
| 24 | /** |
| 25 | * Test class for CommunityName. |
| 26 | */ |
| 27 | public class CommunityNameTest { |
| 28 | |
| 29 | final String cName = "CommunityName"; |
| 30 | |
| 31 | /** |
| 32 | * Checks that the CommunityName class is immutable. |
| 33 | */ |
| 34 | @Test |
| 35 | public void testImmutability() { |
| 36 | assertThatClassIsImmutable(CommunityName.class); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Checks the construction of a community name object with a null |
| 41 | * value passed into it. |
| 42 | */ |
| 43 | @Test |
| 44 | public void testCommunityNameNull() { |
| 45 | CommunityName communityName = CommunityName.communityName(null); |
| 46 | |
| 47 | assertNotNull("The CommunityName should not be null.", communityName); |
| 48 | assertNull("The name should be null.", communityName.name()); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Checks the construction of a community name object with a non-null |
| 53 | * value passed into it. |
| 54 | */ |
| 55 | @Test |
| 56 | public void testCommunityName() { |
| 57 | CommunityName communityName = CommunityName.communityName(cName); |
| 58 | |
| 59 | assertNotNull("The CommunityName should not be null.", communityName); |
| 60 | assertEquals("The name should match the expected value.", cName, communityName.name()); |
| 61 | } |
| 62 | } |