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.when;
27 import java.io.BufferedReader;
28 import java.io.StringReader;
29 import java.util.ArrayList;
30 import java.util.List;
32 import javax.servlet.http.HttpServletRequest;
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;
57 public class FirewallDictionaryControllerTest {
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;
69 public void setUp() throws Exception {
70 logger.info("setUp: Entering");
71 commonClassDao = Mockito.mock(CommonClassDao.class);
73 data = new ArrayList<>();
76 userInfo = new UserInfo();
77 userInfo.setUserLoginId("Test");
78 userInfo.setUserName("Test");
80 doNothing().when(commonClassDao).delete(new Term());
81 doNothing().when(commonClassDao).save(new Term());
83 controller = new FirewallDictionaryController();
84 FirewallDictionaryController.setCommonClassDao(commonClassDao);
86 request = Mockito.mock(HttpServletRequest.class);
87 response = new MockHttpServletResponse();
88 logger.info("setUp: exit");
92 public void testGetPrefixListDictionaryEntityDataByName(){
93 when(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")).thenReturn(data);
94 controller.getPrefixListDictionaryEntityDataByName(response);
96 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
97 } catch (Exception e) {
99 logger.error(e.getMessage(),e);
104 public void testGetPrefixListDictionaryEntityData(){
105 when(commonClassDao.getData(PrefixList.class)).thenReturn(new ArrayList<>());
106 controller.getPrefixListDictionaryEntityData(response);
108 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
109 } catch (Exception e) {
111 logger.error(e.getMessage(),e);
116 public void testGetPortListDictionaryEntityData(){
117 when(commonClassDao.getData(PortList.class)).thenReturn(new ArrayList<>());
118 controller.getPortListDictionaryEntityData(response);
120 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
121 } catch (Exception e) {
123 logger.error(e.getMessage(),e);
128 public void testGetProtocolListDictionaryEntityDataByName(){
129 when(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")).thenReturn(data);
130 controller.getProtocolListDictionaryEntityDataByName(response);
132 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
133 } catch (Exception e) {
135 logger.error(e.getMessage(),e);
140 public void testGetProtocolListDictionaryEntityData(){
141 when(commonClassDao.getData(ProtocolList.class)).thenReturn(new ArrayList<>());
142 controller.getProtocolListDictionaryEntityData(response);
144 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
145 } catch (Exception e) {
147 logger.error(e.getMessage(),e);
152 public void testGetAddressGroupDictionaryEntityDataByName(){
153 when(commonClassDao.getDataByColumn(AddressGroup.class, "name")).thenReturn(data);
154 controller.getAddressGroupDictionaryEntityDataByName(response);
156 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
157 } catch (Exception e) {
159 logger.error(e.getMessage(),e);
164 public void testGetAddressGroupDictionaryEntityData(){
165 when(commonClassDao.getData(AddressGroup.class)).thenReturn(new ArrayList<>());
166 controller.getAddressGroupDictionaryEntityData(response);
168 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
169 } catch (Exception e) {
171 logger.error(e.getMessage(),e);
176 public void testGetActionListDictionaryEntityDataByName(){
177 when(commonClassDao.getDataByColumn(ActionList.class, "actionName")).thenReturn(data);
178 controller.getActionListDictionaryEntityDataByName(response);
180 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
181 } catch (Exception e) {
183 logger.error(e.getMessage(),e);
188 public void testGetActionListDictionaryEntityData(){
189 when(commonClassDao.getData(ActionList.class)).thenReturn(new ArrayList<>());
190 controller.getActionListDictionaryEntityData(response);
192 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
193 } catch (Exception e) {
195 logger.error(e.getMessage(),e);
200 public void testGetServiceGroupDictionaryEntityDataByName(){
201 when(commonClassDao.getDataByColumn(GroupServiceList.class, "name")).thenReturn(data);
202 controller.getServiceGroupDictionaryEntityDataByName(response);
204 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
205 } catch (Exception e) {
207 logger.error(e.getMessage(),e);
212 public void testGetServiceGroupDictionaryEntityData(){
213 when(commonClassDao.getData(GroupServiceList.class)).thenReturn(new ArrayList<>());
214 controller.getServiceGroupDictionaryEntityData(response);
216 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
217 } catch (Exception e) {
219 logger.error(e.getMessage(),e);
224 public void testGetSecurityZoneDictionaryEntityDataByName(){
225 when(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")).thenReturn(data);
226 controller.getSecurityZoneDictionaryEntityDataByName(response);
228 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
229 } catch (Exception e) {
231 logger.error(e.getMessage(),e);
236 public void testGetSecurityZoneDictionaryEntityData(){
237 when(commonClassDao.getData(SecurityZone.class)).thenReturn(new ArrayList<>());
238 controller.getSecurityZoneDictionaryEntityData(response);
240 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
241 } catch (Exception e) {
243 logger.error(e.getMessage(),e);
248 public void testGetServiceListDictionaryEntityDataByName(){
249 when(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")).thenReturn(data);
250 controller.getServiceListDictionaryEntityDataByName(response);
252 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
253 } catch (Exception e) {
255 logger.error(e.getMessage(),e);
260 public void testGetServiceListDictionaryEntityData(){
261 when(commonClassDao.getData(ServiceList.class)).thenReturn(new ArrayList<>());
262 controller.getServiceListDictionaryEntityData(response);
264 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
265 } catch (Exception e) {
267 logger.error(e.getMessage(),e);
272 public void testGetZoneDictionaryEntityDataByName(){
273 when(commonClassDao.getDataByColumn(Zone.class, "zoneName")).thenReturn(data);
274 controller.getZoneDictionaryEntityDataByName(response);
276 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
277 } catch (Exception e) {
279 logger.error(e.getMessage(),e);
284 public void testGetZoneDictionaryEntityData(){
285 when(commonClassDao.getData(Zone.class)).thenReturn(new ArrayList<>());
286 controller.getZoneDictionaryEntityData(response);
288 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
289 } catch (Exception e) {
291 logger.error(e.getMessage(),e);
296 public void testGetTermListDictionaryEntityDataByName(){
297 when(commonClassDao.getDataByColumn(TermList.class, "termName")).thenReturn(data);
298 controller.getTermListDictionaryEntityDataByName(response);
300 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
301 } catch (Exception e) {
303 logger.error(e.getMessage(),e);
308 public void testGetTermListDictionaryEntityData(){
309 when(commonClassDao.getData(TermList.class)).thenReturn(new ArrayList<>());
310 controller.getTermListDictionaryEntityData(response);
312 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
313 } catch (Exception e) {
315 logger.error(e.getMessage(),e);
320 public void testGetFWDictListDictionaryEntityDataByName(){
321 when(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")).thenReturn(data);
322 controller.getFWDictListDictionaryEntityDataByName(response);
324 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
325 } catch (Exception e) {
327 logger.error(e.getMessage(),e);
332 public void testGetFWDictionaryListEntityData(){
333 when(commonClassDao.getData(FirewallDictionaryList.class)).thenReturn(new ArrayList<>());
334 controller.getFWDictionaryListEntityData(response);
336 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
337 } catch (Exception e) {
339 logger.error(e.getMessage(),e);
344 public void testGetTagPickerNameEntityDataByName(){
345 when(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")).thenReturn(data);
346 controller.getTagPickerNameEntityDataByName(response);
348 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
349 } catch (Exception e) {
351 logger.error(e.getMessage(),e);
356 public void testGetTagPickerDictionaryEntityData(){
357 when(commonClassDao.getData(FWTagPicker.class)).thenReturn(new ArrayList<>());
358 controller.getTagPickerDictionaryEntityData(response);
360 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
361 } catch (Exception e) {
363 logger.error(e.getMessage(),e);
368 public void testGetTagNameEntityDataByName(){
369 when(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")).thenReturn(data);
370 controller.getTagNameEntityDataByName(response);
372 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
373 } catch (Exception e) {
375 logger.error(e.getMessage(),e);
380 public void testGetTagDictionaryEntityData(){
381 when(commonClassDao.getData(FWTag.class)).thenReturn(new ArrayList<>());
382 controller.getTagDictionaryEntityData(response);
384 assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
385 } catch (Exception e) {
387 logger.error(e.getMessage(),e);
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"));
399 logger.error("Exception"+ e);
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"));
411 logger.error("Exception"+ e);
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"));
423 logger.error("Exception"+ e);
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"));
435 logger.error("Exception"+ e);
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"));
447 logger.error("Exception"+ e);
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"));
459 logger.error("Exception"+ e);
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"));
471 logger.error("Exception"+ e);
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"));
483 logger.error("Exception"+ e);
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"));
495 logger.error("Exception"+ e);
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"));
507 logger.error("Exception"+ e);
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"));
519 logger.error("Exception"+ e);
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"));
531 logger.error("Exception"+ e);
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"));
543 logger.error("Exception"+ e);
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"));
555 logger.error("Exception"+ e);
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"));
567 logger.error("Exception"+ e);
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"));
579 logger.error("Exception"+ e);
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"));
591 logger.error("Exception"+ e);
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"));
603 logger.error("Exception"+ e);
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"));
615 logger.error("Exception"+ e);
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"));
627 logger.error("Exception"+ e);
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"));
639 logger.error("Exception"+ e);
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"));
651 logger.error("Exception"+ e);
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"));
663 logger.error("Exception"+ e);
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"));
675 logger.error("Exception"+ e);
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"));
687 logger.error("Exception"+ e);
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"));
699 logger.error("Exception"+ e);
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"));
711 logger.error("Exception"+ e);
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"));
723 logger.error("Exception"+ e);
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"));
735 logger.error("Exception"+ e);
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"));
747 logger.error("Exception"+ e);
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"));
759 logger.error("Exception"+ e);
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"));
771 logger.error("Exception"+ e);
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"));
783 logger.error("Exception"+ e);
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"));
795 logger.error("Exception"+ e);
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"));
807 logger.error("Exception"+ e);
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"));
819 logger.error("Exception"+ e);
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"));
831 logger.error("Exception"+ e);
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"));
843 logger.error("Exception"+ e);
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"));
855 logger.error("Exception"+ e);
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"));
867 logger.error("Exception"+ e);