Chanhee Lee | 9401048 | 2017-01-23 23:06:18 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Chanhee Lee | 9401048 | 2017-01-23 23:06:18 -0800 | [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 | |
| 17 | package org.onosproject.security; |
| 18 | |
| 19 | import static org.junit.Assert.assertEquals; |
Chanhee Lee | 9401048 | 2017-01-23 23:06:18 -0800 | [diff] [blame] | 20 | import org.junit.Test; |
| 21 | |
| 22 | /** |
| 23 | * Test of Permission. |
| 24 | */ |
| 25 | public class PermissionTest { |
| 26 | |
| 27 | @Test |
| 28 | public void testHashCode() { |
| 29 | Permission permission = new Permission("classname", "name", "actions"); |
| 30 | assertEquals(0, permission.hashCode()); |
| 31 | } |
| 32 | |
| 33 | @Test |
| 34 | public void testPermissionStringStringString() { |
| 35 | Permission permission = new Permission("classname", "name", "actions"); |
| 36 | assertEquals("classname", permission.getClassName()); |
| 37 | assertEquals("name", permission.getName()); |
| 38 | assertEquals("actions", permission.getActions()); |
| 39 | } |
| 40 | |
| 41 | @Test |
| 42 | public void testPermissionStringString() { |
| 43 | Permission permission = new Permission("classname", "name"); |
| 44 | assertEquals("classname", permission.getClassName()); |
| 45 | assertEquals("name", permission.getName()); |
| 46 | assertEquals("", permission.getActions()); |
| 47 | } |
| 48 | |
| 49 | @Test |
| 50 | public void testGetClassName() { |
| 51 | Permission permission = new Permission("classname", "name"); |
| 52 | assertEquals("classname", permission.getClassName()); |
| 53 | } |
| 54 | |
| 55 | @Test |
| 56 | public void testGetName() { |
| 57 | Permission permission = new Permission("classname", "name"); |
| 58 | assertEquals("name", permission.getName()); |
| 59 | } |
| 60 | |
| 61 | @Test |
| 62 | public void testGetActions() { |
| 63 | Permission permission = new Permission("classname", "name", "actions"); |
| 64 | assertEquals("actions", permission.getActions()); |
| 65 | } |
| 66 | |
| 67 | @Test |
| 68 | public void testEqualsObject() { |
| 69 | Permission permissionA = new Permission("classname", "name", "actions"); |
| 70 | Permission permissionB = new Permission("classname", "name", "actions"); |
Yuta HIGUCHI | fbd9ae9 | 2018-01-24 23:39:06 -0800 | [diff] [blame] | 71 | assertEquals(permissionA, permissionB); |
Chanhee Lee | 9401048 | 2017-01-23 23:06:18 -0800 | [diff] [blame] | 72 | assertEquals(permissionA.getClassName(), permissionB.getClassName()); |
| 73 | assertEquals(permissionA.getName(), permissionB.getName()); |
| 74 | assertEquals(permissionA.getActions(), permissionB.getActions()); |
| 75 | } |
| 76 | |
| 77 | @Test |
| 78 | public void testToString() { |
| 79 | Permission permission = new Permission("classname", "name", "actions"); |
| 80 | assertEquals("(classname, name, actions)", permission.toString()); |
| 81 | } |
| 82 | |
| 83 | } |