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