aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP')
-rw-r--r--POLICY-SDK-APP/pom.xml10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java137
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java18
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java27
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java14
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java14
-rw-r--r--POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties4
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/CLVarbindDictionary.html2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html4
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js9
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js7
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html23
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java42
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java12
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java94
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java232
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java12
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java50
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt2
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt2
-rw-r--r--POLICY-SDK-APP/src/test/resources/test.properties21
-rw-r--r--POLICY-SDK-APP/src/test/resources/xacml.admin.properties4
41 files changed, 686 insertions, 175 deletions
diff --git a/POLICY-SDK-APP/pom.xml b/POLICY-SDK-APP/pom.xml
index 5adb5d169..aea0afc24 100644
--- a/POLICY-SDK-APP/pom.xml
+++ b/POLICY-SDK-APP/pom.xml
@@ -49,7 +49,7 @@
</build>
<properties>
<encoding>UTF-8</encoding>
- <epsdk.version>1.1.0</epsdk.version>
+ <epsdk.version>1.3.1</epsdk.version>
<springframework.version>4.2.0.RELEASE</springframework.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<skipassembly>true</skipassembly>
@@ -59,9 +59,15 @@
</properties>
<dependencies>
<dependency>
- <groupId>org.openecomp.ecompsdkos</groupId>
+ <groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-core</artifactId>
<version>${epsdk.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- Spring -->
<dependency>
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 3febbed44..7ac9ca310 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -34,6 +34,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -49,9 +50,14 @@ public class CheckPDP {
private static HashMap<String, String> pdpMap = null;
private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
- private CheckPDP(){
+ public static Map<String, String> getPdpMap() {
+ return pdpMap;
+ }
+
+ public CheckPDP(){
//default constructor
}
+
public static boolean validateID(String id) {
// ReadFile
try {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index 4f42023c9..d65d1da8a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -7,9 +7,9 @@
* 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.
@@ -91,16 +91,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class PolicyManagerServlet extends HttpServlet {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyManagerServlet.class);
private static final long serialVersionUID = -8453502699403909016L;
-
- private static boolean jUnit = false;
-
- public static boolean isjUnit() {
- return jUnit;
- }
-
- public static void setjUnit(boolean jUnit) {
- PolicyManagerServlet.jUnit = jUnit;
- }
private enum Mode {
LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
@@ -123,11 +113,11 @@ public class PolicyManagerServlet extends HttpServlet {
private static String EDITOR = "editor";
private static String GUEST = "guest";
private static String RESULT = "result";
-
+
private static Path closedLoopJsonLocation;
private static JsonArray policyNames;
private static String testUserId = null;
-
+
public static JsonArray getPolicyNames() {
return policyNames;
}
@@ -154,7 +144,7 @@ public class PolicyManagerServlet extends HttpServlet {
//
PolicyManagerServlet.initializeJSONLoad();
}
-
+
protected static void initializeJSONLoad() {
closedLoopJsonLocation = Paths.get(XACMLProperties
.getProperty(XACMLRestProperties.PROP_ADMIN_CLOSEDLOOP));
@@ -163,7 +153,7 @@ public class PolicyManagerServlet extends HttpServlet {
String location = closedLoopJsonLocation.toString();
try {
inputStream = new FileInputStream(location);
- if (location.endsWith("json")) {
+ if (location.endsWith("json")) {
jsonReader = Json.createReader(inputStream);
policyNames = jsonReader.readArray();
serviceTypeNamesList = new ArrayList<>();
@@ -341,7 +331,7 @@ public class PolicyManagerServlet extends HttpServlet {
try {
//Get the Login Id of the User from Request
String userId = UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
+ //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
roles = new ArrayList<>();
scopes = new HashSet<>();
@@ -356,7 +346,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else{
scopes.add(userRole.getScope());
- }
+ }
}
}
if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
@@ -373,7 +363,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}
}
- }
+ }
if(policyList!= null){
for(int i = 0; i < policyList.length(); i++){
String policyName = policyList.get(i).toString().replace(".xml", "");
@@ -390,7 +380,7 @@ public class PolicyManagerServlet extends HttpServlet {
if(!activeData.isEmpty()){
PolicyVersion policy = (PolicyVersion) activeData.get(0);
JSONObject el = new JSONObject();
- el.put("name", policy.getPolicyName().replace(File.separator, "/"));
+ el.put("name", policy.getPolicyName().replace(File.separator, "/"));
el.put("date", policy.getModifiedDate());
el.put("version", policy.getActiveVersion());
el.put("size", "");
@@ -409,7 +399,7 @@ public class PolicyManagerServlet extends HttpServlet {
PolicyVersion filterdata = (PolicyVersion) filter;
try{
String scopeName = filterdata.getPolicyName().substring(0, filterdata.getPolicyName().lastIndexOf(File.separator));
- if(scopes.contains(scopeName)){
+ if(scopes.contains(scopeName)){
policyData.add(filterdata);
}
}catch(Exception e){
@@ -417,12 +407,12 @@ public class PolicyManagerServlet extends HttpServlet {
}
}
}
-
+
if(!policyData.isEmpty()){
for(int i =0; i < policyData.size(); i++){
PolicyVersion policy = (PolicyVersion) policyData.get(i);
JSONObject el = new JSONObject();
- el.put("name", policy.getPolicyName().replace(File.separator, "/"));
+ el.put("name", policy.getPolicyName().replace(File.separator, "/"));
el.put("date", policy.getModifiedDate());
el.put("version", policy.getActiveVersion());
el.put("size", "");
@@ -436,7 +426,7 @@ public class PolicyManagerServlet extends HttpServlet {
}catch(Exception e){
LOGGER.error("Exception occured while reading policy Data from Policy Version table for Policy Search Data"+e);
}
-
+
return new JSONObject().put(RESULT, resultList);
}
@@ -542,7 +532,7 @@ public class PolicyManagerServlet extends HttpServlet {
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
List<Object> queryData = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
queryData = controller.getDataByQuery(query, peParams);
@@ -574,12 +564,12 @@ public class PolicyManagerServlet extends HttpServlet {
}else{
return error("Error Occured while Describing the Policy");
}
-
+
return object;
}
//Get the List of Policies and Scopes for Showing in Editor tab
- private JSONObject list(JSONObject params, HttpServletRequest request) throws ServletException {
+ private JSONObject list(JSONObject params, HttpServletRequest request) throws ServletException {
Set<String> scopes = null;
List<String> roles = null;
try {
@@ -587,7 +577,7 @@ public class PolicyManagerServlet extends HttpServlet {
//Get the Login Id of the User from Request
String testUserID = getTestUserId();
String userId = testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
+ //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
roles = new ArrayList<>();
scopes = new HashSet<>();
@@ -602,7 +592,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else{
scopes.add(userRole.getScope());
- }
+ }
}
}
@@ -623,8 +613,8 @@ public class PolicyManagerServlet extends HttpServlet {
scopes.add(tempScope);
}
}
- }
-
+ }
+
if("/".equals(path)){
if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
List<Object> scopesList = queryPolicyEditorScopes(null);
@@ -632,7 +622,7 @@ public class PolicyManagerServlet extends HttpServlet {
PolicyEditorScopes scope = (PolicyEditorScopes) list;
if(!(scope.getScopeName().contains(File.separator))){
JSONObject el = new JSONObject();
- el.put("name", scope.getScopeName());
+ el.put("name", scope.getScopeName());
el.put("date", scope.getCreatedDate());
el.put("size", "");
el.put("type", "dir");
@@ -647,7 +637,7 @@ public class PolicyManagerServlet extends HttpServlet {
List<Object> scopesList = queryPolicyEditorScopes(scope.toString());
if(!scopesList.isEmpty()){
PolicyEditorScopes scopeById = (PolicyEditorScopes) scopesList.get(0);
- el.put("name", scopeById.getScopeName());
+ el.put("name", scopeById.getScopeName());
el.put("date", scopeById.getCreatedDate());
el.put("size", "");
el.put("type", "dir");
@@ -663,7 +653,7 @@ public class PolicyManagerServlet extends HttpServlet {
activePolicyList(scopeName, resultList, roles, scopes, onlyFolders);
} catch (Exception ex) {
LOGGER.error("Error Occured While reading Policy Files List"+ex );
- }
+ }
}
return new JSONObject().put(RESULT, resultList);
@@ -684,7 +674,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
PolicyController controller = getPolicyControllerInstance();
List<Object> scopesList = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
scopesList = controller.getDataByQuery(scopeNamequery, params);
@@ -703,13 +693,13 @@ public class PolicyManagerServlet extends HttpServlet {
}
String query = "from PolicyVersion where POLICY_NAME like :scopeName";
String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
-
+
SimpleBindings params = new SimpleBindings();
params.put("scopeName", scopeName + "%");
-
+
List<Object> activePolicies = null;
List<Object> scopesList = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
activePolicies = controller.getDataByQuery(query, null);
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
@@ -732,7 +722,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
if(scopeName.equalsIgnoreCase(checkScope)){
JSONObject el = new JSONObject();
- el.put("name", scope);
+ el.put("name", scope);
el.put("date", scopeById.getModifiedDate());
el.put("size", "");
el.put("type", "dir");
@@ -740,7 +730,7 @@ public class PolicyManagerServlet extends HttpServlet {
el.put("modifiedBy", scopeById.getUserModifiedBy().getUserName());
resultList.add(el);
}
- }
+ }
}
String scopeNameCheck = null;
for (Object list : activePolicies) {
@@ -754,7 +744,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
if(scopeNameValue.equals(scopeNameCheck)){
JSONObject el = new JSONObject();
- el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
+ el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
el.put("date", policy.getModifiedDate());
el.put("version", policy.getActiveVersion());
el.put("size", "");
@@ -765,7 +755,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else if(!scopes.isEmpty() && scopes.contains(scopeNameValue)){
JSONObject el = new JSONObject();
- el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
+ el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
el.put("date", policy.getModifiedDate());
el.put("version", policy.getActiveVersion());
el.put("size", "");
@@ -774,7 +764,7 @@ public class PolicyManagerServlet extends HttpServlet {
el.put("modifiedBy", getUserName(policy.getModifiedBy()));
resultList.add(el);
}
- }
+ }
}
private String getUserName(String loginId){
@@ -836,11 +826,11 @@ public class PolicyManagerServlet extends HttpServlet {
if(activePolicies.size() != policyActiveInPDP.size()){
rename = true;
}
-
+
UserInfo userInfo = new UserInfo();
userInfo.setUserLoginId(userId);
if(policyActiveInPDP.size() == 0){
- renameScope(scopesList, scopeName, newScopeName, controller);
+ renameScope(scopesList, scopeName, newScopeName, controller);
}else if(rename){
renameScope(scopesList, scopeName, newScopeName, controller);
for(String scope : scopeOfPolicyActiveInPDP){
@@ -853,7 +843,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
if(isActive){
return error("The Following policies rename failed. Since they are active in PDP Groups" +policyActiveInPDP);
- }
+ }
}
return success();
} catch (Exception e) {
@@ -861,7 +851,7 @@ public class PolicyManagerServlet extends HttpServlet {
return error(e.getMessage());
}
}
-
+
private void renameScope(List<Object> scopesList, String scopeName, String newScopeName, PolicyController controller){
for(Object object : scopesList){
PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object;
@@ -874,7 +864,7 @@ public class PolicyManagerServlet extends HttpServlet {
controller.updateData(editorScopeEntity);
}
}
-
+
private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
try {
PolicyEntity entity = null;
@@ -909,7 +899,7 @@ public class PolicyManagerServlet extends HttpServlet {
String[] oldPolicySplit = oldPolicyCheck.split(":");
//Check PolicyEntity table with newPolicy Name
- String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_1";
+ String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
SimpleBindings policyParams = new SimpleBindings();
policyParams.put("newPolicySplit_1", newPolicySplit[1]);
policyParams.put("newPolicySplit_0", newPolicySplit[0]);
@@ -951,7 +941,7 @@ public class PolicyManagerServlet extends HttpServlet {
}else{
return error("Policy rename failed due to policy not able to retrieve from database. Please, contact super-admin.");
}
-
+
return success();
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured While Renaming Policy"+e);
@@ -959,7 +949,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}
- private JSONObject checkOldPolicyEntryAndUpdate(PolicyEntity entity, String newScope, String removenewPolicyExtension, String oldScope, String removeoldPolicyExtension,
+ private JSONObject checkOldPolicyEntryAndUpdate(PolicyEntity entity, String newScope, String removenewPolicyExtension, String oldScope, String removeoldPolicyExtension,
String policyName, String newpolicyName, String oldpolicyName, String userId) throws ServletException{
try {
ConfigurationDataEntity configEntity = entity.getConfigurationData();
@@ -1151,7 +1141,7 @@ public class PolicyManagerServlet extends HttpServlet {
cloneRecord(newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], newPolicySplit[0], newPolicySplit[1], entity, userId);
success = true;
}
-
+
if(success){
PolicyVersion entityItem = new PolicyVersion();
entityItem.setActiveVersion(Integer.parseInt(version));
@@ -1202,7 +1192,8 @@ public class PolicyManagerServlet extends HttpServlet {
splitPolicyName = policyNamewithoutExtension.replace(".Decision_", ":Decision_");
}
String[] split = splitPolicyName.split(":");
- query = "FROM PolicyEntity where policyName like split_1 and scope = split_0";
+
+ query = "FROM PolicyEntity where policyName like :split_1 and scope = :split_0";
policyParams.put("split_1", split[1] + "%");
policyParams.put("split_0", split[0]);
}else{
@@ -1210,7 +1201,7 @@ public class PolicyManagerServlet extends HttpServlet {
query = "FROM PolicyEntity where scope like :policyNamewithoutExtension";
policyParams.put("policyNamewithoutExtension", policyNamewithoutExtension + "%");
}
-
+
List<Object> policyEntityobjects = controller.getDataByQuery(query, policyParams);
String activePolicyName = null;
boolean pdpCheck = false;
@@ -1238,7 +1229,7 @@ public class PolicyManagerServlet extends HttpServlet {
controller.deleteData(policyEntity.getConfigurationData());
}else if(policyNamewithoutExtension.contains("Action_")){
controller.deleteData(policyEntity.getActionBodyEntity());
- }
+ }
}
}
}
@@ -1267,11 +1258,11 @@ public class PolicyManagerServlet extends HttpServlet {
String currentVersionPolicyName = policyNamewithExtension.substring(policyNamewithExtension.lastIndexOf(File.separator)+1);
String currentVersionScope = policyNamewithExtension.substring(0, policyNamewithExtension.lastIndexOf(File.separator)).replace(File.separator, ".");
query = "FROM PolicyEntity where policyName = :currentVersionPolicyName and scope = :currentVersionScope";
-
+
SimpleBindings peParams = new SimpleBindings();
peParams.put("currentVersionPolicyName", currentVersionPolicyName);
peParams.put("currentVersionScope", currentVersionScope);
-
+
List<Object> policyEntitys = controller.getDataByQuery(query, peParams);
if(!policyEntitys.isEmpty()){
policyEntity = (PolicyEntity) policyEntitys.get(0);
@@ -1292,9 +1283,9 @@ public class PolicyManagerServlet extends HttpServlet {
}else if(policyNamewithoutExtension.contains("Action_")){
controller.deleteData(policyEntity.getActionBodyEntity());
}
-
+
if(version > 1){
- int highestVersion = 0;
+ int highestVersion = 0;
if(!policyEntityobjects.isEmpty()){
for(Object object : policyEntityobjects){
policyEntity = (PolicyEntity) object;
@@ -1325,7 +1316,7 @@ public class PolicyManagerServlet extends HttpServlet {
return error("Policy can't be deleted, it is active in PDP Groups. PolicyName: '"+policyEntity.getScope() + "." +policyEntity.getPolicyName()+"'");
}
}
- }
+ }
}else{
List<String> activePoliciesInPDP = new ArrayList<String>();
if(!policyEntityobjects.isEmpty()){
@@ -1355,7 +1346,7 @@ public class PolicyManagerServlet extends HttpServlet {
//Delete from policyVersion and policyEditor Scope table
String policyVersionQuery = "delete PolicyVersion where POLICY_NAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
controller.executeQuery(policyVersionQuery);
-
+
//Policy Notification
PolicyVersion entity = new PolicyVersion();
entity.setPolicyName(path);
@@ -1375,7 +1366,7 @@ public class PolicyManagerServlet extends HttpServlet {
insertactivePDPVersion.setModifiedBy(userId);
controller.saveData(insertactivePDPVersion);
}
-
+
return error("All the Policies has been deleted in Scope. Except the following list of Policies:"+activePoliciesInPDP);
}else{
String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
@@ -1401,10 +1392,10 @@ public class PolicyManagerServlet extends HttpServlet {
String mode = params.getString("mode");
String path = params.getString("path");
LOGGER.debug("editFile path: {}"+ path);
-
+
String domain = path.substring(1, path.lastIndexOf("/"));
domain = domain.replace("/", ".");
-
+
path = path.substring(1);
path = path.replace("/", ".");
String dbCheckName = path;
@@ -1415,14 +1406,14 @@ public class PolicyManagerServlet extends HttpServlet {
}else if(dbCheckName.contains("Decision_")){
dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
}
-
+
String[] split = dbCheckName.split(":");
String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
List<Object> queryData = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
queryData = controller.getDataByQuery(query, peParams);
@@ -1432,7 +1423,7 @@ public class PolicyManagerServlet extends HttpServlet {
Object policy = XACMLPolicyScanner.readPolicy(stream);
- PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
policyAdapter.setData(policy);
if("viewPolicy".equalsIgnoreCase(mode)){
@@ -1451,7 +1442,7 @@ public class PolicyManagerServlet extends HttpServlet {
PolicyAdapter setpolicyAdapter = PolicyAdapter.getInstance();
setpolicyAdapter.configure(policyAdapter,entity);
-
+
policyAdapter.setParentPath(null);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(policyAdapter);
@@ -1478,7 +1469,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}else{
name = params.getString("name");
- }
+ }
}catch(Exception e){
name = params.getString("name");
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Adding Scope"+e);
@@ -1493,7 +1484,7 @@ public class PolicyManagerServlet extends HttpServlet {
String validate = PolicyUtils.policySpecialCharValidator(validateName);
if(!validate.contains("success")){
return error(validate);
- }
+ }
}
LOGGER.debug("addFolder path: {} name: {}" + path +name);
if(!name.equals("")){
@@ -1508,7 +1499,7 @@ public class PolicyManagerServlet extends HttpServlet {
newScope.setScopeName(name);
newScope.setUserCreatedBy(userInfo);
newScope.setUserModifiedBy(userInfo);
- controller.saveData(newScope);
+ controller.saveData(newScope);
}else{
return error("Scope Already Exists");
}
@@ -1543,7 +1534,7 @@ public class PolicyManagerServlet extends HttpServlet {
throw new ServletException(e);
}
}
-
+
private PolicyController getPolicyControllerInstance(){
return policyController != null ? getPolicyController() : new PolicyController();
}
@@ -1555,4 +1546,4 @@ public class PolicyManagerServlet extends HttpServlet {
public static void setTestUserId(String testUserId) {
PolicyManagerServlet.testUserId = testUserId;
}
-} \ No newline at end of file
+}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index a4e476200..2326a9fb7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -122,7 +122,12 @@ public class PolicyNotificationMail{
boolean sendFlag = false;
SimpleBindings params = new SimpleBindings();
params.put("policyFileName", policyFileName);
- List<Object> watchList = policyNotificationDao.getDataByQuery(query, params);
+ List<Object> watchList = null;
+ if(PolicyController.isjUnit()){
+ watchList = policyNotificationDao.getDataByQuery(query, null);
+ }else{
+ watchList = policyNotificationDao.getDataByQuery(query, params);
+ }
if(watchList != null && !watchList.isEmpty()){
for(Object watch : watchList){
WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 7234a3b6a..08f80304c 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -82,8 +82,24 @@ public class PolicyRestController extends RestrictedBaseController{
private static final String modal = "model";
private static final String importDictionary = "import_dictionary";
+ private static CommonClassDao commonClassDao;
+
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ PolicyRestController.commonClassDao = commonClassDao;
+ }
+
@Autowired
- CommonClassDao commonClassDao;
+ private PolicyRestController(CommonClassDao commonClassDao){
+ PolicyRestController.commonClassDao = commonClassDao;
+ }
+
+ public PolicyRestController(){
+ //default constructor
+ }
@RequestMapping(value={"/policycreation/save_policy"}, method={RequestMethod.POST})
public void policyCreationController(HttpServletRequest request, HttpServletResponse response) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
index a0f1ba86d..7c60ecfdf 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
@@ -202,7 +202,7 @@ class HtmlProcessor extends SimpleCallback {
combiningAlgo2human.put("only-one-applicable", "to honour the result of the first successfully evaluated $placeholder$ in order");
}
- private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<String, AttributeIdentifiers>();
+ private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<>();
private final StringWriter stringWriter = new StringWriter();
private final PrintWriter htmlOut = new PrintWriter(stringWriter);
@@ -357,7 +357,7 @@ class HtmlProcessor extends SimpleCallback {
else
policySet(policySet, "li");
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("<ol>");
return super.onPreVisitPolicySet(parent, policySet);
@@ -377,7 +377,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policySet.getPolicySetId() +
" Description: " + policySet.getDescription());
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -421,7 +421,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null &&
- policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0) {
+ !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)";
@@ -449,7 +449,7 @@ class HtmlProcessor extends SimpleCallback {
policy(policy);
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("<ol type=\"i\">");
return super.onPreVisitPolicy(parent, policy);
@@ -464,7 +464,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policy.getPolicyId() +
"Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion());
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -506,7 +506,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition() != null &&
- policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0) {
+ !policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "rule") + " (<i>" + combiningAlgorithm + "</i>)";
@@ -710,7 +710,7 @@ class HtmlProcessor extends SimpleCallback {
//
StdAttribute attribute = null;
AttributeValueType value = match.getAttributeValue();
- String attributeDataType = null;
+ String attributeDataType;
if (match.getAttributeDesignator() != null && value != null) {
AttributeDesignatorType designator = match.getAttributeDesignator();
attribute = new StdAttribute(new IdentifierImpl(designator.getCategory()),
@@ -822,11 +822,12 @@ class HtmlProcessor extends SimpleCallback {
}
private String removePrimitives(String in) {
- in = in.replace("string-", "");
- in = in.replace("integer-", "");
- in = in.replace("double-", "");
- in = in.replace("boolean-", "");
- return in;
+ String newIn = in;
+ newIn = newIn.replace("string-", "");
+ newIn = newIn.replace("integer-", "");
+ newIn = newIn.replace("double-", "");
+ newIn = newIn.replace("boolean-", "");
+ return newIn;
}
private String stringifyCondition(ConditionType condition) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
index 353e08a44..32f40b9e7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
@@ -64,4 +64,6 @@ public class HibernateSession{
logSessionFactory = logSessionFactory1;
}
+ private HibernateSession(){
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
index fc7cb60e5..4dc45425a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
@@ -173,7 +173,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
if (flag) {
params.append(line);
}
- if (line.contains("declare Params")) {
+ if (line.contains("declare PapParams")) {
params.append(line);
flag = true;
}
@@ -181,7 +181,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
break;
}
}
- params = new StringBuilder(params.toString().replace("declare Params", "").replace("end", "").replaceAll("\\s+", ""));
+ params = new StringBuilder(params.toString().replace("declare PapParams", "").replace("end", "").replaceAll("\\s+", ""));
String[] components = params.toString().split(":");
String caption = "";
for (int i = 0; i < components.length; i++) {
@@ -400,7 +400,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
if (flag) {
params.append(line);
}
- if (line.contains("rule") && line.contains(".Params\"")) {
+ if (line.contains("rule") && line.contains(".PapParams\"")) {
params.append(line);
flag = true;
}
@@ -408,8 +408,8 @@ public class CreateBRMSParamController extends RestrictedBaseController {
break;
}
}
- params = new StringBuilder(params.substring(params.indexOf(".Params\"")+ 8));
- params = new StringBuilder(params.toString().replaceAll("\\s+", "").replace("salience1000whenthenParamsparams=newParams();","")
+ params = new StringBuilder(params.substring(params.indexOf(".PapParams\"")+ 11));
+ params = new StringBuilder(params.toString().replaceAll("\\s+", "").replace("salience1000whenthenPapParamsparams=newPapParams();","")
.replace("insert(params);end", "")
.replace("params.set", ""));
String[] components = params.toString().split("\\);");
@@ -462,7 +462,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
brmsTemplateVlaue + policyData.getRuleName() + "%$> \n */ \n";
body = body + findRule((String) policyData.getRuleName()) + "\n";
StringBuilder generatedRule = new StringBuilder();
- generatedRule.append("rule \""+ policyData.getDomainDir().replace("\\", ".") +".Config_BRMS_Param_" + policyData.getPolicyName()+".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();");
+ generatedRule.append("rule \""+ policyData.getDomainDir().replace("\\", ".") +".Config_BRMS_Param_" + policyData.getPolicyName()+".PapParams\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tPapParams params = new PapParams();");
if(policyData.getRuleData().size() > 0){
for(Object keyValue: policyData.getRuleData().keySet()){
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
index f10041e38..392adf039 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
@@ -98,24 +98,24 @@ public class CreateClosedLoopPMController{
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ServiceType")){
+ if ("ServiceType".equals(attributeId)){
LinkedHashMap<String, String> serviceTypePolicyName1 = new LinkedHashMap<>();
String key = "serviceTypePolicyName";
serviceTypePolicyName1.put(key, value);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
index 0f55ba6ec..b349adacb 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
@@ -1379,6 +1379,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
@RequestMapping(value={"/ms_dictionary/set_MSModelData"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void SetMSModelData(HttpServletRequest request, HttpServletResponse response) throws IOException, FileUploadException{
+ modelList = new ArrayList<>();
+ dirDependencyList = new ArrayList<>();
+ classMap = new HashMap<>();
+ retmap = new HashMap<>();
+ uniqueKeys= new HashSet<>();
+ uniqueDataKeys= new HashSet<>();
+ dataListBuffer=new StringBuilder();
+ dataConstraints= new ArrayList <>();
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
boolean zip = false;
boolean yml= false;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
index ed0bf4caf..9832f5803 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
@@ -90,6 +90,14 @@ public class CreateFirewallController extends RestrictedBaseController {
private static CommonClassDao commonClassDao;
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ CreateFirewallController.commonClassDao = commonClassDao;
+ }
+
private List<String> tagCollectorList;
private String jsonBody;
List<String> expandablePrefixIPList = new ArrayList<>();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
index 625b2bdd8..71d0b3d03 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
@@ -60,7 +60,7 @@ public class CreatePolicyController extends RestrictedBaseController{
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
policyAdapter.setConfigType(entity.getConfigurationData().getConfigType());
policyAdapter.setConfigBodyData(entity.getConfigurationData().getConfigBody());
- String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf(' ') + 1);
+ String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf('_') + 1);
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try{
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
index 21f3793f1..f987f906d 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
@@ -64,13 +64,13 @@ public class PolicyNotificationController extends RestrictedBaseController {
String responseValue = "";
try {
String userId = UserUtils.getUserSession(request).getOrgUserId();
- System.out.println(userId);
+ logger.info("userid info: " + userId);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
String name = root.get("watchData").get("name").toString();
JsonNode pathList = root.get("watchData").get("path");
- String finalName = "";
+ String finalName;
if(pathList.isArray()){
ArrayNode arrayNode = (ArrayNode) pathList;
for (int i = 0; i < arrayNode.size(); i++) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
index 946f90ac7..c8ed3a096 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
@@ -268,7 +268,12 @@ public class CommonClassDaoImpl implements CommonClassDao{
try {
Query hbquery = session.createQuery(query);
for (Map.Entry<String, Object> paramPair : params.entrySet()) {
- hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
+ if(paramPair.getValue() instanceof java.lang.Long){
+ hbquery.setLong(paramPair.getKey(), (long) paramPair.getValue());
+ }
+ else{
+ hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
+ }
}
data = hbquery.list();
tx.commit();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
index 49024ba0d..c96da506f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
@@ -43,16 +43,6 @@ import org.onap.policy.common.logging.flexlogger.Logger;
public class SystemLogDbDaoImpl implements SystemLogDbDao {
private static final Logger logger = FlexLogger.getLogger(SystemLogDbDaoImpl.class);
- private static boolean jUnit = false;
-
- public static boolean isjUnit() {
- return jUnit;
- }
-
- public static void setjUnit(boolean jUnit) {
- SystemLogDbDaoImpl.jUnit = jUnit;
- }
-
@SuppressWarnings("unchecked")
@Override
public List<SystemLogDB> getLoggingData() {
@@ -61,7 +51,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
List<SystemLogDB> system = null;
try {
String sqlWhere = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
sqlWhere = "";
}else{
sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) ORDER BY date DESC limit "+PolicyController.getLogTableLimit()+"";
@@ -90,7 +80,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
List<SystemLogDB> system = null;
try {
String sqlWhere = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
sqlWhere = "";
}else{
sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) and logtype = 'error' ORDER BY date DESC limit "+PolicyController.getSystemAlertTableLimit()+"";
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
index 04ec3e868..3b3f11957 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
@@ -365,7 +365,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public Object firstItemId() {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
+ if (!this.groups.isEmpty()) {
return this.groups.get(0);
}
}
@@ -375,7 +375,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public Object lastItemId() {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
+ if (!this.groups.isEmpty()) {
return this.groups.get(this.groups.size() - 1);
}
}
@@ -385,8 +385,8 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public boolean isFirstId(Object itemId) {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return (this.groups.get(0).equals(itemId));
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(0).equals(itemId);
}
}
return false;
@@ -395,8 +395,8 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public boolean isLastId(Object itemId) {
synchronized (this.groups) {
- if (this.groups.size() > 0) {
- return (this.groups.get(this.groups.size() - 1).equals(itemId));
+ if (!this.groups.isEmpty()) {
+ return this.groups.get(this.groups.size() - 1).equals(itemId);
}
}
return false;
@@ -444,7 +444,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
//
// You cannot remove the default group
//
- if (((OnapPDPGroup) itemId).getId().equals("Default")) {
+ if ("Default".equals(((OnapPDPGroup) itemId).getId())) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}
//
diff --git a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
index 43b2de708..84c5dc5dd 100644
--- a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
+++ b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
@@ -23,8 +23,8 @@ decryption_key = AGLDdG4D04BKm2IxIWEr8o==
# The following properties MAY require changes by partner applications.
##########################################################################
#Mysql
-db.driver = com.mysql.jdbc.Driver
-db.connectionURL = jdbc:mysql://localhost:3306/onapsdk1707
+db.driver = org.mariadb.jdbc.Driver
+db.connectionURL = jdbc:mariadb://localhost:3306/onapsdk1707
db.userName = root
db.password =
db.hib.dialect = org.hibernate.dialect.MySQLDialect
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/CLVarbindDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/CLVarbindDictionary.html
index 98570f3dd..2271992b0 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/CLVarbindDictionary.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/CLVarbindDictionary.html
@@ -45,7 +45,7 @@
</div>
<div class="form-group row">
<div class="form-group col-sm-6" ng-class="{ 'has-error' : formdata.varbindOID.$invalid && !formdata.varbindOID.$pristine }">
- <label>Varbind OID:</label><br>
+ <label>Varbind OID:<sup><b>*</b></sup></label><br>
<input type="text" ng-model="editCLVarbind.varbindOID" class="form-control" name= "varbindOID" required/>
<p ng-show="formdata.varbindOID.$invalid && !formdata.varbindOID.$pristine" class="help-block">Varbind OID is required.</p>
</div>
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html
index fe7ad5811..89e3aff1e 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html
@@ -34,7 +34,7 @@
<div class="form-group col-sm-6" ng-class="{ 'has-error' : formdata.name.$invalid && !formdata.name.$pristine }">
<label>UUID:<sup><b>*</b></sup></label><br>
<input type="text" ng-model="editDCAEuuid.name" class="form-control" name= "name" required/>
- <p ng-show="formdata.name.$invalid && !formdata.name.$pristine" class="help-block">Onap Name is required.</p>
+ <p ng-show="formdata.name.$invalid && !formdata.name.$pristine" class="help-block">UUID field is required.</p>
</div>
</div>
<div class="form-group row">
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
index 08d4662da..90b77e45d 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
@@ -140,7 +140,7 @@ app.controller('vnfTypeDictGridController', function ($scope, PolicyAppService,
$scope.deleteVnfType = function(data) {
var uuu = "searchDictionary";
- var postData={data: data, type: "attribute"};
+ var postData={data: data, type: "clVnf"};
var searchString = "\n";
$.ajax({
type : 'POST',
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
index 9721e1c2e..f5a5e8678 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html
@@ -220,10 +220,6 @@
<link rel="stylesheet" href="app/fusion/external/ds2/css/digital-ng-library/ionicons.css">
<link rel="stylesheet" href="app/fusion/styles/ecomp.css">
<link rel="stylesheet" href="app/fusion/external/angular-gridster/dist/angular-gridster.min.css">
- <script src= "app/policyApp/CSS/UIGrid/ui-grid.eot"></script>
- <link rel="stylesheet" href="app/policyApp/CSS/UIGrid/ui-grid.svg">
- <script src= "app/policyApp/CSS/UIGrid/ui-grid.woff"></script>
- <script src= "app/policyApp/CSS/UIGrid/ui-grid.ttf"></script>
</head>
<body class="appBody" ng-app="abs" style="padding-top: 0px;">
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
index 2892936f8..a9097d559 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js
@@ -24,6 +24,12 @@ app.controller('actionPolicyController', ['$scope', 'PolicyAppService', 'policyN
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Action"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
index 02c31486b..22511c5a7 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
@@ -24,6 +24,13 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "BRMS_Param"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
index 8f27f2a09..6061b1ef8 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
@@ -24,6 +24,13 @@ angular.module('abs').controller('brmsRawPolicyController', ['$scope', '$window'
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "BRMS_Raw"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
index 891e4098b..7425c92d4 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js
@@ -25,6 +25,13 @@ app.controller('baseConfigController', ['$scope', 'PolicyAppService', 'policyNav
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "Base"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
index b3f702f6a..1015e7aac 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
@@ -24,6 +24,13 @@ angular.module("abs").controller('clFaultController', ['$scope', '$window', 'Pol
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "ClosedLoop_Fault"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
index caec13feb..a67266074 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js
@@ -23,7 +23,14 @@ angular.module("abs").controller('clPMController', ['$scope', '$window', '$timeo
$scope.policyNavigator;
$scope.savebutton = true;
$scope.refreshCheck = false;
-
+
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "ClosedLoop_PM"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
index fb10a2cc9..5b2bdb2b2 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -24,6 +24,12 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Decision"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
index 5988ef302..1051ecd9a 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
@@ -24,6 +24,13 @@ angular.module('abs').controller('fwPolicyController', ['$scope', '$window', 'Po
$scope.savebutton = true;
$scope.refreshCheck = false;
+ if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+ $scope.temp.policy = {
+ policyType : "Config",
+ configPolicyType : "Firewall Config"
+ }
+ };
+
$scope.refresh = function(){
if($scope.refreshCheck){
$scope.policyNavigator.refresh();
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js
index b96a4f732..0e095a841 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js
@@ -26,7 +26,7 @@ angular.module('abs').factory('item', ['$http', '$q', 'policyManagerConfig', fun
path: path || [],
type: model && model.type || 'file',
size: model && parseInt(model.size || 0),
- date: parseMySQLDate(model && model.date),
+ date: model && model.date,
version: model && model.version || '',
createdBy: model && model.createdBy || '',
modifiedBy: model && model.modifiedBy || '',
@@ -139,6 +139,11 @@ angular.module('abs').factory('item', ['$http', '$q', 'policyManagerConfig', fun
self.inprocess = true;
self.error = '';
$http.post(policyManagerConfig.renameUrl, data).success(function(data) {
+ if(data.result.error != undefined){
+ var value = data.result.error;
+ value = value.replace("rename" , "move");
+ data.result.error = value;
+ }
self.deferredHandler(data, deferred);
}).error(function(data) {
self.deferredHandler(data, deferred, 'Error Occured While Moving');
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
index f7a6d2442..77006002c 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
@@ -1,4 +1,4 @@
-<div class="modal animated fadeIn" id="delete" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="delete" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="remove(temp)">
@@ -21,7 +21,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="deletePolicy" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="deletePolicy" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="removePolicy(temp)">
@@ -50,7 +50,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="rename" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="rename" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="rename(temp)">
@@ -75,7 +75,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="searchWindow" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="searchWindow" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form>
@@ -96,7 +96,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="move" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="move" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="move(temp)">
@@ -119,7 +119,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="switchVersion" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="switchVersion" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="switchVersion(temp)">
@@ -147,7 +147,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="copy" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="copy" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="copy(temp)">
@@ -160,9 +160,6 @@
<div class="modal-body">
<label class="radio">Enter new Policy Name to Clone <b>{{temp.model.name}}</b></label>
<input class="form-control" ng-model="temp.tempModel.name" autofocus="autofocus">
-
- <div ng-include data-src="'path-selector'" class="clearfix"></div>
- <div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
@@ -197,7 +194,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="addSubScope" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="addSubScope" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="subScopeFolder(temp)">
@@ -221,7 +218,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="uploadfile" data-toggle="modal" data-backdrop="static" data-keyboard="false">
+<div class="modal" id="uploadfile" data-toggle="modal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<form ng-submit="uploadFiles()">
@@ -250,7 +247,7 @@
</div>
</div>
-<div class="modal animated fadeIn" id="selector" ng-controller="PolicyManagerModalCtrl">
+<div class="modal" id="selector" ng-controller="PolicyManagerModalCtrl">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
new file mode 100644
index 000000000..47358a8f2
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.admin;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.Test;
+
+public class CheckPDPTest {
+
+ @Test
+ public final void testCheckPDP() {
+ try {
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "test.properties");
+ CheckPDP.validateID("http://localhost:8082/pdp/");
+ assertTrue(CheckPDP.getPdpMap().containsKey("http://localhost:8082/pdp/"));
+ assertTrue(CheckPDP.getEncoding("http://localhost:8082/pdp/").equals("dGVzdHBkcDphbHBoYTQ1Ng=="));
+ } catch (Exception e) {
+ fail("Error occured in CheckPDP test");
+ }
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
index 970b67878..22cc82a23 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
@@ -64,6 +64,7 @@ public class PolicyManagerServletTest extends Mockito{
@Before
public void setUp() throws Exception{
logger.info("setUp: Entering");
+ PolicyController.setjUnit(true);
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId("Test");
userinfo.setUserName("Test");
@@ -146,7 +147,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
BufferedReader reader = new BufferedReader(new StringReader("{params: { mode: 'DESCRIBEPOLICYFILE', path: 'com.Config_SampleTest1206.1.xml'}}"));
try {
when(request.getReader()).thenReturn(reader);
@@ -168,7 +168,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'LIST', path: '/', onlyFolders: false}}");
list.add("{params: { mode: 'LIST', path: '/com', onlyFolders: false}}");
@@ -197,7 +196,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_SampleTest1206.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -244,7 +242,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -291,7 +288,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -338,7 +334,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_Fault_TestClosedLoopPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -385,7 +380,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_PM_TestClosedLoopPMPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -439,7 +433,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_MS_vFirewall.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -487,7 +480,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_FW_TestFireWallPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -532,7 +524,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Action_TestActionPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -571,7 +562,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
new file mode 100644
index 000000000..2c56a8b7f
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.admin;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.when;
+import org.onap.policy.controller.PolicyController;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.PolicyVersion;
+import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
+
+public class PolicyNotificationMailTest {
+
+ private PolicyVersion version;
+ private String policyName = "com/Config_Test";
+ private CommonClassDao commonClassDao;
+ private List<Object> data = null;
+
+ @Before
+ public void setUp() throws Exception {
+ PolicyController.setjUnit(true);
+ PolicyController.setSmtpApplicationName("Test");
+ PolicyController.setSmtpEmailExtension("test.com");
+ PolicyController.setSmtpHost("test");
+ PolicyController.setSmtpPort("23");
+ PolicyController.setSmtpPassword("test");
+ PolicyController.setSmtpUsername("test");
+
+ version = new PolicyVersion();
+ version.setPolicyName("com/Config_Test");
+ version.setModifiedBy("xyz");
+
+ WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+ watch.setPolicyName("com/Config_Test");
+ data = new ArrayList<>();
+ data.add(watch);
+
+ commonClassDao = mock(CommonClassDao.class);
+ PolicyController.setCommonClassDao(commonClassDao);
+ when(commonClassDao.getDataByQuery("from WatchPolicyNotificationTable where policyName like:policyFileName", null)).thenReturn(data);
+ }
+
+ @Test
+ public final void testJavaMailSenderImpl() {
+ PolicyNotificationMail notificationMail = new PolicyNotificationMail();
+ try{
+ assertTrue(notificationMail.javaMailSenderImpl() != null);
+ }catch(Exception e){
+ fail();
+ }
+ }
+
+ @Test
+ public final void testSendMail() {
+ PolicyNotificationMail notificationMail = new PolicyNotificationMail();
+ try{
+ notificationMail.sendMail(version, policyName, "EditPolicy", commonClassDao);
+ notificationMail.sendMail(version, policyName, "Rename", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteAll", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteOne", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteScope", commonClassDao);
+ notificationMail.sendMail(version, policyName, "SwitchVersion", commonClassDao);
+ notificationMail.sendMail(version, policyName, "Move", commonClassDao);
+ }catch(Exception e){
+ fail();
+ }
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java
new file mode 100644
index 000000000..1bda7cd41
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java
@@ -0,0 +1,232 @@
+/*-
+ * ============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.admin;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.controller.CreateFirewallController;
+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.FWTagPicker;
+import org.onap.policy.rest.jpa.GroupServiceList;
+import org.onap.policy.rest.jpa.PrefixList;
+import org.onap.policy.rest.jpa.SecurityZone;
+import org.onap.policy.rest.jpa.ServiceList;
+import org.onap.policy.rest.jpa.TermList;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class PolicyRestControllerTest {
+
+ private String clRequestString;
+ private String fwRequestString;
+ private String fwViewRequestString;
+ private HttpServletRequest request;
+ private MockHttpServletResponse response;
+ private static CommonClassDao commonClassDao;
+ private List<Object> prefixListData;
+ private List<Object> actionListData;
+ private List<Object> serviceListData;
+ private List<Object> addressGroupData;
+ private List<Object> securityZoneData;
+ private List<Object> serviceGroupData;
+ private List<Object> tagListData;
+ private List<Object> termListData;
+
+ @Before
+ public void setUp() throws Exception {
+ commonClassDao = mock(CommonClassDao.class);
+ HttpSession mockSession = mock(HttpSession.class);
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ User user = new User();
+ user.setOrgUserId("Test");
+ Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
+ Mockito.when(request.getSession(false)).thenReturn(mockSession);
+ clRequestString = "{\"policyData\":{\"error\":\"\",\"inprocess\":false,\"model\":{\"name\":\"com\","
+ + "\"subScopename\":\"\",\"path\":[],\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\","
+ + "\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\",\"content\":\"\",\"recursive\":false},"
+ + "\"tempModel\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\","
+ + "\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\",\"content\":\"\",\"recursive\":false},\"$$hashKey\":\"object:1439\","
+ + "\"policy\":{\"policyType\":\"Config\",\"configPolicyType\":\"ClosedLoop_Fault\",\"triggerTrapSignatures\":[1,1,2,3],"
+ + "\"triggerfaultSignatures\":[1,1,2,3],\"traptriggerSignatures\":[{\"id\":\"Trap1\",\"$$hashKey\":\"object:1526\"},"
+ + "{\"id\":\"Trap2\",\"$$hashKey\":\"object:1534\"}],\"connecttriggerSignatures\":[{\"id\":\"C1\",\"$$hashKey\":\"object:1554\","
+ + "\"notBox\":\"NOT\",\"connectTrap1\":\"Trap1\",\"trapCount1\":\"12\",\"operatorBox\":\"AND\",\"connectTrap2\":\"Trap2\","
+ + "\"trapCount2\":\"14\"}],\"faulttriggerSignatures\":[{\"id\":\"Fault1\",\"$$hashKey\":\"object:1566\"},{\"id\":\"Fault2\","
+ + "\"$$hashKey\":\"object:1575\"}],\"connectVerificationSignatures\":[{\"id\":\"C1\",\"$$hashKey\":\"object:1595\","
+ + "\"notBox\":\"NOT\",\"connectTrap1\":\"Fault1\",\"trapCount1\":\"11\",\"operatorBox\":\"AND\",\"connectTrap2\":\"Fault2\","
+ + "\"trapCount2\":\"12\"}],\"jsonBodyData\":{\"trapMaxAge\":\"300\",\"vnfType\":\"Test\",\"closedLoopPolicyStatus\":\"Active\","
+ + "\"vUSP\":true,\"trinity\":true,\"vDNS\":true,\"mcr\":true,\"gamma\":true,\"actions\":\"Test\",\"timeInterval\":\"11\","
+ + "\"timeOutvPRO\":\"11\",\"timeOutRuby\":\"11\",\"retrys\":\"1\",\"agingWindow\":\"12\",\"geoLink\":\"test\","
+ + "\"emailAddress\":\"aa@test.com\",\"pepName\":\"Test\",\"pepAction\":\"test\",\"conditions\":\"SEND\"},"
+ + "\"policyName\":\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\",\"riskLevel\":\"1\","
+ + "\"guard\":\"True\",\"onapName\":\"SampleDemo\",\"ttlDate\":\"14/09/2017\",\"clearTimeOut\":\"123\",\"trapMaxAge\":\"11\","
+ + "\"verificationclearTimeOut\":\"13\"}},\"trapData\":{\"trap1\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1528\","
+ + "\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"}],\"trap2\":[{\"id\":\"A1\","
+ + "\"$$hashKey\":\"object:1536\",\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"},"
+ + "{\"id\":\"A2\",\"$$hashKey\":\"object:1542\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"AND\",\"trigger2\":"
+ + "\"Test\"},{\"id\":\"A3\",\"$$hashKey\":\"object:1548\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"OR\","
+ + "\"trigger2\":\"A2\"}]},\"faultData\":{\"trap1\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1568\",\"notBox\":\"NOT\","
+ + "\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"}],\"trap2\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1577\","
+ + "\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"},{\"id\":\"A2\",\"$$hashKey\":"
+ + "\"object:1583\",\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"OR\",\"trigger2\":\"Test\"},{\"id\":\"A3"
+ + "\",\"$$hashKey\":\"object:1589\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"AND\",\"trigger2\":\"A2\"}]}}";
+
+
+ fwRequestString = "{\"policyData\":{\"error\":\"\",\"inprocess\":false,\"model\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],"
+ + "\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\",\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":"
+ + "\"Demo\",\"content\":\"\",\"recursive\":false},\"tempModel\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],\"type\":"
+ + "\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\",\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\","
+ + "\"content\":\"\",\"recursive\":false},\"$$hashKey\":\"object:260\",\"policy\":{\"policyType\":\"Config\",\"configPolicyType"
+ + "\":\"Firewall Config\",\"attributes\":[{\"id\":\"choice1\",\"$$hashKey\":\"object:338\",\"key\":\"Test\",\"value\":\"Test\"}],"
+ + "\"fwattributes\":[],\"policyName\":\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\","
+ + "\"riskLevel\":\"1\",\"guard\":\"True\",\"configName\":\"SampleTest\",\"ttlDate\":\"14/09/2017\",\"securityZone\":\"Test\"}}}";
+
+ fwViewRequestString = "{\"policyData\":{\"policyType\":\"Config\",\"configPolicyType\":\"Firewall Config\",\"attributes\":[{\"id\":"
+ + "\"choice1\",\"$$hashKey\":\"object:338\",\"key\":\"Test\",\"value\":\"Test\"}],\"fwattributes\":[],\"policyName\":"
+ + "\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\",\"riskLevel\":\"1\",\"guard\":\"True\","
+ + "\"configName\":\"SampleTest\",\"ttlDate\":\"14/09/2017\",\"securityZone\":\"Test\"}}";
+
+
+
+ prefixListData = new ArrayList<>();
+ PrefixList prefixList = new PrefixList();
+ prefixList.setPrefixListName("Test");
+ prefixList.setPrefixListValue("10.10.10.10/12");
+ prefixListData.add(prefixList);
+ when(commonClassDao.getData(PrefixList.class)).thenReturn(prefixListData);
+
+ actionListData = new ArrayList<>();
+ ActionList actionList = new ActionList();
+ actionList.setActionName("Test");
+ actionListData.add(actionList);
+ when(commonClassDao.getData(ActionList.class)).thenReturn(actionListData);
+
+ serviceListData = new ArrayList<>();
+ ServiceList serviceList = new ServiceList();
+ serviceList.setServiceName("Test");
+ serviceList.setServiceType("SERVICE");
+ serviceList.setServiceTransProtocol("Test");
+ serviceList.setServiceAppProtocol("Test");
+ serviceList.setServicePorts("8080");
+ serviceListData.add(serviceList);
+ when(commonClassDao.getData(ServiceList.class)).thenReturn(serviceListData);
+
+ addressGroupData = new ArrayList<>();
+ AddressGroup addressGroup = new AddressGroup();
+ addressGroup.setGroupName("Group_Test");
+ addressGroup.setServiceList("Test");
+ addressGroupData.add(addressGroup);
+ when(commonClassDao.getData(AddressGroup.class)).thenReturn(addressGroupData);
+
+ securityZoneData = new ArrayList<>();
+ SecurityZone securityZone = new SecurityZone();
+ securityZone.setZoneName("Test");
+ securityZone.setZoneValue("Test");
+ securityZoneData.add(securityZone);
+ when(commonClassDao.getData(SecurityZone.class)).thenReturn(securityZoneData);
+
+ serviceGroupData = new ArrayList<>();
+ GroupServiceList serviceGroup = new GroupServiceList();
+ serviceGroup.setGroupName("Group_Test");
+ serviceGroup.setServiceList("Test");
+ serviceGroupData.add(serviceGroup);
+ when(commonClassDao.getData(GroupServiceList.class)).thenReturn(serviceGroupData);
+
+ tagListData = new ArrayList<>();
+ FWTagPicker fwPicker = new FWTagPicker();
+ fwPicker.setTagPickerName("Test");
+ fwPicker.setTagValues("Test:8080");
+ tagListData.add(fwPicker);
+ when(commonClassDao.getData(FWTagPicker.class)).thenReturn(tagListData);
+
+ termListData = new ArrayList<>();
+ TermList termList = new TermList();
+ termList.setTermName("Test");
+ termList.setFromZones("Test");
+ termList.setToZones("Test");
+ termList.setSrcIPList("Test");
+ termList.setDestIPList("Test");
+ termList.setSrcPortList("Test");
+ termList.setDestPortList("Test");
+ termList.setAction("Test");
+ termListData.add(termList);
+ when(commonClassDao.getData(TermList.class)).thenReturn(termListData);
+ when(commonClassDao.getDataById(TermList.class, "termName", "Test")).thenReturn(termListData);
+ }
+
+ @Test
+ public final void testPolicyCreationController() {
+ PolicyRestController controller = new PolicyRestController();
+ BufferedReader reader = new BufferedReader(new StringReader(clRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader);
+ controller.policyCreationController(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+ PolicyRestController controller1 = new PolicyRestController();
+ CreateFirewallController.setCommonClassDao(commonClassDao);
+ BufferedReader reader1 = new BufferedReader(new StringReader(fwRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader1);
+ controller1.policyCreationController(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+
+ CreateFirewallController fwController = new CreateFirewallController();
+ CreateFirewallController.setCommonClassDao(commonClassDao);
+ BufferedReader reader2 = new BufferedReader(new StringReader(fwViewRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader2);
+ fwController.setFWViewRule(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public final void testDeleteElasticData() {
+ PolicyRestController controller = new PolicyRestController();
+ try {
+ controller.deleteElasticData("Test");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
index 4931d20d7..f4acaeb9a 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
@@ -41,12 +41,12 @@ public class PolicyUserInfoControllerTest {
@Before
public void setUp() throws Exception {
HttpSession mockSession = mock(HttpSession.class);
- request = mock(HttpServletRequest.class);
- response = new MockHttpServletResponse();
- User user = new User();
- user.setOrgUserId("Test");
- Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
- Mockito.when(request.getSession(false)).thenReturn(mockSession);
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ User user = new User();
+ user.setOrgUserId("Test");
+ Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
+ Mockito.when(request.getSession(false)).thenReturn(mockSession);
}
@Test
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java
index d4b0c650b..63ca29d90 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java
@@ -20,9 +20,13 @@
package org.onap.policy.daoImp;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
@@ -39,9 +43,9 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.conf.HibernateSession;
import org.onap.policy.controller.PolicyController;
-import org.onap.policy.daoImp.CommonClassDaoImpl;
import org.onap.policy.rest.jpa.OnapName;
import org.onap.policy.rest.jpa.PolicyEntity;
+import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.SystemLogDB;
import org.onap.policy.rest.jpa.UserInfo;
@@ -392,11 +396,49 @@ public class CommonClassDaoImplTest{
fail();
}
}
+
+ @Test
+ public void testCommonClassDaoImplMethods(){
+ try{
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ UserInfo userInfoUpdate = (UserInfo) data.get(0);
+ userInfoUpdate.setUserName("Test1");
+ commonClassDao.update(userInfoUpdate);
+ List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+ assertTrue(data1.size() == 1);
+ UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
+ assertTrue("TestID".equals(data2.getUserLoginId()));
+ List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+ assertTrue(data3.size() == 1);
+ PolicyRoles roles = new PolicyRoles();
+ roles.setRole("admin");
+ roles.setLoginId(userInfo);
+ roles.setScope("test");
+ commonClassDao.save(roles);
+ List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
+ assertTrue(roles1.size() == 1);
+ List<String> multipleData = new ArrayList<>();
+ multipleData.add("TestID:Test1");
+ List<Object> data4 = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
+ assertTrue(data4.size() == 1);
+ commonClassDao.delete(data2);
+ }catch(Exception e){
+ logger.debug("Exception Occured"+e);
+ fail();
+ }
+ }
+
+
@Test
public final void testGetLoggingData() {
SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
- SystemLogDbDaoImpl.setjUnit(true);
+ PolicyController.setjUnit(true);
try{
assertTrue(system.getLoggingData() != null);
}catch(Exception e){
@@ -407,7 +449,7 @@ public class CommonClassDaoImplTest{
@Test
public final void testGetSystemAlertData() {
SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
- SystemLogDbDaoImpl.setjUnit(true);
+ PolicyController.setjUnit(true);
try{
assertTrue(system.getSystemAlertData() != null);
}catch(Exception e){
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
index 6ff244ea4..63f93cbe2 100644
--- a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
@@ -88,7 +88,7 @@ import org.onap.policy.drools.system.PolicyEngine;
//
// These parameters are required to build the runtime policy
//
-declare Params
+declare PapParams
closedLoopControlName : String
actor : String
aaiURL : String
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
index 6924fc3a9..a3cdb7851 100644
--- a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
@@ -1,7 +1,7 @@
package com.sample
import com.sample.DroolsTest.Message;
// Declare the Parameters here.
-declare Params
+declare PapParams
samPoll : int
value : String
end
diff --git a/POLICY-SDK-APP/src/test/resources/test.properties b/POLICY-SDK-APP/src/test/resources/test.properties
new file mode 100644
index 000000000..e882dfd20
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/test.properties
@@ -0,0 +1,21 @@
+###
+# ============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=========================================================
+###
+
+PDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
diff --git a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
index 0f285b694..333da49a5 100644
--- a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
+++ b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
@@ -87,8 +87,8 @@ xacml.log.db.password=policy_user
xacml.att.log.timeframe=150
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user