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; |
| 20 | import static org.junit.Assert.assertSame; |
| 21 | |
| 22 | import org.junit.Test; |
| 23 | |
| 24 | /** |
| 25 | * Test of Permission. |
| 26 | */ |
| 27 | public class PermissionTest { |
| 28 | |
| 29 | @Test |
| 30 | public void testHashCode() { |
| 31 | Permission permission = new Permission("classname", "name", "actions"); |
| 32 | assertEquals(0, permission.hashCode()); |
| 33 | } |
| 34 | |
| 35 | @Test |
| 36 | public void testPermissionStringStringString() { |
| 37 | Permission permission = new Permission("classname", "name", "actions"); |
| 38 | assertEquals("classname", permission.getClassName()); |
| 39 | assertEquals("name", permission.getName()); |
| 40 | assertEquals("actions", permission.getActions()); |
| 41 | } |
| 42 | |
| 43 | @Test |
| 44 | public void testPermissionStringString() { |
| 45 | Permission permission = new Permission("classname", "name"); |
| 46 | assertEquals("classname", permission.getClassName()); |
| 47 | assertEquals("name", permission.getName()); |
| 48 | assertEquals("", permission.getActions()); |
| 49 | } |
| 50 | |
| 51 | @Test |
| 52 | public void testGetClassName() { |
| 53 | Permission permission = new Permission("classname", "name"); |
| 54 | assertEquals("classname", permission.getClassName()); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void testGetName() { |
| 59 | Permission permission = new Permission("classname", "name"); |
| 60 | assertEquals("name", permission.getName()); |
| 61 | } |
| 62 | |
| 63 | @Test |
| 64 | public void testGetActions() { |
| 65 | Permission permission = new Permission("classname", "name", "actions"); |
| 66 | assertEquals("actions", permission.getActions()); |
| 67 | } |
| 68 | |
| 69 | @Test |
| 70 | public void testEqualsObject() { |
| 71 | Permission permissionA = new Permission("classname", "name", "actions"); |
| 72 | Permission permissionB = new Permission("classname", "name", "actions"); |
| 73 | assertSame(permissionA, permissionA); |
| 74 | assertEquals(permissionA.getClassName(), permissionB.getClassName()); |
| 75 | assertEquals(permissionA.getName(), permissionB.getName()); |
| 76 | assertEquals(permissionA.getActions(), permissionB.getActions()); |
| 77 | } |
| 78 | |
| 79 | @Test |
| 80 | public void testToString() { |
| 81 | Permission permission = new Permission("classname", "name", "actions"); |
| 82 | assertEquals("(classname, name, actions)", permission.toString()); |
| 83 | } |
| 84 | |
| 85 | } |