JUnits for coverage
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / utils / HashMapFromListTest.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2018 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.utils;
39
40 import java.util.ArrayList;
41 import java.util.Date;
42 import java.util.List;
43
44 import org.junit.Test;
45 import org.onap.portalapp.portal.domain.EPUser;
46 import org.onap.portalapp.portal.domain.EPUserAppRoles;
47
48 public class HashMapFromListTest {
49         
50         private static final String TEST="test";
51         
52         @Test
53         public void testHashMap() {
54                 
55                 List<String> data=new ArrayList<>();
56                 data.add(TEST);
57                 
58                 HashMapFromList<String> map=new HashMapFromList<>();
59                 map.hashMap(data, TEST);
60                 
61         }
62         
63         @Test
64         public void testHashMapUser() {
65                 
66                 List<EPUser> data=new ArrayList<>();
67                 data.add(buildUser());
68                 
69                 HashMapFromList<EPUser> map=new HashMapFromList<>();
70                 map.hashMap(data, "firstName");
71                 
72         }
73         
74         @Test
75         public void testHashMapUserField() {
76                 
77                 List<EPUserAppRoles> data=new ArrayList<>();
78                 EPUserAppRoles role=new EPUserAppRoles();
79                 role.setAppId(2l);
80                 role.setRoleId(3l);
81                 data.add(role);
82                 
83                 HashMapFromList<EPUserAppRoles> map=new HashMapFromList<>();
84                 map.hashMap(data, "appId");
85                 
86         }
87         
88         @Test
89         public void testHashMapUserFieldException() {
90                 
91                 List<EPUserAppRoles> data=new ArrayList<>();
92                 EPUserAppRoles role=new EPUserAppRoles();
93                 role.setAppId(null);
94                 role.setRoleId(3l);
95                 data.add(role);
96                 
97                 HashMapFromList<EPUserAppRoles> map=new HashMapFromList<>();
98                 map.hashMap(data, "appId");
99                 
100         }
101
102         
103         
104         private EPUser buildUser() {
105         EPUser epUser = new EPUser();
106                 
107                 epUser.setId((long)1);
108                 epUser.setManagerId((long) 1234);
109                 epUser.setFirstName(TEST);
110                 epUser.setLastName(TEST);
111                 epUser.setMiddleInitial(TEST);
112                 epUser.setPhone(TEST);
113                 epUser.setFax(TEST);
114                 epUser.setCellular(TEST);
115                 epUser.setEmail(TEST);
116                 epUser.setAddressId((long) 123); 
117                 epUser.setAlertMethodCd(TEST);
118                 epUser.setHrid(TEST);
119                 epUser.setOrgUserId(TEST);
120                 epUser.setOrgCode(TEST);
121                 epUser.setAddress1(TEST);
122                 epUser.setAddress2(TEST);
123                 epUser.setCity(TEST);
124                 epUser.setState(TEST);
125                 epUser.setZipCode(TEST);
126                 epUser.setCountry(TEST);
127                 epUser.setOrgManagerUserId(TEST);
128                 epUser.setLocationClli(TEST);
129                 epUser.setBusinessCountryCode(TEST);
130                 epUser.setBusinessCountryName(TEST);
131                 epUser.setBusinessUnit(TEST);
132                 epUser.setBusinessUnitName(TEST);
133                 epUser.setDepartment(TEST);
134                 epUser.setDepartmentName(TEST);
135                 epUser.setCompanyCode(TEST);
136                 epUser.setCompany(TEST);
137                 epUser.setZipCodeSuffix(TEST);
138                 epUser.setJobTitle(TEST);
139                 epUser.setCommandChain(TEST);
140                 epUser.setSiloStatus(TEST);
141                 epUser.setCostCenter(TEST);
142                 epUser.setFinancialLocCode(TEST);
143                 epUser.setLoginId(TEST);
144                 epUser.setLoginPwd(TEST);
145                 epUser.setLastLoginDate(new Date());
146                 epUser.setActive(false);
147                 epUser.setInternal(false);
148                 epUser.setSelectedProfileId((long) 12345);
149                 epUser.setTimeZoneId((long) 12345);
150                 epUser.setOnline(false);
151                 epUser.setChatId(TEST);
152                 return epUser;
153                                    
154         }
155 }