aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LogParser/pom.xml13
-rw-r--r--ONAP-PAP-REST/pom.xml9
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java4
-rw-r--r--ONAP-PAP-REST/src/main/resources/META-INF/generatedCreate.ddl119
-rw-r--r--ONAP-PAP-REST/src/main/resources/META-INF/generatedDrop.ddl118
-rw-r--r--ONAP-PAP-REST/src/main/resources/META-INF/persistence.xml4
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java161
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/resources/xacml.pap.properties161
-rw-r--r--ONAP-PDP-REST/pom.xml13
-rw-r--r--ONAP-SDK-APP/src/main/webapp/static/fusion/sample/js/jquery.flexslider-min.js5
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java42
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java20
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java25
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java40
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java64
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java29
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java47
-rw-r--r--POLICY-SDK-APP/src/test/resources/xacml.admin.properties203
-rw-r--r--PolicyEngineUtils/pom.xml11
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java4
27 files changed, 799 insertions, 309 deletions
diff --git a/LogParser/pom.xml b/LogParser/pom.xml
index d8cef1745..b638faf21 100644
--- a/LogParser/pom.xml
+++ b/LogParser/pom.xml
@@ -36,16 +36,11 @@
<artifactId>h2</artifactId>
<version>1.4.193</version>
</dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.30</version>
- </dependency>
<dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <version>1.2.3</version>
- </dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.1.1</version>
+ </dependency>
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>ONAP-Logging</artifactId>
diff --git a/ONAP-PAP-REST/pom.xml b/ONAP-PAP-REST/pom.xml
index dc9499276..d2d84db3d 100644
--- a/ONAP-PAP-REST/pom.xml
+++ b/ONAP-PAP-REST/pom.xml
@@ -207,12 +207,11 @@
<artifactId>eclipselink</artifactId>
<version>2.6.0</version>
</dependency>
-
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.30</version>
- </dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.1.1</version>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
index 7c46990ab..483418c59 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -2156,7 +2156,7 @@ public class PolicyDBDao {
String prefix = null;
if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
- prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.indexOf(policy.policyAdapter.getPolicyName()));
+ prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.lastIndexOf(policy.policyAdapter.getPolicyName()));
if(isNullOrEmpty(policy.policyAdapter.getConfigBodyData())){
String configData = "";
try{
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
index e6514469c..5d2b7f6c7 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
@@ -448,4 +448,8 @@ public class CommonClassDaoImpl implements CommonClassDao{
return null;
}
+ public static void setSessionfactory(SessionFactory sessionfactory) {
+ sessionFactory = sessionfactory;
+ }
+
} \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/main/resources/META-INF/generatedCreate.ddl b/ONAP-PAP-REST/src/main/resources/META-INF/generatedCreate.ddl
deleted file mode 100644
index c12949aed..000000000
--- a/ONAP-PAP-REST/src/main/resources/META-INF/generatedCreate.ddl
+++ /dev/null
@@ -1,119 +0,0 @@
-CREATE TABLE PolicyEntity (policyId BIGINT NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP, deleted BOOLEAN NOT NULL, description VARCHAR(2048) NOT NULL, modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, policyData TEXT, policyName VARCHAR(255) NOT NULL, policyVersion INTEGER, scope VARCHAR(255) NOT NULL, version INTEGER, actionBodyId BIGINT, configurationDataId BIGINT, PRIMARY KEY (policyId))
-CREATE TABLE ConfigurationDataEntity (configurationDataId BIGINT NOT NULL, configBody TEXT, configType VARCHAR(255) NOT NULL, configurationName VARCHAR(255) NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP, deleted BOOLEAN NOT NULL, description VARCHAR(2048) NOT NULL, modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, version INTEGER, PRIMARY KEY (configurationDataId))
-CREATE TABLE PolicyDBDaoEntity (policyDBDaoUrl VARCHAR NOT NULL, created_date TIMESTAMP, description VARCHAR(2048) NOT NULL, modified_date TIMESTAMP NOT NULL, password VARCHAR, username VARCHAR, PRIMARY KEY (policyDBDaoUrl))
-CREATE TABLE GroupEntity (groupKey BIGINT NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP, defaultGroup BOOLEAN NOT NULL, deleted BOOLEAN NOT NULL, description VARCHAR(2048) NOT NULL, groupId VARCHAR NOT NULL, groupName VARCHAR(255) NOT NULL, modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, version INTEGER, PRIMARY KEY (groupKey))
-CREATE TABLE PdpEntity (pdpKey BIGINT NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP, deleted BOOLEAN NOT NULL, description VARCHAR(2048) NOT NULL, jmxPort INTEGER NOT NULL, modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, pdpId VARCHAR(255) NOT NULL, pdpName VARCHAR(255) NOT NULL, groupKey BIGINT, PRIMARY KEY (pdpKey))
-CREATE TABLE ActionBodyEntity (actionBodyId BIGINT NOT NULL, actionBody TEXT, actionBodyName VARCHAR(255) NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP, deleted BOOLEAN NOT NULL, modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, version INTEGER, PRIMARY KEY (actionBodyId))
-CREATE TABLE DatabaseLockEntity (lock_key INTEGER NOT NULL, PRIMARY KEY (lock_key))
-CREATE TABLE PolicyVersion (id INTEGER NOT NULL, ACTIVE_VERSION INTEGER, CREATED_BY VARCHAR(45) NOT NULL, created_date TIMESTAMP NOT NULL, HIGHEST_VERSION INTEGER, modified_by VARCHAR(45) NOT NULL, modified_date TIMESTAMP NOT NULL, POLICY_NAME VARCHAR(255) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE POLICYSCORE (id INTEGER NOT NULL, POLICY_NAME VARCHAR NOT NULL, POLICY_SCORE VARCHAR, VERSIONEXTENSION VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE FunctionDefinition (id INTEGER NOT NULL, arg_lb INTEGER NOT NULL, arg_ub INTEGER NOT NULL, ho_arg_lb INTEGER, ho_arg_ub INTEGER, ho_primitive CHAR, is_bag_return INTEGER NOT NULL, is_higher_order INTEGER NOT NULL, short_name VARCHAR(64) NOT NULL, xacml_id VARCHAR(255) NOT NULL, return_datatype INTEGER, PRIMARY KEY (id))
-CREATE TABLE Attribute (id INTEGER NOT NULL, ATTRIBUTE_VALUE VARCHAR, created_date TIMESTAMP, description VARCHAR(2048), is_designator CHAR NOT NULL, modified_date TIMESTAMP NOT NULL, PRIORITY VARCHAR, selector_path VARCHAR(2048), xacml_id VARCHAR NOT NULL UNIQUE, category INTEGER, constraint_type INTEGER, datatype INTEGER, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE Category (id INTEGER NOT NULL, grouping VARCHAR(64) NOT NULL, is_standard CHAR NOT NULL, short_name VARCHAR(64) NOT NULL, xacml_id VARCHAR(255) NOT NULL UNIQUE, PRIMARY KEY (id))
-CREATE TABLE ConstraintType (id INTEGER NOT NULL, constraint_type VARCHAR(64) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE ConstraintValues (id INTEGER NOT NULL, property VARCHAR, value VARCHAR, attribute_id INTEGER, PRIMARY KEY (id))
-CREATE TABLE Datatype (id INTEGER NOT NULL, is_standard CHAR NOT NULL, short_name VARCHAR(64) NOT NULL, xacml_id VARCHAR(255) NOT NULL UNIQUE, PRIMARY KEY (id))
-CREATE TABLE FunctionArguments (id INTEGER NOT NULL, arg_index INTEGER NOT NULL, is_bag INTEGER NOT NULL, datatype_id INTEGER, function_id INTEGER, PRIMARY KEY (id))
-CREATE TABLE UserInfo (loginid VARCHAR(45) NOT NULL, name VARCHAR NOT NULL UNIQUE, PRIMARY KEY (loginid))
-CREATE TABLE ActionPolicyDict (id INTEGER NOT NULL, ATTRIBUTE_NAME VARCHAR NOT NULL, Body VARCHAR, created_date TIMESTAMP, description VARCHAR(2048), Headers VARCHAR, Method VARCHAR NOT NULL, modified_date TIMESTAMP NOT NULL, Type VARCHAR NOT NULL, URL VARCHAR NOT NULL, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE DecisionSettings (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, PRIORITY VARCHAR, xacml_id VARCHAR NOT NULL UNIQUE, datatype INTEGER, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE MicroServiceModels (id INTEGER NOT NULL, annotation VARCHAR(2000) NOT NULL, attributes VARCHAR(255) NOT NULL, dependency VARCHAR(2048), description VARCHAR(2048), enumValues VARCHAR(2000) NOT NULL, modelName VARCHAR NOT NULL UNIQUE, ref_attributes VARCHAR(255) NOT NULL, sub_attributes VARCHAR(2000) NOT NULL, version VARCHAR(2000) NOT NULL, imported_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE actionlist (id INTEGER NOT NULL, actionname VARCHAR NOT NULL, description VARCHAR, PRIMARY KEY (id))
-CREATE TABLE AddressGroup (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, prefixlist VARCHAR, PRIMARY KEY (id))
-CREATE TABLE AttributeAssignment (id INTEGER NOT NULL, attribute_id INTEGER, expression VARCHAR NOT NULL, OBADVICE_id INTEGER, PRIMARY KEY (id))
-CREATE TABLE BRMSParamTemplate (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), rule LONGVARCHAR NOT NULL, param_template_name VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE ClosedLoopD2Services (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, service_Name VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE ClosedLoopSite (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, site_Name VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE DCAEUsers (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE DCAEuuid (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE DescriptiveScope (Id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), scopename VARCHAR NOT NULL, modified_date TIMESTAMP NOT NULL, search VARCHAR, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (Id))
-CREATE TABLE OnapName (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, onap_Name VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE EnforcingType (id INTEGER NOT NULL, connectionQuery VARCHAR(255) NOT NULL, enforcingType VARCHAR NOT NULL UNIQUE, script VARCHAR(255) NOT NULL, valueQuery VARCHAR(255) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE GlobalRoleSettings (role VARCHAR(45) NOT NULL, lockdown BOOLEAN, PRIMARY KEY (role))
-CREATE TABLE GroupPolicyScopeList (id INTEGER NOT NULL, description VARCHAR, groupList VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE GroupServiceList (id INTEGER NOT NULL, name VARCHAR NOT NULL, serviceList VARCHAR, PRIMARY KEY (id))
-CREATE TABLE MicroServiceConfigName (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE MicroServiceLocation (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE Obadvice (id INTEGER NOT NULL, created_by VARCHAR(255) NOT NULL, created_date TIMESTAMP NOT NULL, description VARCHAR(2048), fulfill_on VARCHAR(32), modified_by VARCHAR(255) NOT NULL, modified_date TIMESTAMP NOT NULL, type VARCHAR NOT NULL, xacml_id VARCHAR(255) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE ObadviceExpressions (id INTEGER NOT NULL, type VARCHAR NOT NULL, obadvice_id INTEGER, attribute_id INTEGER, PRIMARY KEY (id))
-CREATE TABLE PEPOptions (Id INTEGER NOT NULL, Actions VARCHAR, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, PEP_NAME VARCHAR NOT NULL, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (Id))
-CREATE TABLE PIPConfigParams (id INTEGER NOT NULL, PARAM_DEFAULT VARCHAR(2048), PARAM_NAME VARCHAR(1024) NOT NULL, PARAM_VALUE VARCHAR(2048) NOT NULL, REQUIRED CHAR NOT NULL, PIP_ID INTEGER, PRIMARY KEY (id))
-CREATE TABLE PIPConfiguration (id INTEGER NOT NULL, CLASSNAME VARCHAR(2048) NOT NULL, CREATED_BY VARCHAR(255) NOT NULL, CREATED_DATE TIMESTAMP NOT NULL, DESCRIPTION VARCHAR(2048), ISSUER VARCHAR(1024), MODIFIED_BY VARCHAR(255) NOT NULL, MODIFIED_DATE TIMESTAMP NOT NULL, NAME VARCHAR(255) NOT NULL, READ_ONLY CHAR NOT NULL, REQUIRES_RESOLVER CHAR NOT NULL, TYPE INTEGER, PRIMARY KEY (id))
-CREATE TABLE PIPResolver (id INTEGER NOT NULL, CLASSNAME VARCHAR(2048) NOT NULL, CREATED_BY VARCHAR(255) NOT NULL, CREATED_DATE TIMESTAMP NOT NULL, DESCRIPTION VARCHAR(2048), ISSUER VARCHAR(1024), MODIFIED_BY VARCHAR(255) NOT NULL, MODIFIED_DATE TIMESTAMP NOT NULL, NAME VARCHAR(255) NOT NULL, READ_ONLY CHAR NOT NULL, PIP_ID INTEGER, PRIMARY KEY (id))
-CREATE TABLE PIPResolverParams (id INTEGER NOT NULL, PARAM_DEFAULT VARCHAR(2048), PARAM_NAME VARCHAR(1024) NOT NULL, PARAM_VALUE VARCHAR(2048) NOT NULL, REQUIRED CHAR NOT NULL, ID_RESOLVER INTEGER, PRIMARY KEY (id))
-CREATE TABLE PIPType (id INTEGER NOT NULL, type VARCHAR(45) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE PolicyAlgorithms (id INTEGER NOT NULL, is_standard CHAR NOT NULL, short_name VARCHAR(64) NOT NULL, xacml_id VARCHAR(255) NOT NULL UNIQUE, PRIMARY KEY (id))
-CREATE TABLE policy_manangement (id INTEGER NOT NULL, CONFIG_NAME VARCHAR(45) NOT NULL, CREATE_DATE_TIME TIMESTAMP NOT NULL, CREATED_BY VARCHAR(45) NOT NULL, ONAP_NAME VARCHAR(45) NOT NULL, POLICY_NAME VARCHAR(45) NOT NULL, scope VARCHAR(45) NOT NULL, UPDATE_DATE_TIME TIMESTAMP NOT NULL, UPDATED_BY VARCHAR(45) NOT NULL, XML CLOB NOT NULL, PRIMARY KEY (id))
-CREATE TABLE PolicyScopeService (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE PolicyScopeType (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE PolicyScopeResource (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE PolicyScopeClosedLoop (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE portlist (id INTEGER NOT NULL, description VARCHAR, portname VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE protocollist (id INTEGER NOT NULL, description VARCHAR, protocolname VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE RemoteCatalogValues (id INTEGER NOT NULL, name VARCHAR NOT NULL, value VARCHAR, PRIMARY KEY (id))
-CREATE TABLE roles (id INTEGER NOT NULL, role VARCHAR(45) NOT NULL, scope VARCHAR(45), loginid VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE RuleAlgorithms (id INTEGER NOT NULL, is_standard CHAR NOT NULL, short_name VARCHAR(64) NOT NULL, xacml_id VARCHAR(255) NOT NULL UNIQUE, PRIMARY KEY (id))
-CREATE TABLE securityzone (id INTEGER NOT NULL, name VARCHAR NOT NULL, value VARCHAR, PRIMARY KEY (id))
-CREATE TABLE servicegroup (id INTEGER NOT NULL, appprotocol VARCHAR, description VARCHAR, name VARCHAR NOT NULL, ports VARCHAR, transportprotocol VARCHAR, type VARCHAR, PRIMARY KEY (id))
-CREATE TABLE SystemLogDB (id INTEGER NOT NULL, date TIMESTAMP NOT NULL, description VARCHAR(2048), logtype VARCHAR(255) NOT NULL, remote VARCHAR(255) NOT NULL, system VARCHAR(255) NOT NULL, type VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE TERM (id INTEGER NOT NULL, action VARCHAR, created_date TIMESTAMP, destIPList VARCHAR, destPortList VARCHAR, fromzone VARCHAR, modified_date TIMESTAMP NOT NULL, portList VARCHAR, protocolList VARCHAR, srcIPList VARCHAR, srcPortList VARCHAR, description VARCHAR, termName VARCHAR NOT NULL, tozone VARCHAR, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE VarbindDictionary (Id INTEGER NOT NULL, created_date TIMESTAMP, modified_date TIMESTAMP NOT NULL, varbind_Description VARCHAR(2048), varbind_Name VARCHAR NOT NULL UNIQUE, varbind_oid VARCHAR NOT NULL, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (Id))
-CREATE TABLE VMType (id INTEGER NOT NULL, description VARCHAR, name VARCHAR NOT NULL, PRIMARY KEY (id))
-CREATE TABLE VNFType (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, vnf_type VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE VSCLAction (id INTEGER NOT NULL, created_date TIMESTAMP, description VARCHAR(2048), modified_date TIMESTAMP NOT NULL, vscl_action VARCHAR NOT NULL UNIQUE, created_by VARCHAR(45), modified_by VARCHAR(45), PRIMARY KEY (id))
-CREATE TABLE zone (id INTEGER NOT NULL, zonename VARCHAR NOT NULL, zonevalue VARCHAR, PRIMARY KEY (id))
-CREATE TABLE BackUpMonitorEntity (id INTEGER NOT NULL, flag VARCHAR NOT NULL, notification_record LONGVARCHAR, resource_name VARCHAR NOT NULL UNIQUE, node_name VARCHAR NOT NULL, last_seen TIMESTAMP, PRIMARY KEY (id))
-CREATE TABLE StateManagementEntity (id BIGINT NOT NULL, adminState VARCHAR(20) NOT NULL, availStatus VARCHAR(20) NOT NULL, created_Date TIMESTAMP, modifiedDate TIMESTAMP NOT NULL, opState VARCHAR(20) NOT NULL, resourceName VARCHAR(100) NOT NULL UNIQUE, standbyStatus VARCHAR(20) NOT NULL, PRIMARY KEY (id))
-CREATE TABLE ForwardProgressEntity (forwardProgressId BIGINT NOT NULL, created_date TIMESTAMP, fpc_count BIGINT NOT NULL, last_updated TIMESTAMP, resourceName VARCHAR(100) NOT NULL UNIQUE, PRIMARY KEY (forwardProgressId))
-CREATE TABLE ResourceRegistrationEntity (ResourceRegistrationId BIGINT NOT NULL, created_date TIMESTAMP, last_updated TIMESTAMP, nodeType VARCHAR(50), resourceName VARCHAR(100) NOT NULL UNIQUE, resourceUrl VARCHAR(255) NOT NULL UNIQUE, site VARCHAR(50), PRIMARY KEY (ResourceRegistrationId))
-CREATE TABLE IntegrityAuditEntity (id BIGINT NOT NULL, createdDate TIMESTAMP, designated BOOLEAN, jdbcDriver VARCHAR NOT NULL, jdbcPassword VARCHAR NOT NULL, jdbcUrl VARCHAR NOT NULL, jdbcUser VARCHAR NOT NULL, lastUpdated TIMESTAMP, nodeType VARCHAR, persistenceUnit VARCHAR NOT NULL, resourceName VARCHAR NOT NULL UNIQUE, site VARCHAR, PRIMARY KEY (id))
-CREATE TABLE PolicyGroupEntity (groupKey BIGINT NOT NULL, policyId BIGINT NOT NULL, PRIMARY KEY (groupKey, policyId))
-ALTER TABLE PolicyEntity ADD CONSTRAINT FK_PolicyEntity_configurationDataId FOREIGN KEY (configurationDataId) REFERENCES ConfigurationDataEntity (configurationDataId)
-ALTER TABLE PolicyEntity ADD CONSTRAINT FK_PolicyEntity_actionBodyId FOREIGN KEY (actionBodyId) REFERENCES ActionBodyEntity (actionBodyId)
-ALTER TABLE PdpEntity ADD CONSTRAINT FK_PdpEntity_groupKey FOREIGN KEY (groupKey) REFERENCES GroupEntity (groupKey)
-ALTER TABLE FunctionDefinition ADD CONSTRAINT FK_FunctionDefinition_return_datatype FOREIGN KEY (return_datatype) REFERENCES Datatype (id)
-ALTER TABLE Attribute ADD CONSTRAINT FK_Attribute_category FOREIGN KEY (category) REFERENCES Category (id)
-ALTER TABLE Attribute ADD CONSTRAINT FK_Attribute_constraint_type FOREIGN KEY (constraint_type) REFERENCES ConstraintType (id)
-ALTER TABLE Attribute ADD CONSTRAINT FK_Attribute_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE Attribute ADD CONSTRAINT FK_Attribute_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE Attribute ADD CONSTRAINT FK_Attribute_datatype FOREIGN KEY (datatype) REFERENCES Datatype (id)
-ALTER TABLE ConstraintValues ADD CONSTRAINT FK_ConstraintValues_attribute_id FOREIGN KEY (attribute_id) REFERENCES Attribute (id)
-ALTER TABLE FunctionArguments ADD CONSTRAINT FK_FunctionArguments_function_id FOREIGN KEY (function_id) REFERENCES FunctionDefinition (id)
-ALTER TABLE FunctionArguments ADD CONSTRAINT FK_FunctionArguments_datatype_id FOREIGN KEY (datatype_id) REFERENCES Datatype (id)
-ALTER TABLE ActionPolicyDict ADD CONSTRAINT FK_ActionPolicyDict_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ActionPolicyDict ADD CONSTRAINT FK_ActionPolicyDict_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE DecisionSettings ADD CONSTRAINT FK_DecisionSettings_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE DecisionSettings ADD CONSTRAINT FK_DecisionSettings_datatype FOREIGN KEY (datatype) REFERENCES Datatype (id)
-ALTER TABLE DecisionSettings ADD CONSTRAINT FK_DecisionSettings_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE MicroServiceModels ADD CONSTRAINT FK_MicroServiceModels_imported_by FOREIGN KEY (imported_by) REFERENCES UserInfo (loginid)
-ALTER TABLE AttributeAssignment ADD CONSTRAINT FK_AttributeAssignment_OBADVICE_id FOREIGN KEY (OBADVICE_id) REFERENCES Obadvice (id)
-ALTER TABLE BRMSParamTemplate ADD CONSTRAINT FK_BRMSParamTemplate_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ClosedLoopD2Services ADD CONSTRAINT FK_ClosedLoopD2Services_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ClosedLoopD2Services ADD CONSTRAINT FK_ClosedLoopD2Services_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ClosedLoopSite ADD CONSTRAINT FK_ClosedLoopSite_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ClosedLoopSite ADD CONSTRAINT FK_ClosedLoopSite_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE DescriptiveScope ADD CONSTRAINT FK_DescriptiveScope_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE DescriptiveScope ADD CONSTRAINT FK_DescriptiveScope_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE OnapName ADD CONSTRAINT FK_OnapName_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE OnapName ADD CONSTRAINT FK_OnapName_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE ObadviceExpressions ADD CONSTRAINT FK_ObadviceExpressions_obadvice_id FOREIGN KEY (obadvice_id) REFERENCES Obadvice (id)
-ALTER TABLE ObadviceExpressions ADD CONSTRAINT FK_ObadviceExpressions_attribute_id FOREIGN KEY (attribute_id) REFERENCES Attribute (id)
-ALTER TABLE PEPOptions ADD CONSTRAINT FK_PEPOptions_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE PEPOptions ADD CONSTRAINT FK_PEPOptions_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE PIPConfigParams ADD CONSTRAINT FK_PIPConfigParams_PIP_ID FOREIGN KEY (PIP_ID) REFERENCES PIPConfiguration (id)
-ALTER TABLE PIPConfiguration ADD CONSTRAINT FK_PIPConfiguration_TYPE FOREIGN KEY (TYPE) REFERENCES PIPType (id)
-ALTER TABLE PIPResolver ADD CONSTRAINT FK_PIPResolver_PIP_ID FOREIGN KEY (PIP_ID) REFERENCES PIPConfiguration (id)
-ALTER TABLE PIPResolverParams ADD CONSTRAINT FK_PIPResolverParams_ID_RESOLVER FOREIGN KEY (ID_RESOLVER) REFERENCES PIPResolver (id)
-ALTER TABLE roles ADD CONSTRAINT FK_roles_loginid FOREIGN KEY (loginid) REFERENCES UserInfo (loginid)
-ALTER TABLE TERM ADD CONSTRAINT FK_TERM_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE TERM ADD CONSTRAINT FK_TERM_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VarbindDictionary ADD CONSTRAINT FK_VarbindDictionary_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VarbindDictionary ADD CONSTRAINT FK_VarbindDictionary_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VNFType ADD CONSTRAINT FK_VNFType_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VNFType ADD CONSTRAINT FK_VNFType_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VSCLAction ADD CONSTRAINT FK_VSCLAction_modified_by FOREIGN KEY (modified_by) REFERENCES UserInfo (loginid)
-ALTER TABLE VSCLAction ADD CONSTRAINT FK_VSCLAction_created_by FOREIGN KEY (created_by) REFERENCES UserInfo (loginid)
-ALTER TABLE PolicyGroupEntity ADD CONSTRAINT FK_PolicyGroupEntity_policyId FOREIGN KEY (policyId) REFERENCES PolicyEntity (policyId)
-ALTER TABLE PolicyGroupEntity ADD CONSTRAINT FK_PolicyGroupEntity_groupKey FOREIGN KEY (groupKey) REFERENCES GroupEntity (groupKey)
-CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMERIC(38), PRIMARY KEY (SEQ_NAME))
-INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)
diff --git a/ONAP-PAP-REST/src/main/resources/META-INF/generatedDrop.ddl b/ONAP-PAP-REST/src/main/resources/META-INF/generatedDrop.ddl
deleted file mode 100644
index ce1769a4d..000000000
--- a/ONAP-PAP-REST/src/main/resources/META-INF/generatedDrop.ddl
+++ /dev/null
@@ -1,118 +0,0 @@
-ALTER TABLE PolicyEntity DROP CONSTRAINT FK_PolicyEntity_configurationDataId
-ALTER TABLE PolicyEntity DROP CONSTRAINT FK_PolicyEntity_actionBodyId
-ALTER TABLE PdpEntity DROP CONSTRAINT FK_PdpEntity_groupKey
-ALTER TABLE FunctionDefinition DROP CONSTRAINT FK_FunctionDefinition_return_datatype
-ALTER TABLE Attribute DROP CONSTRAINT FK_Attribute_category
-ALTER TABLE Attribute DROP CONSTRAINT FK_Attribute_constraint_type
-ALTER TABLE Attribute DROP CONSTRAINT FK_Attribute_created_by
-ALTER TABLE Attribute DROP CONSTRAINT FK_Attribute_modified_by
-ALTER TABLE Attribute DROP CONSTRAINT FK_Attribute_datatype
-ALTER TABLE ConstraintValues DROP CONSTRAINT FK_ConstraintValues_attribute_id
-ALTER TABLE FunctionArguments DROP CONSTRAINT FK_FunctionArguments_function_id
-ALTER TABLE FunctionArguments DROP CONSTRAINT FK_FunctionArguments_datatype_id
-ALTER TABLE ActionPolicyDict DROP CONSTRAINT FK_ActionPolicyDict_modified_by
-ALTER TABLE ActionPolicyDict DROP CONSTRAINT FK_ActionPolicyDict_created_by
-ALTER TABLE DecisionSettings DROP CONSTRAINT FK_DecisionSettings_created_by
-ALTER TABLE DecisionSettings DROP CONSTRAINT FK_DecisionSettings_datatype
-ALTER TABLE DecisionSettings DROP CONSTRAINT FK_DecisionSettings_modified_by
-ALTER TABLE MicroServiceModels DROP CONSTRAINT FK_MicroServiceModels_imported_by
-ALTER TABLE AttributeAssignment DROP CONSTRAINT FK_AttributeAssignment_OBADVICE_id
-ALTER TABLE BRMSParamTemplate DROP CONSTRAINT FK_BRMSParamTemplate_created_by
-ALTER TABLE ClosedLoopD2Services DROP CONSTRAINT FK_ClosedLoopD2Services_modified_by
-ALTER TABLE ClosedLoopD2Services DROP CONSTRAINT FK_ClosedLoopD2Services_created_by
-ALTER TABLE ClosedLoopSite DROP CONSTRAINT FK_ClosedLoopSite_modified_by
-ALTER TABLE ClosedLoopSite DROP CONSTRAINT FK_ClosedLoopSite_created_by
-ALTER TABLE DescriptiveScope DROP CONSTRAINT FK_DescriptiveScope_created_by
-ALTER TABLE DescriptiveScope DROP CONSTRAINT FK_DescriptiveScope_modified_by
-ALTER TABLE OnapName DROP CONSTRAINT FK_OnapName_modified_by
-ALTER TABLE OnapName DROP CONSTRAINT FK_OnapName_created_by
-ALTER TABLE ObadviceExpressions DROP CONSTRAINT FK_ObadviceExpressions_obadvice_id
-ALTER TABLE ObadviceExpressions DROP CONSTRAINT FK_ObadviceExpressions_attribute_id
-ALTER TABLE PEPOptions DROP CONSTRAINT FK_PEPOptions_modified_by
-ALTER TABLE PEPOptions DROP CONSTRAINT FK_PEPOptions_created_by
-ALTER TABLE PIPConfigParams DROP CONSTRAINT FK_PIPConfigParams_PIP_ID
-ALTER TABLE PIPConfiguration DROP CONSTRAINT FK_PIPConfiguration_TYPE
-ALTER TABLE PIPResolver DROP CONSTRAINT FK_PIPResolver_PIP_ID
-ALTER TABLE PIPResolverParams DROP CONSTRAINT FK_PIPResolverParams_ID_RESOLVER
-ALTER TABLE roles DROP CONSTRAINT FK_roles_loginid
-ALTER TABLE TERM DROP CONSTRAINT FK_TERM_modified_by
-ALTER TABLE TERM DROP CONSTRAINT FK_TERM_created_by
-ALTER TABLE VarbindDictionary DROP CONSTRAINT FK_VarbindDictionary_modified_by
-ALTER TABLE VarbindDictionary DROP CONSTRAINT FK_VarbindDictionary_created_by
-ALTER TABLE VNFType DROP CONSTRAINT FK_VNFType_modified_by
-ALTER TABLE VNFType DROP CONSTRAINT FK_VNFType_created_by
-ALTER TABLE VSCLAction DROP CONSTRAINT FK_VSCLAction_modified_by
-ALTER TABLE VSCLAction DROP CONSTRAINT FK_VSCLAction_created_by
-ALTER TABLE PolicyGroupEntity DROP CONSTRAINT FK_PolicyGroupEntity_policyId
-ALTER TABLE PolicyGroupEntity DROP CONSTRAINT FK_PolicyGroupEntity_groupKey
-DROP TABLE PolicyEntity
-DROP TABLE ConfigurationDataEntity
-DROP TABLE PolicyDBDaoEntity
-DROP TABLE GroupEntity
-DROP TABLE PdpEntity
-DROP TABLE ActionBodyEntity
-DROP TABLE DatabaseLockEntity
-DROP TABLE PolicyVersion
-DROP TABLE POLICYSCORE
-DROP TABLE FunctionDefinition
-DROP TABLE Attribute
-DROP TABLE Category
-DROP TABLE ConstraintType
-DROP TABLE ConstraintValues
-DROP TABLE Datatype
-DROP TABLE FunctionArguments
-DROP TABLE UserInfo
-DROP TABLE ActionPolicyDict
-DROP TABLE DecisionSettings
-DROP TABLE MicroServiceModels
-DROP TABLE actionlist
-DROP TABLE AddressGroup
-DROP TABLE AttributeAssignment
-DROP TABLE BRMSParamTemplate
-DROP TABLE ClosedLoopD2Services
-DROP TABLE ClosedLoopSite
-DROP TABLE DCAEUsers
-DROP TABLE DCAEuuid
-DROP TABLE DescriptiveScope
-DROP TABLE OnapName
-DROP TABLE EnforcingType
-DROP TABLE GlobalRoleSettings
-DROP TABLE GroupPolicyScopeList
-DROP TABLE GroupServiceList
-DROP TABLE MicroServiceConfigName
-DROP TABLE MicroServiceLocation
-DROP TABLE Obadvice
-DROP TABLE ObadviceExpressions
-DROP TABLE PEPOptions
-DROP TABLE PIPConfigParams
-DROP TABLE PIPConfiguration
-DROP TABLE PIPResolver
-DROP TABLE PIPResolverParams
-DROP TABLE PIPType
-DROP TABLE PolicyAlgorithms
-DROP TABLE policy_manangement
-DROP TABLE PolicyScopeService
-DROP TABLE PolicyScopeType
-DROP TABLE PolicyScopeResource
-DROP TABLE PolicyScopeClosedLoop
-DROP TABLE portlist
-DROP TABLE protocollist
-DROP TABLE RemoteCatalogValues
-DROP TABLE roles
-DROP TABLE RuleAlgorithms
-DROP TABLE securityzone
-DROP TABLE servicegroup
-DROP TABLE SystemLogDB
-DROP TABLE TERM
-DROP TABLE VarbindDictionary
-DROP TABLE VMType
-DROP TABLE VNFType
-DROP TABLE VSCLAction
-DROP TABLE zone
-DROP TABLE BackUpMonitorEntity
-DROP TABLE StateManagementEntity
-DROP TABLE ForwardProgressEntity
-DROP TABLE ResourceRegistrationEntity
-DROP TABLE IntegrityAuditEntity
-DROP TABLE PolicyGroupEntity
-DELETE FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN'
diff --git a/ONAP-PAP-REST/src/main/resources/META-INF/persistence.xml b/ONAP-PAP-REST/src/main/resources/META-INF/persistence.xml
index b0a76c40a..7be95014d 100644
--- a/ONAP-PAP-REST/src/main/resources/META-INF/persistence.xml
+++ b/ONAP-PAP-REST/src/main/resources/META-INF/persistence.xml
@@ -190,8 +190,8 @@
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
- <property name="javax.persistence.schema-generation.scripts.create-target" value="./src/main/resources/META-INF/generatedCreate.ddl"/>
- <property name="javax.persistence.schema-generation.scripts.drop-target" value="./src/main/resources/META-INF/generatedDrop.ddl"/>
+ <property name="javax.persistence.schema-generation.scripts.create-target" value="./src/test/resources/generatedCreate.ddl"/>
+ <property name="javax.persistence.schema-generation.scripts.drop-target" value="./src/test/resources/generatedDrop.ddl"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.create-source" value="metadata-then-script"/>
<property name="javax.persistence.schema-generation.drop-source" value="script"/>
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
new file mode 100644
index 000000000..f110c5b6a
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
@@ -0,0 +1,161 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pap.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
+import org.hibernate.SessionFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
+import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation;
+import org.onap.policy.utils.PolicyUtils;
+import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletConfig;
+import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
+
+import com.mockrunner.mock.web.MockServletInputStream;
+
+
+public class XACMLPAPTest {
+
+ private static final String ENVIRONMENT_HEADER = "Environment";
+ private List<String> headers = new ArrayList<>();
+ private HttpServletRequest httpServletRequest;
+ private HttpServletResponse httpServletResponse;
+ private ServletOutputStream mockOutput;
+ private ServletConfig servletConfig;
+ private XACMLPapServlet pap;
+ private SessionFactory sessionFactory;
+
+ @Before
+ public void setUp() throws ServletException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
+
+ servletConfig = Mockito.mock(MockServletConfig.class);
+ System.setProperty("com.sun.management.jmxremote.port", "9993");
+ Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME"))
+ .thenReturn("src/test/resources/xacml.pap.properties");
+ pap = new XACMLPapServlet();
+ pap.init(servletConfig);
+ }
+
+ @Test
+ public void testFirwallCreatePolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ String json = "";
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Firewall Config", "test", "testDescription", "Test", false, "test", json, 0,
+ "5","default", "false", "");
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_FW_test.1.xml");
+
+ }
+
+
+
+ private void setDBDao() throws SQLException {
+ BasicDataSource dataSource = new BasicDataSource();
+ dataSource.setDriverClassName("org.h2.Driver");
+ // In-memory DB for testing
+ dataSource.setUrl("jdbc:h2:mem:test");
+ dataSource.setUsername("sa");
+ dataSource.setPassword("");
+ LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
+ sessionBuilder.scanPackages("org.onap.*", "com.*");
+
+ Properties properties = new Properties();
+ properties.put("hibernate.show_sql", "false");
+ properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
+ properties.put("hibernate.hbm2ddl.auto", "drop");
+ properties.put("hibernate.hbm2ddl.auto", "create");
+
+ sessionBuilder.addProperties(properties);
+ sessionFactory = sessionBuilder.buildSessionFactory();
+
+ // Set up dao with SessionFactory
+ CommonClassDaoImpl.setSessionfactory(sessionFactory);
+ PolicyCreation.setCommonClassDao(new CommonClassDaoImpl());
+ }
+
+ @Test
+ public void testDummy() throws ServletException, IOException {
+
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
+ mockOutput = Mockito.mock(ServletOutputStream.class);
+
+ try {
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
+ } catch (IOException e) {
+ fail();
+ }
+
+ try {
+ pap.service(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @After
+ public void destroy(){
+ if(sessionFactory!=null){
+ sessionFactory.close();
+ }
+ pap.destroy();
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
index 3adb94cd1..b93cca36d 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
@@ -57,7 +57,7 @@ public class ActionPolicyTest {
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"xacml.pap.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
dynamicRuleAlgorithmLabels.add("test");
dynamicRuleAlgorithmField1.add("testField1");
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java
index 6d1d44605..3854ab984 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicyTest.java
@@ -65,7 +65,7 @@ public class DecisionPolicyTest {
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"xacml.pap.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
policyAdapter.setPolicyName("Test.Decision_junitTest.1.xml");
policyAdapter.setPolicyDescription("testing");
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
index aed09ce61..1a97d7fad 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
@@ -54,7 +54,7 @@ public class FirewallConfigPolicyTest {
@Before
public void setUp() throws Exception {
logger.info("setup: enter");
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"xacml.pap.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
policyAdapter.setPolicyName("FWjunitTest");
policyAdapter.setPolicyDescription("test");
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
index 14afa01ca..bba2afa21 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
@@ -68,7 +68,7 @@ public class PolicyDBDaoTest {
EntityManagerFactory emf;
@Before
public void init(){
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"xacml.pap.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
emf = Persistence.createEntityManagerFactory("testPapPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
diff --git a/ONAP-PAP-REST/src/test/resources/xacml.pap.properties b/ONAP-PAP-REST/src/test/resources/xacml.pap.properties
new file mode 100644
index 000000000..f886435bf
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/xacml.pap.properties
@@ -0,0 +1,161 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP-PAP-REST
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+#=====================================================================================#
+#================The Below Properties are default, shouldn't change them==============#
+#=====================================================================================#
+#
+# This is our factory that will create our engine
+#
+xacml.PAP.papEngineFactory=org.onap.policy.xacml.std.pap.StdEngineFactory
+# Dictionary and Policy Implementation Classes Properties
+dictionary.impl.className=org.onap.policy.pap.xacml.rest.handler.DictionaryHandlerImpl
+savePolicy.impl.className=org.onap.policy.pap.xacml.rest.handler.SavePolicyHandler
+pushPolicy.impl.className=org.onap.policy.pap.xacml.rest.handler.PushPolicyHandler
+deletePolicy.impl.className=org.onap.policy.pap.xacml.rest.handler.DeleteHandler
+
+#=====================================================================================#
+#===============The Below Properties will be changed based on Environment=============#
+#=====================================================================================#
+#
+# Where we store our PAP PDP Group/Node information
+#
+xacml.pap.pdps=pdps
+#
+# Need the PAP's url (how PDPs will reach it) configured here
+# because we need it to generate the URLs of the Policy Files
+# sent to the PDPs in the configuration when the PAP is first brought up.
+# (In other cases, such as the PDP calling the PAP, we could generate this URL,
+# but for startup there is no other way to get it.)
+#
+#
+xacml.rest.pap.url=http://localhost:8070/pap/
+
+#
+# Upon startup, have the PAP servlet send latest configuration information to all
+# the PDP nodes it knows about.
+#
+xacml.rest.pap.initiate.pdp=true
+#
+# Heartbeat from PAP to PDPs
+#
+# How much time (in milliseconds) between heartbeats
+# (i.e. the time between completing the heartbeat with all PDPs and starting the next cycle)
+#
+xacml.rest.pap.heartbeat.interval=100000
+#
+# Heartbeat connection timeout (in milliseconds)
+#
+xacml.rest.pap.heartbeat.timeout=100000
+
+# new Property Please mention your PAP-REST webapps Location here.
+xacml.rest.config.webapps=src/test/resources/webapps/
+
+#Turn the audit on to synchronize the DB/file system
+#xacml.rest.pap.run.audit.flag=true
+#Turn the audit off to not synchronize the DB/file system
+#xacml.rest.pap.run.audit.flag=false
+xacml.rest.pap.run.audit.flag=true
+
+#Audit will synchronize the file system to match the contents of the DB
+#xacml.rest.pap.filesystem.audit=true
+#Audit will synchronize the DB to match the contents of the file system
+#xacml.rest.pap.filesystem.audit=false
+xacml.rest.pap.filesystem.audit=false
+xacm.xcor.required.pattern=1,1
+# id
+xacml.rest.pap.userid=testpap
+# pass
+xacml.rest.pap.password=alpha123
+# pdps file
+xacml.rest.pdp.idfile=test.properties
+
+#Properties for db access
+#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
+javax.persistence.jdbc.driver=org.h2.Driver
+javax.persistence.jdbc.url=jdbc:h2:file:./sql/xacmlTest
+javax.persistence.jdbc.user=sa
+javax.persistence.jdbc.password=
+
+#Time in ms which a Policy DB transaction will wait to get the transaction lock object
+xacml.rest.pap.transaction.waitms=500000
+
+#Policy DB transaction timeout in ms after it has obtained the transaction lock object
+xacml.rest.pap.transaction.timeoutms=500000
+
+#Policy Audit timeout in ms after it has obtained the transaction lock object
+xacml.rest.pap.audit.timeoutms=500000
+
+#controls how long the pap will wait before giving up when sending notifications to other paps
+xacml.rest.pap.notify.timeoutms=10000
+
+#the number of times an incoming policy update notification will be tried to be processed (or until it succeeds)
+xacml.rest.pap.incomingnotification.tries=4
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+
+#The name of the PAP. Must be unique across the system
+xacml.rest.pap.resource.name=site_1.pap_1
+
+#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
+
+#Interval between forward progress counter updates in seconds
+fp_monitor_interval=30
+
+#Number of forward progress counter failures before failover
+failed_counter_threshold=3
+
+#Interval in seconds between test transactions if there is no other traffic
+test_trans_interval=10
+
+#Interval in seconds between updates of the forward progress counter in the DB
+write_fpc_interval=5
+
+#Name of the site
+site_name=site_1
+
+#Node type. Can take values of: pdp-xacml, pdp-drools, pap, pap-admin, logparser, brms-gateway,
+#astra-gateway, elk-server
+node_type=pap
+
+#Dependency groups are groups of resources upon which a node operational state is dependent upon (dependency_groups).
+#Each group is a comma-separated list of resource names and groups are separated by a semicolon. A group may contain
+#one or more members.
+dependency_groups=site_1.logparser_1;site_1.adminconsole_1;site_1.elk_1
+
+# The (optional) period of time in seconds between executions of the integrity audit.
+# Value < 0 : Audit does not run (default value if property is not present = -1)
+# Value = 0 : Audit runs continuously
+# Value > 0 : The period of time in seconds between execution of the audit on a particular node
+integrity_audit_period_seconds=-1
+
+ENVIRONMENT=DEVL
+
+#
+#PolicySafetyChecker properties
+#
+#Turn safetyChecker on/off
+xacml.rest.pap.safetychecker=on
+PDP_URL1 = http://localhost:8082/pdp/, testpdp, alpha456
+CLIENT_ID=
+CLIENT_KEY=
+
+#Micro Service Model Properties
+xacml.policy.msOnapName=http://org.onap
+xacml.policy.msPolicyName=http://org.onap.policy \ No newline at end of file
diff --git a/ONAP-PDP-REST/pom.xml b/ONAP-PDP-REST/pom.xml
index 64c036a65..a2f7f7207 100644
--- a/ONAP-PDP-REST/pom.xml
+++ b/ONAP-PDP-REST/pom.xml
@@ -80,15 +80,10 @@
<version>19.0</version>
</dependency>
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.30</version>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <version>1.2.3</version>
- </dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.1.1</version>
+ </dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
diff --git a/ONAP-SDK-APP/src/main/webapp/static/fusion/sample/js/jquery.flexslider-min.js b/ONAP-SDK-APP/src/main/webapp/static/fusion/sample/js/jquery.flexslider-min.js
deleted file mode 100644
index 5ad6c3775..000000000
--- a/ONAP-SDK-APP/src/main/webapp/static/fusion/sample/js/jquery.flexslider-min.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- * jQuery FlexSlider v2.6.0
- * Copyright 2012 WooThemes
- * Contributing Author: Tyler Smith
- */!function($){var e=!0;$.flexslider=function(t,a){var n=$(t);n.vars=$.extend({},$.flexslider.defaults,a);var i=n.vars.namespace,s=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,r=("ontouchstart"in window||s||window.DocumentTouch&&document instanceof DocumentTouch)&&n.vars.touch,o="click touchend MSPointerUp keyup",l="",c,d="vertical"===n.vars.direction,u=n.vars.reverse,v=n.vars.itemWidth>0,p="fade"===n.vars.animation,m=""!==n.vars.asNavFor,f={};$.data(t,"flexslider",n),f={init:function(){n.animating=!1,n.currentSlide=parseInt(n.vars.startAt?n.vars.startAt:0,10),isNaN(n.currentSlide)&&(n.currentSlide=0),n.animatingTo=n.currentSlide,n.atEnd=0===n.currentSlide||n.currentSlide===n.last,n.containerSelector=n.vars.selector.substr(0,n.vars.selector.search(" ")),n.slides=$(n.vars.selector,n),n.container=$(n.containerSelector,n),n.count=n.slides.length,n.syncExists=$(n.vars.sync).length>0,"slide"===n.vars.animation&&(n.vars.animation="swing"),n.prop=d?"top":"marginLeft",n.args={},n.manualPause=!1,n.stopped=!1,n.started=!1,n.startTimeout=null,n.transitions=!n.vars.video&&!p&&n.vars.useCSS&&function(){var e=document.createElement("div"),t=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var a in t)if(void 0!==e.style[t[a]])return n.pfx=t[a].replace("Perspective","").toLowerCase(),n.prop="-"+n.pfx+"-transform",!0;return!1}(),n.ensureAnimationEnd="",""!==n.vars.controlsContainer&&(n.controlsContainer=$(n.vars.controlsContainer).length>0&&$(n.vars.controlsContainer)),""!==n.vars.manualControls&&(n.manualControls=$(n.vars.manualControls).length>0&&$(n.vars.manualControls)),""!==n.vars.customDirectionNav&&(n.customDirectionNav=2===$(n.vars.customDirectionNav).length&&$(n.vars.customDirectionNav)),n.vars.randomize&&(n.slides.sort(function(){return Math.round(Math.random())-.5}),n.container.empty().append(n.slides)),n.doMath(),n.setup("init"),n.vars.controlNav&&f.controlNav.setup(),n.vars.directionNav&&f.directionNav.setup(),n.vars.keyboard&&(1===$(n.containerSelector).length||n.vars.multipleKeyboard)&&$(document).bind("keyup",function(e){var t=e.keyCode;if(!n.animating&&(39===t||37===t)){var a=39===t?n.getTarget("next"):37===t?n.getTarget("prev"):!1;n.flexAnimate(a,n.vars.pauseOnAction)}}),n.vars.mousewheel&&n.bind("mousewheel",function(e,t,a,i){e.preventDefault();var s=0>t?n.getTarget("next"):n.getTarget("prev");n.flexAnimate(s,n.vars.pauseOnAction)}),n.vars.pausePlay&&f.pausePlay.setup(),n.vars.slideshow&&n.vars.pauseInvisible&&f.pauseInvisible.init(),n.vars.slideshow&&(n.vars.pauseOnHover&&n.hover(function(){n.manualPlay||n.manualPause||n.pause()},function(){n.manualPause||n.manualPlay||n.stopped||n.play()}),n.vars.pauseInvisible&&f.pauseInvisible.isHidden()||(n.vars.initDelay>0?n.startTimeout=setTimeout(n.play,n.vars.initDelay):n.play())),m&&f.asNav.setup(),r&&n.vars.touch&&f.touch(),(!p||p&&n.vars.smoothHeight)&&$(window).bind("resize orientationchange focus",f.resize),n.find("img").attr("draggable","false"),setTimeout(function(){n.vars.start(n)},200)},asNav:{setup:function(){n.asNav=!0,n.animatingTo=Math.floor(n.currentSlide/n.move),n.currentItem=n.currentSlide,n.slides.removeClass(i+"active-slide").eq(n.currentItem).addClass(i+"active-slide"),s?(t._slider=n,n.slides.each(function(){var e=this;e._gesture=new MSGesture,e._gesture.target=e,e.addEventListener("MSPointerDown",function(e){e.preventDefault(),e.currentTarget._gesture&&e.currentTarget._gesture.addPointer(e.pointerId)},!1),e.addEventListener("MSGestureTap",function(e){e.preventDefault();var t=$(this),a=t.index();$(n.vars.asNavFor).data("flexslider").animating||t.hasClass("active")||(n.direction=n.currentItem<a?"next":"prev",n.flexAnimate(a,n.vars.pauseOnAction,!1,!0,!0))})})):n.slides.on(o,function(e){e.preventDefault();var t=$(this),a=t.index(),s=t.offset().left-$(n).scrollLeft();0>=s&&t.hasClass(i+"active-slide")?n.flexAnimate(n.getTarget("prev"),!0):$(n.vars.asNavFor).data("flexslider").animating||t.hasClass(i+"active-slide")||(n.direction=n.currentItem<a?"next":"prev",n.flexAnimate(a,n.vars.pauseOnAction,!1,!0,!0))})}},controlNav:{setup:function(){n.manualControls?f.controlNav.setupManual():f.controlNav.setupPaging()},setupPaging:function(){var e="thumbnails"===n.vars.controlNav?"control-thumbs":"control-paging",t=1,a,s;if(n.controlNavScaffold=$('<ol class="'+i+"control-nav "+i+e+'"></ol>'),n.pagingCount>1)for(var r=0;r<n.pagingCount;r++){if(s=n.slides.eq(r),void 0===s.attr("data-thumb-alt")&&s.attr("data-thumb-alt",""),altText=""!==s.attr("data-thumb-alt")?altText=' alt="'+s.attr("data-thumb-alt")+'"':"",a="thumbnails"===n.vars.controlNav?'<img src="'+s.attr("data-thumb")+'"'+altText+"/>":'<a href="#">'+t+"</a>","thumbnails"===n.vars.controlNav&&!0===n.vars.thumbCaptions){var c=s.attr("data-thumbcaption");""!==c&&void 0!==c&&(a+='<span class="'+i+'caption">'+c+"</span>")}n.controlNavScaffold.append("<li>"+a+"</li>"),t++}n.controlsContainer?$(n.controlsContainer).append(n.controlNavScaffold):n.append(n.controlNavScaffold),f.controlNav.set(),f.controlNav.active(),n.controlNavScaffold.delegate("a, img",o,function(e){if(e.preventDefault(),""===l||l===e.type){var t=$(this),a=n.controlNav.index(t);t.hasClass(i+"active")||(n.direction=a>n.currentSlide?"next":"prev",n.flexAnimate(a,n.vars.pauseOnAction))}""===l&&(l=e.type),f.setToClearWatchedEvent()})},setupManual:function(){n.controlNav=n.manualControls,f.controlNav.active(),n.controlNav.bind(o,function(e){if(e.preventDefault(),""===l||l===e.type){var t=$(this),a=n.controlNav.index(t);t.hasClass(i+"active")||(a>n.currentSlide?n.direction="next":n.direction="prev",n.flexAnimate(a,n.vars.pauseOnAction))}""===l&&(l=e.type),f.setToClearWatchedEvent()})},set:function(){var e="thumbnails"===n.vars.controlNav?"img":"a";n.controlNav=$("."+i+"control-nav li "+e,n.controlsContainer?n.controlsContainer:n)},active:function(){n.controlNav.removeClass(i+"active").eq(n.animatingTo).addClass(i+"active")},update:function(e,t){n.pagingCount>1&&"add"===e?n.controlNavScaffold.append($('<li><a href="#">'+n.count+"</a></li>")):1===n.pagingCount?n.controlNavScaffold.find("li").remove():n.controlNav.eq(t).closest("li").remove(),f.controlNav.set(),n.pagingCount>1&&n.pagingCount!==n.controlNav.length?n.update(t,e):f.controlNav.active()}},directionNav:{setup:function(){var e=$('<ul class="'+i+'direction-nav"><li class="'+i+'nav-prev"><a class="'+i+'prev" href="#">'+n.vars.prevText+'</a></li><li class="'+i+'nav-next"><a class="'+i+'next" href="#">'+n.vars.nextText+"</a></li></ul>");n.customDirectionNav?n.directionNav=n.customDirectionNav:n.controlsContainer?($(n.controlsContainer).append(e),n.directionNav=$("."+i+"direction-nav li a",n.controlsContainer)):(n.append(e),n.directionNav=$("."+i+"direction-nav li a",n)),f.directionNav.update(),n.directionNav.bind(o,function(e){e.preventDefault();var t;(""===l||l===e.type)&&(t=$(this).hasClass(i+"next")?n.getTarget("next"):n.getTarget("prev"),n.flexAnimate(t,n.vars.pauseOnAction)),""===l&&(l=e.type),f.setToClearWatchedEvent()})},update:function(){var e=i+"disabled";1===n.pagingCount?n.directionNav.addClass(e).attr("tabindex","-1"):n.vars.animationLoop?n.directionNav.removeClass(e).removeAttr("tabindex"):0===n.animatingTo?n.directionNav.removeClass(e).filter("."+i+"prev").addClass(e).attr("tabindex","-1"):n.animatingTo===n.last?n.directionNav.removeClass(e).filter("."+i+"next").addClass(e).attr("tabindex","-1"):n.directionNav.removeClass(e).removeAttr("tabindex")}},pausePlay:{setup:function(){var e=$('<div class="'+i+'pauseplay"><a href="#"></a></div>');n.controlsContainer?(n.controlsContainer.append(e),n.pausePlay=$("."+i+"pauseplay a",n.controlsContainer)):(n.append(e),n.pausePlay=$("."+i+"pauseplay a",n)),f.pausePlay.update(n.vars.slideshow?i+"pause":i+"play"),n.pausePlay.bind(o,function(e){e.preventDefault(),(""===l||l===e.type)&&($(this).hasClass(i+"pause")?(n.manualPause=!0,n.manualPlay=!1,n.pause()):(n.manualPause=!1,n.manualPlay=!0,n.play())),""===l&&(l=e.type),f.setToClearWatchedEvent()})},update:function(e){"play"===e?n.pausePlay.removeClass(i+"pause").addClass(i+"play").html(n.vars.playText):n.pausePlay.removeClass(i+"play").addClass(i+"pause").html(n.vars.pauseText)}},touch:function(){function e(e){e.stopPropagation(),n.animating?e.preventDefault():(n.pause(),t._gesture.addPointer(e.pointerId),T=0,c=d?n.h:n.w,f=Number(new Date),l=v&&u&&n.animatingTo===n.last?0:v&&u?n.limit-(n.itemW+n.vars.itemMargin)*n.move*n.animatingTo:v&&n.currentSlide===n.last?n.limit:v?(n.itemW+n.vars.itemMargin)*n.move*n.currentSlide:u?(n.last-n.currentSlide+n.cloneOffset)*c:(n.currentSlide+n.cloneOffset)*c)}function a(e){e.stopPropagation();var a=e.target._slider;if(a){var n=-e.translationX,i=-e.translationY;return T+=d?i:n,m=T,x=d?Math.abs(T)<Math.abs(-n):Math.abs(T)<Math.abs(-i),e.detail===e.MSGESTURE_FLAG_INERTIA?void setImmediate(function(){t._gesture.stop()}):void((!x||Number(new Date)-f>500)&&(e.preventDefault(),!p&&a.transitions&&(a.vars.animationLoop||(m=T/(0===a.currentSlide&&0>T||a.currentSlide===a.last&&T>0?Math.abs(T)/c+2:1)),a.setProps(l+m,"setTouch"))))}}function i(e){e.stopPropagation();var t=e.target._slider;if(t){if(t.animatingTo===t.currentSlide&&!x&&null!==m){var a=u?-m:m,n=a>0?t.getTarget("next"):t.getTarget("prev");t.canAdvance(n)&&(Number(new Date)-f<550&&Math.abs(a)>50||Math.abs(a)>c/2)?t.flexAnimate(n,t.vars.pauseOnAction):p||t.flexAnimate(t.currentSlide,t.vars.pauseOnAction,!0)}r=null,o=null,m=null,l=null,T=0}}var r,o,l,c,m,f,g,h,S,x=!1,y=0,b=0,T=0;s?(t.style.msTouchAction="none",t._gesture=new MSGesture,t._gesture.target=t,t.addEventListener("MSPointerDown",e,!1),t._slider=n,t.addEventListener("MSGestureChange",a,!1),t.addEventListener("MSGestureEnd",i,!1)):(g=function(e){n.animating?e.preventDefault():(window.navigator.msPointerEnabled||1===e.touches.length)&&(n.pause(),c=d?n.h:n.w,f=Number(new Date),y=e.touches[0].pageX,b=e.touches[0].pageY,l=v&&u&&n.animatingTo===n.last?0:v&&u?n.limit-(n.itemW+n.vars.itemMargin)*n.move*n.animatingTo:v&&n.currentSlide===n.last?n.limit:v?(n.itemW+n.vars.itemMargin)*n.move*n.currentSlide:u?(n.last-n.currentSlide+n.cloneOffset)*c:(n.currentSlide+n.cloneOffset)*c,r=d?b:y,o=d?y:b,t.addEventListener("touchmove",h,!1),t.addEventListener("touchend",S,!1))},h=function(e){y=e.touches[0].pageX,b=e.touches[0].pageY,m=d?r-b:r-y,x=d?Math.abs(m)<Math.abs(y-o):Math.abs(m)<Math.abs(b-o);var t=500;(!x||Number(new Date)-f>t)&&(e.preventDefault(),!p&&n.transitions&&(n.vars.animationLoop||(m/=0===n.currentSlide&&0>m||n.currentSlide===n.last&&m>0?Math.abs(m)/c+2:1),n.setProps(l+m,"setTouch")))},S=function(e){if(t.removeEventListener("touchmove",h,!1),n.animatingTo===n.currentSlide&&!x&&null!==m){var a=u?-m:m,i=a>0?n.getTarget("next"):n.getTarget("prev");n.canAdvance(i)&&(Number(new Date)-f<550&&Math.abs(a)>50||Math.abs(a)>c/2)?n.flexAnimate(i,n.vars.pauseOnAction):p||n.flexAnimate(n.currentSlide,n.vars.pauseOnAction,!0)}t.removeEventListener("touchend",S,!1),r=null,o=null,m=null,l=null},t.addEventListener("touchstart",g,!1))},resize:function(){!n.animating&&n.is(":visible")&&(v||n.doMath(),p?f.smoothHeight():v?(n.slides.width(n.computedW),n.update(n.pagingCount),n.setProps()):d?(n.viewport.height(n.h),n.setProps(n.h,"setTotal")):(n.vars.smoothHeight&&f.smoothHeight(),n.newSlides.width(n.computedW),n.setProps(n.computedW,"setTotal")))},smoothHeight:function(e){if(!d||p){var t=p?n:n.viewport;e?t.animate({height:n.slides.eq(n.animatingTo).height()},e):t.height(n.slides.eq(n.animatingTo).height())}},sync:function(e){var t=$(n.vars.sync).data("flexslider"),a=n.animatingTo;switch(e){case"animate":t.flexAnimate(a,n.vars.pauseOnAction,!1,!0);break;case"play":t.playing||t.asNav||t.play();break;case"pause":t.pause()}},uniqueID:function(e){return e.filter("[id]").add(e.find("[id]")).each(function(){var e=$(this);e.attr("id",e.attr("id")+"_clone")}),e},pauseInvisible:{visProp:null,init:function(){var e=f.pauseInvisible.getHiddenProp();if(e){var t=e.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(t,function(){f.pauseInvisible.isHidden()?n.startTimeout?clearTimeout(n.startTimeout):n.pause():n.started?n.play():n.vars.initDelay>0?setTimeout(n.play,n.vars.initDelay):n.play()})}},isHidden:function(){var e=f.pauseInvisible.getHiddenProp();return e?document[e]:!1},getHiddenProp:function(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++)if(e[t]+"Hidden"in document)return e[t]+"Hidden";return null}},setToClearWatchedEvent:function(){clearTimeout(c),c=setTimeout(function(){l=""},3e3)}},n.flexAnimate=function(e,t,a,s,o){if(n.vars.animationLoop||e===n.currentSlide||(n.direction=e>n.currentSlide?"next":"prev"),m&&1===n.pagingCount&&(n.direction=n.currentItem<e?"next":"prev"),!n.animating&&(n.canAdvance(e,o)||a)&&n.is(":visible")){if(m&&s){var l=$(n.vars.asNavFor).data("flexslider");if(n.atEnd=0===e||e===n.count-1,l.flexAnimate(e,!0,!1,!0,o),n.direction=n.currentItem<e?"next":"prev",l.direction=n.direction,Math.ceil((e+1)/n.visible)-1===n.currentSlide||0===e)return n.currentItem=e,n.slides.removeClass(i+"active-slide").eq(e).addClass(i+"active-slide"),!1;n.currentItem=e,n.slides.removeClass(i+"active-slide").eq(e).addClass(i+"active-slide"),e=Math.floor(e/n.visible)}if(n.animating=!0,n.animatingTo=e,t&&n.pause(),n.vars.before(n),n.syncExists&&!o&&f.sync("animate"),n.vars.controlNav&&f.controlNav.active(),v||n.slides.removeClass(i+"active-slide").eq(e).addClass(i+"active-slide"),n.atEnd=0===e||e===n.last,n.vars.directionNav&&f.directionNav.update(),e===n.last&&(n.vars.end(n),n.vars.animationLoop||n.pause()),p)r?(n.slides.eq(n.currentSlide).css({opacity:0,zIndex:1}),n.slides.eq(e).css({opacity:1,zIndex:2}),n.wrapup(c)):(n.slides.eq(n.currentSlide).css({zIndex:1}).animate({opacity:0},n.vars.animationSpeed,n.vars.easing),n.slides.eq(e).css({zIndex:2}).animate({opacity:1},n.vars.animationSpeed,n.vars.easing,n.wrapup));else{var c=d?n.slides.filter(":first").height():n.computedW,g,h,S;v?(g=n.vars.itemMargin,S=(n.itemW+g)*n.move*n.animatingTo,h=S>n.limit&&1!==n.visible?n.limit:S):h=0===n.currentSlide&&e===n.count-1&&n.vars.animationLoop&&"next"!==n.direction?u?(n.count+n.cloneOffset)*c:0:n.currentSlide===n.last&&0===e&&n.vars.animationLoop&&"prev"!==n.direction?u?0:(n.count+1)*c:u?(n.count-1-e+n.cloneOffset)*c:(e+n.cloneOffset)*c,n.setProps(h,"",n.vars.animationSpeed),n.transitions?(n.vars.animationLoop&&n.atEnd||(n.animating=!1,n.currentSlide=n.animatingTo),n.container.unbind("webkitTransitionEnd transitionend"),n.container.bind("webkitTransitionEnd transitionend",function(){clearTimeout(n.ensureAnimationEnd),n.wrapup(c)}),clearTimeout(n.ensureAnimationEnd),n.ensureAnimationEnd=setTimeout(function(){n.wrapup(c)},n.vars.animationSpeed+100)):n.container.animate(n.args,n.vars.animationSpeed,n.vars.easing,function(){n.wrapup(c)})}n.vars.smoothHeight&&f.smoothHeight(n.vars.animationSpeed)}},n.wrapup=function(e){p||v||(0===n.currentSlide&&n.animatingTo===n.last&&n.vars.animationLoop?n.setProps(e,"jumpEnd"):n.currentSlide===n.last&&0===n.animatingTo&&n.vars.animationLoop&&n.setProps(e,"jumpStart")),n.animating=!1,n.currentSlide=n.animatingTo,n.vars.after(n)},n.animateSlides=function(){!n.animating&&e&&n.flexAnimate(n.getTarget("next"))},n.pause=function(){clearInterval(n.animatedSlides),n.animatedSlides=null,n.playing=!1,n.vars.pausePlay&&f.pausePlay.update("play"),n.syncExists&&f.sync("pause")},n.play=function(){n.playing&&clearInterval(n.animatedSlides),n.animatedSlides=n.animatedSlides||setInterval(n.animateSlides,n.vars.slideshowSpeed),n.started=n.playing=!0,n.vars.pausePlay&&f.pausePlay.update("pause"),n.syncExists&&f.sync("play")},n.stop=function(){n.pause(),n.stopped=!0},n.canAdvance=function(e,t){var a=m?n.pagingCount-1:n.last;return t?!0:m&&n.currentItem===n.count-1&&0===e&&"prev"===n.direction?!0:m&&0===n.currentItem&&e===n.pagingCount-1&&"next"!==n.direction?!1:e!==n.currentSlide||m?n.vars.animationLoop?!0:n.atEnd&&0===n.currentSlide&&e===a&&"next"!==n.direction?!1:n.atEnd&&n.currentSlide===a&&0===e&&"next"===n.direction?!1:!0:!1},n.getTarget=function(e){return n.direction=e,"next"===e?n.currentSlide===n.last?0:n.currentSlide+1:0===n.currentSlide?n.last:n.currentSlide-1},n.setProps=function(e,t,a){var i=function(){var a=e?e:(n.itemW+n.vars.itemMargin)*n.move*n.animatingTo,i=function(){if(v)return"setTouch"===t?e:u&&n.animatingTo===n.last?0:u?n.limit-(n.itemW+n.vars.itemMargin)*n.move*n.animatingTo:n.animatingTo===n.last?n.limit:a;switch(t){case"setTotal":return u?(n.count-1-n.currentSlide+n.cloneOffset)*e:(n.currentSlide+n.cloneOffset)*e;case"setTouch":return u?e:e;case"jumpEnd":return u?e:n.count*e;case"jumpStart":return u?n.count*e:e;default:return e}}();return-1*i+"px"}();n.transitions&&(i=d?"translate3d(0,"+i+",0)":"translate3d("+i+",0,0)",a=void 0!==a?a/1e3+"s":"0s",n.container.css("-"+n.pfx+"-transition-duration",a),n.container.css("transition-duration",a)),n.args[n.prop]=i,(n.transitions||void 0===a)&&n.container.css(n.args),n.container.css("transform",i)},n.setup=function(e){if(p)n.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===e&&(r?n.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+n.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(n.currentSlide).css({opacity:1,zIndex:2}):0==n.vars.fadeFirstSlide?n.slides.css({opacity:0,display:"block",zIndex:1}).eq(n.currentSlide).css({zIndex:2}).css({opacity:1}):n.slides.css({opacity:0,display:"block",zIndex:1}).eq(n.currentSlide).css({zIndex:2}).animate({opacity:1},n.vars.animationSpeed,n.vars.easing)),n.vars.smoothHeight&&f.smoothHeight();else{var t,a;"init"===e&&(n.viewport=$('<div class="'+i+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(n).append(n.container),n.cloneCount=0,n.cloneOffset=0,u&&(a=$.makeArray(n.slides).reverse(),n.slides=$(a),n.container.empty().append(n.slides))),n.vars.animationLoop&&!v&&(n.cloneCount=2,n.cloneOffset=1,"init"!==e&&n.container.find(".clone").remove(),n.container.append(f.uniqueID(n.slides.first().clone().addClass("clone")).attr("aria-hidden","true")).prepend(f.uniqueID(n.slides.last().clone().addClass("clone")).attr("aria-hidden","true"))),n.newSlides=$(n.vars.selector,n),t=u?n.count-1-n.currentSlide+n.cloneOffset:n.currentSlide+n.cloneOffset,d&&!v?(n.container.height(200*(n.count+n.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){n.newSlides.css({display:"block"}),n.doMath(),n.viewport.height(n.h),n.setProps(t*n.h,"init")},"init"===e?100:0)):(n.container.width(200*(n.count+n.cloneCount)+"%"),n.setProps(t*n.computedW,"init"),setTimeout(function(){n.doMath(),n.newSlides.css({width:n.computedW,marginRight:n.computedM,"float":"left",display:"block"}),n.vars.smoothHeight&&f.smoothHeight()},"init"===e?100:0))}v||n.slides.removeClass(i+"active-slide").eq(n.currentSlide).addClass(i+"active-slide"),n.vars.init(n)},n.doMath=function(){var e=n.slides.first(),t=n.vars.itemMargin,a=n.vars.minItems,i=n.vars.maxItems;n.w=void 0===n.viewport?n.width():n.viewport.width(),n.h=e.height(),n.boxPadding=e.outerWidth()-e.width(),v?(n.itemT=n.vars.itemWidth+t,n.itemM=t,n.minW=a?a*n.itemT:n.w,n.maxW=i?i*n.itemT-t:n.w,n.itemW=n.minW>n.w?(n.w-t*(a-1))/a:n.maxW<n.w?(n.w-t*(i-1))/i:n.vars.itemWidth>n.w?n.w:n.vars.itemWidth,n.visible=Math.floor(n.w/n.itemW),n.move=n.vars.move>0&&n.vars.move<n.visible?n.vars.move:n.visible,n.pagingCount=Math.ceil((n.count-n.visible)/n.move+1),n.last=n.pagingCount-1,n.limit=1===n.pagingCount?0:n.vars.itemWidth>n.w?n.itemW*(n.count-1)+t*(n.count-1):(n.itemW+t)*n.count-n.w-t):(n.itemW=n.w,n.itemM=t,n.pagingCount=n.count,n.last=n.count-1),n.computedW=n.itemW-n.boxPadding,n.computedM=n.itemM},n.update=function(e,t){n.doMath(),v||(e<n.currentSlide?n.currentSlide+=1:e<=n.currentSlide&&0!==e&&(n.currentSlide-=1),n.animatingTo=n.currentSlide),n.vars.controlNav&&!n.manualControls&&("add"===t&&!v||n.pagingCount>n.controlNav.length?f.controlNav.update("add"):("remove"===t&&!v||n.pagingCount<n.controlNav.length)&&(v&&n.currentSlide>n.last&&(n.currentSlide-=1,n.animatingTo-=1),f.controlNav.update("remove",n.last))),n.vars.directionNav&&f.directionNav.update()},n.addSlide=function(e,t){var a=$(e);n.count+=1,n.last=n.count-1,d&&u?void 0!==t?n.slides.eq(n.count-t).after(a):n.container.prepend(a):void 0!==t?n.slides.eq(t).before(a):n.container.append(a),n.update(t,"add"),n.slides=$(n.vars.selector+":not(.clone)",n),n.setup(),n.vars.added(n)},n.removeSlide=function(e){var t=isNaN(e)?n.slides.index($(e)):e;n.count-=1,n.last=n.count-1,isNaN(e)?$(e,n.slides).remove():d&&u?n.slides.eq(n.last).remove():n.slides.eq(e).remove(),n.doMath(),n.update(t,"remove"),n.slides=$(n.vars.selector+":not(.clone)",n),n.setup(),n.vars.removed(n)},f.init()},$(window).blur(function(t){e=!1}).focus(function(t){e=!0}),$.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7e3,animationSpeed:600,initDelay:0,randomize:!1,fadeFirstSlide:!0,thumbCaptions:!1,pauseOnAction:!0,pauseOnHover:!1,pauseInvisible:!0,useCSS:!0,touch:!0,video:!1,controlNav:!0,directionNav:!0,prevText:"Previous",nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",customDirectionNav:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:1,maxItems:0,move:0,allowOneSlide:!0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){},init:function(){}},$.fn.flexslider=function(e){if(void 0===e&&(e={}),"object"==typeof e)return this.each(function(){var t=$(this),a=e.selector?e.selector:".slides > li",n=t.find(a);1===n.length&&e.allowOneSlide===!0||0===n.length?(n.fadeIn(400),e.start&&e.start(t)):void 0===t.data("flexslider")&&new $.flexslider(this,e)});var t=$(this).data("flexslider");switch(e){case"play":t.play();break;case"pause":t.pause();break;case"stop":t.stop();break;case"next":t.flexAnimate(t.getTarget("next"),!0);break;case"prev":case"previous":t.flexAnimate(t.getTarget("prev"),!0);break;default:"number"==typeof e&&t.flexAnimate(e,!0)}}}(jQuery); \ No newline at end of file
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 a99d23ed5..4f42023c9 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
@@ -91,6 +91,16 @@ 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
@@ -531,7 +541,12 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
- List<Object> queryData = controller.getDataByQuery(query, peParams);
+ List<Object> queryData = null;
+ if(jUnit){
+ queryData = controller.getDataByQuery(query, null);
+ }else{
+ queryData = controller.getDataByQuery(query, peParams);
+ }
if(!queryData.isEmpty()){
PolicyEntity entity = (PolicyEntity) queryData.get(0);
File temp = null;
@@ -668,7 +683,12 @@ public class PolicyManagerServlet extends HttpServlet {
params.put("scopeName", scopeName + "%");
}
PolicyController controller = getPolicyControllerInstance();
- List<Object> scopesList = controller.getDataByQuery(scopeNamequery, params);
+ List<Object> scopesList = null;
+ if(jUnit){
+ scopesList = controller.getDataByQuery(scopeNamequery, null);
+ }else{
+ scopesList = controller.getDataByQuery(scopeNamequery, params);
+ }
return scopesList;
}
@@ -687,8 +707,15 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings params = new SimpleBindings();
params.put("scopeName", scopeName + "%");
- List<Object> activePolicies = controller.getDataByQuery(query, params);
- List<Object> scopesList = controller.getDataByQuery(scopeNamequery, params);
+ List<Object> activePolicies = null;
+ List<Object> scopesList = null;
+ if(jUnit){
+ activePolicies = controller.getDataByQuery(query, null);
+ scopesList = controller.getDataByQuery(scopeNamequery, null);
+ }else{
+ activePolicies = controller.getDataByQuery(query, params);
+ scopesList = controller.getDataByQuery(scopeNamequery, params);
+ }
for(Object list : scopesList){
PolicyEditorScopes scopeById = (PolicyEditorScopes) list;
String scope = scopeById.getScopeName();
@@ -1394,7 +1421,12 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
- List<Object> queryData = controller.getDataByQuery(query, peParams);
+ List<Object> queryData = null;
+ if(jUnit){
+ queryData = controller.getDataByQuery(query, null);
+ }else{
+ queryData = controller.getDataByQuery(query, peParams);
+ }
PolicyEntity entity = (PolicyEntity) queryData.get(0);
InputStream stream = new ByteArrayInputStream(entity.getPolicyData().getBytes(StandardCharsets.UTF_8));
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
index 65312a957..5020662c8 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
@@ -44,7 +44,7 @@ public class PolicyUserInfoController extends RestrictedBaseController{
private static final Logger LOGGER = FlexLogger.getLogger(PolicyUserInfoController.class);
@RequestMapping(value="/get_PolicyUserInfo", method = RequestMethod.GET)
- private void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response){
+ public void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response){
JsonMessage msg = null;
try {
String userId = UserUtils.getUserSession(request).getOrgUserId();
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 d70f199f0..353e08a44 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
@@ -59,5 +59,9 @@ public class HibernateSession{
public static Session getSession(){
return logSessionFactory.openSession();
}
+
+ public static void setSession(SessionFactory logSessionFactory1){
+ logSessionFactory = logSessionFactory1;
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
index eac06a7b4..321dc72d2 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
@@ -143,6 +143,17 @@ public class PolicyController extends RestrictedBaseController {
//WebApp directories
private static String configHome;
private static String actionHome;
+
+ private static boolean jUnit = false;
+
+
+ public static boolean isjUnit() {
+ return jUnit;
+ }
+
+ public static void setjUnit(boolean jUnit) {
+ PolicyController.jUnit = jUnit;
+ }
@Autowired
private PolicyController(CommonClassDao commonClassDao){
@@ -157,7 +168,12 @@ public class PolicyController extends RestrictedBaseController {
Properties prop = new Properties();
InputStream input = null;
try {
- input = new FileInputStream("xacml.admin.properties");
+ if(jUnit){
+ File file = new File(new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json");
+ input = new FileInputStream(file);
+ }else{
+ input = new FileInputStream("xacml.admin.properties");
+ }
// load a properties file
prop.load(input);
//pap url
@@ -350,7 +366,7 @@ public class PolicyController extends RestrictedBaseController {
}
public static boolean getActivePolicy(String query) {
- if(commonClassDao.getDataByQuery(query, new SimpleBindings()).size() > 0){
+ if(!commonClassDao.getDataByQuery(query, new SimpleBindings()).isEmpty()){
return true;
}else{
return false;
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 4fa64ceb3..49024ba0d 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
@@ -42,6 +42,17 @@ import org.onap.policy.common.logging.flexlogger.Logger;
@Service("SystemLogDbDao")
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() {
@@ -49,7 +60,12 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
Transaction tx = session.beginTransaction();
List<SystemLogDB> system = null;
try {
- String sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) ORDER BY date DESC limit "+PolicyController.getLogTableLimit()+"";
+ String sqlWhere = null;
+ if(jUnit){
+ sqlWhere = "";
+ }else{
+ sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) ORDER BY date DESC limit "+PolicyController.getLogTableLimit()+"";
+ }
Criteria cr = session.createCriteria(SystemLogDB.class);
cr.add(Restrictions.sqlRestriction(sqlWhere));
system = cr.list();
@@ -73,7 +89,12 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
Transaction tx = session.beginTransaction();
List<SystemLogDB> system = null;
try {
- String sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) and logtype = 'error' ORDER BY date DESC limit "+PolicyController.getSystemAlertTableLimit()+"";
+ String sqlWhere = null;
+ if(jUnit){
+ sqlWhere = "";
+ }else{
+ sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) and logtype = 'error' ORDER BY date DESC limit "+PolicyController.getSystemAlertTableLimit()+"";
+ }
Criteria cr = session.createCriteria(SystemLogDB.class);
cr.add(Restrictions.sqlRestriction(sqlWhere));
system = cr.list();
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 a034c8ae9..970b67878 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
@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.script.SimpleBindings;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -147,11 +146,12 @@ 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);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(basePolicyData);
+ String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
+ when(controller.getDataByQuery(query, null)).thenReturn(basePolicyData);
servlet.setPolicyController(controller);
servlet.doPost(request, response);
} catch (Exception e1) {
@@ -168,6 +168,7 @@ 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}}");
@@ -176,9 +177,9 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("from PolicyEditorScopes", new SimpleBindings())).thenReturn(policyEditorScopes);
- when(controller.getDataByQuery("from PolicyEditorScopes where SCOPENAME like 'com%'", new SimpleBindings())).thenReturn(policyEditorScopes);
- when(controller.getDataByQuery("from PolicyVersion where POLICY_NAME like 'com%'", new SimpleBindings())).thenReturn(policyVersion);
+ when(controller.getDataByQuery("from PolicyEditorScopes", null)).thenReturn(policyEditorScopes);
+ when(controller.getDataByQuery("from PolicyEditorScopes where SCOPENAME like :scopeName", null)).thenReturn(policyEditorScopes);
+ when(controller.getDataByQuery("from PolicyVersion where POLICY_NAME like :scopeName", null)).thenReturn(policyVersion);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -196,6 +197,7 @@ 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++){
@@ -203,7 +205,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(basePolicyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(basePolicyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -242,6 +244,7 @@ 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++){
@@ -249,7 +252,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -288,6 +291,7 @@ 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++){
@@ -295,7 +299,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Raw_TestBRMSRawPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -334,6 +338,7 @@ 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++){
@@ -341,7 +346,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_Fault_TestClosedLoopPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -380,6 +385,7 @@ 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++){
@@ -387,7 +393,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_PM_TestClosedLoopPMPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -433,6 +439,7 @@ 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++){
@@ -441,7 +448,7 @@ public class PolicyManagerServletTest extends Mockito{
when(request.getReader()).thenReturn(reader);
when(commonClassDao.getDataById(GroupPolicyScopeList.class, "groupList", "resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop")).thenReturn(groupListData);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_MS_vFirewall.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -480,6 +487,7 @@ 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++){
@@ -487,7 +495,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_FW_TestFireWallPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -524,6 +532,7 @@ 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++){
@@ -531,7 +540,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Action_TestActionPolicy.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
@@ -562,6 +571,7 @@ 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++){
@@ -569,7 +579,7 @@ public class PolicyManagerServletTest extends Mockito{
try {
when(request.getReader()).thenReturn(reader);
when(controller.getRoles("Test")).thenReturn(rolesdata);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = :split_1 and scope = :split_0", null)).thenReturn(policyData);
servlet.setPolicyController(controller);
servlet.setTestUserId("Test");
servlet.doPost(request, response);
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
new file mode 100644
index 000000000..4931d20d7
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class PolicyUserInfoControllerTest {
+
+ private HttpServletRequest request;
+ private MockHttpServletResponse response;
+
+ @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);
+ }
+
+ @Test
+ public final void testGetPolicyUserInfo() {
+ PolicyUserInfoController controller = new PolicyUserInfoController();
+ controller.getPolicyUserInfo(request, response);
+ try{
+ assertTrue(response.getStatus() == 200);
+ }catch(Exception e){
+ fail();
+ }
+
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
index 382637c1b..6f20a6770 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
@@ -19,6 +19,8 @@
*/
package org.onap.policy.controller;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -33,6 +35,8 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.Datatype;
+import org.onap.policy.rest.jpa.FunctionDefinition;
import org.onap.policy.rest.jpa.PolicyEntity;
public class PolicyControllerTest {
@@ -44,6 +48,7 @@ public class PolicyControllerTest {
public void setUp() throws Exception{
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
+ PolicyController.setCommonClassDao(commonClassDao);
List<Object> data = new ArrayList<>();
String policyData = "";
try {
@@ -57,12 +62,30 @@ public class PolicyControllerTest {
entity.setPolicyData(policyData);
entity.setScope("com");
data.add(entity);
-
+
when(commonClassDao.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'", new SimpleBindings())).thenReturn(data);
+
+ FunctionDefinition fnDefinition = new FunctionDefinition();
+ fnDefinition.setXacmlid("Test");
+ fnDefinition.setShortname("Test");
+ Datatype dataType = new Datatype();
+ dataType.setXacmlId("Test");
+ fnDefinition.setDatatypeBean(dataType);
+ List<Object> fnObjects = new ArrayList<>();
+ fnObjects.add(fnDefinition);
+ when(commonClassDao.getData(FunctionDefinition.class)).thenReturn(fnObjects);
}
@Test
- public void dummy(){
- System.out.println("Dummy");
+ public void testInit(){
+ PolicyController controller = new PolicyController();
+ PolicyController.setjUnit(true);
+ controller.init();
+ try{
+ assertTrue(PolicyController.dropDownMap.size() > 0);
+ }catch(Exception e){
+ logger.error("Exception Occured"+e);
+ fail();
+ }
}
}
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 78dd20af2..d4b0c650b 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
@@ -37,10 +37,13 @@ import org.junit.Before;
import org.junit.Test;
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.PolicyVersion;
+import org.onap.policy.rest.jpa.SystemLogDB;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
@@ -79,7 +82,22 @@ public class CommonClassDaoImplTest{
// Set up dao with SessionFactory
commonClassDao = new CommonClassDaoImpl();
CommonClassDaoImpl.setSessionfactory(sessionFactory);
-
+ PolicyController.setLogTableLimit("1");
+ HibernateSession.setSession(sessionFactory);
+ SystemLogDB data1 = new SystemLogDB();
+ data1.setDate(new Date());
+ data1.setLogtype("INFO");
+ data1.setRemote("Test");
+ data1.setSystem("Test");
+ data1.setType("Test");
+ SystemLogDB data2 = new SystemLogDB();
+ data2.setDate(new Date());
+ data2.setLogtype("error");
+ data2.setRemote("Test");
+ data2.setSystem("Test");
+ data2.setType("Test");
+ HibernateSession.getSession().save(data1);
+ HibernateSession.getSession().save(data2);
// Create TCP server for troubleshooting
server = Server.createTcpServer("-tcpAllowOthers").start();
System.out.println("URL: jdbc:h2:" + server.getURL() + "/mem:test");
@@ -329,10 +347,10 @@ public class CommonClassDaoImplTest{
}
}
- /*
- * Test for SQL Injection Protection
- *
+
+ /* Test for SQL Injection Protection
*/
+
@Test
@Transactional
@Rollback(true)
@@ -375,6 +393,27 @@ public class CommonClassDaoImplTest{
}
}
+ @Test
+ public final void testGetLoggingData() {
+ SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
+ SystemLogDbDaoImpl.setjUnit(true);
+ try{
+ assertTrue(system.getLoggingData() != null);
+ }catch(Exception e){
+ fail();
+ }
+ }
+
+ @Test
+ public final void testGetSystemAlertData() {
+ SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
+ SystemLogDbDaoImpl.setjUnit(true);
+ try{
+ assertTrue(system.getSystemAlertData() != null);
+ }catch(Exception e){
+ fail();
+ }
+ }
@After
public void deleteDB(){
diff --git a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
new file mode 100644
index 000000000..0f285b694
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
@@ -0,0 +1,203 @@
+###
+# ============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=========================================================
+###
+
+#
+# This file is set to the defaults one can use to run the XACML-PAP-ADMIN for testing and development.
+#
+# It is not recommended to modify this file directly, but rather copy it to another location and make any modifications
+# necessary to run the application in a development or a production environment. You can set the Java VM System
+# property to change where the application can find the file. For example:
+#
+#-Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties
+#
+#
+# Standard API Factories
+#
+xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory
+xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory
+xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory
+xacml.pipFinderFactory=com.att.research.xacml.std.pip.StdPIPFinderFactory
+#
+# AT&T PDP Implementation Factories
+#
+xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory
+xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory
+xacml.att.functionDefinitionFactory=org.onap.policy.xacml.custom.OnapFunctionDefinitionFactory
+xacml.att.policyFinderFactory=com.att.research.xacmlatt.pdp.std.StdPolicyFinderFactory
+
+#
+# This is an extremely simple policy to demonstrate authorization
+# within the Admin Console.
+#
+xacml.rootPolicies=admin
+#
+# PAP Servlet properties
+#
+xacml.PAP.papEngineFactory=org.onap.policy.xacml.std.pap.StdEngineFactory
+
+#
+# Admin Console properties
+#
+xacml.AC.papEngineFactory=org.onap.policy.xacml.admin.util.RESTfulPAPFactory
+
+# Set your domain here:
+xacml.rest.admin.domain=com
+#
+#
+# Property to declare the max time frame for logs.
+#
+xacml.log.timeframe=30
+#
+#
+#
+xacml.rest.admin.closedLoopJSON =JSONConfig.json
+xacml.rest.admin.microServiceModel=model.properties
+xacm.restful.interface.file=RESTful.interface.properties
+#
+#If the Audit is set false, then Audit function will not work at the Server Run time.
+#This will Syncronize the data between Roles and Userinfo Table
+xacml.audit.userInfo = true
+#
+#The Test Environment User Login LoginIU Should provide below on seperating with Comma
+#
+xacml.testEnvironment.loginId =
+
+#Log DB properties
+xacml.log.db.driver=org.mariadb.jdbc.Driver
+xacml.log.db.url=jdbc:mariadb://localhost:3306/log?failOverReadOnly=false&autoReconnect=true
+xacml.log.db.user=policy_user
+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.user=policy_user
+javax.persistence.jdbc.password=policy_user
+
+# Dashboard refresh rate in miliseconds
+xacml.refresh.rate=40000
+xacml.user.column.count=3
+xacml.sqlcontainer.page.length=75
+xacm.xcor.required.pattern=1,1
+xacm.cache.live.time=2
+xacml.max.priority.count=10
+
+#
+# These can be set so the Admin Console knows who is logged on. Ideally, you can run the console in a J2EE
+# container and setup authentication as you please. Setting HttpSession attribute values will override these
+# values set in the properties files.
+#
+# ((HttpServletRequest) request).getSession().setAttribute("xacml.rest.admin.user.name", "Homer");
+#
+# The default policy: Policy-Admin.xml is extremely simple.
+#
+# You can test authorization within the Admin Console by changing the user id.
+# There are 3 supported user ids:
+# guest - Read only access
+# editor - Read/Write access
+# admin - Read/Write/Admin access
+#
+# An empty or null value for xacml.rest.admin.user.id results in no access to the application at all.
+#
+# This is for development/demonstration purposes only. A production environment should provide authentication which is
+# outside the scope of this application. This application can be used to develop a XACML policy for user authorization
+# within this application.
+#
+#xacml.rest.admin.user.name=Guest
+#xacml.rest.admin.user.id=guest
+#xacml.rest.admin.user.name=Editor
+#xacml.rest.admin.user.id=editor
+xacml.rest.admin.user.name=Administrator
+xacml.rest.admin.user.id=super-admin
+xacml.rest.admin.user.email=
+
+#
+# URL location for the PAP servlet.
+#
+xacml.rest.pap.url=http://localhost:8070/pap/
+
+# id PAP
+xacml.rest.pap.userid=testpap
+# pass PAP
+xacml.rest.pap.password=alpha123
+
+# new Property Please mention your PAP-REST webapps Location here.
+
+xacml.rest.config.webapps=/home/users/PolicyEngine/webapps/ConfigPAP/
+
+# pdps file - Needs to have the location of the PDPs File of the PAP-REST
+xacml.rest.pdp.idfile=test.properties
+
+#Template Versions
+xacml.rest.closedLoopFault=OpenSource.version.1
+xacml.rest.closedLoopPM=OpenSource.version.1
+xacml.rest.microServices=OpenSource.version.1
+xacml.rest.gocPolicy=OpenSource.version.1
+xacml.rest.firewallPolicy=OpenSource.version.1
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+
+#The name of the Admin. Must be unique across the system
+xacml.rest.admin.resource.name=site_1.admin_1
+
+#The site name for the Admin
+site_name=site_1
+
+#Has to be one of pdp_xacml, pdp_drools, pap, pap_admin, logparser, brms_gateway, astra_gateway, elk_server
+node_type=pap_admin
+
+# The (optional) period of time in seconds between executions of the integrity audit.
+# Value < 0 : Audit does not run (default value if property is not present = -1)
+# Value = 0 : Audit runs continuously
+# Value > 0 : The period of time in seconds between execution of the audit on a particular node
+integrity_audit_period_seconds=-1
+
+#Automatic Policy Distribution
+xacml.att.automatic.push = false
+
+
+#Dashboard Tab Limit
+xacml.onap.dashboard.logTableLimit = 5000
+xacml.onap.dashboard.systemAlertTableLimit = 2000
+
+
+#Diff of policies for Firewall feature
+FW_GETURL=https://todo_enter_the_firewallurl
+FW_AUTHOURL=https://todo_enter_the_firewallAuthurl
+FW_PROXY=todo_enter_the_proxy
+FW_PORT=8080
+
+#SMTP Server Details for Java Mail
+onap.smtp.host = smtp_host
+onap.smtp.port = smtp_port
+onap.smtp.userName = smtp_username
+onap.smtp.password = smtp_password
+onap.smtp.emailExtension=smtp_emailExtension
+onap.application.name = smtp_AppName
+
+#Dialect for Database
+onap.dialect = org.hibernate.dialect.MySQLDialect
+
+policyAdapter.impl.className = org.onap.policy.admin.PolicyAdapter
+
+#Micro Service Model Properties
+xacml.policy.msOnapName=http://org.onap
+xacml.policy.msPolicyName=http://org.onap.policy \ No newline at end of file
diff --git a/PolicyEngineUtils/pom.xml b/PolicyEngineUtils/pom.xml
index c0837055f..effaf5b9d 100644
--- a/PolicyEngineUtils/pom.xml
+++ b/PolicyEngineUtils/pom.xml
@@ -63,9 +63,9 @@
<version>2.6.0</version>
</dependency>
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.30</version>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -110,6 +110,11 @@
<version>1.3.0</version>
</dependency>
<dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.1</version>
+ </dependency>
+ <dependency>
<groupId>com.att.aft</groupId>
<artifactId>dme2</artifactId>
<version>3.1.200</version>
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
index b74bd28cc..51409b6f7 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
@@ -45,11 +45,11 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
-import com.att.aft.dme2.internal.gson.JsonParser;
-import com.att.aft.dme2.internal.gson.JsonSyntaxException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.CharMatcher;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
public class PolicyUtils {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyUtils.class);