summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java127
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java7
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java4
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java51
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java44
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java33
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java18
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java24
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java82
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java4
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java4
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AddressGroupJsonTest.java50
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ServiceGroupJsonTest.java51
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java10
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java50
-rw-r--r--ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java72
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java46
-rw-r--r--docs/platform/index.rst4
-rw-r--r--docs/platform/modAmsterTemplate.rst6
-rw-r--r--docs/platform/runningEclipse.rst3
-rw-r--r--docs/platform/tutorial_cl.rst15
36 files changed, 606 insertions, 139 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
index 84cd72fe6..a30c9c7ec 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
@@ -46,7 +46,7 @@ import java.util.Scanner;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
-
+import javax.json.JsonException;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
@@ -792,7 +792,6 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
} else {
PolicyLogger.info("requestID was provided in call to XACMLPapSrvlet (doGet)");
}
- try {
loggingContext.metricStarted();
XACMLRest.dumpRequest(request);
loggingContext.metricEnded();
@@ -907,7 +906,18 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
request.getRemoteHost().equals(request.getLocalAddr())) {
// Return status information - basically all the groups
loggingContext.setServiceName("PAP.getGroups");
- Set<OnapPDPGroup> groups = papEngine.getOnapPDPGroups();
+ Set<OnapPDPGroup> groups = null;
+ try {
+ groups = papEngine.getOnapPDPGroups();
+ } catch(PAPException e) {
+ LOGGER.debug(e);
+ PolicyLogger.error(MessageCodes.ERROR_UNKNOWN, e, "XACMLPapServlet", " GET exception");
+ loggingContext.transactionEnded();
+ PolicyLogger.audit("Transaction Failed - See Error.log");
+ setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ im.endTransaction();
+ return;
+ }
// convert response object to JSON and include in the response
mapperWriteValue(new ObjectMapper(), response, groups);
response.setHeader("content-type", "application/json");
@@ -984,15 +994,6 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
PolicyLogger.audit("Transaction Failed - See Error.log");
setResponseError(response,HttpServletResponse.SC_NOT_FOUND, message);
}
- } catch (PAPException e) {
- LOGGER.debug(e);
- PolicyLogger.error(MessageCodes.ERROR_UNKNOWN, e, "XACMLPapServlet", " GET exception");
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- im.endTransaction();
- return;
- }
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Ended");
im.endTransaction();
@@ -1017,26 +1018,24 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
im.startTransaction();
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPut im startTransaction");
+ } catch(AdministrativeStateException e) {
+ String message = "PUT interface called for PAP " + papResourceName +
+ " but it has an Administrative state of " + im.getStateManager().getAdminState() +
+ "\n Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
+ } catch(StandbyStatusException e) {
+ String message = "PUT interface called for PAP " + papResourceName +
+ " but it has a Standby Status of " + im.getStateManager().getStandbyStatus() +
+ "\n Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
} catch (IntegrityMonitorException e) {
- String message = "PUT interface called for PAP " + papResourceName;
- if (e instanceof AdministrativeStateException) {
- message += " but it has an Administrative state of "
- + im.getStateManager().getAdminState();
- } else if (e instanceof StandbyStatusException) {
- message += " but it has a Standby Status of "
- + im.getStateManager().getStandbyStatus();
- } else {
- message += " but an exception occurred";
-
- }
- message += "\n Exception Message: " + e.getMessage();
-
- LOGGER.info(message, e);
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
- return;
+ String message = "PUT interface called for PAP " + papResourceName +
+ " but an exception occurred" +
+ "\n Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
}
loggingContext.metricStarted();
@@ -1894,7 +1893,16 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
} else {
// request is for top-level properties about all groups
loggingContext.setServiceName("AC:PAP.getAllGroups");
- Set<OnapPDPGroup> groups = papEngine.getOnapPDPGroups();
+ Set<OnapPDPGroup> groups = null;
+ try {
+ groups = papEngine.getOnapPDPGroups();
+ } catch(PAPException e) {
+ PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet", " AC Get exception");
+ loggingContext.transactionEnded();
+ PolicyLogger.audit("Transaction Failed - See Error.log");
+ setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ return;
+ }
// convert response object to JSON and include in the response
mapperWriteValue(new ObjectMapper(), response, groups);
if (LOGGER.isDebugEnabled()) {
@@ -2041,7 +2049,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
LOGGER.info("JSON request from AC: " + json);
// convert Object sent as JSON into local object
ObjectMapper mapper = new ObjectMapper();
- Object objectFromJSON = mapper.readValue(json, StdPDP.class);
+ Object objectFromJSON = null;
+ try {
+ objectFromJSON = mapper.readValue(json, StdPDP.class);
+ } catch(Exception e) {
+ LOGGER.error(e);
+ }
if (pdpId == null ||
objectFromJSON == null ||
! (objectFromJSON instanceof StdPDP) ||
@@ -2146,7 +2159,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
LOGGER.info("JSON request from AC: " + json);
// convert Object sent as JSON into local object
ObjectMapper mapper = new ObjectMapper();
- Object objectFromJSON = mapper.readValue(json, StdPDPGroup.class);
+ Object objectFromJSON = null;
+ try {
+ objectFromJSON = mapper.readValue(json, StdPDPGroup.class);
+ } catch(Exception e) {
+ LOGGER.error(e);
+ }
if (objectFromJSON == null || ! (objectFromJSON instanceof StdPDPGroup) ||
! ((StdPDPGroup)objectFromJSON).getId().equals(group.getId())) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " Group update had bad input. id=" + group.getId() + " objectFromJSON="+objectFromJSON);
@@ -2822,24 +2840,21 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
PolicyLogger.audit("Transaction Failed - See Error.log");
response.setStatus(HttpServletResponse.SC_OK);
return;
- }catch (ForwardProgressException | AdministrativeStateException | StandbyStatusException e){
- String submsg;
- if (e instanceof ForwardProgressException) {
- submsg = " is not making forward progress.";
- } else if (e instanceof AdministrativeStateException) {
- submsg = " Administrative State is LOCKED.";
- } else {
- submsg = " Standby Status is NOT PROVIDING SERVICE.";
- }
-
- String message = "GET:/pap/test called and PAP " + papResourceName + submsg
- + " Exception Message: " + e.getMessage();
- LOGGER.info(message, e);
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
- return;
+ }catch (ForwardProgressException e){
+ String message = "GET:/pap/test called and PAP " + papResourceName + " is not making forward progress."
+ + " Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
+ }catch (AdministrativeStateException e){
+ String message = "GET:/pap/test called and PAP " + papResourceName + " Administrative State is LOCKED."
+ + " Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
+ }catch (StandbyStatusException e){
+ String message = "GET:/pap/test called and PAP " + papResourceName + " Standby Status is NOT PROVIDING SERVICE."
+ + " Exception Message: " + e.getMessage();
+ logMessage(e, message, loggingContext, response);
+ return;
}catch (Exception e) {
//A subsystem is not making progress, is locked, standby or is not responding
String eMsg = e.getMessage();
@@ -3014,4 +3029,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
public static void setMsPolicyName(String msPolicyName) {
XACMLPapServlet.msPolicyName = msPolicyName;
}
+
+ private void logMessage(Exception e, String message, ONAPLoggingContext loggingContext, HttpServletResponse response) {
+ LOGGER.info(message, e);
+ PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
+ loggingContext.transactionEnded();
+ PolicyLogger.audit("Transaction Failed - See Error.log");
+ setResponseError(response,HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }
}
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 9ac858277..a8449e307 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
@@ -127,7 +127,7 @@ public class PolicyDBDao {
public static final String duplicatePolicyId = "Somehow, more than one policy with the id ";
public static final String foundInDB = " were found in the database";
- public static boolean isJunit = false;
+ private static boolean isJunit = false;
public static void setJunit(boolean isJunit) {
PolicyDBDao.isJunit = isJunit;
@@ -1250,6 +1250,9 @@ public class PolicyDBDao {
for(PDPPolicy policy : policies){
try{
String[] stringArray = getNameScopeAndVersionFromPdpPolicy(policy.getId());
+ if(stringArray == null) {
+ throw new IllegalArgumentException("Invalid input - policyID must contain name, scope and version");
+ }
List<PolicyEntity> policyEntityList;
Query getPolicyEntitiesQuery = em.createNamedQuery("PolicyEntity.findByNameAndScope");
getPolicyEntitiesQuery.setParameter("name", stringArray[0]);
@@ -1767,7 +1770,7 @@ public class PolicyDBDao {
policyId = policyName;
policyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:name AND p.scope=:scope");
policyQuery.setParameter("name", policyId);
- policyQuery.setParameter(scope, scope);
+ policyQuery.setParameter("scope", scope);
} else{
policyId = String.valueOf(policyID);
policyQuery = em.createNamedQuery("PolicyEntity.FindById");
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
index 3d275c3d9..59a7ed312 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
@@ -64,7 +64,7 @@ public class ActionPolicyDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_ActionPolicyDictDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
index f07ca3478..0ab5cf935 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
@@ -91,7 +91,7 @@ public class BRMSDictionaryController{
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_BRMSParamDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
index 2b0556716..5d28c82e7 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
@@ -89,7 +89,7 @@ public class ClosedLoopDictionaryController{
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_VSCLActionDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
index 9b79303fa..6e68d78d9 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
@@ -66,7 +66,7 @@ public class DecisionPolicyDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_SettingsDictionaryDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
index 364a4f73a..db710961f 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
@@ -65,7 +65,7 @@ public class DescriptiveDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_DescriptiveScopeByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
index 7e30635f9..0b7693c6f 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
@@ -69,7 +69,7 @@ public class DictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_AttributeDatabyAttributeName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
index d02cbca73..bd1fb0e32 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
@@ -113,7 +113,7 @@ public class FirewallDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value={"/get_PrefixListDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java
index 20e75a08b..becf5adf7 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java
@@ -92,7 +92,7 @@ public class MicroServiceDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@Autowired
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
index 40c9d7269..fd3d2f641 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
@@ -71,7 +71,7 @@ public class PolicyScopeDictionaryController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@Autowired
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
index 23450cbbe..209ba4f45 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
@@ -66,7 +66,7 @@ public class SafePolicyController {
}
private DictionaryUtils getDictionaryUtilsInstance(){
- return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
+ return DictionaryUtils.getDictionaryUtils();
}
@RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java
index e18595956..5610577a9 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java
@@ -58,10 +58,10 @@ public class DictionaryUtils {
private static CommonClassDao commonClassDao;
- public static DictionaryUtils dictionaryUtils;
+ private static DictionaryUtils dictionaryUtils;
public static synchronized DictionaryUtils getDictionaryUtils() {
- return dictionaryUtils;
+ return dictionaryUtils != null ? dictionaryUtils : new DictionaryUtils();
}
public static synchronized void setDictionaryUtils(DictionaryUtils dictionaryUtils) {
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
index ca2b6797d..5208ad7a7 100644
--- 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
@@ -35,18 +35,25 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
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.common.ia.IntegrityAuditProperties;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
@@ -73,8 +80,8 @@ import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
import com.mockrunner.mock.web.MockServletInputStream;
-
public class XACMLPAPTest {
+ private static final Log logger = LogFactory.getLog(XACMLPAPTest.class);
private static final String ENVIRONMENT_HEADER = "Environment";
private List<String> headers = new ArrayList<>();
@@ -86,6 +93,48 @@ public class XACMLPAPTest {
private SessionFactory sessionFactory;
private CommonClassDao commonClassDao;
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+
+ @Before
+ public void setUpDB() throws Exception {
+ logger.info("setUpDB: Entering");
+
+ Properties properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPAPTest.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
+ properties.put(IntegrityAuditProperties.DB_USER, XACMLPAPTest.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, XACMLPAPTest.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
+
+ //Clean the iaTest DB table for IntegrityAuditEntity entries
+ cleanDb("testPapPU", properties);
+
+ logger.info("setUpDB: Exiting");
+ }
+
+ public void cleanDb(String persistenceUnit, Properties properties){
+ logger.debug("cleanDb: enter");
+
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+ EntityManager em = emf.createEntityManager();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
+
+ et.begin();
+
+ // Clean up the DB
+ em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ em.close();
+ logger.debug("cleanDb: exit");
+ }
+
@Before
public void setUp() throws ServletException {
httpServletRequest = Mockito.mock(HttpServletRequest.class);
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java
new file mode 100644
index 000000000..6b58184fe
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pap.xacml.rest.handler;
+
+import static org.junit.Assert.assertNull;
+import org.junit.Test;
+
+public class DictionaryHandlerTest {
+ @Test
+ public void negTestHandler() {
+ // Set the system property temporarily
+ String systemKey = "dictionary.impl.className";
+ String oldProperty = System.getProperty(systemKey);
+ System.setProperty(systemKey, "foobar");
+
+ // Run negative test on instance
+ assertNull(DictionaryHandler.getInstance());
+
+ // Restore the original system property
+ if (oldProperty != null) {
+ System.setProperty(systemKey, oldProperty);
+ } else {
+ System.clearProperty(systemKey);
+ }
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
index 2c852fd5c..9b45c3b53 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
@@ -21,24 +21,27 @@
package org.onap.policy.pap.xacml.rest.util;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import org.junit.Rule;
+import javax.persistence.Query;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
public class JPAUtilsTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void testJPAUtils() throws IllegalAccessException {
- EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
- JPAUtils utils = JPAUtils.getJPAUtilsInstance(emf);
-
- assertEquals(utils.dbLockdownIgnoreErrors(), false);
-
- thrown.expect(NullPointerException.class);
- utils.dbLockdown();
- }
+ @Test(expected = IllegalAccessException.class)
+ public void testJPAUtils() throws IllegalAccessException {
+ // Setup test data
+ EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
+ EntityManager em = Mockito.mock(EntityManager.class);
+ Query query = Mockito.mock(Query.class);
+ Mockito.when(emf.createEntityManager()).thenReturn(em);
+ Mockito.when(em.createNamedQuery(Mockito.any())).thenReturn(query);
+
+ // Test lockdown
+ JPAUtils utils = JPAUtils.getJPAUtilsInstance(emf);
+ assertEquals(utils.dbLockdownIgnoreErrors(), false);
+ utils.dbLockdown();
+ fail("Expecting an exception");
+ }
}
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java
index 5c9f8602f..102d43f0c 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java
@@ -550,20 +550,14 @@ public class XACMLPdpLoader {
// properties
//
changed = true;
+ } catch (MalformedURLException e) {
+ papUrls.failed();
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Policy '" + policy
+ + "' had bad URL in new configuration, URL='" + propLocation + "'");
} catch (Exception e) {
papUrls.failed();
- if (e instanceof MalformedURLException) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Policy '"
- + policy
- + "' had bad URL in new configuration, URL='"
- + propLocation + "'");
-
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while retrieving policy "
- + policy
- + " from URL "
- + url + ", e=" + e);
- }
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while retrieving policy "
+ + policy + " from URL " + url + ", e=" + e);
}
papUrls.getNext();
}
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java
index 59194841f..3c0ea3894 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java
@@ -54,12 +54,16 @@ public class PAPServices {
private int responseCode = 0;
private static String environment = "DEVL";
- public static Boolean junit = false;
+ private static Boolean isJunit = false;
private static List<String> paps = null;
private static final Object papResourceLock = new Object();
private String operation = null;
private String requestMethod = null;
- private String encoding = null;
+ private String encoding = null;
+
+ public static void setJunit(boolean isJunit) {
+ PAPServices.isJunit = isJunit;
+ }
public PAPServices() {
environment = PDPApiAuth.getEnvironment();
@@ -164,7 +168,7 @@ public class PAPServices {
} else if(content != null){
// the content is an object to be encoded in JSON
ObjectMapper mapper = new ObjectMapper();
- if (!junit) {
+ if (!isJunit) {
mapper.writeValue(connection.getOutputStream(),
content);
}
@@ -174,7 +178,7 @@ public class PAPServices {
responseCode = connection.getResponseCode();
// If Connected to PAP then break from the loop and continue
// with the Request
- if (connection.getResponseCode() > 0 || junit) {
+ if (connection.getResponseCode() > 0 || isJunit) {
connected = true;
break;
} else {
@@ -183,7 +187,7 @@ public class PAPServices {
}
} catch (Exception e) {
// This means that the PAP is not working
- if (junit) {
+ if (isJunit) {
connected = true;
break;
}
@@ -212,7 +216,7 @@ public class PAPServices {
XACMLErrorConstants.ERROR_SYSTEM_ERROR
+ "Decoding the result ", e);
}
- if (junit) {
+ if (isJunit) {
response = SUCCESS;
}
}else{
@@ -326,10 +330,10 @@ public class PAPServices {
private String checkResponse(HttpURLConnection connection, UUID requestID) throws IOException {
String response = null;
- if (responseCode == 200 || junit) {
+ if (responseCode == 200 || isJunit) {
// Check for successful creation of policy
String isSuccess = null;
- if (!junit) { // is this a junit test?
+ if (!isJunit) { // is this a junit test?
isSuccess = connection.getHeaderField("successMapKey");
operation = connection.getHeaderField("operation");
} else {
@@ -603,7 +607,7 @@ public class PAPServices {
responseCode = connection.getResponseCode();
// If Connected to PAP then break from the loop and continue
// with the Request
- if (connection.getResponseCode() > 0 || junit) {
+ if (connection.getResponseCode() > 0 || isJunit) {
connected = true;
break;
} else {
@@ -612,7 +616,7 @@ public class PAPServices {
}
} catch (Exception e) {
// This means that the PAP is not working
- if (junit) {
+ if (isJunit) {
connected = true;
break;
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java
new file mode 100644
index 000000000..a48791cf0
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pdp.rest.api.models;
+
+import static org.junit.Assert.assertEquals;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyDecision;
+import org.onap.policy.api.PolicyResponseStatus;
+import org.onap.policy.api.PolicyType;
+
+public class PDPResponseTest {
+ @Test
+ public void testSetAndGet() {
+ // Test values
+ String message = "testMessage";
+ String config = "testConfig";
+ String policyName = "testPolicyName";
+ String policyVersion = "1.0";
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+ PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
+ PolicyType type = PolicyType.JSON;
+ Map<String, String> property = new HashMap<String, String>();
+ PolicyDecision policyDecision = PolicyDecision.PERMIT;
+
+ PDPResponse response = new PDPResponse();
+
+ response.setStatus(message, policyResponseStatus, policyConfigStatus);
+ response.setConfig(config);
+ assertEquals(config, response.getConfig());
+ response.setType(type);
+ assertEquals(type, response.getType());
+ response.setPolicyConfigStatus(policyConfigStatus);
+ assertEquals(policyConfigStatus, response.getPolicyConfigStatus());
+ response.setPolicyConfigMessage(message);
+ assertEquals(message, response.getPolicyConfigMessage());
+ response.setProperty(property);
+ assertEquals(property, response.getProperty());
+ response.setPolicyName(policyName);
+ assertEquals(policyName, response.getPolicyName());
+ response.setPolicyVersion(policyVersion);
+ assertEquals(policyVersion, response.getPolicyVersion());
+ response.setMatchingConditions(property);
+ assertEquals(property, response.getMatchingConditions());
+ response.setResponseAttributes(property);
+ assertEquals(property, response.getResponseAttributes());
+ response.setPolicyResponseStatus(policyResponseStatus);
+ assertEquals(policyResponseStatus, response.getPolicyResponseStatus());
+ response.setDecision(policyDecision);
+ assertEquals(policyDecision, response.getDecision());
+ response.setDetails(message);
+ assertEquals(message, response.getDetails());
+ response.setActionAdvised(property);
+ assertEquals(property, response.getActionAdvised());
+ response.setActionTaken(property);
+ assertEquals(property, response.getActionTaken());
+ response.setRequestAttributes(property);
+ assertEquals(property, response.getRequestAttributes());
+ response.setPolicyResponseMessage(message);
+ assertEquals(message, response.getPolicyResponseMessage());
+ }
+}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
index 8867a7828..23e47f418 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
@@ -50,7 +50,7 @@ public class BRMSParamPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
@@ -80,7 +80,7 @@ public class BRMSParamPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
index de884b349..c21bc9c77 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
@@ -47,7 +47,7 @@ public class ClosedLoopFaultPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
@@ -69,7 +69,7 @@ public class ClosedLoopFaultPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
index 19bb279e6..99dc67742 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
@@ -47,7 +47,7 @@ public class ClosedLoopPMPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
@@ -69,7 +69,7 @@ public class ClosedLoopPMPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
index 0fcb0027c..fe0668115 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
@@ -49,7 +49,7 @@ public class DecisionPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyClass(PolicyClass.Decision);
@@ -94,7 +94,7 @@ public class DecisionPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
index 4343a5060..ccedd7553 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
@@ -46,7 +46,7 @@ public class FirewallPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); //required
@@ -67,7 +67,7 @@ public class FirewallPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
index a9301e728..e460a853b 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
@@ -47,7 +47,7 @@ public class MicroServicesPolicyServiceTest {
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
@@ -69,7 +69,7 @@ public class MicroServicesPolicyServiceTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
index 9d1d13910..93fde841d 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
@@ -40,7 +40,7 @@ public class PAPServicesTest {
@Before
public void setUp() throws Exception {
- PAPServices.junit = true;
+ PAPServices.setJunit(true);
Properties prop = new Properties();
prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
String succeeded = prop.getProperty("xacml.rest.pap.url");
@@ -53,7 +53,7 @@ public class PAPServicesTest {
@After
public void tearDown() throws Exception {
PAPServices.setPaps(null);
- PAPServices.junit = false;
+ PAPServices.setJunit(false);
}
@Test
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AddressGroupJsonTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AddressGroupJsonTest.java
new file mode 100644
index 000000000..c0aa7925e
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AddressGroupJsonTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+public class AddressGroupJsonTest {
+ @Test
+ public void testJson() {
+ // Setup test data
+ String value = "testVal";
+ String value2 = "testVal2";
+
+ // Test constructors
+ AddressGroupJson json = new AddressGroupJson();
+ json.setName(value);
+ AddressGroupJson json2 = new AddressGroupJson();
+ json2.setName(value);
+ AddressGroupJson json3 = new AddressGroupJson();
+ json3.setName(value2);
+
+ // Test equals and hash functions
+ assertTrue(json.equals(json2));
+ assertFalse(json.equals(json3));
+ assertFalse(json.equals(null));
+ assertFalse(json.equals(value));
+ assertEquals(217, json.hashCode());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ServiceGroupJsonTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ServiceGroupJsonTest.java
new file mode 100644
index 000000000..899a9b2b8
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ServiceGroupJsonTest.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+public class ServiceGroupJsonTest {
+ @Test
+ public void testJson() {
+ // Setup test data
+ String value = "testVal";
+ String value2 = "testVal2";
+
+ // Test constructors
+ ServiceGroupJson json = new ServiceGroupJson();
+ json.setName(value);
+ ServiceGroupJson json2 = new ServiceGroupJson();
+ json2.setName(value);
+ ServiceGroupJson json3 = new ServiceGroupJson();
+ json3.setName(value2);
+
+ // Test equals and hash functions
+ assertTrue(json.equals(json2));
+ assertFalse(json.equals(json3));
+ assertFalse(json.equals(null));
+ assertFalse(json.equals(value));
+ assertEquals(217, json.hashCode());
+ assertEquals(0, json.getMembers().size());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
index 457df7062..9302df3b5 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
@@ -128,11 +128,11 @@ public class PDPPolicyContainerTest {
@Test
public void testPDPPolicyItem() {
PDPPolicyItem item = container.new PDPPolicyItem(policy);
- assertEquals(item.getId(), "Config_test");
- assertEquals(item.getName(), "Config_test.1.xml");
- assertEquals(item.getVersion(), "1.0");
- assertEquals(item.getDescription(), "testDescription");
+ assertEquals("Config_test", item.getId());
+ assertEquals("Config_test.1.xml", item.getName());
+ assertEquals("1.0", item.getVersion());
+ assertEquals("testDescription", item.getDescription());
item.setRoot(true);
- assertEquals(item.getRoot(), true);
+ assertEquals(true, item.getRoot());
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
new file mode 100644
index 000000000..9e5ff5d9f
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
+import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
+
+public class PolicyItemSetChangeNotifierTest {
+ @Test
+ public void testNotifier() {
+ // Setup test data
+ ItemSetChangeListener listener = Mockito.mock(ItemSetChangeListener.class);
+ ItemSetChangeEvent event = Mockito.mock(ItemSetChangeEvent.class);
+
+ // Test constructor
+ PolicyItemSetChangeNotifier notifier = new PolicyItemSetChangeNotifier();
+ assertNotNull(notifier);
+
+ // Test listener methods
+ try {
+ notifier.addItemSetChangeListener(listener);
+ notifier.fireItemSetChange(event);
+ notifier.removeItemSetChangeListener(listener);
+ } catch (Exception ex) {
+ fail("Not expecting any exceptions: " + ex);
+ }
+ }
+}
diff --git a/ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java
new file mode 100644
index 000000000..133d4a860
--- /dev/null
+++ b/ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.portalapp.conf;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import java.net.MalformedURLException;
+import java.util.Collections;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.portalapp.scheduler.RegistryAdapter;
+import org.onap.portalsdk.core.scheduler.Registerable;
+import org.onap.portalsdk.workflow.services.WorkflowScheduleService;
+import org.quartz.Trigger;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+
+public class ExternalAppConfigTest {
+ @Test
+ public void testConfig() throws MalformedURLException {
+ // Setup test data
+ ApplicationContext ctx = Mockito.mock(ApplicationContext.class);
+ UrlResource value = new UrlResource("http://localhost");
+ Mockito.when(ctx.getResource(Mockito.any())).thenReturn(value);
+ ResourceHandlerRegistry registry = new ResourceHandlerRegistry(ctx, null);
+ InterceptorRegistry interceptor = new InterceptorRegistry();
+ RegistryAdapter schedulerRegistryAdapter = new RegistryAdapter();
+ Registerable reg = Mockito.mock(Registerable.class);
+ Mockito.when(reg.getTriggers()).thenReturn(new Trigger[1]);
+ schedulerRegistryAdapter.setRegistry(reg);
+ WorkflowScheduleService workflowScheduleService = Mockito.mock(WorkflowScheduleService.class);
+ schedulerRegistryAdapter.setWorkflowScheduleService(workflowScheduleService);
+ Mockito.when(workflowScheduleService.triggerWorkflowScheduling())
+ .thenReturn(Collections.emptyList());
+
+ // Test constructor
+ ExternalAppConfig config = new ExternalAppConfig();
+ assertNotNull(config);
+
+ // Test set and get
+ config.setApplicationContext(ctx);
+ assertNotNull(config.viewResolver());
+ config.addResourceHandlers(registry);
+ assertNotNull(config.dataAccessService());
+ assertNotNull(config.addTileDefinitions());
+ config.addInterceptors(interceptor);
+ assertNotNull(config.cacheManager());
+ config.setSchedulerRegistryAdapter(schedulerRegistryAdapter);
+ assertNull(config.schedulerFactoryBean());
+ assertNotNull(config.loginStrategy());
+ }
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java
new file mode 100644
index 000000000..f211c6df0
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.conf;
+
+import static org.junit.Assert.assertNull;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.controller.PolicyController;
+
+public class HibernateSessionTest {
+ @Before
+ public void setup() {
+ PolicyController.setLogdbUrl("testURL");
+ PolicyController.setLogdbUserName("testUser");
+ PolicyController.setLogdbPassword("testPass");
+ PolicyController.setLogdbDialect("testDialect");
+ PolicyController.setLogdbDriver("testDriver");
+ }
+
+ @Test
+ public void testSession() {
+ SessionFactory factory = Mockito.mock(SessionFactory.class);
+ HibernateSession.setSession(factory);
+ assertNull(HibernateSession.getSession());
+ }
+}
diff --git a/docs/platform/index.rst b/docs/platform/index.rst
index 1bedf09b0..2b89ee752 100644
--- a/docs/platform/index.rst
+++ b/docs/platform/index.rst
@@ -10,7 +10,6 @@ Policy Engine Platform
offeredapis.rst
installation.rst
policygui.rst
- modAmsterTemplate.rst
Policy Software Architecture
----------------------------
@@ -39,8 +38,9 @@ Policy Platform Tutorials
deployPDPPAP.rst
guardpolicy.rst
guardpdp.rst
- runningEclipse.rst
clsimulation.rst
+ modAmsterTemplate.rst
+ runningEclipse.rst
tutorial_cl.rst
tutorial_vDNS.rst
tutorial_VOLTE.rst
diff --git a/docs/platform/modAmsterTemplate.rst b/docs/platform/modAmsterTemplate.rst
index 690dd5d70..c08dbb641 100644
--- a/docs/platform/modAmsterTemplate.rst
+++ b/docs/platform/modAmsterTemplate.rst
@@ -2,9 +2,9 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-****************************************
-Modifying the Amsterdam release template
-****************************************
+******************************
+Modifying the Release Template
+******************************
.. contents::
:depth: 3
diff --git a/docs/platform/runningEclipse.rst b/docs/platform/runningEclipse.rst
index 4d26fdac7..b2bcd88fa 100644
--- a/docs/platform/runningEclipse.rst
+++ b/docs/platform/runningEclipse.rst
@@ -44,7 +44,8 @@ An HTTP 200 message for the GET request will also appear in the console in Eclip
.. image:: RunEcl_pdpd_200.png
-.. seealso:: To create a controller and run a control loop please refer to Modifying the Amsterdam release template.
+
+.. seealso:: To create a controller and run a control loop, refer to `Modifying the Release Template <modAmsterTemplate.html>`_.
End of Document
diff --git a/docs/platform/tutorial_cl.rst b/docs/platform/tutorial_cl.rst
index f73bf8991..3395ea718 100644
--- a/docs/platform/tutorial_cl.rst
+++ b/docs/platform/tutorial_cl.rst
@@ -35,22 +35,17 @@ When the processing is done, you get the choice of immediately deploying the pol
Proceed with testing your new policy as described in the specific tutorials:
-• vCPE - Tutorial: Testing the vCPE use case in a standalone PDP-D
-• vDNS - Tutorial: Testing the vDNS Use Case in a standalone PDP-D
-• vFW - Tutorial: Testing the vFW flow in a standalone PDP-D
-• VoLTE - Tutorial: Testing the VOLTE Use Case in a standalone PDP-D
-
-If you would like to deploy a control loop in Eclipse from the control loop archetype template:
-
-• Modifying the Amsterdam release template
+• vCPE - `Tutorial: Testing the vCPE use case in a standalone PDP-D <tutorial_vCPE.html>`_
+• vDNS - `Tutorial: Testing the vDNS Use Case in a standalone PDP-D <tutorial_vDNS.html>`_
+• vFW - `Tutorial: Testing the vFW flow in a standalone PDP-D <tutorial_vFW.html>`_
+• VoLTE - `Tutorial: Testing the VOLTE Use Case in a standalone PDP-D <tutorial_VOLTE.html>`_
+.. seealso:: To deploy a control loop in Eclipse from the control loop archetype template, refer to `Modifying the Release Template <modAmsterTemplate.html>`_.
End of Document
-
-
.. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Tutorial%3A+Generating+and+Testing+your+own+Control+Loop+Operational+Policy+in+a+standalone+PDP-D