aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/dependency.json2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/adapters/GridData.java28
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java28
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java6
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java41
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java143
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java315
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java5
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java6
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java67
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java10
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java20
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryControllerTest.java157
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java442
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryControllerTest.java163
-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
-rw-r--r--ONAP-PDP/pom.xml2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java64
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java11
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/EnforcingType.java96
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyManagement.java162
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyClasses.java160
-rw-r--r--ONAP-XACML/pom.xml2
28 files changed, 2756 insertions, 778 deletions
diff --git a/BRMSGateway/dependency.json b/BRMSGateway/dependency.json
index fcdcebdea..a8b331712 100644
--- a/BRMSGateway/dependency.json
+++ b/BRMSGateway/dependency.json
@@ -96,7 +96,7 @@
}, {
"groupId": "com.att.research.xacml",
"artifactId": "xacml-pdp",
- "version": "1.0.0"
+ "version": "1.0.1"
}]
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/adapters/GridData.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/adapters/GridData.java
index 1ed4bf3b5..7e05efc63 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/adapters/GridData.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/adapters/GridData.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,43 +20,43 @@
package org.onap.policy.pap.xacml.rest.adapters;
-import java.util.ArrayList;
+import java.util.List;
public class GridData {
- private ArrayList<Object> attributes;
- private ArrayList<Object> alAttributes;
- private ArrayList<Object> transportProtocols;
- private ArrayList<Object> appProtocols;
+ private List<Object> attributes;
+ private List<Object> alAttributes;
+ private List<Object> transportProtocols;
+ private List<Object> appProtocols;
- public ArrayList<Object> getAttributes() {
+ public List<Object> getAttributes() {
return attributes;
}
- public void setAttributes(ArrayList<Object> attributes) {
+ public void setAttributes(List<Object> attributes) {
this.attributes = attributes;
}
- public ArrayList<Object> getAlAttributes() {
+ public List<Object> getAlAttributes() {
return alAttributes;
}
- public void setAlAttributes(ArrayList<Object> alAttributes) {
+ public void setAlAttributes(List<Object> alAttributes) {
this.alAttributes = alAttributes;
}
- public ArrayList<Object> getAppProtocols() {
+ public List<Object> getAppProtocols() {
return appProtocols;
}
- public void setAppProtocols(ArrayList<Object> appProtocols) {
+ public void setAppProtocols(List<Object> appProtocols) {
this.appProtocols = appProtocols;
}
- public ArrayList<Object> getTransportProtocols() {
+ public List<Object> getTransportProtocols() {
return transportProtocols;
}
- public void setTransportProtocols(ArrayList<Object> transportProtocols) {
+ public void setTransportProtocols(List<Object> transportProtocols) {
this.transportProtocols = transportProtocols;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
index 5c9b2b883..02b0707b6 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -61,6 +61,10 @@ public class ActionPolicyDictionaryController {
public ActionPolicyDictionaryController(CommonClassDao commonClassDao){
ActionPolicyDictionaryController.commonClassDao = commonClassDao;
}
+
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ ActionPolicyDictionaryController.commonClassDao = commonClassDao;
+ }
/*
* This is an empty constructor
*/
@@ -124,8 +128,8 @@ public class ActionPolicyDictionaryController {
String userId = null;
if(fromAPI) {
- actionPolicyDict = (ActionPolicyDict)mapper.readValue(root.get("dictionaryFields").toString(), ActionPolicyDict.class);
- adapter = (ActionAdapter)mapper.readValue(root.get("dictionaryFields").toString(), ActionAdapter.class);
+ actionPolicyDict = mapper.readValue(root.get("dictionaryFields").toString(), ActionPolicyDict.class);
+ adapter = mapper.readValue(root.get("dictionaryFields").toString(), ActionAdapter.class);
userId = "API";
//check if update operation or create, get id for data to be updated and update attributeData
@@ -142,11 +146,11 @@ public class ActionPolicyDictionaryController {
actionPolicyDict.setUserCreatedBy(this.getUserInfo(userId));
}
} else {
- actionPolicyDict = (ActionPolicyDict)mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionPolicyDict.class);
+ actionPolicyDict = mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionPolicyDict.class);
adapter = mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionAdapter.class);
userId = root.get("userid").textValue();
}
- String header = "";
+ StringBuilder header = new StringBuilder();
int counter = 0;
if(!adapter.getHeaders().isEmpty()){
for(Object attribute : adapter.getHeaders()){
@@ -154,15 +158,14 @@ public class ActionPolicyDictionaryController {
String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
if(counter>0){
- header = header + ":";
+ header.append(":");
}
- header = header + key + "=";
- header = header + value;
+ header.append(key).append("=").append(value);
counter ++;
}
}
}
- actionPolicyDict.setHeader(header);
+ actionPolicyDict.setHeader(header.toString());
if(actionPolicyDict.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionPolicyDict.getAttributeName(), attributeName, ActionPolicyDict.class);
if(!duplicateData.isEmpty()){
@@ -222,12 +225,12 @@ public class ActionPolicyDictionaryController {
}
@RequestMapping(value={"/action_dictionary/remove_actionPolicyDict"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public void removeActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- ActionPolicyDict actionPolicyDict = (ActionPolicyDict)mapper.readValue(root.get("data").toString(), ActionPolicyDict.class);
+ ActionPolicyDict actionPolicyDict = mapper.readValue(root.get("data").toString(), ActionPolicyDict.class);
commonClassDao.delete(actionPolicyDict);
response.setCharacterEncoding(utf8);
response.setContentType("application / json");
@@ -238,8 +241,6 @@ public class ActionPolicyDictionaryController {
String responseString = mapper.writeValueAsString(ActionPolicyDictionaryController.commonClassDao.getData(ActionPolicyDict.class));
JSONObject j = new JSONObject("{actionPolicyDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(e);
@@ -248,7 +249,6 @@ public class ActionPolicyDictionaryController {
PrintWriter out = response.getWriter();
out.write(e.getMessage());
}
- return null;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
index f359ca2cb..a55ed4004 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -88,6 +88,10 @@ public class ClosedLoopDictionaryController{
public ClosedLoopDictionaryController(CommonClassDao commonClassDao){
ClosedLoopDictionaryController.commonClassDao = commonClassDao;
}
+
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ ClosedLoopDictionaryController.commonClassDao = commonClassDao;
+ }
/*
* This is an empty constructor
*/
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
index a12f17b50..b38351806 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -64,15 +64,20 @@ public class DescriptiveDictionaryController {
DescriptiveDictionaryController.commonClassDao = commonClassDao;
}
- public DescriptiveDictionaryController(){}
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ DescriptiveDictionaryController.commonClassDao = commonClassDao;
+ }
+
+ public DescriptiveDictionaryController(){
+ //Empty Constructor
+ }
public UserInfo getUserInfo(String loginId){
- UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
- return name;
+ return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
}
@RequestMapping(value={"/get_DescriptiveScopeByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getDescriptiveDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+ public void getDescriptiveDictionaryByNameEntityData(HttpServletResponse response){
try{
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
@@ -121,8 +126,8 @@ public class DescriptiveDictionaryController {
GridData data;
String userId = null;
if (fromAPI) {
- descriptiveScope = (DescriptiveScope)mapper.readValue(root.get("dictionaryFields").toString(), DescriptiveScope.class);
- data = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
+ descriptiveScope = mapper.readValue(root.get("dictionaryFields").toString(), DescriptiveScope.class);
+ data = mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
userId = "API";
//check if update operation or create, get id for data to be updated and update attributeData
@@ -140,27 +145,26 @@ public class DescriptiveDictionaryController {
descriptiveScope.setUserCreatedBy(this.getUserInfo(userId));
}
} else {
- descriptiveScope = (DescriptiveScope)mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), DescriptiveScope.class);
- data = (GridData)mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), GridData.class);
+ descriptiveScope = mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), DescriptiveScope.class);
+ data = mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), GridData.class);
userId = root.get("userid").textValue();
}
- String header = "";
+ StringBuilder header = new StringBuilder();
int counter = 0;
- if(data.getAttributes().size() > 0){
+ if(!data.getAttributes().isEmpty()){
for(Object attribute : data.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
if(counter>0){
- header = header + "AND";
+ header.append("AND");
}
- header = header + key + ":";
- header = header + value;
+ header.append(key).append(":").append(value);
counter ++;
}
}
}
- descriptiveScope.setSearch(header);
+ descriptiveScope.setSearch(header.toString());
if(descriptiveScope.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(descriptiveScope.getScopeName(), "descriptiveScopeName", DescriptiveScope.class);
if(!duplicateData.isEmpty()){
@@ -217,12 +221,12 @@ public class DescriptiveDictionaryController {
}
@RequestMapping(value={"/descriptive_dictionary/remove_descriptiveScope"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void removeDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- DescriptiveScope descriptiveScope = (DescriptiveScope)mapper.readValue(root.get("data").toString(), DescriptiveScope.class);
+ DescriptiveScope descriptiveScope = mapper.readValue(root.get("data").toString(), DescriptiveScope.class);
commonClassDao.delete(descriptiveScope);
response.setCharacterEncoding("UTF-8");
response.setContentType("application / json");
@@ -233,8 +237,6 @@ public class DescriptiveDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(DescriptiveScope.class));
JSONObject j = new JSONObject("{descriptiveScopeDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -243,7 +245,6 @@ public class DescriptiveDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
index 0b487010c..a56689547 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -296,7 +296,7 @@ public class DictionaryImportController {
if(dictionaryName.startsWith("ClosedLoopService")){
dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
- ClosedLoopD2Services attribute = new ClosedLoopD2Services("", userId);
+ ClosedLoopD2Services attribute = new ClosedLoopD2Services();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java
deleted file mode 100644
index 9e248bf62..000000000
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-PAP-REST
- * ================================================================================
- * Copyright (C) 2017 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 java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.json.JSONObject;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.pap.xacml.rest.util.JsonMessage;
-import org.onap.policy.rest.dao.CommonClassDao;
-import org.onap.policy.rest.jpa.EnforcingType;
-import org.onap.policy.utils.PolicyUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Controller
-public class EnforcerDictionaryController {
-
- private static final Logger LOGGER = FlexLogger.getLogger(EnforcerDictionaryController.class);
-
- @Autowired
- CommonClassDao commonClassDao;
-
- @RequestMapping(value={"/get_EnforcerTypeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getEnforcerDictionaryEntityData(HttpServletResponse response){
- try{
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- List<Object> list = commonClassDao.getData(EnforcingType.class);
- List<String> dictList = new ArrayList<>();
- for(int i = 0; i < list.size(); i++){
- EnforcingType dict = (EnforcingType) list.get(i);
- dictList.add(dict.getEnforcingType());
- }
- model.put("enforcerDictionaryDatas", mapper.writeValueAsString(dictList));
- org.onap.policy.pap.xacml.rest.util.JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.getWriter().write(j.toString());
- }
- catch (Exception e){
- LOGGER.error("Exception Occured"+e);
- }
- }
-
- @RequestMapping(value={"/enforcer_dictionary/save_enforcerType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- EnforcingType enforcingType = (EnforcingType)mapper.readValue(root.get("enforcerDictionaryData").toString(), EnforcingType.class);
- if(enforcingType.getId() == 0){
- commonClassDao.save(enforcingType);
- }else{
- commonClassDao.update(enforcingType);
- }
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
- String responseString = mapper.writeValueAsString(commonClassDao.getData(EnforcingType.class));
- JSONObject j = new JSONObject("{enforcerDictionaryDatas: " + responseString + "}");
-
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
- LOGGER.error(e);
- }
- return null;
- }
-
- @RequestMapping(value={"/enforcer_dictionary/remove_enforcer"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- EnforcingType enforcingType = (EnforcingType)mapper.readValue(root.get("data").toString(), EnforcingType.class);
- commonClassDao.delete(enforcingType);
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
-
- String responseString = mapper.writeValueAsString(commonClassDao.getData(EnforcingType.class));
- JSONObject j = new JSONObject("{enforcerDictionaryDatas: " + responseString + "}");
- out.write(j.toString());
-
- return null;
- }
- catch (Exception e){
- System.out.println(e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
- }
- return null;
- }
-}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
index 6b60c586a..0466debb8 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -23,7 +23,6 @@ package org.onap.policy.pap.xacml.rest.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.UnknownHostException;
-import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -46,8 +45,8 @@ 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.PrefixList;
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;
@@ -96,7 +95,6 @@ public class FirewallDictionaryController {
private static String termName = "termName";
private static String userid = "userid";
private static String tagPickerName = "tagPickerName";
- private static String fwTagPickerDictionaryData = "fwTagPickerDictionaryData";
private static String fwTagDictionaryDatas = "fwTagDictionaryDatas";
@@ -109,10 +107,11 @@ public class FirewallDictionaryController {
commonClassDao = clDao;
}
- /*
- * This is an empty constructor
- */
- public FirewallDictionaryController(){}
+ public FirewallDictionaryController(){
+ /*
+ * This is an empty constructor
+ */
+ }
public UserInfo getUserInfo(String loginId){
return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
@@ -167,10 +166,10 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PrefixList prefixList;
if (fromAPI) {
- prefixList = (PrefixList)mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
+ prefixList = mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
//check if update operation or create, get id for data to be updated and update attributeData
- if ((update).equals(request.getParameter(operation))) {
+ if (update.equals(request.getParameter(operation))) {
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
PrefixList data = (PrefixList) duplicateData.get(0);
int id = data.getId();
@@ -182,7 +181,7 @@ public class FirewallDictionaryController {
}
}
} else {
- prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
+ prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
}
if(prefixList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
@@ -235,12 +234,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
+ PrefixList prefixList = mapper.readValue(root.get("data").toString(), PrefixList.class);
commonClassDao.delete(prefixList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -250,7 +249,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -259,16 +257,15 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
+ PrefixList prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
String responseValidation = successMessage;
try{
CIDR.newCIDR(prefixList.getPrefixListValue());
@@ -283,7 +280,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
JSONObject j = new JSONObject("{result: " + responseValidation + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -292,7 +288,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -321,7 +316,7 @@ public class FirewallDictionaryController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
+ PortList portList = mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
if(portList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
if(!duplicateData.isEmpty()){
@@ -360,12 +355,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
+ PortList portList = mapper.readValue(root.get("data").toString(), PortList.class);
commonClassDao.delete(portList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -375,7 +370,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -384,7 +378,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -435,7 +428,7 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
ProtocolList protocolList;
if (fromAPI) {
- protocolList = (ProtocolList)mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
+ protocolList = mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
//check if update operation or create, get id for data to be updated and update attributeData
if ((update).equals(request.getParameter(operation))) {
@@ -450,7 +443,7 @@ public class FirewallDictionaryController {
}
}
} else {
- protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
+ protocolList = mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
}
if(protocolList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
@@ -503,12 +496,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
+ ProtocolList protocolList = mapper.readValue(root.get("data").toString(), ProtocolList.class);
commonClassDao.delete(protocolList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -519,7 +512,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -528,7 +520,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -580,8 +571,8 @@ public class FirewallDictionaryController {
AddressGroup addressGroup;
GridData gridData;
if (fromAPI) {
- addressGroup = (AddressGroup)mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
- gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+ addressGroup = mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
+ gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
if(!addressGroup.getGroupName().startsWith(groupNameStart)){
String groupName = groupNameStart+addressGroup.getGroupName();
@@ -601,28 +592,28 @@ public class FirewallDictionaryController {
}
}
} else {
- addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
- gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
+ addressGroup = mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
+ gridData = mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
if(!addressGroup.getGroupName().startsWith(groupNameStart)){
String groupName = groupNameStart+addressGroup.getGroupName();
addressGroup.setGroupName(groupName);
}
}
- String userValue = "";
+ StringBuilder userValue = new StringBuilder();
int counter = 0;
if(!gridData.getAttributes().isEmpty()){
for(Object attribute : gridData.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(counter>0){
- userValue = userValue + ",";
+ userValue.append(",");
}
- userValue = userValue + key ;
+ userValue.append(key) ;
counter ++;
}
}
}
- addressGroup.setServiceList(userValue);
+ addressGroup.setServiceList(userValue.toString());
if(addressGroup.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
if(!duplicateData.isEmpty()){
@@ -673,12 +664,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
+ AddressGroup addressGroup = mapper.readValue(root.get("data").toString(), AddressGroup.class);
commonClassDao.delete(addressGroup);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -689,7 +680,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -698,7 +688,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -706,13 +695,8 @@ public class FirewallDictionaryController {
try{
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
- List<Object> list = commonClassDao.getData(ActionList.class);
- List<String> dictList = new ArrayList<>();
- for(int i = 0; i < list.size(); i++){
- ActionList dict = (ActionList) list.get(i);
- dictList.add(dict.getActionName());
- }
- model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
+ List<String> list = commonClassDao.getDataByColumn(ActionList.class, "actionName");
+ model.put("actionListDictionaryDatas", mapper.writeValueAsString(list));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -755,7 +739,7 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
ActionList actionList;
if (fromAPI) {
- actionList = (ActionList)mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
+ actionList = mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
//check if update operation or create, get id for data to be updated and update attributeData
if ((update).equals(request.getParameter(operation))) {
@@ -770,7 +754,7 @@ public class FirewallDictionaryController {
}
}
} else {
- actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
+ actionList = mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
}
if(actionList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
@@ -823,12 +807,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
+ ActionList actionList = mapper.readValue(root.get("data").toString(), ActionList.class);
commonClassDao.delete(actionList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -838,7 +822,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -847,7 +830,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -899,8 +881,8 @@ public class FirewallDictionaryController {
GroupServiceList groupServiceList;
GridData gridData;
if (fromAPI) {
- groupServiceList = (GroupServiceList)mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
- gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+ groupServiceList = mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
+ gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
String groupName = groupNameStart+groupServiceList.getGroupName();
@@ -920,28 +902,28 @@ public class FirewallDictionaryController {
}
}
} else {
- groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
- gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
+ groupServiceList = mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
+ gridData = mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
}
if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
String groupName = groupNameStart+groupServiceList.getGroupName();
groupServiceList.setGroupName(groupName);
}
- String userValue = "";
+ StringBuilder userValue = new StringBuilder();
int counter = 0;
if(!gridData.getAttributes().isEmpty()){
for(Object attribute : gridData.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(counter>0){
- userValue = userValue + ",";
+ userValue.append(",");
}
- userValue = userValue + key ;
+ userValue.append(key);
counter ++;
}
}
}
- groupServiceList.setServiceList(userValue);
+ groupServiceList.setServiceList(userValue.toString());
if(groupServiceList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
if(!duplicateData.isEmpty()){
@@ -993,12 +975,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
+ GroupServiceList groupServiceList = mapper.readValue(root.get("data").toString(), GroupServiceList.class);
commonClassDao.delete(groupServiceList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1009,8 +991,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(e);
@@ -1019,7 +999,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1070,7 +1049,7 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
SecurityZone securityZone;
if (fromAPI) {
- securityZone = (SecurityZone)mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
+ securityZone = mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
//check if update operation or create, get id for data to be updated and update attributeData
if ((update).equals(request.getParameter(operation))) {
@@ -1085,7 +1064,7 @@ public class FirewallDictionaryController {
}
}
} else {
- securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
+ securityZone = mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
}
if(securityZone.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
@@ -1139,12 +1118,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public void removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
+ SecurityZone securityZone = mapper.readValue(root.get("data").toString(), SecurityZone.class);
commonClassDao.delete(securityZone);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1155,8 +1134,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -1165,7 +1142,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@@ -1218,8 +1194,8 @@ public class FirewallDictionaryController {
ServiceList serviceList;
GridData serviceListGridData;
if (fromAPI) {
- serviceList = (ServiceList)mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
- serviceListGridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+ serviceList = mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
+ serviceListGridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
//check if update operation or create, get id for data to be updated and update attributeData
if ((update).equals(request.getParameter(operation))) {
@@ -1234,39 +1210,39 @@ public class FirewallDictionaryController {
}
}
}else{
- serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
- serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
+ serviceList = mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
+ serviceListGridData = mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
}
- String tcpValue = "";
+ StringBuilder tcpValue = new StringBuilder();
int counter = 0;
if(!serviceListGridData.getTransportProtocols().isEmpty()){
for(Object attribute : serviceListGridData.getTransportProtocols()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(counter>0){
- tcpValue = tcpValue + ",";
+ tcpValue.append(",");
}
- tcpValue = tcpValue + key ;
+ tcpValue.append(key);
counter ++;
}
}
}
- serviceList.setServiceTransProtocol(tcpValue);
- String appValue = "";
+ serviceList.setServiceTransProtocol(tcpValue.toString());
+ StringBuilder appValue = new StringBuilder();
int counter1 = 0;
if(!serviceListGridData.getAppProtocols().isEmpty()){
for(Object attribute : serviceListGridData.getAppProtocols()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(counter1>0){
- appValue = appValue + ",";
+ appValue.append(",");
}
- appValue = appValue + key ;
+ appValue.append(key);
counter1 ++;
}
}
}
- serviceList.setServiceAppProtocol(appValue);
+ serviceList.setServiceAppProtocol(appValue.toString());
serviceList.setServiceType("SERVICE");
if(serviceList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
@@ -1315,17 +1291,16 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
-
return null;
}
@RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public void removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
+ ServiceList serviceList = mapper.readValue(root.get("data").toString(), ServiceList.class);
commonClassDao.delete(serviceList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1336,8 +1311,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(e);
@@ -1346,7 +1319,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1395,7 +1367,7 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
Zone zone;
if (fromAPI) {
- zone = (Zone)mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
+ zone = mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
//check if update operation or create, get id for data to be updated and update attributeData
if ((update).equals(request.getParameter(operation))) {
@@ -1410,7 +1382,7 @@ public class FirewallDictionaryController {
}
}
} else {
- zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
+ zone = mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
}
if(zone.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
@@ -1463,12 +1435,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
+ Zone zone = mapper.readValue(root.get("data").toString(), Zone.class);
commonClassDao.delete(zone);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1479,8 +1451,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -1489,7 +1459,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1542,8 +1511,8 @@ public class FirewallDictionaryController {
TermListData termListDatas;
String userId = null;
if (fromAPI) {
- termList = (TermList)mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
- termListDatas = (TermListData)mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
+ termList = mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
+ termListDatas = mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
userId = "API";
//check if update operation or create, get id for data to be updated and update attributeData
@@ -1560,121 +1529,121 @@ public class FirewallDictionaryController {
termList.setUserCreatedBy(this.getUserInfo(userId));
}
} else {
- termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
- termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
+ termList = mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
+ termListDatas = mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
userId = root.get(userid).textValue();
}
- String fromZoneValue = "";
+ StringBuilder fromZoneValue = new StringBuilder();
int counter = 0;
if(!termListDatas.getFromZoneDatas().isEmpty()){
for(Object fromZone : termListDatas.getFromZoneDatas()){
if(fromZone instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) fromZone).get(option).toString();
if(counter>0){
- fromZoneValue = fromZoneValue + ",";
+ fromZoneValue.append(",");
}
- fromZoneValue = fromZoneValue + key ;
+ fromZoneValue.append(key);
counter ++;
}
}
}
- termList.setFromZones(fromZoneValue);
+ termList.setFromZones(fromZoneValue.toString());
- String toZoneValue = "";
+ StringBuilder toZoneValue = new StringBuilder();
int toZonecounter = 0;
if(!termListDatas.getToZoneDatas().isEmpty()){
for(Object toZone : termListDatas.getToZoneDatas()){
if(toZone instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) toZone).get(option).toString();
if(toZonecounter>0){
- toZoneValue = toZoneValue + ",";
+ toZoneValue.append(",");
}
- toZoneValue = toZoneValue + key ;
+ toZoneValue.append(key);
toZonecounter ++;
}
}
}
- termList.setToZones(toZoneValue);
+ termList.setToZones(toZoneValue.toString());
- String srcListValues = "";
+ StringBuilder srcListValues = new StringBuilder();
int srcListcounter = 0;
if(!termListDatas.getSourceListDatas().isEmpty()){
for(Object srcList : termListDatas.getSourceListDatas()){
if(srcList instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) srcList).get(option).toString();
if(srcListcounter>0){
- srcListValues = srcListValues + ",";
+ srcListValues.append(",");
}
- srcListValues = srcListValues + key ;
+ srcListValues.append(key);
srcListcounter ++;
}
}
}
- termList.setSrcIPList(srcListValues);
+ termList.setSrcIPList(srcListValues.toString());
- String desListValues = "";
+ StringBuilder desListValues = new StringBuilder();
int destListcounter = 0;
if(!termListDatas.getDestinationListDatas().isEmpty()){
for(Object desList : termListDatas.getDestinationListDatas()){
if(desList instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) desList).get(option).toString();
if(destListcounter>0){
- desListValues = desListValues + ",";
+ desListValues.append(",");
}
- desListValues = desListValues + key ;
+ desListValues.append(key);
destListcounter ++;
}
}
}
- termList.setDestIPList(desListValues);
+ termList.setDestIPList(desListValues.toString());
- String srcSerValue = "";
+ StringBuilder srcSerValue = new StringBuilder();
int srcSercounter = 0;
if(!termListDatas.getSourceServiceDatas().isEmpty()){
for(Object srcSrc : termListDatas.getSourceServiceDatas()){
if(srcSrc instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) srcSrc).get(option).toString();
if(srcSercounter>0){
- srcSerValue = srcSerValue + ",";
+ srcSerValue.append(",");
}
- srcSerValue = srcSerValue + key ;
+ srcSerValue.append(key);
srcSercounter ++;
}
}
}
- termList.setSrcPortList(srcSerValue);
+ termList.setSrcPortList(srcSerValue.toString());
- String desSrcValue = "";
+ StringBuilder desSrcValue = new StringBuilder();
int desSrccounter = 0;
if(!termListDatas.getDestinationServiceDatas().isEmpty()){
for(Object desSrc : termListDatas.getDestinationServiceDatas()){
if(desSrc instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) desSrc).get(option).toString();
if(desSrccounter>0){
- desSrcValue = desSrcValue + ",";
+ desSrcValue.append(",");
}
- desSrcValue = desSrcValue + key ;
+ desSrcValue.append(key);
desSrccounter ++;
}
}
}
- termList.setDestPortList(desSrcValue);
+ termList.setDestPortList(desSrcValue.toString());
- String actionValue = "";
+ StringBuilder actionValue = new StringBuilder();
int actioncounter = 0;
if(!termListDatas.getActionListDatas().isEmpty()){
for(Object actionList : termListDatas.getActionListDatas()){
if(actionList instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) actionList).get(option).toString();
if(actioncounter>0){
- actionValue = actionValue + ",";
+ actionValue.append(",");
}
- actionValue = actionValue + key ;
+ actionValue.append(key);
actioncounter ++;
}
}
}
- termList.setAction(actionValue);
+ termList.setAction(actionValue.toString());
if(termList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
@@ -1732,12 +1701,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
+ TermList termList = mapper.readValue(root.get("data").toString(), TermList.class);
commonClassDao.delete(termList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1748,8 +1717,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -1758,7 +1725,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
//ParentList Dictionary Data
@RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1802,38 +1768,38 @@ public class FirewallDictionaryController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
- GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
- String userSLValue = "";
+ FirewallDictionaryList fwDictList = mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
+ GridData gridData = mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
+ StringBuilder userSLValue = new StringBuilder();
int slcounter = 0;
if(!gridData.getAttributes().isEmpty()){
for(Object attribute : gridData.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(slcounter>0){
- userSLValue = userSLValue + ",";
+ userSLValue.append(",");
}
- userSLValue = userSLValue + key ;
+ userSLValue.append(key);
slcounter ++;
}
}
}
- fwDictList.setServiceList(userSLValue);
- String userALValue = "";
+ fwDictList.setServiceList(userSLValue.toString());
+ StringBuilder userALValue = new StringBuilder();
int alcounter = 0;
if(!gridData.getAlAttributes().isEmpty()){
for(Object attribute : gridData.getAlAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
if(alcounter>0){
- userALValue = userALValue + ",";
+ userALValue.append(",");
}
- userALValue = userALValue + key ;
+ userALValue.append(key);
alcounter ++;
}
}
}
- fwDictList.setAddressList(userALValue);
+ fwDictList.setAddressList(userALValue.toString());
if(fwDictList.getId() == 0){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
if(!duplicateData.isEmpty()){
@@ -1856,9 +1822,7 @@ public class FirewallDictionaryController {
responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
}
JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
-
out.write(j.toString());
-
return null;
}
catch (Exception e){
@@ -1872,12 +1836,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public void removeFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws IOException {
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
+ FirewallDictionaryList fwDictList = mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
commonClassDao.delete(fwDictList);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -1888,8 +1852,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -1898,7 +1860,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@@ -1938,9 +1899,8 @@ public class FirewallDictionaryController {
public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try {
boolean duplicateflag = false;
- boolean isFakeUpdate = false;
boolean fromAPI = false;
- if (request.getParameter("apiflag")!=null && ("api").equalsIgnoreCase (request.getParameter("apiflag"))) {
+ if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase (request.getParameter(apiflag))) {
fromAPI = true;
}
ObjectMapper mapper = new ObjectMapper();
@@ -1950,11 +1910,11 @@ public class FirewallDictionaryController {
String userId = "";
if (fromAPI) {
- fwTagPicker = (FWTagPicker)mapper.readValue(root.get("dictionaryFields").toString(), FWTagPicker.class);
+ fwTagPicker = mapper.readValue(root.get(dictionaryFields).toString(), FWTagPicker.class);
userId = "API";
//check if update operation or create, get id for data to be updated and update attributeData
- if (("update").equals(request.getParameter("operation"))) {
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
+ if ((update).equals(request.getParameter(operation))) {
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
int id = 0;
FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
id = dbdata.getId();
@@ -1963,9 +1923,9 @@ public class FirewallDictionaryController {
}
} else {
TagGridValues data;
- fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
- data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
- userId = root.get("userid").textValue();
+ fwTagPicker = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
+ data = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
+ userId = root.get(userid).textValue();
StringBuilder header = new StringBuilder();
int counter = 0;
@@ -1986,7 +1946,7 @@ public class FirewallDictionaryController {
}
if(fwTagPicker.getId() == 0){
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
if(!duplicateData.isEmpty()){
duplicateflag = true;
}else{
@@ -2035,12 +1995,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public void removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
+ FWTagPicker fwTagPicker = mapper.readValue(root.get("data").toString(), FWTagPicker.class);
commonClassDao.delete(fwTagPicker);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -2050,7 +2010,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
out.write(j.toString());
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -2059,7 +2018,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
@RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -2080,7 +2038,7 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getTagNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
+ public void getTagNameEntityDataByName(HttpServletResponse response){
try{
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
@@ -2110,10 +2068,10 @@ public class FirewallDictionaryController {
String userId="";
if (fromAPI) {
- fwTag = mapper.readValue(root.get("dictionaryFields").toString(), FWTag.class);
+ fwTag = mapper.readValue(root.get(dictionaryFields).toString(), FWTag.class);
userId = "API";
//check if update operation or create, get id for data to be updated and update attributeData
- if ("update".equals(request.getParameter("operation"))) {
+ if (update.equals(request.getParameter(operation))) {
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
int id = 0;
FWTag data = (FWTag) duplicateData.get(0);
@@ -2125,7 +2083,7 @@ public class FirewallDictionaryController {
TagGridValues tagGridValues;
fwTag = mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
tagGridValues = mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
- userId = root.get("userid").textValue();
+ userId = root.get(userid).textValue();
StringBuilder userValue = new StringBuilder();
int counter = 0;
@@ -2151,14 +2109,11 @@ public class FirewallDictionaryController {
}else{
fwTag.setUserCreatedBy(this.getUserInfo(userId));
fwTag.setUserModifiedBy(this.getUserInfo(userId));
-
commonClassDao.save(fwTag);
}
}else{
-
- fwTag.setUserModifiedBy(this.getUserInfo(userId));
- commonClassDao.update(fwTag);
-
+ fwTag.setUserModifiedBy(this.getUserInfo(userId));
+ commonClassDao.update(fwTag);
}
String responseString = "";
if(duplicateflag){
@@ -2175,7 +2130,6 @@ public class FirewallDictionaryController {
result.setViewName(responseString);
return result;
} else {
-
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
request.setCharacterEncoding(utf8);
@@ -2197,12 +2151,12 @@ public class FirewallDictionaryController {
}
@RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ public void removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
+ FWTag fwTag = mapper.readValue(root.get("data").toString(), FWTag.class);
commonClassDao.delete(fwTag);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -2213,8 +2167,6 @@ public class FirewallDictionaryController {
String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
@@ -2223,7 +2175,6 @@ public class FirewallDictionaryController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
index 4b2f299a5..f430536a2 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -85,6 +85,9 @@ public class PolicyScopeDictionaryController {
PolicyScopeDictionaryController.commonClassDao = commonClassDao;
}
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ PolicyScopeDictionaryController.commonClassDao = commonClassDao;
+ }
public UserInfo getUserInfo(String loginId){
return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
index a695ec389..9c25b3aee 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -66,6 +66,10 @@ public class PushPolicyController {
public PushPolicyController(CommonClassDao commonClassDao){
PushPolicyController.commonClassDao = commonClassDao;
}
+
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ PushPolicyController.commonClassDao = commonClassDao;
+ }
/*
* This is an empty constructor
*/
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
index 02d53c6b4..561dea864 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -66,14 +67,19 @@ public class SafePolicyController {
SafePolicyController.commonClassDao = commonClassDao;
}
- public SafePolicyController(){}
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ SafePolicyController.commonClassDao = commonClassDao;
+ }
+
+ public SafePolicyController(){
+ //Empty Constructor
+ }
public UserInfo getUserInfo(String loginId){
return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
}
- @RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ @RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getRiskTypeDictionaryByNameEntityData(HttpServletResponse response) {
try {
Map<String, Object> model = new HashMap<>();
@@ -87,9 +93,8 @@ public class SafePolicyController {
}
}
- @RequestMapping(value = { "/get_RiskTypeData" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
- public void getOnapNameDictionaryEntityData(HttpServletResponse response) {
+ @RequestMapping(value = { "/get_RiskTypeData" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getRiskTypeDictionaryEntityData(HttpServletResponse response) {
try {
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
@@ -106,10 +111,8 @@ public class SafePolicyController {
}
}
- @RequestMapping(value = { "/sp_dictionary/save_riskType" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.POST })
- public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ @RequestMapping(value = { "/sp_dictionary/save_riskType" }, method = {RequestMethod.POST })
+ public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
boolean duplicateflag = false;
boolean isFakeUpdate = false;
@@ -123,7 +126,7 @@ public class SafePolicyController {
RiskType riskTypeData;
String userId = null;
if (fromAPI) {
- riskTypeData = (RiskType) mapper.readValue(root.get("dictionaryFields").toString(),
+ riskTypeData = mapper.readValue(root.get("dictionaryFields").toString(),
RiskType.class);
userId = "API";
@@ -143,7 +146,7 @@ public class SafePolicyController {
riskTypeData.setUserCreatedBy(this.getUserInfo(userId));
}
} else {
- riskTypeData = (RiskType) mapper.readValue(root.get("riskTypeDictionaryData").toString(), RiskType.class);
+ riskTypeData = mapper.readValue(root.get("riskTypeDictionaryData").toString(), RiskType.class);
userId = root.get("userid").textValue();
}
@@ -201,15 +204,13 @@ public class SafePolicyController {
return null;
}
- @RequestMapping(value = { "/sp_dictionary/remove_riskType" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.POST })
- public ModelAndView removeOnapDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException{
+ @RequestMapping(value = { "/sp_dictionary/remove_riskType" }, method = {RequestMethod.POST })
+ public ModelAndView removeRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- RiskType onapData = (RiskType) mapper.readValue(root.get("data").toString(), RiskType.class);
+ RiskType onapData = mapper.readValue(root.get("data").toString(), RiskType.class);
commonClassDao.delete(onapData);
response.setCharacterEncoding(utf8);
response.setContentType(applicationJsonContentType);
@@ -232,8 +233,7 @@ public class SafePolicyController {
return null;
}
- @RequestMapping(value = { "/get_SafePolicyWarningDataByName" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ @RequestMapping(value = { "/get_SafePolicyWarningDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningEntityDataByName(HttpServletResponse response) {
try {
Map<String, Object> model = new HashMap<>();
@@ -248,8 +248,7 @@ public class SafePolicyController {
}
}
- @RequestMapping(value = { "/get_SafePolicyWarningData" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ @RequestMapping(value = { "/get_SafePolicyWarningData" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningeEntityData(HttpServletResponse response) {
try {
Map<String, Object> model = new HashMap<>();
@@ -268,10 +267,8 @@ public class SafePolicyController {
}
}
- @RequestMapping(value = { "/sp_dictionary/save_safePolicyWarning" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.POST })
- public ModelAndView saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ @RequestMapping(value = { "/sp_dictionary/save_safePolicyWarning" }, method = {RequestMethod.POST })
+ public ModelAndView saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
boolean duplicateflag = false;
boolean isFakeUpdate = false;
@@ -284,8 +281,7 @@ public class SafePolicyController {
JsonNode root = mapper.readTree(request.getReader());
SafePolicyWarning safePolicyWarning;
if (fromAPI) {
- safePolicyWarning = (SafePolicyWarning) mapper
- .readValue(root.get("dictionaryFields").toString(), SafePolicyWarning.class);
+ safePolicyWarning = mapper.readValue(root.get("dictionaryFields").toString(), SafePolicyWarning.class);
//check if update operation or create, get id for data to be updated and update attributeData
if (("update").equals(request.getParameter(operation))) {
@@ -301,7 +297,7 @@ public class SafePolicyController {
}
}
} else {
- safePolicyWarning = (SafePolicyWarning) mapper.readValue(root.get("safePolicyWarningData").toString(), SafePolicyWarning.class);
+ safePolicyWarning = mapper.readValue(root.get("safePolicyWarningData").toString(), SafePolicyWarning.class);
}
if (safePolicyWarning.getId() == 0) {
@@ -355,15 +351,13 @@ public class SafePolicyController {
return null;
}
- @RequestMapping(value = { "/sp_dictionary/remove_SafePolicyWarning" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.POST })
- public ModelAndView removeSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ @RequestMapping(value = { "/sp_dictionary/remove_SafePolicyWarning" }, method = {RequestMethod.POST })
+ public void removeSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- SafePolicyWarning safePolicyWarningData = (SafePolicyWarning) mapper.readValue(root.get("data").toString(),
+ SafePolicyWarning safePolicyWarningData = mapper.readValue(root.get("data").toString(),
SafePolicyWarning.class);
commonClassDao.delete(safePolicyWarningData);
response.setCharacterEncoding(utf8);
@@ -373,10 +367,8 @@ public class SafePolicyController {
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
- JSONObject j = new JSONObject("{groupPolicyScopeListDatas: " + responseString + "}");
+ JSONObject j = new JSONObject("{safePolicyWarningDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
} catch (Exception e) {
LOGGER.error(e);
response.setCharacterEncoding(utf8);
@@ -384,7 +376,6 @@ public class SafePolicyController {
PrintWriter out = response.getWriter();
out.write(PolicyUtils.CATCH_EXCEPTION);
}
- return null;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java
index ae749adb5..f1cc9e6e4 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -75,9 +75,6 @@ public class DictionaryHandlerImpl implements DictionaryHandler{
case "DescriptiveScope":
dictionary.getDescriptiveDictionary(response);
break;
- case "Enforcer":
- dictionary.getEnforcerDictionary(response);
- break;
case "ActionList":
dictionary.getActionListDictionary(response);
break;
@@ -139,7 +136,7 @@ public class DictionaryHandlerImpl implements DictionaryHandler{
dictionary.getRiskTypeDictionary(response);
break;
case "SafePolicyWarning":
- dictionary.getSafePolicyWarningDictionary(request, response);
+ dictionary.getSafePolicyWarningDictionary(response);
break;
case "MicroServiceDictionary":
dictionary.getMicroServiceDictionary(response);
@@ -221,9 +218,6 @@ public class DictionaryHandlerImpl implements DictionaryHandler{
case "DescriptiveScope":
result = dictionary.saveDescriptiveDictionary(request, response);
break;
- case "Enforcer":
- result = dictionary.saveEnforcerDictionary(request, response);
- break;
case "ActionList":
result = dictionary.saveActionListDictionary(request, response);
break;
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
index 6e19b9b1c..00ae10fb6 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -23,13 +23,13 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.DecisionPolicyDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.DescriptiveDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.DictionaryController;
-import org.onap.policy.pap.xacml.rest.controller.EnforcerDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.MicroServiceDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.PolicyScopeDictionaryController;
@@ -135,13 +135,6 @@ public class DictionaryService {
return result.getViewName();
}
- public String saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
-
- EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
- ModelAndView result = dictionary.saveEnforcerDictionary(request, response);
- return result.getViewName();
- }
-
public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
@@ -360,11 +353,6 @@ public class DictionaryService {
dictionary.getDescriptiveDictionaryEntityData(response);
}
- public void getEnforcerDictionary(HttpServletResponse response){
- EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
- dictionary.getEnforcerDictionaryEntityData(response);
- }
-
public void getActionListDictionary(HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getActionListDictionaryEntityData(response);
@@ -463,10 +451,10 @@ public class DictionaryService {
public void getRiskTypeDictionary(HttpServletResponse response){
SafePolicyController dictionary = new SafePolicyController();
- dictionary.getOnapNameDictionaryEntityData(response);
+ dictionary.getRiskTypeDictionaryEntityData(response);
}
- public void getSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) {
+ public void getSafePolicyWarningDictionary(HttpServletResponse response) {
SafePolicyController dictionary = new SafePolicyController();
dictionary.getSafePolicyWarningeEntityData(response);
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryControllerTest.java
new file mode 100644
index 000000000..0191acf23
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryControllerTest.java
@@ -0,0 +1,157 @@
+/*-
+ * ============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.Date;
+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.ActionPolicyDict;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class ActionPolicyDictionaryControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(ActionPolicyDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private ActionPolicyDictionaryController controller = null;
+ private MockHttpServletResponse response = null;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+ List<String> data = new ArrayList<>();
+ List<Object> objectData = new ArrayList<>();
+ data.add("Test");
+
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+
+ ActionPolicyDict actionData = new ActionPolicyDict();
+ actionData.setAttributeName("Test");
+ assertTrue("Test".equals(actionData.getAttributeName()));
+ actionData.setBody("Test");
+ assertTrue("Test".equals(actionData.getBody()));
+ actionData.setCreatedDate(new Date());
+ assertTrue(actionData.getCreatedDate()!= null);
+ actionData.setModifiedDate(new Date());
+ assertTrue(actionData.getModifiedDate()!= null);
+ actionData.setHeader("Test");
+ assertTrue("Test".equals(actionData.getHeader()));
+ actionData.setMethod("POST");
+ assertTrue("POST".equals(actionData.getMethod()));
+ actionData.setType("Test");
+ assertTrue("Test".equals(actionData.getType()));
+ actionData.setUrl("http://test.com");
+ assertTrue("http://test.com".equals(actionData.getUrl()));
+ actionData.setUserCreatedBy(userInfo);
+ assertTrue(actionData.getUserCreatedBy()!= null);
+ actionData.setUserModifiedBy(userInfo);
+ assertTrue(actionData.getUserModifiedBy()!= null);
+
+ objectData.add(actionData);
+ when(commonClassDao.getDataByColumn(ActionPolicyDict.class, "attributeName")).thenReturn(data);
+ when(commonClassDao.getData(ActionPolicyDict.class)).thenReturn(objectData);
+ doNothing().when(commonClassDao).delete(new ActionPolicyDict());
+ doNothing().when(commonClassDao).save(new ActionPolicyDict());
+ controller = new ActionPolicyDictionaryController();
+ controller.setCommonClassDao(commonClassDao);
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetActionEntitybyName(){
+ controller.getActionEntitybyName(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionPolicyDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetActionPolicyDictionaryEntityData(){
+ controller.getActionPolicyDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionPolicyDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSaveActionPolicyDictionary(){
+ jsonString = "{\"actionPolicyDictionaryData\":{\"attributeName\":\"Test\",\"body\":\"{}\",\"description\":\"test\",\"headers\":[{\"$$hashKey\":\"object:548\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"method\":\"GET\",\"type\":\"REST\",\"url\":\"http://test.com\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveActionPolicyDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionPolicyDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateActionPolicyDictionary(){
+ jsonString = "{\"actionPolicyDictionaryData\":{\"id\":1,\"attributeName\":\"Test\",\"body\":\"{}\",\"description\":\"test\",\"headers\":[{\"$$hashKey\":\"object:548\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"method\":\"GET\",\"type\":\"REST\",\"url\":\"http://test.com\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveActionPolicyDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionPolicyDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveActionPolicyDictionary(){
+ jsonString = "{\"data\":{\"$$hashKey\":\"uiGrid-003S\",\"attributeName\":\"Test\",\"body\":\"{}\",\"createdDate\":1518195117000,\"description\":\"test\",\"header\":\"test=12\",\"id\":1,\"method\":\"GET\",\"modifiedDate\":1518195489000,\"type\":\"REST\",\"url\":\"http://test.com\",\"userCreatedBy\":{\"userLoginId\":\"demo\",\"userName\":\"Demo\"},\"userModifiedBy\":{\"userLoginId\":\"demo\",\"userName\":\"Demo\"}}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeActionPolicyDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("actionPolicyDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+}
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
new file mode 100644
index 000000000..bd521a9d9
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryControllerTest.java
@@ -0,0 +1,442 @@
+/*-
+ * ============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.ClosedLoopD2Services;
+import org.onap.policy.rest.jpa.ClosedLoopSite;
+import org.onap.policy.rest.jpa.PEPOptions;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.onap.policy.rest.jpa.VNFType;
+import org.onap.policy.rest.jpa.VSCLAction;
+import org.onap.policy.rest.jpa.VarbindDictionary;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class ClosedLoopDictionaryControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(ClosedLoopDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private ClosedLoopDictionaryController 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 VSCLAction());
+ doNothing().when(commonClassDao).save(new VSCLAction());
+
+ controller = new ClosedLoopDictionaryController();
+ controller.setCommonClassDao(commonClassDao);
+
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetVSCLActionDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(VSCLAction.class, "vsclaction")).thenReturn(data);
+ controller.getVSCLActionDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetVSCLActionDictionaryEntityData(){
+ when(commonClassDao.getData(VSCLAction.class)).thenReturn(new ArrayList<>());
+ controller.getVSCLActionDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetVNFTypeDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(VNFType.class, "vnftype")).thenReturn(data);
+ controller.getVNFTypeDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetVNFTypeDictionaryEntityData(){
+ when(commonClassDao.getData(VNFType.class)).thenReturn(new ArrayList<>());
+ controller.getVNFTypeDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPEPOptionsDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(PEPOptions.class, "pepName")).thenReturn(data);
+ controller.getPEPOptionsDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetPEPOptionsDictionaryEntityData(){
+ when(commonClassDao.getData(PEPOptions.class)).thenReturn(new ArrayList<>());
+ controller.getPEPOptionsDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetVarbindDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(VarbindDictionary.class, "varbindName")).thenReturn(data);
+ controller.getVarbindDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetVarbindDictionaryEntityData(){
+ when(commonClassDao.getData(VarbindDictionary.class)).thenReturn(new ArrayList<>());
+ controller.getVarbindDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetClosedLoopServiceDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(ClosedLoopD2Services.class, "serviceName")).thenReturn(data);
+ controller.getClosedLoopServiceDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetClosedLoopServiceDictionaryEntityData(){
+ when(commonClassDao.getData(ClosedLoopD2Services.class)).thenReturn(new ArrayList<>());
+ controller.getClosedLoopServiceDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetClosedLoopSiteDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(ClosedLoopSite.class, "siteName")).thenReturn(data);
+ controller.getClosedLoopSiteDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetClosedLoopSiteDictionaryEntityData(){
+ when(commonClassDao.getData(ClosedLoopSite.class)).thenReturn(new ArrayList<>());
+ controller.getClosedLoopSiteDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSaveVSCLAction(){
+ jsonString = "{\"userid\":\"demo\",\"vsclActionDictionaryData\":{\"description\":\"test\",\"vsclaction\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVSCLAction(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateVSCLAction(){
+ jsonString = "{\"userid\":\"demo\",\"vsclActionDictionaryData\":{\"id\":1,\"description\":\"test\",\"vsclaction\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVSCLAction(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveVSCLAction(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"vsclaction\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeVSCLAction(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vsclActionDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveVnfType(){
+ jsonString = "{\"userid\":\"demo\",\"vnfTypeDictionaryData\":{\"description\":\"test\",\"vnftype\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVnfType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateVnfType(){
+ jsonString = "{\"userid\":\"demo\",\"vnfTypeDictionaryData\":{\"id\":1,\"description\":\"test\",\"vnftype\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVnfType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveVnfType(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"vnftype\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeVnfType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("vnfTypeDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSavePEPOptions(){
+ jsonString = "{\"pepOptionsDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePEPOptions(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdatePEPOptions(){
+ jsonString = "{\"pepOptionsDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\",\"id\":1},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.savePEPOptions(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemovePEPOptions(){
+ jsonString = "{\"data\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"pepName\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removePEPOptions(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("pepOptionsDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveServiceType(){
+ jsonString = "{\"userid\":\"demo\",\"closedLoopServiceDictionaryData\":{\"description\":\"test\",\"serviceName\":\"Test\",\"id\":1}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateServiceType(){
+ jsonString = "{\"userid\":\"demo\",\"closedLoopServiceDictionaryData\":{\"id\":1,\"description\":\"test\",\"serviceName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveServiceType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveServiceType(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"serviceName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeServiceType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopServiceDictionaryData"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveSiteType(){
+ jsonString = "{\"userid\":\"demo\",\"closedLoopSiteDictionaryData\":{\"description\":\"test\",\"siteName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSiteType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateSiteType(){
+ jsonString = "{\"userid\":\"demo\",\"closedLoopSiteDictionaryData\":{\"id\":1,\"description\":\"test\",\"siteName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveSiteType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveSiteType(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"siteName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeSiteType(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("closedLoopSiteDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testSaveVarbind(){
+ jsonString = "{\"userid\":\"demo\",\"varbindDictionaryData\":{\"description\":\"test\",\"varbindName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVarbind(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateVarbind(){
+ jsonString = "{\"userid\":\"demo\",\"varbindDictionaryData\":{\"id\":1,\"description\":\"test\",\"varbindName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveVarbind(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveVarbind(){
+ jsonString = "{\"userid\":\"demo\",\"data\":{\"id\":1,\"description\":\"test\",\"varbindName\":\"Test\"}}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeVarbind(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("varbindDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryControllerTest.java
new file mode 100644
index 000000000..185410532
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryControllerTest.java
@@ -0,0 +1,163 @@
+/*-
+ * ============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.Date;
+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.DescriptiveScope;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class DescriptiveDictionaryControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(DescriptiveDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private DescriptiveDictionaryController 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 DescriptiveScope());
+ doNothing().when(commonClassDao).save(new DescriptiveScope());
+
+ controller = new DescriptiveDictionaryController();
+ controller.setCommonClassDao(commonClassDao);
+
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ logger.info("setUp: exit");
+ }
+
+ public List<Object> testDescriptiveScope(){
+ List<Object> objectData = new ArrayList<>();
+
+ DescriptiveScope data = new DescriptiveScope();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setScopeName("Test");
+ assertTrue("Test".equals(data.getScopeName()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setSearch("Test");
+ assertTrue("Test".equals(data.getSearch()));
+ 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 testGetDescriptiveDictionaryByNameEntityData(){
+ when(commonClassDao.getDataByColumn(DescriptiveScope.class, "descriptiveScopeName")).thenReturn(data);
+ controller.getDescriptiveDictionaryByNameEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testGetDescriptiveDictionaryEntityData(){
+ when(commonClassDao.getData(DescriptiveScope.class)).thenReturn(testDescriptiveScope());
+ controller.getDescriptiveDictionaryEntityData(response);
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ } catch (Exception e) {
+ fail();
+ logger.error(e.getMessage(),e);
+ }
+ }
+
+ @Test
+ public void testSaveDescriptiveDictionary(){
+ jsonString = "{\"descriptiveScopeDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"descriptiveScopeName\":\"Test\",\"search\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveDescriptiveDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testUpdateDescriptiveDictionary(){
+ jsonString = "{\"descriptiveScopeDictionaryData\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"descriptiveScopeName\":\"Test\",\"id\":1,\"search\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.saveDescriptiveDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+
+ @Test
+ public void testRemoveDescriptiveDictionary(){
+ jsonString = "{\"data\":{\"attributes\":[{\"$$hashKey\":\"object:257\",\"id\":\"choice1\",\"number\":\"12\",\"option\":\"test\"}],\"description\":\"test\",\"descriptiveScopeName\":\"Test\",\"id\":1,\"search\":\"Test\"},\"userid\":\"demo\"}";
+ try(BufferedReader br = new BufferedReader(new StringReader(jsonString))){
+ when(request.getReader()).thenReturn(br);
+ controller.removeDescriptiveDictionary(request, response);
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ }catch(Exception e){
+ logger.error("Exception"+ e);
+ }
+ }
+} \ No newline at end of file
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);
+ }
+ }
+}
diff --git a/ONAP-PDP/pom.xml b/ONAP-PDP/pom.xml
index 456217a6b..d302c955d 100644
--- a/ONAP-PDP/pom.xml
+++ b/ONAP-PDP/pom.xml
@@ -72,7 +72,7 @@
<dependency>
<groupId>com.att.research.xacml</groupId>
<artifactId>xacml-pdp</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java
deleted file mode 100644
index ea1cfb548..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 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.rest.adapter;
-
-
-public class ClosedLoopPolicy {
- public static final String CLFAULT_UIFIELD_D2_SERVICES_TRINITY = "Hosted Voice (Trinity)";
- public static final String CLFAULT_UIJSON_D2_SERVICES_TRINITY = "trinity";
-
- public static final String CLFAULT_UIFIELD_D2_SERVICES_VUSP = "vUSP";
- public static final String CLFAULT_UIJSON_D2_SERVICES_VUSP = "vUSP";
-
- public static final String CLFAULT_UIFIELD_D2_SERVICES_MCR = "MCR";
- public static final String CLFAULT_UIJSON_D2_SERVICES_MCR = "mcr";
-
- public static final String CLFAULT_UIFIELD_D2_SERVICES_GAMMA = "Gamma";
- public static final String CLFAULT_UIJSON_D2_SERVICES_GAMMA = "gama";
-
- public static final String CLFAULT_UIFIELD_D2_SERVICES_VDNS = "vDNS";
- public static final String CLFAULT_UIJSON_D2_SERVICES_VDNS = "vDNS";
-
- public static final String CLFAULT_UIFIELD_EMAIL_ADDRESS = "Email Address";
- public static final String CLFAULT_UIJSON_EMAIL_ADDRESS = "emailAddress";
-
- public static final String CLFAULT_UIFIELD_TRIGGER_SIGNATURE = "Trigger Signature";
- public static final String CLFAULT_UIJSON_TRIGGER_SIGNATURE = "triggerSignaturesUsedForUI.signatures";
-
- public static final String CLFAULT_UIFIELD_VERIFICATION_SIGNATURE = "Verification Signature";
- public static final String CLFAULT_UIJSON_VERIFICATION_SIGNATURE = "verificationSignaturesUsedForUI.signatures";
-
- public static final String CLFAULT_UIFIELD_CONNECT_ALL_TRAPS = "Connect All Traps";
- public static final String CLFAULT_UIJSON_CONNECT_ALL_TRAPS = "triggerSignaturesUsedForUI.connectSignatures";
-
- public static final String CLFAULT_UIFIELD_CONNECT_ALL_FAULTS = "Connect All Faults";
- public static final String CLFAULT_UIJSON_CONNECT_ALL_FAULTS = "verificationSignaturesUsedForUI.connectSignatures";
-
- public static final String CLFAULT_UIFIELD_POLICY_STATUS_ACTIVE = "Active";
- public static final String CLFAULT_UIJSON_POLICY_STATUS_ACTIVE = "ACTIVE";
-
- public static final String CLFAULT_UIFIELD_POLICY_STATUS_INACTIVE = "InActive";
- public static final String CLFAULT_UIJSON_POLICY_STATUS_INACTIVE = "INACTIVE";
-
- private ClosedLoopPolicy(){
- // Empty constructor
- }
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
index dfc6dff49..a9daf1732 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,7 +20,6 @@
package org.onap.policy.rest.adapter;
-import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
index c69476fac..576889504 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
@@ -53,9 +53,6 @@ import org.onap.policy.rest.XacmlAdminAuthorization;
public class ClosedLoopD2Services implements Serializable{
private static final long serialVersionUID = 1L;
- private static String domain;
-
-
@Id
@Column(name ="id")
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -105,14 +102,6 @@ public class ClosedLoopD2Services implements Serializable{
public ClosedLoopD2Services(){
//An empty constructor
}
-
- public ClosedLoopD2Services(String string, String userid) {
- this(domain);
- }
-
- public ClosedLoopD2Services(String domain) {
- this.serviceName = domain;
- }
@PrePersist
public void prePersist() {
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/EnforcingType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/EnforcingType.java
deleted file mode 100644
index 9c1cda451..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/EnforcingType.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2017 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.rest.jpa;
-
-import java.io.Serializable;
-
-import javax.persistence.*;
-
-/**
- * Entity implementation class for Entity: EnforcingType
- *
- */
-@Entity
-@Table(name="EnforcingType")
-@NamedQuery(name="EnforcingType.findAll", query="SELECT e FROM EnforcingType e ")
-public class EnforcingType implements Serializable {
-
-
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
- private int id;
- @Column(name="enforcingType", nullable=false, unique=true)
- @OrderBy("asc")
- private String enforcingType;
- @Column(name="script", nullable=false, length=255)
- private String script;
- @Column(name="connectionQuery", nullable=false, length=255)
- private String connectionQuery;
- @Column(name="valueQuery", nullable=false, length=255)
- private String valueQuery;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getEnforcingType() {
- return enforcingType;
- }
-
- public void setEnforcingType(String enforcingType) {
- this.enforcingType = enforcingType;
- }
-
- public String getScript() {
- return script;
- }
-
- public void setScript(String script) {
- this.script = script;
- }
-
- public String getConnectionQuery() {
- return connectionQuery;
- }
-
- public void setConnectionQuery(String connectionQuery) {
- this.connectionQuery = connectionQuery;
- }
-
- public String getValueQuery() {
- return valueQuery;
- }
-
- public void setValueQuery(String valueQuery) {
- this.valueQuery = valueQuery;
- }
-
- public EnforcingType() {
- super();
- }
-
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyManagement.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyManagement.java
deleted file mode 100644
index c79ee1e82..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyManagement.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2017 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.rest.jpa;
-
-import java.io.Serializable;
-import java.sql.Clob;
-import java.sql.Timestamp;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-
-/**
- * The persistent class for the roles database table.
- *
- */
-@Entity
-@Table(name="policy_manangement")
-@NamedQuery(name="PolicyManagement.findAll", query="SELECT r FROM PolicyManagement r")
-public class PolicyManagement implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
-
- @Column(name="id")
- private int id;
-
- @Column(name="POLICY_NAME", nullable=false, length=45)
- private String policyName;
-
- @Column(name="scope", nullable=false, length=45)
- private String scope;
-
- @Column(name="ONAP_NAME", nullable=false, length=45)
- private String onapName;
-
- @Column(name="CONFIG_NAME", nullable=false, length=45)
- private String configName;
-
- @Column(name="XML", nullable=false)
- private transient Clob xml;
-
- @Column(name="CREATE_DATE_TIME", nullable=false)
- private Timestamp createDateTime;
-
-
- @Column(name="CREATED_BY", nullable=false, length=45)
- private String createdBy;
-
- @Column(name="UPDATE_DATE_TIME", nullable=false)
- private Timestamp updateDateTime;
-
- @Column(name="UPDATED_BY", nullable=false, length=45)
- private String updatedBy;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getScope() {
- return scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- public String getOnapName() {
- return onapName;
- }
-
- public void setOnapName(String onapName) {
- this.onapName = onapName;
- }
-
- public String getConfigName() {
- return configName;
- }
-
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- public Clob getXml() {
- return xml;
- }
-
- public void setXml(Clob xml) {
- this.xml = xml;
- }
-
- public Timestamp getCreateDateTime() {
- return createDateTime;
- }
-
- public void setCreateDateTime(Timestamp createDateTime) {
- this.createDateTime = createDateTime;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Timestamp getUpdateDateTime() {
- return updateDateTime;
- }
-
- public void setUpdateDateTime(Timestamp updateDateTime) {
- this.updateDateTime = updateDateTime;
- }
-
- public String getUpdatedBy() {
- return updatedBy;
- }
-
- public void setUpdatedBy(String updatedBy) {
- this.updatedBy = updatedBy;
- }
-
-
-
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyClasses.java
new file mode 100644
index 000000000..93691e48b
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyClasses.java
@@ -0,0 +1,160 @@
+/*-
+ * ============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.rest.jpa;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+public class ClosedLoopPolicyClasses {
+
+ private static Logger logger = FlexLogger.getLogger(ClosedLoopPolicyClasses.class);
+ private UserInfo userInfo;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testVSCLAction(){
+ 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);
+ }
+
+ @Test
+ public void testVNFType(){
+ 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);
+ }
+
+ @Test
+ public void testPEPOptions(){
+ 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);
+ }
+
+ @Test
+ public void testVarbindDictionary(){
+ 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);
+ }
+
+ @Test
+ public void testClosedLoopD2Services(){
+ 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);
+ }
+
+ @Test
+ public void testClosedLoopSite(){
+ 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);
+ }
+}
diff --git a/ONAP-XACML/pom.xml b/ONAP-XACML/pom.xml
index 271b7f458..c399e3fa9 100644
--- a/ONAP-XACML/pom.xml
+++ b/ONAP-XACML/pom.xml
@@ -82,7 +82,7 @@
<dependency>
<groupId>com.att.research.xacml</groupId>
<artifactId>xacml</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
</dependency>
</dependencies>
</project>