2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.pap.xacml.rest.controller;
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;
28 import java.io.BufferedReader;
29 import java.io.StringReader;
30 import java.util.ArrayList;
31 import java.util.List;
33 import javax.servlet.http.HttpServletRequest;
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;
59 public class FirewallDictionaryControllerTest {
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;
71 public void setUp() throws Exception {
72 logger.info("setUp: Entering");
73 commonClassDao = Mockito.mock(CommonClassDao.class);
75 data = new ArrayList<>();
78 userInfo = new UserInfo();
79 userInfo.setUserLoginId("Test");
80 userInfo.setUserName("Test");
82 doNothing().when(commonClassDao).delete(new Term());
83 doNothing().when(commonClassDao).save(new Term());
85 controller = new FirewallDictionaryController();
86 FirewallDictionaryController.setCommonClassDao(commonClassDao);
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");
97 public void testGetPrefixListDictionaryEntityDataByName(){
98 when(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")).thenReturn(data);
99 controller.getPrefixListDictionaryEntityDataByName(response);
101 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
102 } catch (Exception e) {
104 logger.error(e.getMessage(),e);
109 public void testGetPrefixListDictionaryEntityData(){
110 when(commonClassDao.getData(PrefixList.class)).thenReturn(new ArrayList<>());
111 controller.getPrefixListDictionaryEntityData(response);
113 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
114 } catch (Exception e) {
116 logger.error(e.getMessage(),e);
121 public void testGetPortListDictionaryEntityData(){
122 when(commonClassDao.getData(PortList.class)).thenReturn(new ArrayList<>());
123 controller.getPortListDictionaryEntityData(response);
125 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
126 } catch (Exception e) {
128 logger.error(e.getMessage(),e);
133 public void testGetProtocolListDictionaryEntityDataByName(){
134 when(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")).thenReturn(data);
135 controller.getProtocolListDictionaryEntityDataByName(response);
137 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
138 } catch (Exception e) {
140 logger.error(e.getMessage(),e);
145 public void testGetProtocolListDictionaryEntityData(){
146 when(commonClassDao.getData(ProtocolList.class)).thenReturn(new ArrayList<>());
147 controller.getProtocolListDictionaryEntityData(response);
149 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
150 } catch (Exception e) {
152 logger.error(e.getMessage(),e);
157 public void testGetAddressGroupDictionaryEntityDataByName(){
158 when(commonClassDao.getDataByColumn(AddressGroup.class, "name")).thenReturn(data);
159 controller.getAddressGroupDictionaryEntityDataByName(response);
161 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
162 } catch (Exception e) {
164 logger.error(e.getMessage(),e);
169 public void testGetAddressGroupDictionaryEntityData(){
170 when(commonClassDao.getData(AddressGroup.class)).thenReturn(new ArrayList<>());
171 controller.getAddressGroupDictionaryEntityData(response);
173 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
174 } catch (Exception e) {
176 logger.error(e.getMessage(),e);
181 public void testGetActionListDictionaryEntityDataByName(){
182 when(commonClassDao.getDataByColumn(ActionList.class, "actionName")).thenReturn(data);
183 controller.getActionListDictionaryEntityDataByName(response);
185 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
186 } catch (Exception e) {
188 logger.error(e.getMessage(),e);
193 public void testGetActionListDictionaryEntityData(){
194 when(commonClassDao.getData(ActionList.class)).thenReturn(new ArrayList<>());
195 controller.getActionListDictionaryEntityData(response);
197 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
198 } catch (Exception e) {
200 logger.error(e.getMessage(),e);
205 public void testGetServiceGroupDictionaryEntityDataByName(){
206 when(commonClassDao.getDataByColumn(GroupServiceList.class, "name")).thenReturn(data);
207 controller.getServiceGroupDictionaryEntityDataByName(response);
209 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
210 } catch (Exception e) {
212 logger.error(e.getMessage(),e);
217 public void testGetServiceGroupDictionaryEntityData(){
218 when(commonClassDao.getData(GroupServiceList.class)).thenReturn(new ArrayList<>());
219 controller.getServiceGroupDictionaryEntityData(response);
221 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
222 } catch (Exception e) {
224 logger.error(e.getMessage(),e);
229 public void testGetSecurityZoneDictionaryEntityDataByName(){
230 when(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")).thenReturn(data);
231 controller.getSecurityZoneDictionaryEntityDataByName(response);
233 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
234 } catch (Exception e) {
236 logger.error(e.getMessage(),e);
241 public void testGetSecurityZoneDictionaryEntityData(){
242 when(commonClassDao.getData(SecurityZone.class)).thenReturn(new ArrayList<>());
243 controller.getSecurityZoneDictionaryEntityData(response);
245 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
246 } catch (Exception e) {
248 logger.error(e.getMessage(),e);
253 public void testGetServiceListDictionaryEntityDataByName(){
254 when(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")).thenReturn(data);
255 controller.getServiceListDictionaryEntityDataByName(response);
257 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
258 } catch (Exception e) {
260 logger.error(e.getMessage(),e);
265 public void testGetServiceListDictionaryEntityData(){
266 when(commonClassDao.getData(ServiceList.class)).thenReturn(new ArrayList<>());
267 controller.getServiceListDictionaryEntityData(response);
269 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
270 } catch (Exception e) {
272 logger.error(e.getMessage(),e);
277 public void testGetZoneDictionaryEntityDataByName(){
278 when(commonClassDao.getDataByColumn(Zone.class, "zoneName")).thenReturn(data);
279 controller.getZoneDictionaryEntityDataByName(response);
281 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
282 } catch (Exception e) {
284 logger.error(e.getMessage(),e);
289 public void testGetZoneDictionaryEntityData(){
290 when(commonClassDao.getData(Zone.class)).thenReturn(new ArrayList<>());
291 controller.getZoneDictionaryEntityData(response);
293 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
294 } catch (Exception e) {
296 logger.error(e.getMessage(),e);
301 public void testGetTermListDictionaryEntityDataByName(){
302 when(commonClassDao.getDataByColumn(TermList.class, "termName")).thenReturn(data);
303 controller.getTermListDictionaryEntityDataByName(response);
305 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
306 } catch (Exception e) {
308 logger.error(e.getMessage(),e);
313 public void testGetTermListDictionaryEntityData(){
314 when(commonClassDao.getData(TermList.class)).thenReturn(new ArrayList<>());
315 controller.getTermListDictionaryEntityData(response);
317 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
318 } catch (Exception e) {
320 logger.error(e.getMessage(),e);
325 public void testGetFWDictListDictionaryEntityDataByName(){
326 when(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")).thenReturn(data);
327 controller.getFWDictListDictionaryEntityDataByName(response);
329 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
330 } catch (Exception e) {
332 logger.error(e.getMessage(),e);
337 public void testGetFWDictionaryListEntityData(){
338 when(commonClassDao.getData(FirewallDictionaryList.class)).thenReturn(new ArrayList<>());
339 controller.getFWDictionaryListEntityData(response);
341 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
342 } catch (Exception e) {
344 logger.error(e.getMessage(),e);
349 public void testGetTagPickerNameEntityDataByName(){
350 when(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")).thenReturn(data);
351 controller.getTagPickerNameEntityDataByName(response);
353 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
354 } catch (Exception e) {
356 logger.error(e.getMessage(),e);
361 public void testGetTagPickerDictionaryEntityData(){
362 when(commonClassDao.getData(FWTagPicker.class)).thenReturn(new ArrayList<>());
363 controller.getTagPickerDictionaryEntityData(response);
365 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
366 } catch (Exception e) {
368 logger.error(e.getMessage(),e);
373 public void testGetTagNameEntityDataByName(){
374 when(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")).thenReturn(data);
375 controller.getTagNameEntityDataByName(response);
377 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
378 } catch (Exception e) {
380 logger.error(e.getMessage(),e);
385 public void testGetTagDictionaryEntityData(){
386 when(commonClassDao.getData(FWTag.class)).thenReturn(new ArrayList<>());
387 controller.getTagDictionaryEntityData(response);
389 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
390 } catch (Exception e) {
392 logger.error(e.getMessage(),e);
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"));
404 logger.error("Exception"+ e);
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"));
416 logger.error("Exception"+ e);
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"));
428 logger.error("Exception"+ e);
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"));
440 logger.error("Exception"+ e);
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"));
452 logger.error("Exception"+ e);
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"));
464 logger.error("Exception"+ e);
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"));
476 logger.error("Exception"+ e);
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"));
488 logger.error("Exception"+ e);
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"));
500 logger.error("Exception"+ e);
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"));
512 logger.error("Exception"+ e);
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"));
524 logger.error("Exception"+ e);
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"));
536 logger.error("Exception"+ e);
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"));
548 logger.error("Exception"+ e);
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"));
560 logger.error("Exception"+ e);
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"));
572 logger.error("Exception"+ e);
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"));
584 logger.error("Exception"+ e);
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"));
596 logger.error("Exception"+ e);
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"));
608 logger.error("Exception"+ e);
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"));
620 logger.error("Exception"+ e);
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"));
632 logger.error("Exception"+ e);
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"));
644 logger.error("Exception"+ e);
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"));
656 logger.error("Exception"+ e);
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"));
668 logger.error("Exception"+ e);
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"));
680 logger.error("Exception"+ e);
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"));
692 logger.error("Exception"+ e);
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"));
704 logger.error("Exception"+ e);
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"));
716 logger.error("Exception"+ e);
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"));
728 logger.error("Exception"+ e);
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"));
740 logger.error("Exception"+ e);
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"));
752 logger.error("Exception"+ e);
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"));
764 logger.error("Exception"+ e);
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"));
776 logger.error("Exception"+ e);
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"));
788 logger.error("Exception"+ e);
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"));
800 logger.error("Exception"+ e);
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"));
812 logger.error("Exception"+ e);
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"));
824 logger.error("Exception"+ e);
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"));
836 logger.error("Exception"+ e);
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"));
848 logger.error("Exception"+ e);
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"));
860 logger.error("Exception"+ e);
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"));
872 logger.error("Exception"+ e);