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============================================
38 package org.onap.portalapp.portal.transport;
40 import static org.junit.Assert.*;
42 import java.util.Date;
43 import java.util.SortedSet;
44 import java.util.TreeSet;
46 import org.junit.Test;
48 public class CentralRoleTest {
50 CentralRole centralRole=new CentralRole();
53 /*public CentralV2Role mockCentralRole(){
54 CentralV2Role centralV2Role = new CentralV2Role((long)1, null, null, (long)1, (long)1, (long)1,
55 "test", false, 1, null, null, null);
57 centralV2Role.setId((long)1);
58 centralV2Role.setCreatedId((long)1);
59 centralV2Role.setModifiedId((long)1);
60 centralV2Role.setRowNum((long)1);
61 centralV2Role.setName("test");
62 centralV2Role.setActive(false);
63 centralV2Role.setPriority(1);
65 centralV2Role.setCreated(null);
66 centralV2Role.setModified(null);
67 centralV2Role.setRoleFunctions(null);
68 centralV2Role.setChildRoles(null);
69 centralV2Role.setParentRoles(null);
75 public void centralRoleTest(){
76 CentralV2Role centralV2Role = mockCentralRole();
78 CentralV2Role centralRole1 = new CentralV2Role((long)1, null, null, (long)1, (long)1, (long)1,
79 "test", false, 1, null, null, null);
81 CentralV2Role centralRole2 = new CentralV2Role((long)1, "test");
83 assertEquals(centralV2Role.getId(), new Long(1));
84 assertEquals(centralV2Role.getCreatedId(), new Long(1));
85 assertEquals(centralV2Role.getModifiedId(), new Long(1));
86 assertEquals(centralV2Role.getRowNum(), new Long(1));
87 assertEquals(centralV2Role.getName(), "test");
88 assertEquals(centralV2Role.getActive(), false);
89 assertEquals(centralV2Role.getCreated(), null);
90 assertEquals(centralV2Role.getModified(), null);
91 assertEquals(centralV2Role.getRoleFunctions(), null);
92 assertEquals(centralV2Role.getChildRoles(), null);
93 assertEquals(centralV2Role.getParentRoles(), null);
94 assertEquals(centralV2Role.getPriority().toString(), "1");
95 assertEquals(centralV2Role.hashCode(), centralRole1.hashCode());
96 assertTrue(centralV2Role.equals(centralRole1));
97 assertEquals(centralV2Role, centralRole1);
98 assertEquals(centralRole2, new CentralV2Role((long)1, "test"));
102 public void unt_centralRoleConstructorTest(){
103 centralRole=new CentralRole(null, null, null, null, null, null, null, false, null, null, null, null);
104 assertEquals(false, centralRole.isActive());
108 public void unt_centralRoleConstructor2Test(){
109 centralRole=new CentralRole(null, null, false, null, null);
110 assertEquals(false, centralRole.isActive());
114 public void unt_IdTest(){
115 Long defaultValue=123L;
116 centralRole.setId(defaultValue);
117 assertEquals(defaultValue, centralRole.getId());
121 public void unt_createdTest(){
122 Date defaultValue=new Date();
123 centralRole.setCreated(defaultValue);
124 assertEquals(defaultValue, centralRole.getCreated());
128 public void unt_modifiedTest(){
129 Date defaultValue=new Date();
130 centralRole.setModified(defaultValue);
131 assertEquals(defaultValue, centralRole.getModified());
135 public void unt_modifiedIdTest(){
136 Long defaultValue=123L;
137 centralRole.setModifiedId(defaultValue);
138 assertEquals(defaultValue, centralRole.getModifiedId());
142 public void unt_createdIdTest(){
143 Long defaultValue=123L;
144 centralRole.setCreatedId(defaultValue);
145 assertEquals(defaultValue, centralRole.getCreatedId());
149 public void unt_rowNumTest(){
150 Long defaultValue=123L;
151 centralRole.setRowNum(defaultValue);
152 assertEquals(defaultValue, centralRole.getRowNum());
156 public void unt_nameTest(){
157 String defaultValue="test";
158 centralRole.setName(defaultValue);
159 assertEquals(defaultValue, centralRole.getName());
163 public void unt_activeTest(){
164 Boolean defaultValue=false;
165 centralRole.setActive(defaultValue);
166 assertEquals(defaultValue, centralRole.isActive());
170 public void unt_priorityTest(){
171 Integer defaultValue=123;
172 centralRole.setPriority(defaultValue);
173 assertEquals(defaultValue, centralRole.getPriority());
177 public void unt_getRoleFunctionsTest(){
178 //Integer defaultValue=123;
179 SortedSet<CentralRoleFunction> roleFunctions = new TreeSet<>();
180 CentralRoleFunction centralRoleFunction=new CentralRoleFunction();
181 roleFunctions.add(centralRoleFunction);
182 centralRole.setRoleFunctions(roleFunctions);
183 assertNotNull(centralRole.getRoleFunctions());
187 public void unt_childRolesTest(){
188 //Integer defaultValue=123;
189 SortedSet<CentralRole> centralRoles=new TreeSet<>();
190 //CentralRole centralRole=new CentralRole();
191 //centralRoles.add(centralRole);
192 centralRole.setChildRoles(centralRoles);
193 assertNotNull(centralRole.getChildRoles());
197 public void unt_parentRolesTest(){
198 //Integer defaultValue=123;
199 SortedSet<CentralRole> centralRoles=new TreeSet<>();
200 centralRole.setParentRoles(centralRoles);
201 assertNotNull(centralRole.getParentRoles());