2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 package org.onap.portalapp.portal.domain;
41 import static org.junit.Assert.assertEquals;
42 import static org.junit.Assert.assertNotNull;
44 import java.util.SortedSet;
45 import java.util.TreeSet;
47 import org.junit.Test;
48 import org.onap.portalapp.portal.domain.EPRole;
49 import org.onap.portalsdk.core.domain.RoleFunction;
50 import org.onap.portalsdk.core.restful.domain.EcompRoleFunction;
52 public class EPRoleTest {
56 public void testEpRole() {
57 EPRole role=new EPRole();
60 role.setAppRoleId(2l);
62 role.setName("TEST_ADMIN");
63 SortedSet<EPRole> childRoles = new TreeSet<EPRole>();
64 EPRole child=new EPRole();
65 child.setActive(true);
67 child.setAppRoleId(3l);
69 child.setName("TEST_USER");
70 childRoles.add(child);
71 role.setChildRoles(childRoles);
72 SortedSet<EPRole> parentRoles = new TreeSet<EPRole>();
73 EPRole parent=new EPRole();
74 parent.setActive(true);
76 parent.setAppRoleId(3l);
78 parent.setName("TEST_USER");
79 parentRoles.add(parent);
80 role.setParentRoles(parentRoles);
82 SortedSet<RoleFunction> rolefunction = new TreeSet<RoleFunction>();
83 RoleFunction function=new RoleFunction();
84 function.setAction("Test");;
85 function.setCode("code");
86 rolefunction.add(function);
87 role.setRoleFunctions(rolefunction);
89 role.setAppRoleId(3l);
90 assertEquals(3l, role.getAppRoleId().longValue());
91 assertNotNull(role.getChildRoles());
92 assertNotNull(role.getParentRoles());
93 assertNotNull(role.getRoleFunctions());
95 assertEquals(1l, role.getAppId().longValue());
96 assertEquals("TEST_ADMIN",role.getName());
97 role.removeChildRole(6l);
98 role.removeParentRole(6l);
99 assertEquals(role.toString(), "[Id = 3, name = TEST_ADMIN]");
100 role.removeRoleFunction("code");
101 role.addChildRole(child);
102 role.addParentRole(parent);
103 role.addRoleFunction(function);