5ba983c405fa86a54e62722511d35fe32501c3cf
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / transport / CentralRoleTest.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
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
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
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
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
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.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.transport;
39
40 import static org.junit.Assert.*;
41
42 import java.util.Date;
43 import java.util.SortedSet;
44 import java.util.TreeSet;
45
46 import org.junit.Test;
47
48 public class CentralRoleTest {
49
50         CentralRole centralRole=new CentralRole();
51         
52         
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);
56             
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);
64             
65             centralV2Role.setCreated(null);
66             centralV2Role.setModified(null);
67             centralV2Role.setRoleFunctions(null);
68             centralV2Role.setChildRoles(null);
69             centralV2Role.setParentRoles(null);
70             
71                 return centralV2Role;
72         }
73         
74         @Test
75         public void centralRoleTest(){
76                 CentralV2Role centralV2Role = mockCentralRole();
77                 
78                 CentralV2Role centralRole1 = new CentralV2Role((long)1, null, null, (long)1, (long)1, (long)1,
79                                 "test", false, 1, null, null, null);
80                 
81                 CentralV2Role centralRole2 = new CentralV2Role((long)1, "test");
82                 
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"));
99         }*/
100         
101         @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());
105         }
106         
107         @Test
108         public void unt_centralRoleConstructor2Test(){
109                  centralRole=new CentralRole(null, null, false, null, null);
110                 assertEquals(false, centralRole.isActive());
111         }
112         
113         @Test
114         public void unt_IdTest(){
115                 Long defaultValue=123L;
116                 centralRole.setId(defaultValue);
117                 assertEquals(defaultValue, centralRole.getId());
118         }
119         
120         @Test
121         public void unt_createdTest(){
122                 Date defaultValue=new Date();
123                 centralRole.setCreated(defaultValue);
124                 assertEquals(defaultValue, centralRole.getCreated());
125         }
126         
127         @Test
128         public void unt_modifiedTest(){
129                 Date defaultValue=new Date();
130                 centralRole.setModified(defaultValue);
131                 assertEquals(defaultValue, centralRole.getModified());
132         }
133         
134         @Test
135         public void unt_modifiedIdTest(){
136                 Long defaultValue=123L;
137                 centralRole.setModifiedId(defaultValue);
138                 assertEquals(defaultValue, centralRole.getModifiedId());
139         }
140         
141         @Test
142         public void unt_createdIdTest(){
143                 Long defaultValue=123L;
144                 centralRole.setCreatedId(defaultValue);
145                 assertEquals(defaultValue, centralRole.getCreatedId());
146         }
147         
148         @Test
149         public void unt_rowNumTest(){
150                 Long defaultValue=123L;
151                 centralRole.setRowNum(defaultValue);
152                 assertEquals(defaultValue, centralRole.getRowNum());
153         }
154         
155         @Test
156         public void unt_nameTest(){
157                 String defaultValue="test";
158                 centralRole.setName(defaultValue);
159                 assertEquals(defaultValue, centralRole.getName());
160         }
161         
162         @Test
163         public void unt_activeTest(){
164                 Boolean defaultValue=false;
165                 centralRole.setActive(defaultValue);
166                 assertEquals(defaultValue, centralRole.isActive());
167         }
168         
169         @Test
170         public void unt_priorityTest(){
171                 Integer defaultValue=123;
172                 centralRole.setPriority(defaultValue);
173                 assertEquals(defaultValue, centralRole.getPriority());
174         }
175         
176         @Test
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());
184         }
185         
186         @Test
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());
194         }
195         
196         @Test
197         public void unt_parentRolesTest(){
198                 //Integer defaultValue=123;
199                 SortedSet<CentralRole> centralRoles=new TreeSet<>();
200                 centralRole.setParentRoles(centralRoles);
201                 assertNotNull(centralRole.getParentRoles());
202         }
203         
204 }