summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2018-02-12 22:46:09 -0500
committerrb7147 <rb7147@att.com>2018-02-12 22:49:05 -0500
commitef9258807505ff24e8221bae25d06ab65029397c (patch)
treeff9d8d5f5bd12e867644f5c8b24515f8c62b8e4d /ONAP-PAP-REST/src/test/java/org
parent1ef83d84ac1f803280686cca6960d1dc20695ace (diff)
Added Junits for Policy PAP-REST
Resolved the sonar issues. Added JUnits for ONAP-PAP-REST and ONAP-REST Component. Issue-ID: POLICY-338 Change-Id: Ibec2613f4f61e9ed426583af17c2a9d5b8c8d85d Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java154
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryControllerTest.java870
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryControllerTest.java380
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyControllerTest.java149
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java198
5 files changed, 1603 insertions, 148 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java
index d1af82c93..bd521a9d9 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.when;
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@@ -81,147 +80,6 @@ public class ClosedLoopDictionaryControllerTest {
logger.info("setUp: exit");
}
- public List<Object> testVSCLAction(){
- List<Object> objectData = new ArrayList<>();
-
- VSCLAction data = new VSCLAction();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setVsclaction("Test");
- assertTrue("Test".equals(data.getVsclaction()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
- public List<Object> testVNFType(){
- List<Object> objectData = new ArrayList<>();
-
- VNFType data = new VNFType();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setVnftype("Test");
- assertTrue("Test".equals(data.getVnftype()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
- public List<Object> testPEPOptions(){
- List<Object> objectData = new ArrayList<>();
-
- PEPOptions data = new PEPOptions();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setPepName("Test");
- assertTrue("Test".equals(data.getPepName()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
- public List<Object> testVarbindDictionary(){
- List<Object> objectData = new ArrayList<>();
-
- VarbindDictionary data = new VarbindDictionary();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setVarbindName("Test");
- assertTrue("Test".equals(data.getVarbindName()));
- data.setVarbindDescription("Test");
- assertTrue("Test".equals(data.getVarbindDescription()));
- data.setVarbindOID("Test");
- assertTrue("Test".equals(data.getVarbindOID()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
- public List<Object> testClosedLoopD2Services(){
- List<Object> objectData = new ArrayList<>();
-
- ClosedLoopD2Services data = new ClosedLoopD2Services();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setServiceName("Test");
- assertTrue("Test".equals(data.getServiceName()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
-
- public List<Object> testClosedLoopSite(){
- List<Object> objectData = new ArrayList<>();
-
- ClosedLoopSite data = new ClosedLoopSite();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setSiteName("Test");
- assertTrue("Test".equals(data.getSiteName()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
- objectData.add(data);
-
- return objectData;
- }
-
@Test
public void testGetVSCLActionDictionaryByNameEntityData(){
when(commonClassDao.getDataByColumn(VSCLAction.class, "vsclaction")).thenReturn(data);
@@ -236,7 +94,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetVSCLActionDictionaryEntityData(){
- when(commonClassDao.getData(VSCLAction.class)).thenReturn(testVSCLAction());
+ when(commonClassDao.getData(VSCLAction.class)).thenReturn(new ArrayList<>());
controller.getVSCLActionDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
@@ -260,7 +118,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetVNFTypeDictionaryEntityData(){
- when(commonClassDao.getData(VNFType.class)).thenReturn(testVNFType());
+ when(commonClassDao.getData(VNFType.class)).thenReturn(new ArrayList<>());
controller.getVNFTypeDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryDatas"));
@@ -284,7 +142,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetPEPOptionsDictionaryEntityData(){
- when(commonClassDao.getData(PEPOptions.class)).thenReturn(testPEPOptions());
+ when(commonClassDao.getData(PEPOptions.class)).thenReturn(new ArrayList<>());
controller.getPEPOptionsDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
@@ -308,7 +166,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetVarbindDictionaryEntityData(){
- when(commonClassDao.getData(VarbindDictionary.class)).thenReturn(testVarbindDictionary());
+ when(commonClassDao.getData(VarbindDictionary.class)).thenReturn(new ArrayList<>());
controller.getVarbindDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
@@ -332,7 +190,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetClosedLoopServiceDictionaryEntityData(){
- when(commonClassDao.getData(ClosedLoopD2Services.class)).thenReturn(testClosedLoopD2Services());
+ when(commonClassDao.getData(ClosedLoopD2Services.class)).thenReturn(new ArrayList<>());
controller.getClosedLoopServiceDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryDatas"));
@@ -356,7 +214,7 @@ public class ClosedLoopDictionaryControllerTest {
@Test
public void testGetClosedLoopSiteDictionaryEntityData(){
- when(commonClassDao.getData(ClosedLoopSite.class)).thenReturn(testClosedLoopSite());
+ when(commonClassDao.getData(ClosedLoopSite.class)).thenReturn(new ArrayList<>());
controller.getClosedLoopSiteDictionaryEntityData(response);
try {
assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryControllerTest.java
new file mode 100644
index 000000000..7d8bb381a
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryControllerTest.java
@@ -0,0 +1,870 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.adapter.Term;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.ActionList;
+import org.onap.policy.rest.jpa.AddressGroup;
+import org.onap.policy.rest.jpa.FWTag;
+import org.onap.policy.rest.jpa.FWTagPicker;
+import org.onap.policy.rest.jpa.FirewallDictionaryList;
+import org.onap.policy.rest.jpa.GroupServiceList;
+import org.onap.policy.rest.jpa.PortList;
+import org.onap.policy.rest.jpa.PrefixList;
+import org.onap.policy.rest.jpa.ProtocolList;
+import org.onap.policy.rest.jpa.SecurityZone;
+import org.onap.policy.rest.jpa.ServiceList;
+import org.onap.policy.rest.jpa.TermList;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.onap.policy.rest.jpa.Zone;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class FirewallDictionaryControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(FirewallDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private FirewallDictionaryController controller = null;
+ private MockHttpServletResponse response = null;
+ private UserInfo userInfo;
+ private List<String> data;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+
+ data = new ArrayList<>();
+ data.add("Test");
+
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+
+ doNothing().when(commonClassDao).delete(new Term());
+ doNothing().when(commonClassDao).save(new Term());
+
+ controller = new FirewallDictionaryController();
+ FirewallDictionaryController.setCommonClassDao(commonClassDao);
+
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetPrefixListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")).thenReturn(data);
+ controller.getPrefixListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPrefixListDictionaryEntityData(){
+ when(commonClassDao.getData(PrefixList.class)).thenReturn(new ArrayList<>());
+ controller.getPrefixListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPortListDictionaryEntityData(){
+ when(commonClassDao.getData(PortList.class)).thenReturn(new ArrayList<>());
+ controller.getPortListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetProtocolListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")).thenReturn(data);
+ controller.getProtocolListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetProtocolListDictionaryEntityData(){
+ when(commonClassDao.getData(ProtocolList.class)).thenReturn(new ArrayList<>());
+ controller.getProtocolListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetAddressGroupDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(AddressGroup.class, "name")).thenReturn(data);
+ controller.getAddressGroupDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetAddressGroupDictionaryEntityData(){
+ when(commonClassDao.getData(AddressGroup.class)).thenReturn(new ArrayList<>());
+ controller.getAddressGroupDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetActionListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(ActionList.class, "actionName")).thenReturn(data);
+ controller.getActionListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetActionListDictionaryEntityData(){
+ when(commonClassDao.getData(ActionList.class)).thenReturn(new ArrayList<>());
+ controller.getActionListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetServiceGroupDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(GroupServiceList.class, "name")).thenReturn(data);
+ controller.getServiceGroupDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetServiceGroupDictionaryEntityData(){
+ when(commonClassDao.getData(GroupServiceList.class)).thenReturn(new ArrayList<>());
+ controller.getServiceGroupDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetSecurityZoneDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")).thenReturn(data);
+ controller.getSecurityZoneDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetSecurityZoneDictionaryEntityData(){
+ when(commonClassDao.getData(SecurityZone.class)).thenReturn(new ArrayList<>());
+ controller.getSecurityZoneDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetServiceListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")).thenReturn(data);
+ controller.getServiceListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetServiceListDictionaryEntityData(){
+ when(commonClassDao.getData(ServiceList.class)).thenReturn(new ArrayList<>());
+ controller.getServiceListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetZoneDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(Zone.class, "zoneName")).thenReturn(data);
+ controller.getZoneDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetZoneDictionaryEntityData(){
+ when(commonClassDao.getData(Zone.class)).thenReturn(new ArrayList<>());
+ controller.getZoneDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTermListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(TermList.class, "termName")).thenReturn(data);
+ controller.getTermListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTermListDictionaryEntityData(){
+ when(commonClassDao.getData(TermList.class)).thenReturn(new ArrayList<>());
+ controller.getTermListDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetFWDictListDictionaryEntityDataByName(){
+ when(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")).thenReturn(data);
+ controller.getFWDictListDictionaryEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetFWDictionaryListEntityData(){
+ when(commonClassDao.getData(FirewallDictionaryList.class)).thenReturn(new ArrayList<>());
+ controller.getFWDictionaryListEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTagPickerNameEntityDataByName(){
+ when(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")).thenReturn(data);
+ controller.getTagPickerNameEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTagPickerDictionaryEntityData(){
+ when(commonClassDao.getData(FWTagPicker.class)).thenReturn(new ArrayList<>());
+ controller.getTagPickerDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTagNameEntityDataByName(){
+ when(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")).thenReturn(data);
+ controller.getTagNameEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetTagDictionaryEntityData(){
+ when(commonClassDao.getData(FWTag.class)).thenReturn(new ArrayList<>());
+ controller.getTagDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSavePrefixListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"description\":\"test\",\"prefixListName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePrefixListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePrefixListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePrefixListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePrefixListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePrefixListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("prefixListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testValidatePrefixListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"prefixListDictionaryData\":{\"id\":1,\"description\":\"test\",\"prefixListName\":\"Test\",\"prefixListValue\":\"10.10.10\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.validatePrefixListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("result"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePortListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"portListDictionaryData\":{\"description\":\"test\",\"portName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePortListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePortListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"portListDictionaryData\":{\"id\":1,\"description\":\"test\",\"portName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePortListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePortListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"portName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePortListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("portListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveProtocolListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"protocolListDictionaryData\":{\"description\":\"test\",\"protocolName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveProtocolListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateProtocolListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"protocolListDictionaryData\":{\"id\":1,\"description\":\"test\",\"protocolName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveProtocolListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveProtocolListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"protocolName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeProtocolListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("protocolListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveAddressGroupDictionary(){
+ jsonString = "{\"addressGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:409\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"groupName\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveAddressGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateAddressGroupDictionary(){
+ jsonString = "{\"addressGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:409\",\"id\":\"choice1\",\"option\":\"Test\"}],\"description\":\"test\",\"groupName\":\"Test\"},\"userid\":\"demo\",\"id\":1}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveAddressGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveAddressGroupDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeAddressGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("addressGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveActionListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"actionListDictionaryData\":{\"description\":\"test\",\"actionName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveActionListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateActionListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"actionListDictionaryData\":{\"id\":1,\"description\":\"test\",\"actionName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveActionListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveActionListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"actionName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeActionListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveServiceGroupDictionary(){
+ jsonString = "{\"serviceGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:657\",\"id\":\"choice1\",\"option\":\"Test\"}],\"groupName\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateServiceGroupDictionary(){
+ jsonString = "{\"serviceGroupDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:657\",\"id\":\"choice1\",\"option\":\"Test\"}],\"groupName\":\"Test\"},\"userid\":\"demo\",\"id\":1}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveServiceGroupDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeServiceGroupDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceGroupDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveSecurityZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"securityZoneDictionaryData\":{\"description\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSecurityZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateSecurityZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"securityZoneDictionaryData\":{\"id\":1,\"description\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSecurityZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveSecurityZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeSecurityZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("securityZoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveServiceListDictionary(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateServiceListDictionary(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveServiceListDictionary(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeServiceListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("serviceListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"zoneDictionaryData\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"zoneDictionaryData\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveZoneDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"zoneValue\":\"test\",\"zoneName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeZoneDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("zoneDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveTermListDictionary(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveTermListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateTermListDictionary(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveTermListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveTermListDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"termDescription\":\"test\",\"termName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeTermListDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("termListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveFWDictionaryList(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFWDictionaryList(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateFWDictionaryList(){
+ 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\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFWDictionaryList(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveFWDictionaryList(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"parentItemName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeFWDictionaryList(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwDictListDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveFirewallTagPickerDictionary(){
+ jsonString = "{\"fwTagPickerDictionaryData\":{\"description\":\"test\",\"networkRole\":\"test\",\"tagPickerName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1855\",\"id\":\"choice1\",\"number\":\"test\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFirewallTagPickerDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateFirewallTagPickerDictionary(){
+ jsonString = "{\"fwTagPickerDictionaryData\":{\"id\":1,\"description\":\"test\",\"networkRole\":\"test\",\"tagPickerName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1855\",\"id\":\"choice1\",\"number\":\"test\",\"option\":\"Test\"}]},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFirewallTagPickerDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveFirewallTagPickerDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"tagPickerName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeFirewallTagPickerDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagPickerDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveFirewallTagDictionary(){
+ jsonString = "{\"fwTagDictionaryData\":{\"description\":\"test\",\"fwTagName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1690\",\"id\":\"choice1\",\"tags\":\"test\"}]},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFirewallTagDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateFirewallTagDictionary(){
+ jsonString = "{\"fwTagDictionaryData\":{\"id\":1,\"description\":\"test\",\"fwTagName\":\"Test\",\"tags\":[{\"$$hashKey\":\"object:1690\",\"id\":\"choice1\",\"tags\":\"test\"}]},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveFirewallTagDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveFirewallTagDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"fwTagName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeFirewallTagDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("fwTagDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryControllerTest.java
new file mode 100644
index 000000000..fcc54013f
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryControllerTest.java
@@ -0,0 +1,380 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.GroupPolicyScopeList;
+import org.onap.policy.rest.jpa.PolicyScopeClosedLoop;
+import org.onap.policy.rest.jpa.PolicyScopeResource;
+import org.onap.policy.rest.jpa.PolicyScopeService;
+import org.onap.policy.rest.jpa.PolicyScopeType;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class PolicyScopeDictionaryControllerTest {
+ private static Logger logger = FlexLogger.getLogger(PolicyScopeDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private PolicyScopeDictionaryController controller = null;
+ private MockHttpServletResponse response = null;
+ private UserInfo userInfo;
+ private List<String> data;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+
+ data = new ArrayList<>();
+ data.add("Test");
+
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+
+ doNothing().when(commonClassDao).delete(new GroupPolicyScopeList());
+ doNothing().when(commonClassDao).save(new GroupPolicyScopeList());
+
+ controller = new PolicyScopeDictionaryController();
+ controller.setCommonClassDao(commonClassDao);
+
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetGroupPolicyScopeEntityDataByName(){
+ when(commonClassDao.getDataByColumn(GroupPolicyScopeList.class, "name")).thenReturn(data);
+ controller.getGroupPolicyScopeEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("groupPolicyScopeListDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetGroupPolicyScopeEntityData(){
+ when(commonClassDao.getData(GroupPolicyScopeList.class)).thenReturn(new ArrayList<>());
+ controller.getGroupPolicyScopeEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("groupPolicyScopeListDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSClosedLoopEntityDataByName(){
+ when(commonClassDao.getDataByColumn(PolicyScopeClosedLoop.class, "name")).thenReturn(data);
+ controller.getPSClosedLoopEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psClosedLoopDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSClosedLoopEntityData(){
+ when(commonClassDao.getData(PolicyScopeClosedLoop.class)).thenReturn(new ArrayList<>());
+ controller.getPSClosedLoopEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psClosedLoopDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSServiceEntityDataByName(){
+ when(commonClassDao.getDataByColumn(PolicyScopeService.class, "name")).thenReturn(data);
+ controller.getPSServiceEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psServiceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSServiceEntityData(){
+ when(commonClassDao.getData(PolicyScopeService.class)).thenReturn(new ArrayList<>());
+ controller.getPSServiceEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psServiceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSTypeEntityDataByName(){
+ when(commonClassDao.getDataByColumn(PolicyScopeType.class, "name")).thenReturn(data);
+ controller.getPSTypeEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSTypeEntityData(){
+ when(commonClassDao.getData(PolicyScopeType.class)).thenReturn(new ArrayList<>());
+ controller.getPSTypeEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSResourceEntityDataByName(){
+ when(commonClassDao.getDataByColumn(PolicyScopeResource.class, "name")).thenReturn(data);
+ controller.getPSResourceEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psResourceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPSResourceEntityData(){
+ when(commonClassDao.getData(PolicyScopeResource.class)).thenReturn(new ArrayList<>());
+ controller.getPSResourceEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("psResourceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSavePSGroupScopeDictionary(){
+ jsonString = "{\"groupPolicyScopeListData\":{\"description\":\"test\",\"groupName\":\"Test\"},\"groupPolicyScopeListData1\":{\"closedloop\":\"SampleClosedLoop\",\"resource\":\"SampleResource\",\"service\":\"SampleService\",\"type\":\"SampleType\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSGroupScopeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("groupPolicyScopeListDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePSGroupScopeDictionary(){
+ jsonString = "{\"groupPolicyScopeListData\":{\"id\":1,\"description\":\"test\",\"groupName\":\"Test\"},\"groupPolicyScopeListData1\":{\"closedloop\":\"SampleClosedLoop\",\"resource\":\"SampleResource\",\"service\":\"SampleService\",\"type\":\"SampleType\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSGroupScopeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("groupPolicyScopeListDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePSGroupScopeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePSGroupScopeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("groupPolicyScopeListDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePSClosedLoopDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psClosedLoopDictionaryData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSClosedLoopDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psClosedLoopDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePSClosedLoopDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psClosedLoopDictionaryData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSClosedLoopDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psClosedLoopDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePSClosedLoopDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePSClosedLoopDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psClosedLoopDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePSServiceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psServiceDictionaryData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSServiceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psServiceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePSServiceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psServiceDictionaryData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSServiceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psServiceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePSServiceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePSServiceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psServiceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePSTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psTypeDictionaryData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePSTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psTypeDictionaryData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePSTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePSTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePSResourceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psResourceDictionaryData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSResourceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psResourceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePSResourceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"psResourceDictionaryData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePSResourceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psResourceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePSResourceDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePSResourceDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("psResourceDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyControllerTest.java
new file mode 100644
index 000000000..1f8cb6f90
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyControllerTest.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.PolicyVersion;
+import org.springframework.mock.web.MockServletConfig;
+
+import com.att.research.xacml.api.pap.PAPException;
+
+
+public class PushPolicyControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(PushPolicyControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private PushPolicyController controller = null;
+ private HttpServletResponse response = null;
+ private List<String> headers = new ArrayList<>();
+ private ServletConfig servletConfig;
+ private XACMLPapServlet pap;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ request = Mockito.mock(HttpServletRequest.class);
+ response = Mockito.mock(HttpServletResponse.class);
+ Mockito.when(request.getHeaderNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(request.getAttributeNames()).thenReturn(Collections.enumeration(headers));
+
+ servletConfig = Mockito.mock(MockServletConfig.class);
+ System.setProperty("com.sun.management.jmxremote.port", "9993");
+ Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("src/test/resources/xacml.pap.properties");
+
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+ controller = new PushPolicyController();
+ controller.setCommonClassDao(commonClassDao);
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testPushPolicy() throws ServletException, PAPException{
+ PolicyVersion versionData = new PolicyVersion();
+ versionData.setPolicyName("com"+File.separator+"Config_Test");
+ versionData.setActiveVersion(1);
+ versionData.setHigherVersion(1);
+ List<Object> data = new ArrayList<>();
+ data.add(versionData);
+ when(commonClassDao.getDataById(PolicyVersion.class, "policyName", "com"+File.separator+"Config_Test")).thenReturn(data);
+ pap = new XACMLPapServlet();
+ pap.init(servletConfig);
+ callPushPolicy();
+ when(commonClassDao.getDataById(PolicyVersion.class, "policyName", "com"+File.separator+"Config_Test")).thenReturn(null);
+ callPushPolicy();
+ }
+
+ public void callPushPolicy(){
+ jsonString = "{\"policyScope\":\"com\",\"filePrefix\":\"Config_\",\"policyName\":\"Test\",\"pdpGroup\":\"default\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ char[] charBuffer = new char[8 * 1024];
+ StringBuilder builder = new StringBuilder();
+ int numCharsRead;
+ while ((numCharsRead = br.read(charBuffer, 0, charBuffer.length)) != -1) {
+ builder.append(charBuffer, 0, numCharsRead);
+ }
+ when(request.getInputStream()).thenReturn(getInputStream(builder.toString().getBytes(StandardCharsets.UTF_8)));
+ controller.pushPolicy(request, response);
+ assertTrue(response != null);
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ public ServletInputStream getInputStream(byte[] body) throws IOException {
+ final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body);
+ ServletInputStream servletInputStream = new ServletInputStream() {
+ public int read() throws IOException {
+ return byteArrayInputStream.read();
+ }
+
+ @Override
+ public boolean isFinished() {
+ return false;
+ }
+
+ @Override
+ public boolean isReady() {
+ return false;
+ }
+
+ @Override
+ public void setReadListener(ReadListener readListener) {
+ }
+ };
+ return servletInputStream;
+ }
+
+ @After
+ public void destroy(){
+ if(pap!=null)
+ pap.destroy();
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java
new file mode 100644
index 000000000..48af2442c
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java
@@ -0,0 +1,198 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.RiskType;
+import org.onap.policy.rest.jpa.SafePolicyWarning;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class SafePolicyControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(SafePolicyControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private SafePolicyController controller = null;
+ private MockHttpServletResponse response = null;
+ private UserInfo userInfo;
+ private List<String> data;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+
+ data = new ArrayList<>();
+ data.add("Test");
+
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+
+ doNothing().when(commonClassDao).delete(new RiskType());
+ doNothing().when(commonClassDao).save(new RiskType());
+
+ controller = new SafePolicyController();
+ controller.setCommonClassDao(commonClassDao);
+
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetRiskTypeDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(RiskType.class, "name")).thenReturn(data);
+ controller.getRiskTypeDictionaryByNameEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("riskTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetRiskTypeDictionaryEntityData(){
+ when(commonClassDao.getData(RiskType.class)).thenReturn(new ArrayList<>());
+ controller.getRiskTypeDictionaryEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("riskTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetSafePolicyWarningEntityDataByName(){
+ when(commonClassDao.getDataByColumn(SafePolicyWarning.class, "name")).thenReturn(data);
+ controller.getSafePolicyWarningEntityDataByName(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("safePolicyWarningDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetSafePolicyWarningeEntityData(){
+ when(commonClassDao.getData(SafePolicyWarning.class)).thenReturn(new ArrayList<>());
+ controller.getSafePolicyWarningeEntityData(response);
+ try {
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("safePolicyWarningDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSaveRiskTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"riskTypeDictionaryData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveRiskTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("riskTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateRiskTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"riskTypeDictionaryData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveRiskTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("riskTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveRiskTypeDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeRiskTypeDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("riskTypeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveSafePolicyWarningDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"safePolicyWarningData\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSafePolicyWarningDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("safePolicyWarningDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateSafePolicyWarningDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"safePolicyWarningData\":{\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSafePolicyWarningDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("safePolicyWarningDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveSafePolicyWarningDictionary(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"name\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeSafePolicyWarningDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("safePolicyWarningDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+}