blob: bdab240cad42942d7e293246660f71abcaca7030 [file] [log] [blame]
Chanhee Lee94010482017-01-23 23:06:18 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Chanhee Lee94010482017-01-23 23:06:18 -08003 *
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
17package org.onosproject.security;
18
19import static org.junit.Assert.assertEquals;
Chanhee Lee94010482017-01-23 23:06:18 -080020import org.junit.Test;
21
22/**
23 * Test of Permission.
24 */
25public 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 HIGUCHI1edc36b2018-01-24 23:39:06 -080071 assertEquals(permissionA, permissionB);
Chanhee Lee94010482017-01-23 23:06:18 -080072 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}