Merge "JUnit additions for PAP-REST,REST"
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 ca2b679..5208ad7 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.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 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 @@
     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/docs/platform/index.rst b/docs/platform/index.rst
index 1bedf09..2b89ee7 100644
--- a/docs/platform/index.rst
+++ b/docs/platform/index.rst
@@ -10,7 +10,6 @@
    offeredapis.rst
    installation.rst
    policygui.rst
-   modAmsterTemplate.rst
 
 Policy Software Architecture
 ----------------------------
@@ -39,8 +38,9 @@
    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 690dd5d..c08dbb6 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 4d26fda..b2bcd88 100644
--- a/docs/platform/runningEclipse.rst
+++ b/docs/platform/runningEclipse.rst
@@ -44,7 +44,8 @@
 
     .. 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 f73bf89..3395ea7 100644
--- a/docs/platform/tutorial_cl.rst
+++ b/docs/platform/tutorial_cl.rst
@@ -35,22 +35,17 @@
 
 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