7de3026ddcf306a27aded8d93458112a516427b2
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / controller / FirewallDictionaryControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.policy.pap.xacml.rest.controller;
21
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
24 import static org.mockito.Mockito.doNothing;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27
28 import java.io.BufferedReader;
29 import java.io.StringReader;
30 import java.util.ArrayList;
31 import java.util.List;
32
33 import javax.servlet.http.HttpServletRequest;
34
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.mockito.Mockito;
38 import org.onap.policy.common.logging.flexlogger.FlexLogger;
39 import org.onap.policy.common.logging.flexlogger.Logger;
40 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
41 import org.onap.policy.rest.adapter.Term;
42 import org.onap.policy.rest.dao.CommonClassDao;
43 import org.onap.policy.rest.jpa.ActionList;
44 import org.onap.policy.rest.jpa.AddressGroup;
45 import org.onap.policy.rest.jpa.FWTag;
46 import org.onap.policy.rest.jpa.FWTagPicker;
47 import org.onap.policy.rest.jpa.FirewallDictionaryList;
48 import org.onap.policy.rest.jpa.GroupServiceList;
49 import org.onap.policy.rest.jpa.PortList;
50 import org.onap.policy.rest.jpa.PrefixList;
51 import org.onap.policy.rest.jpa.ProtocolList;
52 import org.onap.policy.rest.jpa.SecurityZone;
53 import org.onap.policy.rest.jpa.ServiceList;
54 import org.onap.policy.rest.jpa.TermList;
55 import org.onap.policy.rest.jpa.UserInfo;
56 import org.onap.policy.rest.jpa.Zone;
57 import org.springframework.mock.web.MockHttpServletResponse;
58
59 public class FirewallDictionaryControllerTest {
60
61         private static Logger logger = FlexLogger.getLogger(FirewallDictionaryControllerTest.class);
62         private static CommonClassDao commonClassDao;
63         private String jsonString = null;
64         private HttpServletRequest request = null;
65         private FirewallDictionaryController controller = null;
66         private MockHttpServletResponse response = null;
67         private UserInfo userInfo;
68         private List<String>  data;
69
70         @Before
71         public void setUp() throws Exception {
72                 logger.info("setUp: Entering");
73                 commonClassDao = Mockito.mock(CommonClassDao.class);
74                 
75                 data = new ArrayList<>();
76                 data.add("Test");
77                 
78                 userInfo = new UserInfo();
79                 userInfo.setUserLoginId("Test");
80                 userInfo.setUserName("Test");
81         
82                 doNothing().when(commonClassDao).delete(new Term());
83                 doNothing().when(commonClassDao).save(new Term());
84                 
85                 controller = new FirewallDictionaryController();
86                 FirewallDictionaryController.setCommonClassDao(commonClassDao);
87                 
88                 request = Mockito.mock(HttpServletRequest.class);
89                 response =  new MockHttpServletResponse();  
90                 new DictionaryUtils(commonClassDao);
91         DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
92         mock(DictionaryUtils.class);
93                 logger.info("setUp: exit");
94         }
95         
96         @Test
97         public void testGetPrefixListDictionaryEntityDataByName(){
98                 when(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")).thenReturn(data);
99                 controller.getPrefixListDictionaryEntityDataByName(response);
100                 try {
101                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
102                 } catch (Exception e) {
103                         fail();
104                         logger.error(e.getMessage(),e);
105                 }
106         }
107         
108         @Test
109         public void testGetPrefixListDictionaryEntityData(){
110                 when(commonClassDao.getData(PrefixList.class)).thenReturn(new ArrayList<>());
111                 controller.getPrefixListDictionaryEntityData(response);
112                 try {
113                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
114                 } catch (Exception e) {
115                         fail();
116                         logger.error(e.getMessage(),e);
117                 }
118         }
119         
120         @Test
121         public void testGetPortListDictionaryEntityData(){
122                 when(commonClassDao.getData(PortList.class)).thenReturn(new ArrayList<>());
123                 controller.getPortListDictionaryEntityData(response);
124                 try {
125                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
126                 } catch (Exception e) {
127                         fail();
128                         logger.error(e.getMessage(),e);
129                 }
130         }
131         
132         @Test
133         public void testGetProtocolListDictionaryEntityDataByName(){
134                 when(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")).thenReturn(data);
135                 controller.getProtocolListDictionaryEntityDataByName(response);
136                 try {
137                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
138                 } catch (Exception e) {
139                         fail();
140                         logger.error(e.getMessage(),e);
141                 }
142         }
143         
144         @Test
145         public void testGetProtocolListDictionaryEntityData(){
146                 when(commonClassDao.getData(ProtocolList.class)).thenReturn(new ArrayList<>());
147                 controller.getProtocolListDictionaryEntityData(response);
148                 try {
149                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
150                 } catch (Exception e) {
151                         fail();
152                         logger.error(e.getMessage(),e);
153                 }
154         }
155         
156         @Test
157         public void testGetAddressGroupDictionaryEntityDataByName(){
158                 when(commonClassDao.getDataByColumn(AddressGroup.class, "name")).thenReturn(data);
159                 controller.getAddressGroupDictionaryEntityDataByName(response);
160                 try {
161                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
162                 } catch (Exception e) {
163                         fail();
164                         logger.error(e.getMessage(),e);
165                 }
166         }
167         
168         @Test
169         public void testGetAddressGroupDictionaryEntityData(){
170                 when(commonClassDao.getData(AddressGroup.class)).thenReturn(new ArrayList<>());
171                 controller.getAddressGroupDictionaryEntityData(response);
172                 try {
173                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
174                 } catch (Exception e) {
175                         fail();
176                         logger.error(e.getMessage(),e);
177                 }
178         }
179         
180         @Test
181         public void testGetActionListDictionaryEntityDataByName(){
182                 when(commonClassDao.getDataByColumn(ActionList.class, "actionName")).thenReturn(data);
183                 controller.getActionListDictionaryEntityDataByName(response);
184                 try {
185                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
186                 } catch (Exception e) {
187                         fail();
188                         logger.error(e.getMessage(),e);
189                 }
190         }
191         
192         @Test
193         public void testGetActionListDictionaryEntityData(){
194                 when(commonClassDao.getData(ActionList.class)).thenReturn(new ArrayList<>());
195                 controller.getActionListDictionaryEntityData(response);
196                 try {
197                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
198                 } catch (Exception e) {
199                         fail();
200                         logger.error(e.getMessage(),e);
201                 }
202         }
203         
204         @Test
205         public void testGetServiceGroupDictionaryEntityDataByName(){
206                 when(commonClassDao.getDataByColumn(GroupServiceList.class, "name")).thenReturn(data);
207                 controller.getServiceGroupDictionaryEntityDataByName(response);
208                 try {
209                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
210                 } catch (Exception e) {
211                         fail();
212                         logger.error(e.getMessage(),e);
213                 }
214         }
215         
216         @Test
217         public void testGetServiceGroupDictionaryEntityData(){
218                 when(commonClassDao.getData(GroupServiceList.class)).thenReturn(new ArrayList<>());
219                 controller.getServiceGroupDictionaryEntityData(response);
220                 try {
221                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
222                 } catch (Exception e) {
223                         fail();
224                         logger.error(e.getMessage(),e);
225                 }
226         }
227         
228         @Test
229         public void testGetSecurityZoneDictionaryEntityDataByName(){
230                 when(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")).thenReturn(data);
231                 controller.getSecurityZoneDictionaryEntityDataByName(response);
232                 try {
233                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
234                 } catch (Exception e) {
235                         fail();
236                         logger.error(e.getMessage(),e);
237                 }
238         }
239         
240         @Test
241         public void testGetSecurityZoneDictionaryEntityData(){
242                 when(commonClassDao.getData(SecurityZone.class)).thenReturn(new ArrayList<>());
243                 controller.getSecurityZoneDictionaryEntityData(response);
244                 try {
245                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
246                 } catch (Exception e) {
247                         fail();
248                         logger.error(e.getMessage(),e);
249                 }
250         }
251         
252         @Test
253         public void testGetServiceListDictionaryEntityDataByName(){
254                 when(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")).thenReturn(data);
255                 controller.getServiceListDictionaryEntityDataByName(response);
256                 try {
257                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
258                 } catch (Exception e) {
259                         fail();
260                         logger.error(e.getMessage(),e);
261                 }
262         }
263         
264         @Test
265         public void testGetServiceListDictionaryEntityData(){
266                 when(commonClassDao.getData(ServiceList.class)).thenReturn(new ArrayList<>());
267                 controller.getServiceListDictionaryEntityData(response);
268                 try {
269                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
270                 } catch (Exception e) {
271                         fail();
272                         logger.error(e.getMessage(),e);
273                 }
274         }
275         
276         @Test
277         public void testGetZoneDictionaryEntityDataByName(){
278                 when(commonClassDao.getDataByColumn(Zone.class, "zoneName")).thenReturn(data);
279                 controller.getZoneDictionaryEntityDataByName(response);
280                 try {
281                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
282                 } catch (Exception e) {
283                         fail();
284                         logger.error(e.getMessage(),e);
285                 }
286         }
287         
288         @Test
289         public void testGetZoneDictionaryEntityData(){
290                 when(commonClassDao.getData(Zone.class)).thenReturn(new ArrayList<>());
291                 controller.getZoneDictionaryEntityData(response);
292                 try {
293                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
294                 } catch (Exception e) {
295                         fail();
296                         logger.error(e.getMessage(),e);
297                 }
298         }
299         
300         @Test
301         public void testGetTermListDictionaryEntityDataByName(){
302                 when(commonClassDao.getDataByColumn(TermList.class, "termName")).thenReturn(data);
303                 controller.getTermListDictionaryEntityDataByName(response);
304                 try {
305                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
306                 } catch (Exception e) {
307                         fail();
308                         logger.error(e.getMessage(),e);
309                 }
310         }
311         
312         @Test
313         public void testGetTermListDictionaryEntityData(){
314                 when(commonClassDao.getData(TermList.class)).thenReturn(new ArrayList<>());
315                 controller.getTermListDictionaryEntityData(response);
316                 try {
317                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
318                 } catch (Exception e) {
319                         fail();
320                         logger.error(e.getMessage(),e);
321                 }
322         }
323         
324         @Test
325         public void testGetFWDictListDictionaryEntityDataByName(){
326                 when(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")).thenReturn(data);
327                 controller.getFWDictListDictionaryEntityDataByName(response);
328                 try {
329                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
330                 } catch (Exception e) {
331                         fail();
332                         logger.error(e.getMessage(),e);
333                 }
334         }
335         
336         @Test
337         public void testGetFWDictionaryListEntityData(){
338                 when(commonClassDao.getData(FirewallDictionaryList.class)).thenReturn(new ArrayList<>());
339                 controller.getFWDictionaryListEntityData(response);
340                 try {
341                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
342                 } catch (Exception e) {
343                         fail();
344                         logger.error(e.getMessage(),e);
345                 }
346         }
347         
348         @Test
349         public void testGetTagPickerNameEntityDataByName(){
350                 when(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")).thenReturn(data);
351                 controller.getTagPickerNameEntityDataByName(response);
352                 try {
353                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
354                 } catch (Exception e) {
355                         fail();
356                         logger.error(e.getMessage(),e);
357                 }
358         }
359         
360         @Test
361         public void testGetTagPickerDictionaryEntityData(){
362                 when(commonClassDao.getData(FWTagPicker.class)).thenReturn(new ArrayList<>());
363                 controller.getTagPickerDictionaryEntityData(response);
364                 try {
365                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
366                 } catch (Exception e) {
367                         fail();
368                         logger.error(e.getMessage(),e);
369                 }
370         }
371         
372         @Test
373         public void testGetTagNameEntityDataByName(){
374                 when(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")).thenReturn(data);
375                 controller.getTagNameEntityDataByName(response);
376                 try {
377                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
378                 } catch (Exception e) {
379                         fail();
380                         logger.error(e.getMessage(),e);
381                 }
382         }
383         
384         @Test
385         public void testGetTagDictionaryEntityData(){
386                 when(commonClassDao.getData(FWTag.class)).thenReturn(new ArrayList<>());
387                 controller.getTagDictionaryEntityData(response);
388                 try {
389                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
390                 } catch (Exception e) {
391                         fail();
392                         logger.error(e.getMessage(),e);
393                 }
394         }
395         
396         @Test
397         public void testSavePrefixListDictionary(){
398                 jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"description\":\"test\",\"prefixListName\":\"Test\"}}";
399                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
400                         when(request.getReader()).thenReturn(br);
401                         controller.savePrefixListDictionary(request, response);
402                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
403                 }catch(Exception e){
404                         logger.error("Exception"+ e);
405                 } 
406         }
407         
408         @Test
409         public void testUpdatePrefixListDictionary(){
410                 jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\"}}";
411                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
412                         when(request.getReader()).thenReturn(br);
413                         controller.savePrefixListDictionary(request, response);
414                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
415                 }catch(Exception e){
416                         logger.error("Exception"+ e);
417                 } 
418         }
419         
420         @Test
421         public void testRemovePrefixListDictionary(){
422                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\"}}";
423                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
424                         when(request.getReader()).thenReturn(br);
425                         controller.removePrefixListDictionary(request, response);
426                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
427                 }catch(Exception e){
428                         logger.error("Exception"+ e);
429                 } 
430         }
431         
432         @Test
433         public void testValidatePrefixListDictionary(){
434                 jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\",\"prefixListValue\":\"10.10.10\"}}";
435                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
436                         when(request.getReader()).thenReturn(br);
437                         controller.validatePrefixListDictionary(request, response);
438                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("result"));
439                 }catch(Exception e){
440                         logger.error("Exception"+ e);
441                 } 
442         }
443         
444         @Test
445         public void testSavePortListDictionary(){
446                 jsonString = "{\"userid\":\"demo\",\"portListDictionaryData\":{\"description\":\"test\",\"portName\":\"Test\"}}";
447                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
448                         when(request.getReader()).thenReturn(br);
449                         controller.savePortListDictionary(request, response);
450                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
451                 }catch(Exception e){
452                         logger.error("Exception"+ e);
453                 } 
454         }
455         
456         @Test
457         public void testUpdatePortListDictionary(){
458                 jsonString = "{\"userid\":\"demo\",\"portListDictionaryData\":{\"id\":1,\"description\":\"test\",\"portName\":\"Test\"}}";
459                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
460                         when(request.getReader()).thenReturn(br);
461                         controller.savePortListDictionary(request, response);
462                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
463                 }catch(Exception e){
464                         logger.error("Exception"+ e);
465                 } 
466         }
467         
468         @Test
469         public void testRemovePortListDictionary(){
470                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"portName\":\"Test\"}}";
471                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
472                         when(request.getReader()).thenReturn(br);
473                         controller.removePortListDictionary(request, response);
474                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
475                 }catch(Exception e){
476                         logger.error("Exception"+ e);
477                 } 
478         }
479         
480         @Test
481         public void testSaveProtocolListDictionary(){
482                 jsonString = "{\"userid\":\"demo\",\"protocolListDictionaryData\":{\"description\":\"test\",\"protocolName\":\"Test\"}}";
483                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
484                         when(request.getReader()).thenReturn(br);
485                         controller.saveProtocolListDictionary(request, response);
486                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
487                 }catch(Exception e){
488                         logger.error("Exception"+ e);
489                 } 
490         }
491         
492         @Test
493         public void testUpdateProtocolListDictionary(){
494                 jsonString = "{\"userid\":\"demo\",\"protocolListDictionaryData\":{\"id\":1,\"description\":\"test\",\"protocolName\":\"Test\"}}";
495                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
496                         when(request.getReader()).thenReturn(br);
497                         controller.saveProtocolListDictionary(request, response);
498                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
499                 }catch(Exception e){
500                         logger.error("Exception"+ e);
501                 } 
502         }
503         
504         @Test
505         public void testRemoveProtocolListDictionary(){
506                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"protocolName\":\"Test\"}}";
507                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
508                         when(request.getReader()).thenReturn(br);
509                         controller.removeProtocolListDictionary(request, response);
510                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
511                 }catch(Exception e){
512                         logger.error("Exception"+ e);
513                 } 
514         }
515         
516         @Test
517         public void testSaveAddressGroupDictionary(){
518                 jsonString = "{\"addressGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:409\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"groupName\":\"Test\"},\"userid\":\"demo\"}";
519                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
520                         when(request.getReader()).thenReturn(br);
521                         controller.saveAddressGroupDictionary(request, response);
522                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
523                 }catch(Exception e){
524                         logger.error("Exception"+ e);
525                 } 
526         }
527         
528         @Test
529         public void testUpdateAddressGroupDictionary(){
530                 jsonString = "{\"addressGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:409\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"groupName\":\"Test\"},\"userid\":\"demo\",\"id\":1}";
531                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
532                         when(request.getReader()).thenReturn(br);
533                         controller.saveAddressGroupDictionary(request, response);
534                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
535                 }catch(Exception e){
536                         logger.error("Exception"+ e);
537                 } 
538         }
539         
540         @Test
541         public void testRemoveAddressGroupDictionary(){
542                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
543                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
544                         when(request.getReader()).thenReturn(br);
545                         controller.removeAddressGroupDictionary(request, response);
546                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
547                 }catch(Exception e){
548                         logger.error("Exception"+ e);
549                 } 
550         }
551         
552         @Test
553         public void testSaveActionListDictionary(){
554                 jsonString = "{\"userid\":\"demo\",\"actionListDictionaryData\":{\"description\":\"test\",\"actionName\":\"Test\"}}";
555                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
556                         when(request.getReader()).thenReturn(br);
557                         controller.saveActionListDictionary(request, response);
558                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
559                 }catch(Exception e){
560                         logger.error("Exception"+ e);
561                 } 
562         }
563         
564         @Test
565         public void testUpdateActionListDictionary(){
566                 jsonString = "{\"userid\":\"demo\",\"actionListDictionaryData\":{\"id\":1,\"description\":\"test\",\"actionName\":\"Test\"}}";
567                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
568                         when(request.getReader()).thenReturn(br);
569                         controller.saveActionListDictionary(request, response);
570                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
571                 }catch(Exception e){
572                         logger.error("Exception"+ e);
573                 } 
574         }
575         
576         @Test
577         public void testRemoveActionListDictionary(){
578                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"actionName\":\"Test\"}}";
579                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
580                         when(request.getReader()).thenReturn(br);
581                         controller.removeActionListDictionary(request, response);
582                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
583                 }catch(Exception e){
584                         logger.error("Exception"+ e);
585                 } 
586         }
587         
588         @Test
589         public void testSaveServiceGroupDictionary(){
590                 jsonString = "{\"serviceGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:657\",\"id\":\"choice1\",\"option\":\"Test\"}],\"groupName\":\"Test\"},\"userid\":\"demo\"}";
591                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
592                         when(request.getReader()).thenReturn(br);
593                         controller.saveServiceGroupDictionary(request, response);
594                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
595                 }catch(Exception e){
596                         logger.error("Exception"+ e);
597                 } 
598         }
599         
600         @Test
601         public void testUpdateServiceGroupDictionary(){
602                 jsonString = "{\"serviceGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:657\",\"id\":\"choice1\",\"option\":\"Test\"}],\"groupName\":\"Test\"},\"userid\":\"demo\",\"id\":1}";
603                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
604                         when(request.getReader()).thenReturn(br);
605                         controller.saveServiceGroupDictionary(request, response);
606                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
607                 }catch(Exception e){
608                         logger.error("Exception"+ e);
609                 } 
610         }
611         
612         @Test
613         public void testRemoveServiceGroupDictionary(){
614                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
615                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
616                         when(request.getReader()).thenReturn(br);
617                         controller.removeServiceGroupDictionary(request, response);
618                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
619                 }catch(Exception e){
620                         logger.error("Exception"+ e);
621                 } 
622         }
623         
624         @Test
625         public void testSaveSecurityZoneDictionary(){
626                 jsonString = "{\"userid\":\"demo\",\"securityZoneDictionaryData\":{\"description\":\"test\",\"zoneName\":\"Test\"}}";
627                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
628                         when(request.getReader()).thenReturn(br);
629                         controller.saveSecurityZoneDictionary(request, response);
630                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
631                 }catch(Exception e){
632                         logger.error("Exception"+ e);
633                 } 
634         }
635         
636         @Test
637         public void testUpdateSecurityZoneDictionary(){
638                 jsonString = "{\"userid\":\"demo\",\"securityZoneDictionaryData\":{\"id\":1,\"description\":\"test\",\"zoneName\":\"Test\"}}";
639                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
640                         when(request.getReader()).thenReturn(br);
641                         controller.saveSecurityZoneDictionary(request, response);
642                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
643                 }catch(Exception e){
644                         logger.error("Exception"+ e);
645                 } 
646         }
647         
648         @Test
649         public void testRemoveSecurityZoneDictionary(){
650                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"zoneName\":\"Test\"}}";
651                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
652                         when(request.getReader()).thenReturn(br);
653                         controller.removeSecurityZoneDictionary(request, response);
654                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
655                 }catch(Exception e){
656                         logger.error("Exception"+ e);
657                 } 
658         }
659         
660         @Test
661         public void testSaveServiceListDictionary(){
662                 jsonString = "{\"serviceListDictionaryData\":{\"appProtocols\":[{\"$$hashKey\":\"object:560\",\"id\":\"choice1\",\"option\":\"Test\"}],\"serviceDescription\":\"test\",\"serviceName\":\"Test\",\"servicePorts\":\"1010\",\"transportProtocols\":[{\"$$hashKey\":\"object:555\",\"id\":\"choice1\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
663                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
664                         when(request.getReader()).thenReturn(br);
665                         controller.saveServiceListDictionary(request, response);
666                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
667                 }catch(Exception e){
668                         logger.error("Exception"+ e);
669                 } 
670         }
671         
672         @Test
673         public void testUpdateServiceListDictionary(){
674                 jsonString = "{\"serviceListDictionaryData\":{\"appProtocols\":[{\"$$hashKey\":\"object:560\",\"id\":\"choice1\",\"option\":\"Test\"}],\"serviceDescription\":\"test\",\"id\":1,\"serviceName\":\"Test\",\"servicePorts\":\"1010\",\"transportProtocols\":[{\"$$hashKey\":\"object:555\",\"id\":\"choice1\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
675                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
676                         when(request.getReader()).thenReturn(br);
677                         controller.saveServiceListDictionary(request, response);
678                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
679                 }catch(Exception e){
680                         logger.error("Exception"+ e);
681                 } 
682         }
683         
684         @Test
685         public void testRemoveServiceListDictionary(){
686                 jsonString = "{\"data\":{\"appProtocols\":[{\"$$hashKey\":\"object:560\",\"id\":\"choice1\",\"option\":\"Test\"}],\"serviceDescription\":\"test\",\"id\":1,\"serviceName\":\"Test\",\"servicePorts\":\"1010\",\"transportProtocols\":[{\"$$hashKey\":\"object:555\",\"id\":\"choice1\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
687                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
688                         when(request.getReader()).thenReturn(br);
689                         controller.removeServiceListDictionary(request, response);
690                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
691                 }catch(Exception e){
692                         logger.error("Exception"+ e);
693                 } 
694         }
695         
696         @Test
697         public void testSaveZoneDictionary(){
698                 jsonString = "{\"userid\":\"demo\",\"zoneDictionaryData\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
699                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
700                         when(request.getReader()).thenReturn(br);
701                         controller.saveZoneDictionary(request, response);
702                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
703                 }catch(Exception e){
704                         logger.error("Exception"+ e);
705                 } 
706         }
707         
708         @Test
709         public void testUpdateZoneDictionary(){
710                 jsonString = "{\"userid\":\"demo\",\"zoneDictionaryData\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
711                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
712                         when(request.getReader()).thenReturn(br);
713                         controller.saveZoneDictionary(request, response);
714                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
715                 }catch(Exception e){
716                         logger.error("Exception"+ e);
717                 } 
718         }
719         
720         @Test
721         public void testRemoveZoneDictionary(){
722                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
723                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
724                         when(request.getReader()).thenReturn(br);
725                         controller.removeZoneDictionary(request, response);
726                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
727                 }catch(Exception e){
728                         logger.error("Exception"+ e);
729                 } 
730         }
731         
732         @Test
733         public void testSaveTermListDictionary(){
734                 jsonString = "{\"termListDictionaryData\":{\"actionListDatas\":[{\"$$hashKey\":\"object:1220\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"destinationListDatas\":[{\"$$hashKey\":\"object:1220\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"destinationServiceDatas\":[{\"$$hashKey\":\"object:1230\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"fromZoneDatas\":[{\"$$hashKey\":\"object:1245\",\"id\":\"choice1\",\"option\":\"Test\"}],\"sourceListDatas\":[{\"$$hashKey\":\"object:1215\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"sourceServiceDatas\":[{\"$$hashKey\":\"object:1225\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"termDescription\":\"test\",\"termName\":\"Test\",\"toZoneDatas\":[{\"$$hashKey\":\"object:1240\",\"id\":\"choice1\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
735                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
736                         when(request.getReader()).thenReturn(br);
737                         controller.saveTermListDictionary(request, response);
738                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
739                 }catch(Exception e){
740                         logger.error("Exception"+ e);
741                 } 
742         }
743         
744         @Test
745         public void testUpdateTermListDictionary(){
746                 jsonString = "{\"termListDictionaryData\":{\"id\":1,\"actionListDatas\":[{\"$$hashKey\":\"object:1220\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"destinationListDatas\":[{\"$$hashKey\":\"object:1220\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"destinationServiceDatas\":[{\"$$hashKey\":\"object:1230\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"fromZoneDatas\":[{\"$$hashKey\":\"object:1245\",\"id\":\"choice1\",\"option\":\"Test\"}],\"sourceListDatas\":[{\"$$hashKey\":\"object:1215\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"sourceServiceDatas\":[{\"$$hashKey\":\"object:1225\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"termDescription\":\"test\",\"termName\":\"Test\",\"toZoneDatas\":[{\"$$hashKey\":\"object:1240\",\"id\":\"choice1\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
747                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
748                         when(request.getReader()).thenReturn(br);
749                         controller.saveTermListDictionary(request, response);
750                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
751                 }catch(Exception e){
752                         logger.error("Exception"+ e);
753                 } 
754         }
755         
756         @Test
757         public void testRemoveTermListDictionary(){
758                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"termDescription\":\"test\",\"termName\":\"Test\"}}";
759                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
760                         when(request.getReader()).thenReturn(br);
761                         controller.removeTermListDictionary(request, response);
762                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
763                 }catch(Exception e){
764                         logger.error("Exception"+ e);
765                 } 
766         }
767         
768         @Test
769         public void testSaveFWDictionaryList(){
770                 jsonString = "{\"fwDictListDictionaryData\":{\"alAttributes\":[{\"$$hashKey\":\"object:1379\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"attributes\":[{\"$$hashKey\":\"object:1374\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"parentItemName\":\"Test\"},\"userid\":\"demo\"}";
771                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
772                         when(request.getReader()).thenReturn(br);
773                         controller.saveFWDictionaryList(request, response);
774                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
775                 }catch(Exception e){
776                         logger.error("Exception"+ e);
777                 } 
778         }
779         
780         @Test
781         public void testUpdateFWDictionaryList(){
782                 jsonString = "{\"fwDictListDictionaryData\":{\"id\":1,\"alAttributes\":[{\"$$hashKey\":\"object:1379\",\"id\":\"choice1\",\"option\":\"Group_Test\"}],\"attributes\":[{\"$$hashKey\":\"object:1374\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"parentItemName\":\"Test\"},\"userid\":\"demo\"}";
783                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
784                         when(request.getReader()).thenReturn(br);
785                         controller.saveFWDictionaryList(request, response);
786                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
787                 }catch(Exception e){
788                         logger.error("Exception"+ e);
789                 } 
790         }
791         
792         @Test
793         public void testRemoveFWDictionaryList(){
794                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"parentItemName\":\"Test\"}}";
795                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
796                         when(request.getReader()).thenReturn(br);
797                         controller.removeFWDictionaryList(request, response);
798                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
799                 }catch(Exception e){
800                         logger.error("Exception"+ e);
801                 } 
802         }
803         
804         @Test
805         public void testSaveFirewallTagPickerDictionary(){
806                 jsonString = "{\"fwTagPickerDictionaryData\":{\"description\":\"test\",\"networkRole\":\"test\",\"tagPickerName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1855\",\"id\":\"choice1\",\"number\":\"test\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
807                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
808                         when(request.getReader()).thenReturn(br);
809                         controller.saveFirewallTagPickerDictionary(request, response);
810                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
811                 }catch(Exception e){
812                         logger.error("Exception"+ e);
813                 } 
814         }
815         
816         @Test
817         public void testUpdateFirewallTagPickerDictionary(){
818                 jsonString = "{\"fwTagPickerDictionaryData\":{\"id\":1,\"description\":\"test\",\"networkRole\":\"test\",\"tagPickerName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1855\",\"id\":\"choice1\",\"number\":\"test\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
819                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
820                         when(request.getReader()).thenReturn(br);
821                         controller.saveFirewallTagPickerDictionary(request, response);
822                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
823                 }catch(Exception e){
824                         logger.error("Exception"+ e);
825                 } 
826         }
827         
828         @Test
829         public void testRemoveFirewallTagPickerDictionary(){
830                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"tagPickerName\":\"Test\"}}";
831                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
832                         when(request.getReader()).thenReturn(br);
833                         controller.removeFirewallTagPickerDictionary(request, response);
834                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
835                 }catch(Exception e){
836                         logger.error("Exception"+ e);
837                 } 
838         }
839         
840         @Test
841         public void testSaveFirewallTagDictionary(){
842                 jsonString = "{\"fwTagDictionaryData\":{\"description\":\"test\",\"fwTagName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1690\",\"id\":\"choice1\",\"tags\":\"test\"}]},\"userid\":\"demo\"}";
843                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
844                         when(request.getReader()).thenReturn(br);
845                         controller.saveFirewallTagDictionary(request, response);
846                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
847                 }catch(Exception e){
848                         logger.error("Exception"+ e);
849                 } 
850         }
851         
852         @Test
853         public void testUpdateFirewallTagDictionary(){
854                 jsonString = "{\"fwTagDictionaryData\":{\"id\":1,\"description\":\"test\",\"fwTagName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1690\",\"id\":\"choice1\",\"tags\":\"test\"}]},\"userid\":\"demo\"}";
855                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
856                         when(request.getReader()).thenReturn(br);
857                         controller.saveFirewallTagDictionary(request, response);
858                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
859                 }catch(Exception e){
860                         logger.error("Exception"+ e);
861                 } 
862         }
863         
864         @Test
865         public void testRemoveFirewallTagDictionary(){
866                 jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"fwTagName\":\"Test\"}}";
867                 try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
868                         when(request.getReader()).thenReturn(br);
869                         controller.removeFirewallTagDictionary(request, response);
870                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
871                 }catch(Exception e){
872                         logger.error("Exception"+ e);
873                 } 
874         }
875 }