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.CentralRoleBuilder().createCentralRole();
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.CentralRoleBuilder().setId(null).setCreated(null).setModified(null)
104 .setCreatedId(null).setModifiedId(null).setRowNum(null).setName(null).setActive(false).setPriority(null)
105 .setRoleFunctions(null).setChildRoles(null).setParentRoles(null).createCentralRole();
106 assertEquals(false, centralRole.isActive());
110 public void unt_centralRoleConstructor2Test() {
111 centralRole = new CentralRole.CentralRoleBuilder().setId(null).setName(null).setActive(false).setPriority(null)
112 .setRoleFunctions(null).createCentralRole();
113 assertEquals(false, centralRole.isActive());
117 public void unt_IdTest(){
118 Long defaultValue=123L;
119 centralRole.setId(defaultValue);
120 assertEquals(defaultValue, centralRole.getId());
124 public void unt_createdTest(){
125 Date defaultValue=new Date();
126 centralRole.setCreated(defaultValue);
127 assertEquals(defaultValue, centralRole.getCreated());
131 public void unt_modifiedTest(){
132 Date defaultValue=new Date();
133 centralRole.setModified(defaultValue);
134 assertEquals(defaultValue, centralRole.getModified());
138 public void unt_modifiedIdTest(){
139 Long defaultValue=123L;
140 centralRole.setModifiedId(defaultValue);
141 assertEquals(defaultValue, centralRole.getModifiedId());
145 public void unt_createdIdTest(){
146 Long defaultValue=123L;
147 centralRole.setCreatedId(defaultValue);
148 assertEquals(defaultValue, centralRole.getCreatedId());
152 public void unt_rowNumTest(){
153 Long defaultValue=123L;
154 centralRole.setRowNum(defaultValue);
155 assertEquals(defaultValue, centralRole.getRowNum());
159 public void unt_nameTest(){
160 String defaultValue="test";
161 centralRole.setName(defaultValue);
162 assertEquals(defaultValue, centralRole.getName());
166 public void unt_activeTest(){
167 Boolean defaultValue=false;
168 centralRole.setActive(defaultValue);
169 assertEquals(defaultValue, centralRole.isActive());
173 public void unt_priorityTest(){
174 Integer defaultValue=123;
175 centralRole.setPriority(defaultValue);
176 assertEquals(defaultValue, centralRole.getPriority());
180 public void unt_getRoleFunctionsTest(){
181 //Integer defaultValue=123;
182 SortedSet<CentralRoleFunction> roleFunctions = new TreeSet<>();
183 CentralRoleFunction centralRoleFunction=new CentralRoleFunction();
184 roleFunctions.add(centralRoleFunction);
185 centralRole.setRoleFunctions(roleFunctions);
186 assertNotNull(centralRole.getRoleFunctions());
190 public void unt_childRolesTest(){
191 //Integer defaultValue=123;
192 SortedSet<CentralRole> centralRoles=new TreeSet<>();
193 //CentralRole centralRole=new CentralRole();
194 //centralRoles.add(centralRole);
195 centralRole.setChildRoles(centralRoles);
196 assertNotNull(centralRole.getChildRoles());
200 public void unt_parentRolesTest(){
201 //Integer defaultValue=123;
202 SortedSet<CentralRole> centralRoles=new TreeSet<>();
203 centralRole.setParentRoles(centralRoles);
204 assertNotNull(centralRole.getParentRoles());