Merge "Fix a Bug in View Mode"
authorJorge Hernandez <jh1730@att.com>
Fri, 30 Mar 2018 16:03:04 +0000 (16:03 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 30 Mar 2018 16:03:04 +0000 (16:03 +0000)
44 files changed:
BRMSGateway/pom.xml
BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsGateway.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSGateway.java with 75% similarity]
BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsHandler.java [new file with mode: 0644]
BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java with 61% similarity]
BRMSGateway/src/main/java/org/onap/policy/brms/api/ControllerPojo.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/ControllerPOJO.java with 60% similarity]
BRMSGateway/src/main/java/org/onap/policy/brms/api/NotificationPojo.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/NotificationPOJO.java with 61% similarity]
BRMSGateway/src/main/java/org/onap/policy/brms/entity/BrmsGroupInfo.java [new file with mode: 0644]
BRMSGateway/src/main/java/org/onap/policy/brms/entity/BrmsPolicyInfo.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/jpa/BRMSPolicyInfo.java with 64% similarity]
BRMSGateway/src/main/java/org/onap/policy/brms/entity/DependencyInfo.java [moved from BRMSGateway/src/main/java/org/onap/policy/brmsInterface/jpa/DependencyInfo.java with 76% similarity]
BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java [deleted file]
BRMSGateway/src/main/java/org/onap/policy/brmsInterface/jpa/BRMSGroupInfo.java [deleted file]
BRMSGateway/src/main/resources/META-INF/persistenceBRMS.xml
BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSJpaTest.java [deleted file]
BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSPushTest.java [deleted file]
BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsJpaTest.java [new file with mode: 0644]
BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsPushTest.java [new file with mode: 0644]
BRMSGateway/src/test/java/org/onap/brmsgw/test/ControllerPojoTest.java [moved from BRMSGateway/src/test/java/org/onap/brmsgw/test/ControllerPOJOTest.java with 64% similarity]
BRMSGateway/src/test/java/org/onap/brmsgw/test/NotificationPojoTest.java [moved from BRMSGateway/src/test/java/org/onap/brmsgw/test/NotificationPOJOTest.java with 60% similarity]
BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsGatewayTest.java [moved from BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSGatewayTest.java with 63% similarity]
BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java [new file with mode: 0644]
BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java [new file with mode: 0644]
BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSHandlerTest.java [deleted file]
BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSPushTest.java [deleted file]
BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml
ONAP-PDP/pom.xml
ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java
ONAP-PDP/src/main/java/org/onap/policy/xacml/action/package-info.java
ONAP-PDP/src/main/java/org/onap/policy/xacml/custom/OnapFunctionDefinitionFactory.java
ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactory.java [deleted file]
ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/OnapPdpEngine.java [moved from ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/ONAPPDPEngine.java with 55% similarity]
ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactory.java [new file with mode: 0644]
ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java
ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/std/functions/PolicyList.java
ONAP-PDP/src/test/java/org/onap/policy/xacml/action/DummyRest.java
ONAP-PDP/src/test/java/org/onap/policy/xacml/action/FindActionTest.java
ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactoryTest.java [deleted file]
ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java [new file with mode: 0644]
ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineTest.java [moved from ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/ONAPPDPEngineTest.java with 71% similarity]
ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatchTest.java
ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/std/functions/PolicyListTest.java
ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java [new file with mode: 0644]
ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java [new file with mode: 0644]

index 2f4612a..9be5c30 100644 (file)
   -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.policy.engine</groupId>
-               <artifactId>PolicyEngineSuite</artifactId>
-               <version>1.2.0-SNAPSHOT</version>
-       </parent>
-       <artifactId>BRMSGateway</artifactId>
-       <description>This application will take in BRMS rules and acts as interface between PR and PDP XACML</description>
-       <dependencies>
-               <dependency>
-                       <groupId>com.h2database</groupId>
-                       <artifactId>h2</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.policy.engine</groupId>
-                       <artifactId>PolicyEngineAPI</artifactId>
-                       <version>${project.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>com.att.nsa</groupId>
-                                       <artifactId>cambriaClient</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.maven</groupId>
-                       <artifactId>maven-model</artifactId>
-                       <version>3.5.3</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.maven.shared</groupId>
-                       <artifactId>maven-invoker</artifactId>
-                       <version>3.0.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.policy.common</groupId>
-                       <artifactId>integrity-monitor</artifactId>
-                       <version>${project.version}</version>
-               </dependency>
-               <!--
-               CLM security fix - force use of commons-collections 3.2.2.
-               Remove this if a new version of nexus-rest-client-java is upgraded
-               to not use velocity (and then subsequently commons-collections v3.1 
-                -->
-               <dependency>
-                   <groupId>commons-collections</groupId>
-                   <artifactId>commons-collections</artifactId>
-                   <version>3.2.2</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.sonatype.nexus</groupId>
-                       <artifactId>nexus-rest-client-java</artifactId>
-                       <version>2.3.1-01</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>commons-collections</groupId>
-                                       <artifactId>commons-collections</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>com.thoughtworks.xstream</groupId>
-                       <artifactId>xstream</artifactId>
-                       <version>1.4.10</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.att.nsa</groupId>
-                       <artifactId>cambriaClient</artifactId>
-                       <version>0.0.1</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.slf4j</groupId>
-                                       <artifactId>slf4j-log4j12</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
-                       <artifactId>dmaapClient</artifactId>
-                       <version>${dmaap.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.slf4j</groupId>
-                                       <artifactId>slf4j-log4j12</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>com.att.aft</groupId>
-                                       <artifactId>dme2</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.httpcomponents</groupId>
-                       <artifactId>httpclient</artifactId>
-                       <version>${httpclient.version}</version>
-               </dependency>
-       </dependencies>
-       <build>
-               <plugins>
-                       <plugin>
-                               <!-- Build an executable JAR -->
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-assembly-plugin</artifactId>
-                               <version>2.2</version>
-                               <configuration>
-                                       <archive>
-                                               <manifest>
-                                                       <addClasspath>true</addClasspath>
-                                                       <classpathPrefix>lib/</classpathPrefix>
-                                                       <mainClass>org.onap.policy.brmsInterface.BRMSGateway</mainClass>
-                                               </manifest>
-                                       </archive>
-                                       <descriptorRefs>
-                                               <descriptorRef>jar-with-dependencies</descriptorRef>
-                                       </descriptorRefs>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <id>make-assembly</id>
-                                               <phase>package</phase>
-                                               <goals>
-                                                       <goal>single</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-               </plugins>
-       </build>
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.policy.engine</groupId>
+        <artifactId>PolicyEngineSuite</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>BRMSGateway</artifactId>
+    <description>This application will take in BRMS rules and acts as interface between PR and PDP XACML</description>
+    <dependencies>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.policy.engine</groupId>
+            <artifactId>PolicyEngineAPI</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.att.nsa</groupId>
+                    <artifactId>cambriaClient</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-model</artifactId>
+            <version>3.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-invoker</artifactId>
+            <version>3.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.policy.common</groupId>
+            <artifactId>integrity-monitor</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!-- CLM security fix - force use of commons-collections 3.2.2. Remove 
+            this if a new version of nexus-rest-client-java is upgraded to not use velocity 
+            (and then subsequently commons-collections v3.1 -->
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.sonatype.nexus</groupId>
+            <artifactId>nexus-rest-client-java</artifactId>
+            <version>2.3.1-01</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-collections</groupId>
+                    <artifactId>commons-collections</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.thoughtworks.xstream</groupId>
+            <artifactId>xstream</artifactId>
+            <version>1.4.10</version>
+        </dependency>
+        <dependency>
+            <groupId>com.att.nsa</groupId>
+            <artifactId>cambriaClient</artifactId>
+            <version>0.0.1</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
+            <artifactId>dmaapClient</artifactId>
+            <version>${dmaap.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.att.aft</groupId>
+                    <artifactId>dme2</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>${httpclient.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>onap-java-style</id>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                        <phase>process-sources</phase>
+                        <configuration>
+                            <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml 
+                                with minor changes -->
+                            <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+                            <!-- <sourceDirectory> is needed so that checkstyle 
+                                ignores the generated sources directory -->
+                            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+                            <includeResources>true</includeResources>
+                            <includeTestSourceDirectory>true</includeTestSourceDirectory>
+                            <includeTestResources>true</includeTestResources>
+                            <consoleOutput>true</consoleOutput>
+                            <failOnViolation>true</failOnViolation>
+                            <violationSeverity>warning</violationSeverity>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.onap.oparent</groupId>
+                        <artifactId>checkstyle</artifactId>
+                        <version>0.1.1</version>
+                        <scope>compile</scope>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <!-- Build an executable JAR -->
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.2</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>lib/</classpathPrefix>
+                            <mainClass>org.onap.policy.brmsInterface.BRMSGateway</mainClass>
+                        </manifest>
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
 
 import org.onap.policy.api.NotificationScheme;
 import org.onap.policy.api.PolicyEngine;
@@ -28,29 +28,30 @@ import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 
 /**
- * BRMSGateway: This application acts as the Gateway interface between the PDP XACML and PDP Drools. The listens for
- * BRMS based policies and pushes them to the specified Policy Repository, from where the PDP Drools reads the Rule Jar.
+ * BRMSGateway: This application acts as the Gateway interface between the PDP XACML and PDP Drools.
+ * The listens for BRMS based policies and pushes them to the specified Policy Repository, from
+ * where the PDP Drools reads the Rule Jar.
  * 
  * @version 0.1
  */
-class BRMSGateway {
-       
-    private static final Logger logger = FlexLogger.getLogger(BRMSGateway.class);
+class BrmsGateway {
+
+    private static final Logger logger = FlexLogger.getLogger(BrmsGateway.class);
     private static final String CONFIGFILE = "config.properties";
 
     private static PolicyEngine policyEngine = null;
 
-    private BRMSGateway() {
-       // Default private constructor
+    private BrmsGateway() {
+        // Default private constructor
     }
-    
-    public static void main(String[] args) throws Exception {
+
+    public static void main(final String[] args) throws Exception {
         // Initialize Handler.
         logger.info("Initializing BRMS Handler");
-        BRMSHandler bRMSHandler = null;
+        BrmsHandler brmsHandler = null;
         try {
-            bRMSHandler = new BRMSHandler(CONFIGFILE);
-        } catch (PolicyException e) {
+            brmsHandler = new BrmsHandler(CONFIGFILE);
+        } catch (final PolicyException e) {
             logger.error("Check your property file: " + e.getMessage(), e);
             System.exit(1);
         }
@@ -58,24 +59,24 @@ class BRMSGateway {
         // Set Handler with Auto Notification and initialize policyEngine
         try {
             logger.info("Initializing policyEngine with Auto Notifications");
-            policyEngine = new PolicyEngine(CONFIGFILE, NotificationScheme.AUTO_ALL_NOTIFICATIONS, bRMSHandler);
-        } catch (Exception e) {
+            policyEngine = new PolicyEngine(CONFIGFILE, NotificationScheme.AUTO_ALL_NOTIFICATIONS, brmsHandler);
+        } catch (final Exception e) {
             logger.error(XACMLErrorConstants.ERROR_UNKNOWN + "Error while Initializing Policy Engine " + e.getMessage(),
                     e);
         }
 
         // Keep Running....
-        Runnable runnable = () -> {
+        final Runnable runnable = () -> {
             while (true) {
                 try {
                     Thread.sleep(30000);
-                } catch (InterruptedException e) {
+                } catch (final InterruptedException e) {
                     logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Thread Exception " + e.getMessage());
                     Thread.currentThread().interrupt();
                 }
             }
         };
-        Thread thread = new Thread(runnable);
+        final Thread thread = new Thread(runnable);
         thread.start();
     }
 
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsHandler.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsHandler.java
new file mode 100644 (file)
index 0000000..0f686fe
--- /dev/null
@@ -0,0 +1,200 @@
+/*-
+ * ============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.brms.api;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onap.policy.api.ConfigRequestParameters;
+import org.onap.policy.api.LoadedPolicy;
+import org.onap.policy.api.NotificationType;
+import org.onap.policy.api.PDPNotification;
+import org.onap.policy.api.PolicyConfig;
+import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyEngine;
+import org.onap.policy.api.PolicyException;
+import org.onap.policy.api.RemovedPolicy;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.utils.BackUpHandler;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
+
+/**
+ * BRMSHandler: Notification Handler which listens for PDP Notifications. Take action only for BRMS
+ * policies.
+ * 
+ * @version 0.3
+ */
+public class BrmsHandler implements BackUpHandler {
+
+    private static final Logger logger = FlexLogger.getLogger(BrmsHandler.class.getName());
+
+    private BrmsPush brmsPush = null;
+
+    public BrmsHandler(final String propertiesFile) throws PolicyException {
+        setBrmsPush(new BrmsPush(propertiesFile, this));
+    }
+
+    public void setBrmsPush(final BrmsPush brmsPush) {
+        this.brmsPush = brmsPush;
+    }
+
+    /*
+     * This Method is executed upon notification by the Policy Engine API Notification.
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.onap.policy.utils.BackUpHandler#notificationReceived(org.onap.policy.api.PDPNotification)
+     */
+    @Override
+    public void notificationReceived(final PDPNotification notification) {
+        logger.info("Notification Recieved");
+        logger.info(notification.getNotificationType().toString());
+        final Boolean flag = BrmsPush.getBackUpMonitor().getFlag();
+        brmsPush.initiate(flag);
+        if (flag) {
+            logger.info("Master Application performing on Notification ");
+            runOnNotification(notification);
+        } else {
+            logger.info("Slave application Skipping Notification.. ");
+        }
+    }
+
+    /*
+     * Executed when a policy is removed from PDP.
+     */
+    private void removedPolicies(final Collection<RemovedPolicy> removedPolicies) {
+        Boolean removed = false;
+        logger.info("Removed Policies");
+        for (final RemovedPolicy removedPolicy : removedPolicies) {
+            logger.info(removedPolicy.getPolicyName());
+            logger.info(removedPolicy.getVersionNo());
+            if (removedPolicy.getPolicyName().contains("_BRMS_")) {
+                try {
+                    logger.info("Policy Removed with this policy Name : " + removedPolicy.getPolicyName());
+                    brmsPush.removeRule(removedPolicy.getPolicyName());
+                    removed = true;
+                } catch (final Exception e) {
+                    logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Rertriving policy failed " + e.getMessage(),
+                            e);
+                }
+            }
+        }
+        Boolean failureFlag;
+        int index = 0;
+        do {
+            failureFlag = false;
+            if (removed) {
+                try {
+                    brmsPush.pushRules();
+                } catch (final PolicyException e) {
+                    // Upon Notification failure
+                    failureFlag = true;
+                    brmsPush.rotateUrls();
+                    logger.error("Failure during Push Operation ", e);
+                }
+            }
+            index++;
+        } 
+        while (failureFlag && index < brmsPush.urlListSize());
+    }
+
+    /*
+     * This method is executed if BRMSGW is "MASTER" (non-Javadoc)
+     * 
+     * @see
+     * org.onap.policy.utils.BackUpHandler#runOnNotification(org.onap.policy.api.PDPNotification)
+     */
+    @Override
+    public void runOnNotification(final PDPNotification notification) {
+        // reset the BRMSPush data structures
+        brmsPush.resetDs();
+        if (notification.getNotificationType().equals(NotificationType.REMOVE)) {
+            removedPolicies(notification.getRemovedPolicies());
+        } else if (notification.getNotificationType().equals(NotificationType.UPDATE)
+                || notification.getNotificationType().equals(NotificationType.BOTH)) {
+            logger.info("Updated Policies: \n");
+            final ArrayList<PolicyConfig> brmsPolicies = addedPolicies(notification);
+            Boolean successFlag = false;
+            for (int i = 0; !successFlag && i < brmsPush.urlListSize(); i++) {
+                if (i != 0) {
+                    for (final PolicyConfig policyConfig : brmsPolicies) {
+                        logger.info("Policy Retry with this Name notified: " + policyConfig.getPolicyName());
+                        brmsPush.addRule(policyConfig.getPolicyName(), policyConfig.toOther(),
+                                policyConfig.getResponseAttributes());
+                    }
+                }
+                try {
+                    brmsPush.pushRules();
+                    successFlag = true;
+                } catch (final PolicyException e) {
+                    // Upon Notification failure
+                    successFlag = false;
+                    brmsPush.rotateUrls();
+                    logger.error("Failure during Push Operation ", e);
+                }
+            }
+        }
+    }
+
+    /*
+     * Executed when a policy is added to PDP.
+     */
+    private ArrayList<PolicyConfig> addedPolicies(final PDPNotification notification) {
+        final ArrayList<PolicyConfig> result = new ArrayList<>();
+        for (final LoadedPolicy updatedPolicy : notification.getLoadedPolicies()) {
+            logger.info("policyName : " + updatedPolicy.getPolicyName());
+            logger.info("policyVersion :" + updatedPolicy.getVersionNo());
+            logger.info("Matches: " + updatedPolicy.getMatches());
+            // Checking the Name is correct or not.
+            if (updatedPolicy.getPolicyName().contains("_BRMS_")) {
+                try {
+                    final PolicyEngine policyEngine = getPolicyEngine();
+                    if (policyEngine != null) {
+                        final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
+                        configRequestParameters.setPolicyName(updatedPolicy.getPolicyName());
+                        final Collection<PolicyConfig> policyConfigs = policyEngine.getConfig(configRequestParameters);
+                        for (final PolicyConfig policyConfig : policyConfigs) {
+                            if (policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)) {
+                                logger.info(
+                                        "Policy Retrieved with this Name notified: " + policyConfig.getPolicyName());
+                                result.add(policyConfig);
+                                brmsPush.addRule(policyConfig.getPolicyName(), policyConfig.toOther(),
+                                        policyConfig.getResponseAttributes());
+                            } else {
+                                logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR
+                                        + "Fail to retrieve policy so rule will not be pushed to PolicyRepo !!!!\n\n");
+                            }
+                        }
+                    }
+                } catch (final Exception e) {
+                    logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Rertriving policy failed " + e.getMessage(),
+                            e);
+                }
+            }
+        }
+        return result;
+    }
+
+    public PolicyEngine getPolicyEngine() {
+        return BrmsGateway.getPolicyEngine();
+    }
+}
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaClientBuilders;
+import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+import com.fasterxml.jackson.core.JsonProcessingException;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -71,9 +76,9 @@ import org.codehaus.plexus.util.WriterFactory;
 import org.eclipse.persistence.config.PersistenceUnitProperties;
 import org.onap.policy.api.PEDependency;
 import org.onap.policy.api.PolicyException;
-import org.onap.policy.brmsInterface.jpa.BRMSGroupInfo;
-import org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo;
-import org.onap.policy.brmsInterface.jpa.DependencyInfo;
+import org.onap.policy.brms.entity.BrmsGroupInfo;
+import org.onap.policy.brms.entity.BrmsPolicyInfo;
+import org.onap.policy.brms.entity.DependencyInfo;
 import org.onap.policy.common.im.IntegrityMonitor;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
@@ -90,32 +95,29 @@ import org.sonatype.nexus.client.NexusConnectionException;
 import org.sonatype.nexus.client.rest.NexusRestClient;
 import org.sonatype.nexus.rest.model.NexusArtifact;
 
-import com.att.nsa.cambria.client.CambriaBatchingPublisher;
-import com.att.nsa.cambria.client.CambriaClientBuilders;
-import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
-import com.fasterxml.jackson.core.JsonProcessingException;
-
 /**
- * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR). Mavenize and push policy
- * to PR
+ * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR).
+ * Mavenize and push policy to PR
  * 
  * @version 1.0
  */
 
 @SuppressWarnings("deprecation")
-public class BRMSPush {
+public class BrmsPush {
     private static final String GROUP_NAMES = "groupNames";
-       private static final String DROOLS_APPS_TEMPLATE_GROUP = "org.onap.policy.drools-applications.controlloop.templates";
-       private static final String DROOLS_APPS_MODEL_GROUP    = "org.onap.policy.drools-applications.controlloop.common.model-impl";
-       private static final String META_INF = "META-INF";
-       private static final String KMODULE_XML_FILE = "kmodule.xml";
-       private static final String POM_XML_FILE = "pom.xml";
-       private static final String VERSION_0_1_0 = "0.1.0";
-       private static final String RULES = "rules";
-       private static final String RESOURCES = "resources";
-       private static final Logger LOGGER = FlexLogger.getLogger(BRMSPush.class.getName());
+    private static final String DROOLS_APPS_TEMPLATE_GROUP =
+            "org.onap.policy.drools-applications.controlloop.templates";
+    private static final String DROOLS_APPS_MODEL_GROUP =
+            "org.onap.policy.drools-applications.controlloop.common.model-impl";
+    private static final String META_INF = "META-INF";
+    private static final String KMODULE_XML_FILE = "kmodule.xml";
+    private static final String POM_XML_FILE = "pom.xml";
+    private static final String VERSION_0_1_0 = "0.1.0";
+    private static final String RULES = "rules";
+    private static final String RESOURCES = "resources";
+    private static final Logger LOGGER = FlexLogger.getLogger(BrmsPush.class.getName());
     private static final String PROJECTSLOCATION = "RuleProjects";
-    private static final String[] GOALS = { "clean", "deploy" };
+    private static final String[] GOALS = {"clean", "deploy"};
     private static final String DEFAULT_VERSION = "1.2.0-SNAPSHOT";
     private static final String DEPENDENCY_FILE = "dependency.json";
     private static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
@@ -124,12 +126,12 @@ public class BRMSPush {
     private static IntegrityMonitor im;
     private static BackUpMonitor bm;
     private String defaultName = null;
-    private String repID = null;
+    private String repId = null;
     private String repName = null;
-    private ArrayList<String> repURLs = null;
+    private List<String> repUrlList = null;
     private String repUserName = null;
     private String repPassword = null;
-    private String policyKeyID = null;
+    private String policyKeyId = null;
     private boolean createFlag = false;
     private String uebList = null;
     private List<String> dmaapList = null;
@@ -139,19 +141,26 @@ public class BRMSPush {
     private Long uebDelay = Long.parseLong("20");
     private Long dmaapDelay = Long.parseLong("5000");
     private String notificationType = null;
-    private ArrayList<ControllerPOJO> controllers;
-    private HashMap<String, ArrayList<Object>> groupMap = new HashMap<>();
-    private Map<String, String> policyMap = new HashMap<>();
+    private List<ControllerPojo> controllers;
+    private Map<String, ArrayList<Object>> groupMap = new HashMap<>();
+    private final Map<String, String> policyMap = new HashMap<>();
     private String brmsdependencyversion;
     private EntityManager em;
     private boolean syncFlag = false;
 
-    public BRMSPush(String propertiesFile, BackUpHandler handler) throws PolicyException {
-        if(propertiesFile==null || handler==null){
+    /**
+     * Responsible to push policies to the BRMS PDP Policy Repository (PR).
+     * 
+     * @param propertiesFile the properties file
+     * @param handler the {@link BackUpHandler}
+     * @throws PolicyException PolicyException related to the operation
+     */
+    public BrmsPush(final String propertiesFile, final BackUpHandler handler) throws PolicyException {
+        if (propertiesFile == null || handler == null) {
             throw new PolicyException("Error no propertiesFile or handler");
         }
-        Properties config = new Properties();
-        Path file = Paths.get(propertiesFile);
+        final Properties config = new Properties();
+        final Path file = Paths.get(propertiesFile);
         if (Files.notExists(file)) {
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Config File doesn't Exist in the specified Path "
                     + file.toString());
@@ -165,12 +174,13 @@ public class BRMSPush {
         }
     }
 
-    private void setProperty(Path file, Properties config, BackUpHandler handler) throws PolicyException {
+    private void setProperty(final Path file, final Properties config, final BackUpHandler handler)
+            throws PolicyException {
         InputStream in;
         try {
             in = new FileInputStream(file.toFile());
             config.load(in);
-        } catch (IOException e) {
+        } catch (final IOException e) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "Data/File Read Error while reading from the property file.",
                     e);
@@ -188,22 +198,23 @@ public class BRMSPush {
             }
             resourceName = resourceName.trim();
             setIntegrityMonitor(IntegrityMonitor.getInstance(resourceName, config));
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error starting Integerity Monitor: " + e);
         }
         LOGGER.info("Trying to set up BackUpMonitor");
         try {
             setBackupMonitor(BackUpMonitor.getInstance(BackUpMonitor.ResourceNode.BRMS.toString(), resourceName, config,
                     handler));
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error starting BackUpMonitor: " + e);
         }
-        if(!config.containsKey(BRMSPERSISTENCE)){
+        if (!config.containsKey(BRMSPERSISTENCE)) {
             config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/persistenceBRMS.xml");
         } else {
-            config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, config.getProperty(BRMSPERSISTENCE,"META-INF/persistenceBRMS.xml"));
+            config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
+                    config.getProperty(BRMSPERSISTENCE, "META-INF/persistenceBRMS.xml"));
         }
-        EntityManagerFactory emf = Persistence.createEntityManagerFactory("BRMSGW", config);
+        final EntityManagerFactory emf = Persistence.createEntityManagerFactory("BRMSGW", config);
         em = emf.createEntityManager();
         defaultName = config.getProperty("defaultName");
         if (defaultName == null) {
@@ -213,14 +224,14 @@ public class BRMSPush {
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "defaultName property is missing from the property file");
         }
         defaultName = defaultName.trim();
-        repID = config.getProperty("repositoryID");
-        if (repID == null) {
+        repId = config.getProperty("repositoryID");
+        if (repId == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryID property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryID property is missing from the property file ");
         }
-        repID = repID.trim();
+        repId = repId.trim();
         repName = config.getProperty("repositoryName");
         if (repName == null) {
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
@@ -229,18 +240,18 @@ public class BRMSPush {
                     + "repositoryName property is missing from the property file ");
         }
         repName = repName.trim();
-        String repURL = config.getProperty("repositoryURL");
-        if (repURL == null) {
+        final String repUrl = config.getProperty("repositoryURL");
+        if (repUrl == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryURL property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryURL property is missing from the property file ");
         }
-        if (repURL.contains(",")) {
-            repURLs = new ArrayList<>(Arrays.asList(repURL.trim().split(",")));
+        if (repUrl.contains(",")) {
+            repUrlList = new ArrayList<>(Arrays.asList(repUrl.trim().split(",")));
         } else {
-            repURLs = new ArrayList<>();
-            repURLs.add(repURL);
+            repUrlList = new ArrayList<>();
+            repUrlList.add(repUrl);
         }
         repUserName = config.getProperty("repositoryUsername");
         repPassword = config.getProperty("repositoryPassword");
@@ -252,15 +263,15 @@ public class BRMSPush {
         }
         repUserName = repUserName.trim();
         repPassword = repPassword.trim();
-        policyKeyID = config.getProperty("policyKeyID");
-        if (policyKeyID == null) {
+        policyKeyId = config.getProperty("policyKeyID");
+        if (policyKeyId == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "policyKeyID property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "policyKeyID property is missing from the property file ");
         }
-        policyKeyID = policyKeyID.trim();
-        String syncF = config.getProperty("sync", "false").trim();
+        policyKeyId = policyKeyId.trim();
+        final String syncF = config.getProperty("sync", "false").trim();
         syncFlag = Boolean.parseBoolean(syncF);
         if (syncFlag) {
             PolicyLogger.info("SYNC Flag is turned ON. DB will be given Priority.");
@@ -282,8 +293,8 @@ public class BRMSPush {
             // Setting up the Publisher for DMaaP MR
             String dmaapServers = config.getProperty("NOTIFICATION_SERVERS");
             pubTopic = config.getProperty("NOTIFICATION_TOPIC");
-            String aafLogin = config.getProperty("CLIENT_ID").trim();
-            String aafPassword = config.getProperty("CLIENT_KEY").trim();
+            final String aafLogin = config.getProperty("CLIENT_ID").trim();
+            final String aafPassword = config.getProperty("CLIENT_KEY").trim();
 
             if (dmaapServers == null || pubTopic == null) {
                 LOGGER.error(
@@ -302,15 +313,15 @@ public class BRMSPush {
                 dmaapList.add(dmaapServers);
             }
 
-            this.publisher = new BusPublisher.DmaapPublisherWrapper(this.dmaapList, this.pubTopic, aafLogin,
-                    aafPassword);
+            this.publisher =
+                    new BusPublisher.DmaapPublisherWrapper(this.dmaapList, this.pubTopic, aafLogin, aafPassword);
 
-            String dDelay = config.getProperty("NOTIFICATION_DELAY");
-            if (dDelay != null && !dDelay.isEmpty()) {
-                dDelay = dDelay.trim();
+            String notificationDelay = config.getProperty("NOTIFICATION_DELAY");
+            if (notificationDelay != null && !notificationDelay.isEmpty()) {
+                notificationDelay = notificationDelay.trim();
                 try {
-                    dmaapDelay = Long.parseLong(dDelay);
-                } catch (NumberFormatException e) {
+                    dmaapDelay = Long.parseLong(notificationDelay);
+                } catch (final NumberFormatException e) {
                     LOGGER.error("DMAAP_DELAY not a long format number" + e);
                 }
             }
@@ -321,8 +332,6 @@ public class BRMSPush {
             // Setting up the Publisher for UEB
             uebList = config.getProperty("NOTIFICATION_SERVERS");
             pubTopic = config.getProperty("NOTIFICATION_TOPIC");
-            String apiKey = config.getProperty("UEB_API_KEY");
-            String apiSecret = config.getProperty("UEB_API_SECRET");
             if (uebList == null || pubTopic == null) {
                 LOGGER.error(
                         XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
@@ -333,17 +342,19 @@ public class BRMSPush {
             pubTopic = pubTopic.trim();
             pubBuilder = new CambriaClientBuilders.PublisherBuilder();
             pubBuilder.usingHosts(uebList).onTopic(pubTopic);
+            String apiKey = config.getProperty("UEB_API_KEY");
+            String apiSecret = config.getProperty("UEB_API_SECRET");
             if (apiKey != null && !apiKey.isEmpty() && apiSecret != null && !apiSecret.isEmpty()) {
                 apiKey = apiKey.trim();
                 apiSecret = apiSecret.trim();
                 pubBuilder.authenticatedBy(apiKey, apiSecret);
             }
-            String uDelay = config.getProperty("NOTIFICATION_DELAY");
-            if (uDelay != null && !uDelay.isEmpty()) {
-                uDelay = uDelay.trim();
+            String notificationDelay = config.getProperty("NOTIFICATION_DELAY");
+            if (notificationDelay != null && !notificationDelay.isEmpty()) {
+                notificationDelay = notificationDelay.trim();
                 try {
-                    uebDelay = Long.parseLong(uDelay);
-                } catch (NumberFormatException e) {
+                    uebDelay = Long.parseLong(notificationDelay);
+                } catch (final NumberFormatException e) {
                     LOGGER.error("UEB_DELAY not a long format number" + e);
                 }
             }
@@ -353,31 +364,32 @@ public class BRMSPush {
 
     }
 
-    private static void setBackupMonitor(BackUpMonitor instance) {
+    private static void setBackupMonitor(final BackUpMonitor instance) {
         bm = instance;
     }
 
-    private static void setIntegrityMonitor(IntegrityMonitor instance) {
+    private static void setIntegrityMonitor(final IntegrityMonitor instance) {
         im = instance;
     }
 
     /**
      * Will Initialize the variables required for BRMSPush.
      */
-    public void initiate(boolean flag) {
+    public void initiate(final boolean flag) {
         resetModifiedGroups();
         controllers = new ArrayList<>();
         try {
             bm.updateNotification();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error while updating Notification: " + e.getMessage(), e);
         }
-        if (flag)
+        if (flag) {
             syncGroupInfo();
+        }
     }
-    
-    public void resetDS(){
-       resetModifiedGroups();
+
+    public void resetDs() {
+        resetModifiedGroups();
         controllers = new ArrayList<>();
     }
 
@@ -388,57 +400,56 @@ public class BRMSPush {
     /**
      * Will Add rules to projects. Creates necessary folders if required.
      */
-    public void addRule(String name, String rule, Map<String, String> responseAttributes) {
+    public void addRule(final String name, final String rule, final Map<String, String> responseAttributes) {
         // 1 check the response Attributes and determine if this belongs to any projects.
         // 2 if not create folder
         // 3 create pom.
         // 4 copy the rule.
         // 5 store the groups that have been updated.
-        String kSessionName = null;
+        String ksessionName = null;
         String selectedName = null;
         if (!responseAttributes.isEmpty()) {
             // Pick selected Value
             String userControllerName = null;
-            ArrayList<PEDependency> userDependencies = new ArrayList<>();
-            for (Map.Entry<String, String> entry: responseAttributes.entrySet()) {
-               String key = entry.getKey();
-               String value = entry.getValue();
-                if (key.equals(policyKeyID)) {
+            final ArrayList<PEDependency> userDependencies = new ArrayList<>();
+            for (final Map.Entry<String, String> entry : responseAttributes.entrySet()) {
+                final String key = entry.getKey();
+                String value = entry.getValue();
+                if (key.equals(policyKeyId)) {
                     selectedName = value;
                 }
                 // kmodule configurations
                 else if ("kSessionName".equals(key)) {
-                    kSessionName = value;
+                    ksessionName = value;
                 }
                 // Check User Specific values.
                 if ("$controller:".equals(key)) {
                     try {
-                        PEDependency dependency = PolicyUtils.jsonStringToObject(value,
-                                PEDependency.class);
+                        final PEDependency dependency = PolicyUtils.jsonStringToObject(value, PEDependency.class);
                         userControllerName = key.replaceFirst("$controller:", "");
-                        LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - " + dependency);
+                        LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - "
+                                + dependency);
                         addToGroup(userControllerName, dependency);
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
                     }
 
                 } else if ("$dependency$".equals(key) && value.startsWith("[") && value.endsWith("]")) {
                     value = value.substring(1, value.length() - 1).trim();
-                    List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
-                    for (String dependencyString : dependencyStrings) {
+                    final List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
+                    for (final String dependencyString : dependencyStrings) {
                         try {
-                            userDependencies
-                                    .add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
-                        } catch (Exception e) {
-                            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW
-                                    + "Error while resolving Dependencies: " + e);
+                            userDependencies.add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
+                        } catch (final Exception e) {
+                            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Dependencies: "
+                                    + e);
                         }
                     }
                 }
             }
             if (userControllerName != null) {
                 // Adding custom dependencies here.
-                ArrayList<Object> values = groupMap.get(userControllerName);
+                final ArrayList<Object> values = groupMap.get(userControllerName);
                 values.add(userDependencies);
                 groupMap.put(userControllerName, values);
                 selectedName = userControllerName;
@@ -449,45 +460,48 @@ public class BRMSPush {
             selectedName = defaultName;
         }
         if (groupMap.containsKey(selectedName)) {
-            // If the key is not got as parameters set by the user, setting the default value for kSessionName as
+            // If the key is not got as parameters set by the user, setting the default value for
+            // kSessionName as
             // closedLoop
-            if (kSessionName == null) {
-               LOGGER.info("kSessionName is null, selectedName is  : " + selectedName );
+            if (ksessionName == null) {
+                LOGGER.info("kSessionName is null, selectedName is  : " + selectedName);
                 if (selectedName.equalsIgnoreCase(defaultName)) {
-                    kSessionName = "closedloop";
+                    ksessionName = "closedloop";
                 } else {
-                    kSessionName = "closedloop-" + selectedName;
+                    ksessionName = "closedloop-" + selectedName;
                 }
             }
             // create directories if missing.
-            manageProject(selectedName, kSessionName, name, rule);
-            addModifiedGroup(selectedName, "update"); // Will check for Create Later after generating the Pom.
+            manageProject(selectedName, ksessionName, name, rule);
+
+            // Will check for Create Later after generating the Pom.
+            addModifiedGroup(selectedName, "update");
         }
     }
 
     private void syncGroupInfo() {
         // Sync DB to JMemory.
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSGroupInfo AS b");
-        List<?> bList = query.getResultList();
-        if (bList.size() != groupMap.size()) {
-            for (Object value : bList) {
-                BRMSGroupInfo brmsGroupInfo = (BRMSGroupInfo) value;
-                PEDependency dependency = new PEDependency();
+        Query query = em.createQuery("select b from BrmsGroupInfo AS b");
+        List<?> result = query.getResultList();
+        if (result.size() != groupMap.size()) {
+            for (final Object value : result) {
+                final BrmsGroupInfo brmsGroupInfo = (BrmsGroupInfo) value;
+                final PEDependency dependency = new PEDependency();
                 dependency.setArtifactId(brmsGroupInfo.getArtifactId());
                 dependency.setGroupId(brmsGroupInfo.getGroupId());
                 dependency.setVersion(brmsGroupInfo.getVersion());
-                ArrayList<Object> values = new ArrayList<>();
+                final ArrayList<Object> values = new ArrayList<>();
                 values.add(dependency);
                 groupMap.put(brmsGroupInfo.getControllerName(), values);
             }
         }
-        query = em.createQuery("select g from BRMSPolicyInfo AS g");
-        bList = query.getResultList();
-        if (bList.size() != policyMap.size()) {
-            for (Object value : bList) {
-                BRMSPolicyInfo brmsPolicyInfo = (BRMSPolicyInfo) value;
+        query = em.createQuery("select g from BrmsPolicyInfo AS g");
+        result = query.getResultList();
+        if (result.size() != policyMap.size()) {
+            for (final Object value : result) {
+                final BrmsPolicyInfo brmsPolicyInfo = (BrmsPolicyInfo) value;
                 policyMap.put(brmsPolicyInfo.getPolicyName(), brmsPolicyInfo.getControllerName().getControllerName());
             }
         }
@@ -495,32 +509,33 @@ public class BRMSPush {
         LOGGER.info("Updated Local Memory values with values from database.");
     }
 
-    private void manageProject(String selectedName, String kSessionName, String name, String rule) {
+    private void manageProject(final String selectedName, final String ksessionName, final String name,
+            final String rule) {
         // Check if the Project is in Sync. If not get the latest Version.
         syncProject(selectedName);
-        createProject(PROJECTSLOCATION + File.separator + getArtifactID(selectedName) + File.separator + "src"
-                + File.separator + "main" + File.separator + RESOURCES, kSessionName);
-        copyDataToFile(PROJECTSLOCATION + File.separator + getArtifactID(selectedName) + File.separator + "src"
-                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES + File.separator
-                + name + ".drl", rule);
+        createProject(PROJECTSLOCATION + File.separator + getArtifactId(selectedName) + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES, ksessionName);
+        copyDataToFile(PROJECTSLOCATION + File.separator + getArtifactId(selectedName) + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES + File.separator + name
+                + ".drl", rule);
         addToPolicy(name, selectedName);
     }
 
     /*
      * Add Policy to JMemory and DataBase.
      */
-    private void addToPolicy(String policyName, String controllerName) {
+    private void addToPolicy(final String policyName, final String controllerName) {
         policyMap.put(policyName, controllerName);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
+        Query query = em.createQuery("select b from BrmsPolicyInfo as b where b.policyName = :pn");
         query.setParameter("pn", policyName);
-        List<?> pList = query.getResultList();
+        final List<?> pList = query.getResultList();
         boolean create = false;
-        BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
+        BrmsPolicyInfo brmsPolicyInfo = new BrmsPolicyInfo();
         if (!pList.isEmpty()) {
             // Already exists.
-            brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
+            brmsPolicyInfo = (BrmsPolicyInfo) pList.get(0);
             if (!brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
                 create = true;
             }
@@ -528,12 +543,12 @@ public class BRMSPush {
             create = true;
         }
         if (create) {
-            query = em.createQuery("select b from BRMSGroupInfo as b where b.controllerName = :cn");
+            query = em.createQuery("select b from BrmsGroupInfo as b where b.controllerName = :cn");
             query.setParameter("cn", controllerName);
-            List<?> bList = query.getResultList();
-            BRMSGroupInfo brmsGroupInfo = new BRMSGroupInfo();
+            final List<?> bList = query.getResultList();
+            BrmsGroupInfo brmsGroupInfo = new BrmsGroupInfo();
             if (!bList.isEmpty()) {
-                brmsGroupInfo = (BRMSGroupInfo) bList.get(0);
+                brmsGroupInfo = (BrmsGroupInfo) bList.get(0);
             }
             brmsPolicyInfo.setPolicyName(policyName);
             brmsPolicyInfo.setControllerName(brmsGroupInfo);
@@ -543,8 +558,8 @@ public class BRMSPush {
         et.commit();
     }
 
-    private void syncProject(String selectedName) {
-        boolean projectExists = checkProject(selectedName);
+    private void syncProject(final String selectedName) {
+        final boolean projectExists = checkProject(selectedName);
         if (projectExists) {
             String version;
             version = getVersion(selectedName);
@@ -553,8 +568,8 @@ public class BRMSPush {
                         + " going with Default value");
                 version = VERSION_0_1_0;
             }
-            String nextVersion = incrementVersion(version);
-            boolean outOfSync = checkRemoteSync(selectedName, nextVersion);
+            final String nextVersion = incrementVersion(version);
+            final boolean outOfSync = checkRemoteSync(selectedName, nextVersion);
             if (!outOfSync) {
                 return;
             }
@@ -563,80 +578,83 @@ public class BRMSPush {
         downloadProject(selectedName);
     }
 
-    private void downloadProject(String selectedName) {
-        NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
-        if (artifact == null)
+    private void downloadProject(final String selectedName) {
+        final NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
+        if (artifact == null) {
             return;
-        String dirName = getDirectoryName(selectedName);
+        }
+        final String dirName = getDirectoryName(selectedName);
         URL website;
-        String fileName = "rule.jar";
+        final String fileName = "rule.jar";
         try {
             website = new URL(artifact.getResourceURI());
-            tryReadableByteChannel rbc = Channels.newChannel(website.openStream());
-                       FileOutputStream fos = new FileOutputStream(fileName)){
-               fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+            try (ReadableByteChannel rbc = Channels.newChannel(website.openStream());
+                    FileOutputStream fos = new FileOutputStream(fileName)) {
+                fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
                 extractJar(fileName, dirName);
                 new File(fileName).delete();
-            }catch (IOException e) {
-         LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
-                       }
-          
-        } catch (IOException e1) {
+            } catch (final IOException e) {
+                LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+            }
+
+        } catch (final IOException e1) {
             LOGGER.error("Error while retrieve the artifact. " + e1.getMessage(), e1);
         }
     }
 
-private void extractJar(String jarFileName, String artifactId){
-               try (JarFile jar = new JarFile(jarFileName)) {  
-        Enumeration<?> enumEntries = jar.entries();
-        while (enumEntries.hasMoreElements()) {
-            JarEntry file = (JarEntry) enumEntries.nextElement();
-            File f = null;
-            String fileName = file.getName().substring(file.getName().lastIndexOf("/") + 1);
-            if (file.getName().endsWith(".drl")) {
-                String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src" + File.separator
-                        + "main" + File.separator + RESOURCES + File.separator + RULES;
-                new File(path).mkdirs();
-                if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
-                    f = new File(path + File.separator + fileName);
-                } else {
-                    f = new File(path + File.separator + fileName);
+    private void extractJar(final String jarFileName, final String artifactId) {
+        try (JarFile jar = new JarFile(jarFileName)) {
+            final Enumeration<?> enumEntries = jar.entries();
+            while (enumEntries.hasMoreElements()) {
+                final JarEntry jarEntry = (JarEntry) enumEntries.nextElement();
+                File file = null;
+                final String fileName = jarEntry.getName().substring(jarEntry.getName().lastIndexOf("/") + 1);
+                if (jarEntry.getName().endsWith(".drl")) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                            + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
+                    new File(path).mkdirs();
+                    if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
+                        file = new File(path + File.separator + fileName);
+                    } else {
+                        file = new File(path + File.separator + fileName);
+                    }
+                } else if (jarEntry.getName().endsWith(POM_XML_FILE)) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId;
+                    new File(path).mkdirs();
+                    file = new File(path + File.separator + fileName);
+                } else if (jarEntry.getName().endsWith(KMODULE_XML_FILE)) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                            + File.separator + "main" + File.separator + RESOURCES + File.separator + META_INF;
+                    new File(path).mkdirs();
+                    file = new File(path + File.separator + fileName);
                 }
-            } else if (file.getName().endsWith(POM_XML_FILE)) {
-                String path = PROJECTSLOCATION + File.separator + artifactId;
-                new File(path).mkdirs();
-                f = new File(path + File.separator + fileName);
-            } else if (file.getName().endsWith(KMODULE_XML_FILE)) {
-                String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src" + File.separator
-                        + "main" + File.separator + RESOURCES + File.separator + META_INF;
-                new File(path).mkdirs();
-                f = new File(path + File.separator + fileName);
-            }
-            if (f != null) {
-                               try (InputStream is = jar.getInputStream(file); FileOutputStream fos = new FileOutputStream(f)) {
-                while (is.available() > 0) {
-                    fos.write(is.read());
+                if (file != null) {
+                    try (InputStream is = jar.getInputStream(jarEntry);
+                            FileOutputStream fos = new FileOutputStream(file)) {
+                        while (is.available() > 0) {
+                            fos.write(is.read());
+                        }
+                        LOGGER.info(fileName + " Created..");
+                    } catch (final IOException e) {
+                        LOGGER.info("exception Occured" + e);
+                    }
                 }
-                LOGGER.info(fileName + " Created..");
-                               } catch (IOException e) {
-                                               LOGGER.info("exception Occured" + e);
-                                       }
             }
-         }
-               } catch (IOException e) {
-                       LOGGER.info("exception Occured" + e);
-               }
-  }
-
-    private NexusArtifact getLatestArtifactFromNexus(String selectedName) {
-        List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, null);
+        } catch (final IOException e) {
+            LOGGER.info("exception Occured" + e);
+        }
+    }
+
+    private NexusArtifact getLatestArtifactFromNexus(final String selectedName) {
+        final List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, null);
         int bigNum = 0;
         int smallNum = 0;
         NexusArtifact result = null;
-        for (NexusArtifact artifact : artifacts) {
-            int majorVal = Integer.parseInt(artifact.getVersion().substring(0, artifact.getVersion().indexOf(".")));
-            int minorVal = Integer.parseInt(artifact.getVersion().substring(artifact.getVersion().indexOf(".") + 1,
-                    artifact.getVersion().lastIndexOf(".")));
+        for (final NexusArtifact artifact : artifacts) {
+            final int majorVal =
+                    Integer.parseInt(artifact.getVersion().substring(0, artifact.getVersion().indexOf(".")));
+            final int minorVal = Integer.parseInt(artifact.getVersion()
+                    .substring(artifact.getVersion().indexOf(".") + 1, artifact.getVersion().lastIndexOf(".")));
             if (majorVal > bigNum) {
                 bigNum = majorVal;
                 smallNum = minorVal;
@@ -652,36 +670,36 @@ private void extractJar(String jarFileName, String artifactId){
     }
 
     // Additional Check due to Limitations from Nexus API to check if the artifact is the latest.
-    private NexusArtifact additionalNexusLatestCheck(String selectedName, NexusArtifact result) {
-        if(result==null){
+    private NexusArtifact additionalNexusLatestCheck(final String selectedName, final NexusArtifact result) {
+        if (result == null) {
             return result;
         }
-        String nextVersion = incrementVersion(result.getVersion());
-        List<NexusArtifact> artifact = getArtifactFromNexus(selectedName, nextVersion);
+        final String nextVersion = incrementVersion(result.getVersion());
+        final List<NexusArtifact> artifact = getArtifactFromNexus(selectedName, nextVersion);
         return artifact.isEmpty() ? result : additionalNexusLatestCheck(selectedName, artifact.get(0));
     }
 
-    private boolean checkRemoteSync(String selectedName, String version) {
-        List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
+    private boolean checkRemoteSync(final String selectedName, final String version) {
+        final List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
         return artifacts.isEmpty() ? false : true;
     }
 
-    private List<NexusArtifact> getArtifactFromNexus(String selectedName, String version) {
+    private List<NexusArtifact> getArtifactFromNexus(final String selectedName, final String version) {
         final NexusClient client = new NexusRestClient();
-        int i = 0;
+        int index = 0;
         boolean flag = false;
-        while (i < repURLs.size()) {
+        while (index < repUrlList.size()) {
             try {
-                String repURL = repURLs.get(0);
-                client.connect(repURL.substring(0, repURL.indexOf(repURL.split(":[0-9]+\\/nexus")[1])), repUserName,
+                final String repUrl = repUrlList.get(0);
+                client.connect(repUrl.substring(0, repUrl.indexOf(repUrl.split(":[0-9]+\\/nexus")[1])), repUserName,
                         repPassword);
                 final NexusArtifact template = new NexusArtifact();
-                template.setGroupId(getGroupID(selectedName));
-                template.setArtifactId(getArtifactID(selectedName));
+                template.setGroupId(getGroupId(selectedName));
+                template.setArtifactId(getArtifactId(selectedName));
                 if (version != null) {
                     template.setVersion(version);
                 }
-                List<NexusArtifact> resultList = client.searchByGAV(template);
+                final List<NexusArtifact> resultList = client.searchByGAV(template);
                 if (resultList != null) {
                     flag = true;
                     return resultList;
@@ -697,29 +715,15 @@ private void extractJar(String jarFileName, String artifactId){
                             + e.getMessage(), e);
                 }
                 if (!flag) {
-                    Collections.rotate(repURLs, -1);
-                    i++;
+                    Collections.rotate(repUrlList, -1);
+                    index++;
                 }
             }
         }
         return new ArrayList<>();
     }
 
-    private void setVersion(String selectedName) {
-        String newVersion = VERSION_0_1_0;
-        createFlag = false;
-        NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
-        if (artifact != null) {
-            newVersion = incrementVersion(artifact.getVersion());
-        }
-        if (VERSION_0_1_0.equals(newVersion)) {
-            createFlag = true;
-        }
-        setVersion(newVersion, selectedName);
-        LOGGER.info("Controller: " + selectedName + "is on version: " + newVersion);
-    }
-
-    private String incrementVersion(String version) {
+    private String incrementVersion(final String version) {
         int majorVal = Integer.parseInt(version.substring(0, version.indexOf(".")));
         int minorVal = Integer.parseInt(version.substring(version.indexOf(".") + 1, version.lastIndexOf(".")));
         if (minorVal >= 9) {
@@ -731,52 +735,50 @@ private void extractJar(String jarFileName, String artifactId){
         return majorVal + "." + minorVal + version.substring(version.lastIndexOf("."));
     }
 
-    private boolean checkProject(String selectedName) {
+    private boolean checkProject(final String selectedName) {
         return new File(PROJECTSLOCATION + File.separator + getDirectoryName(selectedName)).exists();
     }
 
-    private String getDirectoryName(String selectedName) {
-        return getArtifactID(selectedName);
+    private String getDirectoryName(final String selectedName) {
+        return getArtifactId(selectedName);
     }
 
     /**
      * Will Push policies to the PolicyRepo.
      * 
-     * @param notificationType
-     *            <String> type of notification Type.
-     * @throws PolicyException
+     * @throws PolicyException PolicyException related to the operation
      */
     public void pushRules() throws PolicyException {
         // Check how many groups have been updated.
         // Invoke their Maven process.
         try {
             im.startTransaction();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error while starting Transaction " + e);
         }
         if (!modifiedGroups.isEmpty()) {
             Boolean flag = false;
-            for (Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
+            for (final Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
                 InvocationResult result = null;
-               String group = entry.getKey();
+                final String group = entry.getKey();
                 try {
-                       LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
-                    InvocationRequest request = new DefaultInvocationRequest();
+                    LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
+                    final InvocationRequest request = new DefaultInvocationRequest();
                     setVersion(group);
                     createPom(group);
                     request.setPomFile(new File(
-                            PROJECTSLOCATION + File.separator + getArtifactID(group) + File.separator + POM_XML_FILE));
+                            PROJECTSLOCATION + File.separator + getArtifactId(group) + File.separator + POM_XML_FILE));
                     request.setGoals(Arrays.asList(GOALS));
-                    Invoker invoker = new DefaultInvoker();
+                    final Invoker invoker = new DefaultInvoker();
                     result = invoker.execute(request);
                     if (result.getExecutionException() != null) {
                         LOGGER.error(result.getExecutionException());
                     } else if (result.getExitCode() != 0) {
                         LOGGER.error("Maven Invocation failure..!");
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation issue for "
-                            + getArtifactID(group) + e.getMessage(), e);
+                            + getArtifactId(group) + e.getMessage(), e);
                 }
                 if (result != null && result.getExitCode() == 0) {
                     LOGGER.info("Build Completed..!");
@@ -802,8 +804,8 @@ private void extractJar(String jarFileName, String artifactId){
     /**
      * Removes a Rule from Rule Projects.
      */
-    public void removeRule(String name) {
-        String controllerName = getGroupName(name);
+    public void removeRule(final String name) {
+        final String controllerName = getGroupName(name);
         if (controllerName == null) {
             LOGGER.info("Error finding the controllerName for the given Policy: " + name);
             return;
@@ -812,7 +814,7 @@ private void extractJar(String jarFileName, String artifactId){
         getNameAndSetRemove(controllerName, name);
     }
 
-    private String getGroupName(String name) {
+    private String getGroupName(final String name) {
         if (policyMap.containsKey(name)) {
             return policyMap.get(name);
         } else {
@@ -821,57 +823,57 @@ private void extractJar(String jarFileName, String artifactId){
         }
     }
 
-    private void addModifiedGroup(String controllerName, String operation) {
+    private void addModifiedGroup(final String controllerName, final String operation) {
         if (controllerName != null) {
             modifiedGroups.put(controllerName, operation);
         }
     }
 
-    private void addNotification(String controllerName, String operation) {
-        ControllerPOJO controllerPOJO = new ControllerPOJO();
-        controllerPOJO.setName(controllerName);
-        controllerPOJO.setOperation(operation);
-        HashMap<String, String> drools = new HashMap<>();
-        drools.put("groupId", getGroupID(controllerName));
-        drools.put("artifactId", getArtifactID(controllerName));
+    private void addNotification(final String controllerName, final String operation) {
+        final ControllerPojo controllerPojo = new ControllerPojo();
+        controllerPojo.setName(controllerName);
+        controllerPojo.setOperation(operation);
+        final HashMap<String, String> drools = new HashMap<>();
+        drools.put("groupId", getGroupId(controllerName));
+        drools.put("artifactId", getArtifactId(controllerName));
         drools.put("version", getVersion(controllerName));
-        controllerPOJO.setDrools(drools);
-        controllers.add(controllerPOJO);
+        controllerPojo.setDrools(drools);
+        controllers.add(controllerPojo);
         try {
-            LOGGER.debug("Notification added: " + PolicyUtils.objectToJsonString(controllerPOJO));
-        } catch (JsonProcessingException e) {
+            LOGGER.debug("Notification added: " + PolicyUtils.objectToJsonString(controllerPojo));
+        } catch (final JsonProcessingException e) {
             LOGGER.error(MessageCodes.ERROR_SCHEMA_INVALID + "Json Processing Error " + e);
         }
     }
 
-    private void removedRuleModifiedGroup(String controllerName) {
+    private void removedRuleModifiedGroup(final String controllerName) {
         // This will be sending Notification to PDPD directly to Lock
-        ControllerPOJO controllerPOJO = new ControllerPOJO();
-        controllerPOJO.setName(controllerName);
-        controllerPOJO.setOperation("lock");
-        List<ControllerPOJO> controllerPojos = new ArrayList<>();
-        controllerPojos.add(controllerPOJO);
+        final ControllerPojo controllerPojo = new ControllerPojo();
+        controllerPojo.setName(controllerName);
+        controllerPojo.setOperation("lock");
+        final List<ControllerPojo> controllerPojos = new ArrayList<>();
+        controllerPojos.add(controllerPojo);
         sendNotification(controllerPojos);
     }
 
-    private void sendNotification(List<ControllerPOJO> controllers) {
-        NotificationPOJO notification = new NotificationPOJO();
-        String requestId = UUID.randomUUID().toString();
+    private void sendNotification(final List<ControllerPojo> controllers) {
+        final NotificationPojo notification = new NotificationPojo();
+        final String requestId = UUID.randomUUID().toString();
         LOGGER.info("Generating notification RequestID : " + requestId);
-        notification.setRequestID(requestId);
+        notification.setRequestId(requestId);
         notification.setEntity("controller");
         notification.setControllers(controllers);
         try {
-            String notificationJson = PolicyUtils.objectToJsonString(notification);
+            final String notificationJson = PolicyUtils.objectToJsonString(notification);
             LOGGER.info("Sending Notification :\n" + notificationJson);
             sendMessage(notificationJson);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while sending notification to PDP-D "
                     + e.getMessage(), e);
         }
     }
 
-    private void sendMessage(String message) throws IOException, GeneralSecurityException, InterruptedException {
+    private void sendMessage(final String message) throws IOException, GeneralSecurityException, InterruptedException {
 
         if ("dmaap".equalsIgnoreCase(notificationType)) {
             // Sending Message through DMaaP Message Router
@@ -887,7 +889,7 @@ private void extractJar(String jarFileName, String artifactId){
             // Sending Message through UEB interface.
             LOGGER.debug("UEB Publishing Message");
 
-            CambriaBatchingPublisher pub = pubBuilder.build();
+            final CambriaBatchingPublisher pub = pubBuilder.build();
             pub.send("MyPartitionKey", message);
 
             final List<?> stuck = pub.close(uebDelay, TimeUnit.SECONDS);
@@ -900,26 +902,26 @@ private void extractJar(String jarFileName, String artifactId){
 
     }
 
-    private void createPom(String name) {
-        Model model = new Model();
+    private void createPom(final String name) {
+        final Model model = new Model();
         model.setModelVersion("4.0.0");
-        model.setGroupId(getGroupID(name));
-        model.setArtifactId(getArtifactID(name));
+        model.setGroupId(getGroupId(name));
+        model.setArtifactId(getArtifactId(name));
         model.setVersion(getVersion(name));
         model.setName(name);
-        DistributionManagement distributionManagement = new DistributionManagement();
-        DeploymentRepository repository = new DeploymentRepository();
-        repository.setId(repID);
+        final DistributionManagement distributionManagement = new DistributionManagement();
+        final DeploymentRepository repository = new DeploymentRepository();
+        repository.setId(repId);
         repository.setName(repName);
-        repository.setUrl(repURLs.get(0));
+        repository.setUrl(repUrlList.get(0));
         distributionManagement.setRepository(repository);
         model.setDistributionManagement(distributionManagement);
         // Dependency Management goes here.
         List<Dependency> dependencyList = new ArrayList<>();
         if (groupMap.get(name).size() > 1) {
             @SuppressWarnings("unchecked")
-            ArrayList<PEDependency> dependencies = (ArrayList<PEDependency>) groupMap.get(name).get(1);
-            for (PEDependency dependency : dependencies) {
+            final ArrayList<PEDependency> dependencies = (ArrayList<PEDependency>) groupMap.get(name).get(1);
+            for (final PEDependency dependency : dependencies) {
                 dependencyList.add(dependency.getDependency());
             }
         } else {
@@ -930,30 +932,31 @@ private void extractJar(String jarFileName, String artifactId){
         Writer writer = null;
         try {
             writer = WriterFactory.newXmlWriter(
-                    new File(PROJECTSLOCATION + File.separator + getArtifactID(name) + File.separator + POM_XML_FILE));
-            MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+                    new File(PROJECTSLOCATION + File.separator + getArtifactId(name) + File.separator + POM_XML_FILE));
+            final MavenXpp3Writer pomWriter = new MavenXpp3Writer();
             pomWriter.write(writer, model);
-        } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating POM for " + getArtifactID(name)
+        } catch (final Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating POM for " + getArtifactId(name)
                     + e.getMessage(), e);
         } finally {
             IOUtil.close(writer);
         }
     }
 
-    private List<Dependency> getDependencies(String controllerName) {
+    private List<Dependency> getDependencies(final String controllerName) {
         // Read the Dependency Information from property file.
-        Path file = Paths.get(DEPENDENCY_FILE);
+        final Path file = Paths.get(DEPENDENCY_FILE);
         if (!Files.notExists(file)) {
             try {
-                String dependencyJSON = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
-                DependencyInfo dependencyInfo = PolicyUtils.jsonStringToObject(dependencyJSON, DependencyInfo.class);
+                final String dependencyJson = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
+                final DependencyInfo dependencyInfo =
+                        PolicyUtils.jsonStringToObject(dependencyJson, DependencyInfo.class);
                 String controller = "default";
                 if (dependencyInfo.getDependencies().containsKey(controllerName)) {
                     controller = controllerName;
                 }
-                List<Dependency> dependencyList = new ArrayList<>();
-                for (PEDependency dependency : dependencyInfo.getDependencies().get(controller)) {
+                final List<Dependency> dependencyList = new ArrayList<>();
+                for (final PEDependency dependency : dependencyInfo.getDependencies().get(controller)) {
                     dependencyList.add(dependency.getDependency());
                 }
                 return dependencyList;
@@ -966,49 +969,54 @@ private void extractJar(String jarFileName, String artifactId){
         return defaultDependencies(controllerName);
     }
 
-    // Default Dependency Section. Can be changed as required.
-    public List<Dependency> defaultDependencies(String controllerName) {
+    /**
+     * Default Dependency Section. Can be changed as required.
+     * 
+     * @param controllerName the controller name
+     * @return changed dependency list
+     */
+    public List<Dependency> defaultDependencies(final String controllerName) {
 
-        List<Dependency> dependencyList = new ArrayList<>();
-        String version = StringEscapeUtils.escapeJava(brmsdependencyversion);
+        final List<Dependency> dependencyList = new ArrayList<>();
+        final String version = StringEscapeUtils.escapeJava(brmsdependencyversion);
 
-        Dependency demoDependency = new Dependency();
+        final Dependency demoDependency = new Dependency();
         demoDependency.setGroupId(DROOLS_APPS_TEMPLATE_GROUP);
         demoDependency.setArtifactId("template.demo");
         demoDependency.setVersion(version);
         dependencyList.add(demoDependency);
 
-        Dependency controlloopDependency = new Dependency();
+        final Dependency controlloopDependency = new Dependency();
         controlloopDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         controlloopDependency.setArtifactId("events");
         controlloopDependency.setVersion(version);
         dependencyList.add(controlloopDependency);
 
-        Dependency restDependency = new Dependency();
+        final Dependency restDependency = new Dependency();
         restDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         restDependency.setArtifactId("controlloop.common.model-impl.rest");
         restDependency.setVersion(version);
         dependencyList.add(restDependency);
 
-        Dependency appcDependency = new Dependency();
+        final Dependency appcDependency = new Dependency();
         appcDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         appcDependency.setArtifactId("controlloop.common.model-impl.appc");
         appcDependency.setVersion(version);
         dependencyList.add(appcDependency);
 
-        Dependency aaiDependency = new Dependency();
+        final Dependency aaiDependency = new Dependency();
         aaiDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         aaiDependency.setArtifactId("controlloop.common.model-impl.aai");
         aaiDependency.setVersion(version);
         dependencyList.add(aaiDependency);
 
-        Dependency msoDependency = new Dependency();
+        final Dependency msoDependency = new Dependency();
         msoDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         msoDependency.setArtifactId("controlloop.common.model-impl.so");
         msoDependency.setVersion(version);
         dependencyList.add(msoDependency);
 
-        Dependency trafficgeneratorDependency = new Dependency();
+        final Dependency trafficgeneratorDependency = new Dependency();
         trafficgeneratorDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         trafficgeneratorDependency.setArtifactId("controlloop.common.model-impl.trafficgenerator");
         trafficgeneratorDependency.setVersion(version);
@@ -1016,12 +1024,12 @@ private void extractJar(String jarFileName, String artifactId){
         return dependencyList;
     }
 
-    private void createProject(String path, String ksessionName) {
+    private void createProject(final String path, final String ksessionName) {
         new File(path + File.separator + RULES).mkdirs();
         new File(path + File.separator + META_INF).mkdirs();
         if (!Files.exists(Paths.get(path + File.separator + META_INF + File.separator + KMODULE_XML_FILE))) {
             // Hard coding XML for PDP Drools to accept our Rules.
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n"
+            final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n"
                     + "<kmodule xmlns=\"http://jboss.org/kie/6.0.0/kmodule\">" + "\n"
                     + "<kbase name=\"rules\" packages=\"rules\">" + "\n" + "<ksession name=\"" + ksessionName + "\"/>"
                     + "\n" + "</kbase></kmodule>";
@@ -1029,75 +1037,72 @@ private void extractJar(String jarFileName, String artifactId){
         }
     }
 
-    private void copyDataToFile(String file, String rule) {
+    private void copyDataToFile(final String file, final String rule) {
         try {
             FileUtils.writeStringToFile(new File(file), rule);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating Rule for " + file + e.getMessage(),
                     e);
         }
     }
 
-    private void readGroups(Properties config) throws PolicyException {
+    private void readGroups(final Properties config) throws PolicyException {
         String[] groupNames;
-        String groupNamesError = "groupNames property is missing or empty from the property file ";
-               if (!config.containsKey(GROUP_NAMES) || config.getProperty(GROUP_NAMES)==null){
-            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
+        final String groupNamesError = "groupNames property is missing or empty from the property file ";
+        if (!config.containsKey(GROUP_NAMES) || config.getProperty(GROUP_NAMES) == null) {
+            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
         }
         if (config.getProperty(GROUP_NAMES).contains(",")) {
             groupNames = config.getProperty(GROUP_NAMES).replaceAll(" ", "").split(",");
         } else {
-            groupNames = new String[] { config.getProperty(GROUP_NAMES).replaceAll(" ", "") };
+            groupNames = new String[] {config.getProperty(GROUP_NAMES).replaceAll(" ", "")};
         }
         if (groupNames == null || groupNames.length == 0) {
-            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
-            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
+            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
         }
         groupMap = new HashMap<>();
         for (int counter = 0; counter < groupNames.length; counter++) {
-            String name = groupNames[counter];
-            String groupID = config.getProperty(name + ".groupID");
-            if (groupID == null) {
+            final String name = groupNames[counter];
+            final String groupId = config.getProperty(name + ".groupID");
+            if (groupId == null) {
                 LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".groupID property is missing from the property file ");
                 throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".groupID property is missing from the property file ");
             }
-            String artifactID = config.getProperty(name + ".artifactID");
-            if (artifactID == null) {
+            final String artifactId = config.getProperty(name + ".artifactID");
+            if (artifactId == null) {
                 LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".artifactID property is missing from the property file ");
                 throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".artifactID property is missing from the property file ");
             }
-            PEDependency dependency = new PEDependency();
-            dependency.setArtifactId(artifactID);
-            dependency.setGroupId(groupID);
+            final PEDependency dependency = new PEDependency();
+            dependency.setArtifactId(artifactId);
+            dependency.setGroupId(groupId);
             // Add to list if we got all
             addToGroup(name, dependency);
         }
     }
 
-    private void addToGroup(String name, PEDependency dependency) {
-        ArrayList<Object> values = new ArrayList<>();
+    private void addToGroup(final String name, final PEDependency dependency) {
+        final ArrayList<Object> values = new ArrayList<>();
         values.add(dependency);
         groupMap.put(name, values);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSGroupInfo as b where b.controllerName = :cn");
+        final Query query = em.createQuery("select b from BrmsGroupInfo as b where b.controllerName = :cn");
         query.setParameter("cn", name);
-        List<?> groupList = query.getResultList();
-        BRMSGroupInfo brmsGroupInfo = null;
+        final List<?> groupList = query.getResultList();
+        BrmsGroupInfo brmsGroupInfo = null;
         if (!groupList.isEmpty()) {
             LOGGER.info("Controller name already Existing in DB. Will be updating the DB Values" + name);
-            brmsGroupInfo = (BRMSGroupInfo) groupList.get(0);
+            brmsGroupInfo = (BrmsGroupInfo) groupList.get(0);
         }
         if (brmsGroupInfo == null) {
-            brmsGroupInfo = new BRMSGroupInfo();
+            brmsGroupInfo = new BrmsGroupInfo();
         }
         brmsGroupInfo.setControllerName(name);
         brmsGroupInfo.setGroupId(dependency.getGroupId());
@@ -1108,23 +1113,23 @@ private void extractJar(String jarFileName, String artifactId){
         et.commit();
     }
 
-    private String getArtifactID(String name) {
+    private String getArtifactId(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getArtifactId();
     }
 
-    private String getGroupID(String name) {
+    private String getGroupId(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getGroupId();
     }
 
-    private String getVersion(String name) {
+    private String getVersion(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getVersion();
     }
 
-    private void getNameAndSetRemove(String controllerName, String policyName) {
-        String artifactName = getArtifactID(controllerName);
-        String ruleFolder = PROJECTSLOCATION + File.separator + artifactName + File.separator + "src" + File.separator
-                + "main" + File.separator + RESOURCES + File.separator + RULES;
-        File file = new File(ruleFolder + File.separator + policyName + ".drl");
+    private void getNameAndSetRemove(final String controllerName, final String policyName) {
+        final String artifactName = getArtifactId(controllerName);
+        final String ruleFolder = PROJECTSLOCATION + File.separator + artifactName + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
+        final File file = new File(ruleFolder + File.separator + policyName + ".drl");
         if (file.delete()) {
             LOGGER.info("Deleted File.. " + file.getAbsolutePath());
             removePolicyFromGroup(policyName, controllerName);
@@ -1138,17 +1143,17 @@ private void extractJar(String jarFileName, String artifactId){
     }
 
     // Removes Policy from Memory and Database.
-    private void removePolicyFromGroup(String policyName, String controllerName) {
+    private void removePolicyFromGroup(final String policyName, final String controllerName) {
         policyMap.remove(policyName);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
+        final Query query = em.createQuery("select b from BrmsPolicyInfo as b where b.policyName = :pn");
         query.setParameter("pn", policyName);
-        List<?> pList = query.getResultList();
-        BRMSPolicyInfo brmsPolicyInfo;
+        final List<?> pList = query.getResultList();
+        BrmsPolicyInfo brmsPolicyInfo;
         if (!pList.isEmpty()) {
             // Already exists.
-            brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
+            brmsPolicyInfo = (BrmsPolicyInfo) pList.get(0);
             if (brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
                 em.remove(brmsPolicyInfo);
                 em.flush();
@@ -1157,8 +1162,22 @@ private void extractJar(String jarFileName, String artifactId){
         et.commit();
     }
 
-    private void setVersion(String newVersion, String controllerName) {
-        PEDependency userController = (PEDependency) groupMap.get(controllerName).get(0);
+    private void setVersion(final String selectedName) {
+        String newVersion = VERSION_0_1_0;
+        createFlag = false;
+        final NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
+        if (artifact != null) {
+            newVersion = incrementVersion(artifact.getVersion());
+        }
+        if (VERSION_0_1_0.equals(newVersion)) {
+            createFlag = true;
+        }
+        setVersion(newVersion, selectedName);
+        LOGGER.info("Controller: " + selectedName + "is on version: " + newVersion);
+    }
+
+    private void setVersion(final String newVersion, final String controllerName) {
+        final PEDependency userController = (PEDependency) groupMap.get(controllerName).get(0);
         userController.setVersion(newVersion);
         groupMap.get(controllerName).set(0, userController);
     }
@@ -1168,16 +1187,21 @@ private void extractJar(String jarFileName, String artifactId){
         return bm;
     }
 
-    public void rotateURLs() {
-        if (repURLs != null) {
-            Collections.rotate(repURLs, -1);
+    /**
+     * Rotate URLs list.
+     */
+    public void rotateUrls() {
+        if (repUrlList != null) {
+            Collections.rotate(repUrlList, -1);
         }
     }
 
+    /**
+     * Get URL List Size.
+     * 
+     * @return URL list size
+     */
     public int urlListSize() {
-        if (repURLs != null) {
-            return repURLs.size();
-        } else
-            return 0;
+        return repUrlList != null ? repUrlList.size() : 0;
     }
 }
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
 
 import java.util.Map;
 
 /**
- * POJO for controller information. 
+ * POJO for controller information.
  * 
  */
-public class ControllerPOJO {
-       private String name;
-       private Map<String,String> drools;
-       private String operation;
-       public String getName() {
-               return name;
-       }
-       public void setName(String name) {
-               this.name = name;
-       }
-       public Map<String,String> getDrools() {
-               return drools;
-       }
-       public void setDrools(Map<String,String> drools) {
-               this.drools = drools;
-       }
-       public String getOperation() {
-               return operation;
-       }
-       public void setOperation(String operation) {
-               this.operation = operation;
-       }
-}
+public class ControllerPojo {
+    private String name;
+    private Map<String, String> drools;
+    private String operation;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public Map<String, String> getDrools() {
+        return drools;
+    }
 
+    public void setDrools(final Map<String, String> drools) {
+        this.drools = drools;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public void setOperation(final String operation) {
+        this.operation = operation;
+    }
+}
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
 
 import java.util.List;
 
 /**
- * This POJO will be transformed to JSON for Notification Purposes.  
+ * This POJO will be transformed to JSON for Notification Purposes.
  * 
  */
-public class NotificationPOJO {
-       private String requestID;
-       private String entity;
-       private List<ControllerPOJO> controllers;
-       public String getRequestID() {
-               return requestID;
-       }
-       public void setRequestID(String requestID) {
-               this.requestID = requestID;
-       }
-       public String getEntity() {
-               return entity;
-       }
-       public void setEntity(String entity) {
-               this.entity = entity;
-       }
-       public List<ControllerPOJO> getControllers() {
-               return controllers;
-       }
-       public void setControllers(List<ControllerPOJO> controllers) {
-               this.controllers = controllers;
-       }
-       
+public class NotificationPojo {
+    private String requestId;
+    private String entity;
+    private List<ControllerPojo> controllers;
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(final String requestId) {
+        this.requestId = requestId;
+    }
+
+    public String getEntity() {
+        return entity;
+    }
+
+    public void setEntity(final String entity) {
+        this.entity = entity;
+    }
+
+    public List<ControllerPojo> getControllers() {
+        return controllers;
+    }
+
+    public void setControllers(final List<ControllerPojo> controllers) {
+        this.controllers = controllers;
+    }
+
 }
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/entity/BrmsGroupInfo.java b/BRMSGateway/src/main/java/org/onap/policy/brms/entity/BrmsGroupInfo.java
new file mode 100644 (file)
index 0000000..f710b41
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============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.brms.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "brmsgroup_info")
+public class BrmsGroupInfo {
+
+    @Id
+    @Column(name = "controllerName", nullable = false, length = 255)
+    private String controllerName;
+
+    @Column(name = "groupId", nullable = false, length = 255)
+    private String groupId;
+
+    @Column(name = "artifactId", nullable = false, length = 255)
+    private String artifactId;
+
+    @Column(name = "version", length = 255)
+    private String version;
+
+    public String getControllerName() {
+        return controllerName;
+    }
+
+    public void setControllerName(final String controllerName) {
+        this.controllerName = controllerName;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(final String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public void setArtifactId(final String artifactId) {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(final String version) {
+        this.version = version;
+    }
+}
@@ -17,7 +17,8 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.policy.brmsInterface.jpa;
+
+package org.onap.policy.brms.entity;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
@@ -27,30 +28,30 @@ import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
 @Entity
-@Table(name="brmsgroup_policy")
-public class BRMSPolicyInfo {
-       
-       @Id
-       @Column(name="policyName")
-       private String policyName;
-       
-       @ManyToOne
-       @JoinColumn(name="controllerName")
-       private BRMSGroupInfo controllerName;
-       
-       public String getPolicyName() {
-               return policyName;
-       }
-
-       public void setPolicyName(String policyName) {
-               this.policyName = policyName;
-       }
-
-       public BRMSGroupInfo getControllerName() {
-               return controllerName;
-       }
-
-       public void setControllerName(BRMSGroupInfo controllerName) {
-               this.controllerName = controllerName;
-       }
+@Table(name = "brmsgroup_policy")
+public class BrmsPolicyInfo {
+
+    @Id
+    @Column(name = "policyName")
+    private String policyName;
+
+    @ManyToOne
+    @JoinColumn(name = "controllerName")
+    private BrmsGroupInfo controllerName;
+
+    public String getPolicyName() {
+        return policyName;
+    }
+
+    public void setPolicyName(final String policyName) {
+        this.policyName = policyName;
+    }
+
+    public BrmsGroupInfo getControllerName() {
+        return controllerName;
+    }
+
+    public void setControllerName(final BrmsGroupInfo controllerName) {
+        this.controllerName = controllerName;
+    }
 }
@@ -17,7 +17,8 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.policy.brmsInterface.jpa;
+
+package org.onap.policy.brms.entity;
 
 import java.util.List;
 import java.util.Map;
@@ -25,14 +26,15 @@ import java.util.Map;
 import org.onap.policy.api.PEDependency;
 
 public class DependencyInfo {
-       private Map<String, List<PEDependency>> dependencies;
+    
+    private Map<String, List<PEDependency>> dependencies;
+
+    public Map<String, List<PEDependency>> getDependencies() {
+        return dependencies;
+    }
 
-       public Map<String, List<PEDependency>> getDependencies() {
-               return dependencies;
-       }
+    public void setDependencies(final Map<String, List<PEDependency>> dependencies) {
+        this.dependencies = dependencies;
+    }
 
-       public void setDependencies(Map<String, List<PEDependency>> dependencies) {
-               this.dependencies = dependencies;
-       }
-       
 }
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
deleted file mode 100644 (file)
index b460fb8..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * ============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.brmsInterface;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.onap.policy.api.ConfigRequestParameters;
-import org.onap.policy.api.LoadedPolicy;
-import org.onap.policy.api.NotificationType;
-import org.onap.policy.api.PDPNotification;
-import org.onap.policy.api.PolicyConfig;
-import org.onap.policy.api.PolicyConfigStatus;
-import org.onap.policy.api.PolicyEngine;
-import org.onap.policy.api.PolicyException;
-import org.onap.policy.api.RemovedPolicy;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.utils.BackUpHandler;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-
-/**
- * BRMSHandler: Notification Handler which listens for PDP Notifications. 
- * Take action only for BRMS policies. 
- * 
- * @version 0.3
- */
-public class BRMSHandler implements BackUpHandler{
-       
-       private static final Logger logger = FlexLogger.getLogger(BRMSHandler.class.getName());
-       
-       private BRMSPush bRMSPush = null;
-       
-       public BRMSHandler(String propertiesFile) throws PolicyException{
-               setBRMSPush(new BRMSPush(propertiesFile, this));
-       }
-
-       public void setBRMSPush(BRMSPush brmsPush) {
-               this.bRMSPush = brmsPush;
-       }
-       
-       /*
-        * This Method is executed upon notification by the Policy Engine API Notification. 
-        * (non-Javadoc)
-        * @see org.onap.policy.utils.BackUpHandler#notificationReceived(org.onap.policy.api.PDPNotification)
-        */
-       @Override
-       public void notificationReceived(PDPNotification notification) {
-               logger.info("Notification Recieved");
-               logger.info(notification.getNotificationType().toString());
-               Boolean flag = BRMSPush.getBackUpMonitor().getFlag();
-               bRMSPush.initiate(flag);
-               if(flag){
-                       logger.info("Master Application performing on Notification ");
-                       runOnNotification(notification);
-               }else{
-                       logger.info("Slave application Skipping Notification.. ");
-               }
-       }
-       
-       /*
-        * Executed when a policy is removed from PDP.  
-        */
-       private void removedPolicies(Collection<RemovedPolicy> removedPolicies){
-               Boolean removed = false;
-               logger.info("Removed Policies");
-               for(RemovedPolicy removedPolicy: removedPolicies){
-                       logger.info(removedPolicy.getPolicyName());
-                       logger.info(removedPolicy.getVersionNo());
-                       if(removedPolicy.getPolicyName().contains("_BRMS_")){
-                               try{
-                                       logger.info("Policy Removed with this policy Name : " + removedPolicy.getPolicyName());
-                                       bRMSPush.removeRule(removedPolicy.getPolicyName());
-                                       removed = true;
-                               }catch(Exception e){
-                                       logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Rertriving policy failed " + e.getMessage(), e);
-                               }
-                       }
-               }
-               Boolean failureFlag;
-               int i = 0;
-               do{
-                       failureFlag = false;
-                       if(removed){
-                               try{
-                                       bRMSPush.pushRules();
-                               }catch(PolicyException e){
-                                       //Upon Notification failure 
-                                       failureFlag = true;
-                                       bRMSPush.rotateURLs();
-                                       logger.error("Failure during Push Operation " , e);
-                               }
-                       }
-                       i++;
-               }while(failureFlag && i< bRMSPush.urlListSize());
-       }
-       
-       /*
-        * This method is executed if BRMSGW is "MASTER" 
-        * (non-Javadoc)
-        * @see org.onap.policy.utils.BackUpHandler#runOnNotification(org.onap.policy.api.PDPNotification)
-        */
-       @Override
-       public void runOnNotification(PDPNotification notification){
-               // reset the BRMSPush data structures
-               bRMSPush.resetDS();
-               if(notification.getNotificationType().equals(NotificationType.REMOVE)){
-                       removedPolicies(notification.getRemovedPolicies());
-               }else if(notification.getNotificationType().equals(NotificationType.UPDATE)|| notification.getNotificationType().equals(NotificationType.BOTH)){
-                       logger.info("Updated Policies: \n");
-                       ArrayList<PolicyConfig> brmsPolicies = addedPolicies(notification);
-                       Boolean successFlag = false;
-                       for(int i=0; !successFlag && i< bRMSPush.urlListSize(); i++){
-                               if(i!=0){
-                                       for(PolicyConfig policyConfig: brmsPolicies){
-                                               logger.info("Policy Retry with this Name notified: " + policyConfig.getPolicyName());
-                                               bRMSPush.addRule(policyConfig.getPolicyName(),policyConfig.toOther(),policyConfig.getResponseAttributes());
-                                       }
-                               }
-                               try{
-                                       bRMSPush.pushRules();
-                                       successFlag = true;
-                               }catch(PolicyException e){
-                                       //Upon Notification failure 
-                                       successFlag = false;
-                                       bRMSPush.rotateURLs();
-                                       logger.error("Failure during Push Operation " , e);
-                               }
-                       }
-               }
-       }
-
-       /*
-        * Executed when a policy is added to PDP.  
-        */
-       private ArrayList<PolicyConfig> addedPolicies(PDPNotification notification) {
-               ArrayList<PolicyConfig> result = new ArrayList<>();
-               for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){
-                       logger.info("policyName : " + updatedPolicy.getPolicyName());
-                       logger.info("policyVersion :" + updatedPolicy.getVersionNo());
-                       logger.info("Matches: " + updatedPolicy.getMatches());
-                       // Checking the Name is correct or not. 
-                       if(updatedPolicy.getPolicyName().contains("_BRMS_")){
-                               try{
-                                       PolicyEngine policyEngine = getPolicyEngine();
-                                       if(policyEngine!=null){
-                                               ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
-                                               configRequestParameters.setPolicyName(updatedPolicy.getPolicyName());
-                                               Collection<PolicyConfig> policyConfigs = policyEngine.getConfig(configRequestParameters);
-                                               for(PolicyConfig policyConfig: policyConfigs){
-                                                       if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
-                                                               logger.info("Policy Retrieved with this Name notified: " + policyConfig.getPolicyName());
-                                                               result.add(policyConfig);
-                                                               bRMSPush.addRule(policyConfig.getPolicyName(),policyConfig.toOther(),policyConfig.getResponseAttributes());
-                                                       }else{
-                                                               logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Fail to retrieve policy so rule will not be pushed to PolicyRepo !!!!\n\n");
-                                                       }
-                                               }
-                                       }
-                               }catch(Exception e){
-                                       logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Rertriving policy failed " + e.getMessage(), e);
-                               }
-                       }
-               }
-               return result;
-       }
-
-       public PolicyEngine getPolicyEngine() {
-               return BRMSGateway.getPolicyEngine();
-       }
-}
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/jpa/BRMSGroupInfo.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/jpa/BRMSGroupInfo.java
deleted file mode 100644 (file)
index 6b4a2bf..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.policy.brmsInterface.jpa;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="brmsgroup_info")
-public class BRMSGroupInfo{
-       
-       @Id
-       @Column(name = "controllerName", nullable=false, length=255)
-       private String controllerName;
-       
-       @Column(name = "groupId", nullable=false, length=255)
-       private String groupId;
-       
-       @Column(name = "artifactId", nullable=false, length=255)
-       private String artifactId;
-       
-       @Column(name = "version", length=255)
-       private String version;
-       
-       public String getControllerName() {
-               return controllerName;
-       }
-
-       public void setControllerName(String controllerName) {
-               this.controllerName = controllerName;
-       }
-
-       public String getGroupId() {
-               return groupId;
-       }
-
-       public void setGroupId(String groupId) {
-               this.groupId = groupId;
-       }
-
-       public String getArtifactId() {
-               return artifactId;
-       }
-
-       public void setArtifactId(String artifactId) {
-               this.artifactId = artifactId;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-}
index 99e6b92..f490218 100644 (file)
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
   PolicyEngineUtils
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   -->
 
 <persistence version="2.1"
-       xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
-       <persistence-unit name="BRMSGW" transaction-type="RESOURCE_LOCAL">
-               <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-               <class>org.onap.policy.brmsInterface.jpa.BRMSGroupInfo</class>
-               <class>org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo</class>
-       </persistence-unit>
+    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    <persistence-unit name="BRMSGW" transaction-type="RESOURCE_LOCAL">
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+        <class>org.onap.policy.brms.entity.BrmsGroupInfo</class>
+        <class>org.onap.policy.brms.entity.BrmsPolicyInfo</class>
+    </persistence-unit>
 </persistence>
\ No newline at end of file
diff --git a/BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSJpaTest.java b/BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSJpaTest.java
deleted file mode 100644 (file)
index ffcc2e3..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============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.brmsgw.test;
-
-import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.api.PEDependency;
-import org.onap.policy.brmsInterface.jpa.BRMSGroupInfo;
-import org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo;
-import org.onap.policy.brmsInterface.jpa.DependencyInfo;
-
-public class BRMSJpaTest {
-       @Test
-       public void testJpa() {
-               String testVal = "testVal";
-               BRMSGroupInfo groupInfo = new BRMSGroupInfo();
-               
-               // Test group info
-               groupInfo.setControllerName(testVal);
-               assertEquals(groupInfo.getControllerName(), testVal);
-               groupInfo.setGroupId(testVal);
-               assertEquals(groupInfo.getGroupId(), testVal);
-               groupInfo.setArtifactId(testVal);
-               assertEquals(groupInfo.getArtifactId(), testVal);
-               groupInfo.setVersion(testVal);
-               assertEquals(groupInfo.getVersion(), testVal);
-               
-               // Test policy info
-               BRMSPolicyInfo policyInfo = new BRMSPolicyInfo();
-               policyInfo.setPolicyName(testVal);
-               assertEquals(policyInfo.getPolicyName(), testVal);
-               policyInfo.setControllerName(groupInfo);
-               assertEquals(policyInfo.getControllerName(), groupInfo);
-       }
-       
-       @Test
-       public void testDependencyInfo() {
-               String testKey = "testKey";
-               PEDependency dependency = new PEDependency();
-               List<PEDependency> list = new ArrayList<PEDependency>();
-               list.add(dependency);
-               Map<String, List<PEDependency>> map = new HashMap<String, List<PEDependency>>();
-               map.put(testKey, list);
-               DependencyInfo info = new DependencyInfo();
-               
-               info.setDependencies(map);
-               assertEquals(info.getDependencies(), map);
-       }
-}
diff --git a/BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSPushTest.java b/BRMSGateway/src/test/java/org/onap/brmsgw/test/BRMSPushTest.java
deleted file mode 100644 (file)
index aa25744..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.brmsgw.test;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.onap.policy.api.PolicyException;
-import org.onap.policy.brmsInterface.BRMSHandler;
-
-public class BRMSPushTest {
-    
-    private final String VALIDFILE = "src/test/resources/config.properties";
-    private final String INVALIDFILE = "src/test/resources/failure.properties";
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest() throws PolicyException {
-        new BRMSHandler(null);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest1() throws PolicyException {
-        new BRMSHandler("src/test/resources/filenotexists.txt");
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest2() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "defaultName";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest3() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "repositoryID";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        prop = new PropertyChange();
-        prop.key = "RESOURCE_NAME";
-        prop.remove = true;
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest4() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "repositoryURL";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest5() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "repositoryName";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest6() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "repositoryURL";
-        prop.value = "http://nexus:8081/nexus/content/repositories/releases, http://nexus:8081/nexus/content/repositories/releases";
-        prop.remove = false;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        prop = new PropertyChange();
-        prop.key = "repositoryUsername";
-        prop.remove = true;
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest7() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "repositoryPassword";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest8() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "policyKeyID";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest9() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "sync";
-        prop.value = "true";
-        prop.remove = false;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        prop = new PropertyChange();
-        prop.key = "brms.dependency.version";
-        prop.remove = true;
-        props.add(prop);
-        prop = new PropertyChange();
-        prop.key = "groupNames";
-        prop.remove = true;
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest10() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "groupNames";
-        prop.value = "";
-        prop.remove = false;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest11() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "default.groupID";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest12() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "default.artifactID";
-        prop.remove = true;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test (expected = PolicyException.class)
-    public void bRMSHandlerFailTest13() throws PolicyException {
-        PropertyChange prop = new PropertyChange();
-        prop.key = "NOTIFICATION_TYPE";
-        prop.value = "dmaap";
-        prop.remove = false;
-        List<PropertyChange> props = new LinkedList<>();
-        props.add(prop);
-        prop = new PropertyChange();
-        prop.key = "NOTIFICATION_SERVERS";
-        prop.remove = true;
-        props.add(prop);
-        setFailureProperties(props);
-        new BRMSHandler(INVALIDFILE);
-    }
-    
-    @Test
-    public void BRMSHandlerTest() throws PolicyException {
-        assertNotNull(new BRMSHandler(VALIDFILE));
-    }
-    
-    private void setFailureProperties(List<PropertyChange> properties) throws PolicyException {
-        Properties validProp = new Properties();
-        try {
-            validProp.load(new FileInputStream(VALIDFILE));
-            for (PropertyChange prop: properties) {
-                if(prop.remove) {
-                    validProp.remove(prop.key);
-                }else {
-                    validProp.setProperty(prop.key, prop.value);
-                }
-            }
-            validProp.store(new FileOutputStream(INVALIDFILE), null);
-        } catch (IOException e) {
-            throw new PolicyException(e);
-        }
-    }
-    
-    class PropertyChange {
-        public String key = null;
-        public String value = null;
-        public Boolean remove = false;
-    }
-}
diff --git a/BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsJpaTest.java b/BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsJpaTest.java
new file mode 100644 (file)
index 0000000..32ed314
--- /dev/null
@@ -0,0 +1,73 @@
+/*-
+ * ============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.brmsgw.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.policy.api.PEDependency;
+import org.onap.policy.brms.entity.BrmsGroupInfo;
+import org.onap.policy.brms.entity.BrmsPolicyInfo;
+import org.onap.policy.brms.entity.DependencyInfo;
+
+public class BrmsJpaTest {
+    @Test
+    public void testJpa() {
+        final String testVal = "testVal";
+        final BrmsGroupInfo groupInfo = new BrmsGroupInfo();
+
+        // Test group info
+        groupInfo.setControllerName(testVal);
+        assertEquals(groupInfo.getControllerName(), testVal);
+        groupInfo.setGroupId(testVal);
+        assertEquals(groupInfo.getGroupId(), testVal);
+        groupInfo.setArtifactId(testVal);
+        assertEquals(groupInfo.getArtifactId(), testVal);
+        groupInfo.setVersion(testVal);
+        assertEquals(groupInfo.getVersion(), testVal);
+
+        // Test policy info
+        final BrmsPolicyInfo policyInfo = new BrmsPolicyInfo();
+        policyInfo.setPolicyName(testVal);
+        assertEquals(policyInfo.getPolicyName(), testVal);
+        policyInfo.setControllerName(groupInfo);
+        assertEquals(policyInfo.getControllerName(), groupInfo);
+    }
+
+    @Test
+    public void testDependencyInfo() {
+        final String testKey = "testKey";
+        final PEDependency dependency = new PEDependency();
+        final List<PEDependency> list = new ArrayList<PEDependency>();
+        list.add(dependency);
+        final Map<String, List<PEDependency>> map = new HashMap<String, List<PEDependency>>();
+        map.put(testKey, list);
+        final DependencyInfo info = new DependencyInfo();
+
+        info.setDependencies(map);
+        assertEquals(info.getDependencies(), map);
+    }
+}
diff --git a/BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/brmsgw/test/BrmsPushTest.java
new file mode 100644 (file)
index 0000000..36e6336
--- /dev/null
@@ -0,0 +1,235 @@
+/*-
+ * ============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.brmsgw.test;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.onap.policy.api.PolicyException;
+import org.onap.policy.brms.api.BrmsHandler;
+
+public class BrmsPushTest {
+
+    private static final String VALID_FILE = "src/test/resources/config.properties";
+    private static final String INVALID_FILE = "src/test/resources/failure.properties";
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest() throws PolicyException {
+        new BrmsHandler(null);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest1() throws PolicyException {
+        new BrmsHandler("src/test/resources/filenotexists.txt");
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest2() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "defaultName";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest3() throws PolicyException {
+        PropertyChange prop = new PropertyChange();
+        prop.key = "repositoryID";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        prop = new PropertyChange();
+        prop.key = "RESOURCE_NAME";
+        prop.remove = true;
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest4() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "repositoryURL";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest5() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "repositoryName";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest6() throws PolicyException {
+        PropertyChange prop = new PropertyChange();
+        prop.key = "repositoryURL";
+        prop.value =
+                "http://nexus:8081/nexus/content/repositories/releases, http://nexus:8081/nexus/content/repositories/releases";
+        prop.remove = false;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        prop = new PropertyChange();
+        prop.key = "repositoryUsername";
+        prop.remove = true;
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest7() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "repositoryPassword";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest8() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "policyKeyID";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest9() throws PolicyException {
+        PropertyChange prop = new PropertyChange();
+        prop.key = "sync";
+        prop.value = "true";
+        prop.remove = false;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        prop = new PropertyChange();
+        prop.key = "brms.dependency.version";
+        prop.remove = true;
+        props.add(prop);
+        prop = new PropertyChange();
+        prop.key = "groupNames";
+        prop.remove = true;
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest10() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "groupNames";
+        prop.value = "";
+        prop.remove = false;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest11() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "default.groupID";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest12() throws PolicyException {
+        final PropertyChange prop = new PropertyChange();
+        prop.key = "default.artifactID";
+        prop.remove = true;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test(expected = PolicyException.class)
+    public void brmsHandlerFailTest13() throws PolicyException {
+        PropertyChange prop = new PropertyChange();
+        prop.key = "NOTIFICATION_TYPE";
+        prop.value = "dmaap";
+        prop.remove = false;
+        final List<PropertyChange> props = new LinkedList<>();
+        props.add(prop);
+        prop = new PropertyChange();
+        prop.key = "NOTIFICATION_SERVERS";
+        prop.remove = true;
+        props.add(prop);
+        setFailureProperties(props);
+        new BrmsHandler(INVALID_FILE);
+    }
+
+    @Test
+    public void brmsHandlerTest() throws PolicyException {
+        assertNotNull(new BrmsHandler(VALID_FILE));
+    }
+
+    private void setFailureProperties(final List<PropertyChange> properties) throws PolicyException {
+        final Properties validProp = new Properties();
+        try {
+            validProp.load(new FileInputStream(VALID_FILE));
+            for (final PropertyChange prop : properties) {
+                if (prop.remove) {
+                    validProp.remove(prop.key);
+                } else {
+                    validProp.setProperty(prop.key, prop.value);
+                }
+            }
+            validProp.store(new FileOutputStream(INVALID_FILE), null);
+        } catch (final IOException e) {
+            throw new PolicyException(e);
+        }
+    }
+
+    class PropertyChange {
+        public String key = null;
+        public String value = null;
+        public Boolean remove = false;
+    }
+}
 package org.onap.brmsgw.test;
 
 import static org.junit.Assert.assertEquals;
+
 import java.util.HashMap;
 import java.util.Map;
+
 import org.junit.Test;
-import org.onap.policy.brmsInterface.ControllerPOJO;
+import org.onap.policy.brms.api.ControllerPojo;
+
+public class ControllerPojoTest {
+    @Test
+    public void testPojo() {
+        final String testKey = "testKey";
+        final String testVal = "testVal";
+        final Map<String, String> testMap = new HashMap<String, String>();
+        testMap.put(testKey, testVal);
+        final ControllerPojo pojo = new ControllerPojo();
 
-public class ControllerPOJOTest {
-       @Test
-       public void testPojo() {
-               String testKey = "testKey";
-               String testVal = "testVal";
-               Map<String, String> testMap = new HashMap<String, String>();
-               testMap.put(testKey, testVal);
-               ControllerPOJO pojo = new ControllerPOJO();
-               
-               pojo.setName(testVal);
-               assertEquals(pojo.getName(), testVal);
-               pojo.setDrools(testMap);
-               assertEquals(pojo.getDrools(), testMap);
-               pojo.setOperation(testVal);
-               assertEquals(pojo.getOperation(), testVal);
-       }
+        pojo.setName(testVal);
+        assertEquals(pojo.getName(), testVal);
+        pojo.setDrools(testMap);
+        assertEquals(pojo.getDrools(), testMap);
+        pojo.setOperation(testVal);
+        assertEquals(pojo.getOperation(), testVal);
+    }
 }
 package org.onap.brmsgw.test;
 
 import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.List;
+
 import org.junit.Test;
-import org.onap.policy.brmsInterface.ControllerPOJO;
-import org.onap.policy.brmsInterface.NotificationPOJO;
+import org.onap.policy.brms.api.ControllerPojo;
+import org.onap.policy.brms.api.NotificationPojo;
+
+public class NotificationPojoTest {
+    @Test
+    public void testPojo() {
+        final String testVal = "testVal";
+        final ControllerPojo ctrlPojo = new ControllerPojo();
+        final List<ControllerPojo> controllers = new ArrayList<ControllerPojo>();
+        controllers.add(ctrlPojo);
+        final NotificationPojo pojo = new NotificationPojo();
 
-public class NotificationPOJOTest {
-       @Test
-       public void testPojo() {
-               String testVal = "testVal";
-               ControllerPOJO ctrlPojo = new ControllerPOJO();
-               List<ControllerPOJO> controllers = new ArrayList<ControllerPOJO>();
-               controllers.add(ctrlPojo);
-               NotificationPOJO pojo = new NotificationPOJO();
-               
-               pojo.setRequestID(testVal);
-               assertEquals(pojo.getRequestID(), testVal);
-               pojo.setEntity(testVal);
-               assertEquals(pojo.getEntity(), testVal);
-               pojo.setControllers(controllers);
-               assertEquals(pojo.getControllers(), controllers);
-       }
+        pojo.setRequestId(testVal);
+        assertEquals(pojo.getRequestId(), testVal);
+        pojo.setEntity(testVal);
+        assertEquals(pojo.getEntity(), testVal);
+        pojo.setControllers(controllers);
+        assertEquals(pojo.getControllers(), controllers);
+    }
 }
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
 
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
@@ -31,31 +32,30 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 @RunWith(PowerMockRunner.class)
-public class BRMSGatewayTest {
-       @Test
-       public void testGet() {
-               assertNull(BRMSGateway.getPolicyEngine());
-       }
+public class BrmsGatewayTest {
+    @Test
+    public void testGet() {
+        assertNull(BrmsGateway.getPolicyEngine());
+    }
 
-       @PrepareForTest({Thread.class, BRMSGateway.class})
-       @Test
-       public void testMain() throws Exception {
-               // Mock Thread
-               PowerMockito.spy(Thread.class);
-               PowerMockito.doNothing().when(Thread.class);
-               Thread.sleep(1000);
+    @PrepareForTest({Thread.class, BrmsGateway.class})
+    @Test
+    public void testMain() throws Exception {
+        // Mock Thread
+        PowerMockito.spy(Thread.class);
+        PowerMockito.doNothing().when(Thread.class);
+        Thread.sleep(1000);
 
-               // Mock handler
-               BRMSHandler handler = Mockito.mock(BRMSHandler.class);
-               PowerMockito.whenNew(BRMSHandler.class).withArguments(any()).thenReturn(handler);
+        // Mock handler
+        final BrmsHandler handler = Mockito.mock(BrmsHandler.class);
+        PowerMockito.whenNew(BrmsHandler.class).withArguments(any()).thenReturn(handler);
 
-               // Run app
-               try {
-                       String[] args = null;
-                       BRMSGateway.main(args);
-               }
-               catch (Exception ex) {
-                       fail("Not expected an exception: " + ex);
-               }
-       }
+        // Run app
+        try {
+            final String[] args = null;
+            BrmsGateway.main(args);
+        } catch (final Exception ex) {
+            fail("Not expected an exception: " + ex);
+        }
+    }
 }
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java
new file mode 100644 (file)
index 0000000..58bacef
--- /dev/null
@@ -0,0 +1,94 @@
+/*-
+ * ============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.brms.api;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.policy.api.NotificationType;
+import org.onap.policy.std.StdPDPNotification;
+import org.onap.policy.utils.BackUpMonitor;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class BrmsHandlerTest {
+    @PrepareForTest({Persistence.class, BackUpMonitor.class})
+    @Test
+    public void negativeTestNotifications() throws Exception {
+        // Mock emf, persistence, and query
+        final EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
+        final EntityManager em = Mockito.mock(EntityManager.class);
+        Mockito.when(emf.createEntityManager()).thenReturn(em);
+        PowerMockito.mockStatic(Persistence.class);
+        PowerMockito.when(Persistence.createEntityManagerFactory(any(), any())).thenReturn(emf);
+        final EntityTransaction et = Mockito.mock(EntityTransaction.class);
+        Mockito.when(em.getTransaction()).thenReturn(et);
+        final Query query = Mockito.mock(Query.class);
+        Mockito.when(em.createQuery(Mockito.anyString())).thenReturn(query);
+
+        // Mock backup monitor
+        PowerMockito.mockStatic(BackUpMonitor.class);
+        final BackUpMonitor monitor = Mockito.mock(BackUpMonitor.class);
+        PowerMockito.when(BackUpMonitor.getInstance(any(), any(), any(), any())).thenReturn(monitor);
+
+        // Test constructor
+        final StdPDPNotification notification = new StdPDPNotification();
+        final String propFile = "config.properties";
+        final BrmsHandler handler = new BrmsHandler(propFile);
+        final BrmsPush brmsPush = new BrmsPush(propFile, handler);
+        handler.setBrmsPush(brmsPush);
+        assertNotNull(handler);
+        assertNotNull(brmsPush);
+        assertNull(handler.getPolicyEngine());
+
+        try {
+            // Test update
+            notification.setNotificationType(NotificationType.UPDATE);
+            handler.runOnNotification(notification);
+            handler.notificationReceived(notification);
+
+            // Test remove
+            notification.setNotificationType(NotificationType.REMOVE);
+            handler.runOnNotification(notification);
+            handler.notificationReceived(notification);
+
+            // Test both
+            notification.setNotificationType(NotificationType.BOTH);
+            handler.runOnNotification(notification);
+            handler.notificationReceived(notification);
+        } catch (final Exception ex) {
+            fail("Not expecting an exception: " + ex);
+        }
+    }
+}
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java
new file mode 100644 (file)
index 0000000..2b13640
--- /dev/null
@@ -0,0 +1,125 @@
+/*-
+ * ============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.brms.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.policy.api.PolicyException;
+import org.onap.policy.utils.BackUpHandler;
+import org.onap.policy.utils.BackUpMonitor;
+import org.onap.policy.utils.BackUpMonitorException;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class BrmsPushTest {
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @PrepareForTest({Persistence.class, BackUpMonitor.class})
+    @Test
+    public void testPush() throws BackUpMonitorException, PolicyException {
+        // Mock emf, persistence, and query
+        final EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
+        final EntityManager em = Mockito.mock(EntityManager.class);
+        Mockito.when(emf.createEntityManager()).thenReturn(em);
+        PowerMockito.mockStatic(Persistence.class);
+        PowerMockito.when(Persistence.createEntityManagerFactory(Mockito.any(), Mockito.any())).thenReturn(emf);
+        final EntityTransaction et = Mockito.mock(EntityTransaction.class);
+        Mockito.when(em.getTransaction()).thenReturn(et);
+        final Query query = Mockito.mock(Query.class);
+        Mockito.when(em.createQuery(Mockito.anyString())).thenReturn(query);
+
+        // Mock backup monitor
+        PowerMockito.mockStatic(BackUpMonitor.class);
+        final BackUpMonitor monitor = Mockito.mock(BackUpMonitor.class);
+        PowerMockito.when(BackUpMonitor.getInstance(any(), any(), any(), any())).thenReturn(monitor);
+
+        // Test constructor
+        final String propFile = "config.properties";
+        final BackUpHandler handler = Mockito.mock(BackUpHandler.class);
+        final BrmsPush push = new BrmsPush(propFile, handler);
+        assertNotNull(push);
+
+        final String name = "testName";
+        try {
+            // Test initiate
+            push.initiate(true);
+
+            // Test reset
+            push.resetDs();
+
+            // Test add
+            final String rule = "testRule";
+            final Map<String, String> responseAttributes = new HashMap<String, String>();
+            responseAttributes.put("$controller:", "{\n\"testKey\": \"testVal\"\n}\n");
+            responseAttributes.put("$dependency$", "[a,b]");
+            push.addRule(name, rule, responseAttributes);
+        } catch (final Exception ex) {
+            fail("Not expecting an exception: " + ex);
+        }
+
+        try {
+            // Test remove
+            push.removeRule(name);
+        } catch (final Exception ex) {
+            fail("Not expecting an exception: " + ex);
+
+        }
+
+        // Test misc methods
+        final String controllerName = "testController";
+        final List<Dependency> deps = push.defaultDependencies(controllerName);
+        assertEquals(deps.size(), 7);
+        assertNotNull(BrmsPush.getBackUpMonitor());
+        assertEquals(push.urlListSize(), 1);
+
+        try {
+            push.rotateUrls();
+        } catch (final Exception ex) {
+            fail("Not expecting an exception: " + ex);
+        }
+
+        // Test push
+        thrown.expect(PolicyException.class);
+        push.pushRules();
+    }
+}
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSHandlerTest.java b/BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSHandlerTest.java
deleted file mode 100644 (file)
index 8e15cdf..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============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.brmsInterface;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.policy.api.NotificationType;
-import org.onap.policy.std.StdPDPNotification;
-import org.onap.policy.utils.BackUpMonitor;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-public class BRMSHandlerTest {
-       @PrepareForTest({Persistence.class, BackUpMonitor.class})
-       @Test
-       public void negativeTestNotifications() throws Exception {
-               // Mock emf, persistence, and query
-               EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
-               EntityManager em = Mockito.mock(EntityManager.class);
-               Mockito.when(emf.createEntityManager()).thenReturn(em);
-               PowerMockito.mockStatic(Persistence.class);
-               PowerMockito.when(Persistence.createEntityManagerFactory(any(), any())).thenReturn(emf);
-               EntityTransaction et = Mockito.mock(EntityTransaction.class);
-               Mockito.when(em.getTransaction()).thenReturn(et);               
-               Query query = Mockito.mock(Query.class);
-               Mockito.when(em.createQuery(Mockito.anyString())).thenReturn(query);            
-               
-               // Mock backup monitor
-               PowerMockito.mockStatic(BackUpMonitor.class);
-               BackUpMonitor monitor = Mockito.mock(BackUpMonitor.class);
-               PowerMockito.when(BackUpMonitor.getInstance(any(), any(), any(), any())).thenReturn(monitor);
-
-               // Test constructor
-               StdPDPNotification notification = new StdPDPNotification();
-               String propFile = "config.properties";
-               BRMSHandler handler = new BRMSHandler(propFile);
-               BRMSPush brmsPush = new BRMSPush(propFile, handler);
-               handler.setBRMSPush(brmsPush);
-               assertNotNull(handler);
-               assertNotNull(brmsPush);
-               assertNull(handler.getPolicyEngine());
-
-               try {
-                       // Test update
-                       notification.setNotificationType(NotificationType.UPDATE);
-                       handler.runOnNotification(notification);
-                       handler.notificationReceived(notification);
-                       
-                       // Test remove
-                       notification.setNotificationType(NotificationType.REMOVE);
-                       handler.runOnNotification(notification);
-                       handler.notificationReceived(notification);
-                       
-                       // Test both
-                       notification.setNotificationType(NotificationType.BOTH);
-                       handler.runOnNotification(notification);
-                       handler.notificationReceived(notification);             
-               }
-               catch (Exception ex) {
-                       fail("Not expecting an exception: " + ex);
-               }
-       }
-}
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brmsInterface/BRMSPushTest.java
deleted file mode 100644 (file)
index 5ca2b30..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============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.brmsInterface;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.policy.api.PolicyException;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.onap.policy.utils.BackUpHandler;
-import org.onap.policy.utils.BackUpMonitor;
-import org.onap.policy.utils.BackUpMonitorException;
-import org.apache.maven.model.Dependency;
-import javax.persistence.Query;
-
-@RunWith(PowerMockRunner.class)
-public class BRMSPushTest {
-       @Rule
-       public ExpectedException thrown = ExpectedException.none();
-       
-       @PrepareForTest({Persistence.class, BackUpMonitor.class})
-       @Test
-       public void testPush() throws BackUpMonitorException, PolicyException {
-               // Mock emf, persistence, and query
-               EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
-               EntityManager em = Mockito.mock(EntityManager.class);
-               Mockito.when(emf.createEntityManager()).thenReturn(em);
-               PowerMockito.mockStatic(Persistence.class);
-               PowerMockito.when(Persistence.createEntityManagerFactory(Mockito.any(), Mockito.any())).thenReturn(emf);
-               EntityTransaction et = Mockito.mock(EntityTransaction.class);
-               Mockito.when(em.getTransaction()).thenReturn(et);               
-               Query query = Mockito.mock(Query.class);
-               Mockito.when(em.createQuery(Mockito.anyString())).thenReturn(query);            
-
-               // Mock backup monitor
-               PowerMockito.mockStatic(BackUpMonitor.class);
-               BackUpMonitor monitor = Mockito.mock(BackUpMonitor.class);
-               PowerMockito.when(BackUpMonitor.getInstance(any(), any(), any(), any())).thenReturn(monitor);
-
-               // Test constructor
-               String propFile = "config.properties";
-               BackUpHandler handler = Mockito.mock(BackUpHandler.class);
-               BRMSPush push = new BRMSPush(propFile, handler);
-               assertNotNull(push);
-               
-               String name = "testName";
-               try {
-                       // Test initiate
-                       push.initiate(true);
-                       
-                       // Test reset
-                       push.resetDS();
-               
-                       // Test add
-                       String rule = "testRule";
-                       Map<String, String> responseAttributes = new HashMap<String, String>();
-                       responseAttributes.put("$controller:", "{\n\"testKey\": \"testVal\"\n}\n");
-                       responseAttributes.put("$dependency$", "[a,b]");
-                       push.addRule(name, rule, responseAttributes);
-               }
-               catch (Exception ex) {
-                       fail("Not expecting an exception: " + ex);
-               }
-                               
-               try {
-                       // Test remove
-                       push.removeRule(name);
-               }
-               catch (Exception ex) {
-                       fail("Not expecting an exception: " + ex);
-
-               }
-               
-               // Test misc methods
-               String controllerName = "testController";
-               List<Dependency> deps = push.defaultDependencies(controllerName);
-               assertEquals(deps.size(), 7);
-               assertNotNull(BRMSPush.getBackUpMonitor());
-               assertEquals(push.urlListSize(), 1);
-
-               try {
-                       push.rotateURLs();
-               }
-               catch (Exception ex) {
-                       fail("Not expecting an exception: " + ex);
-               }
-
-               // Test push
-               thrown.expect(PolicyException.class);
-               push.pushRules();
-       }
-}
index f757aca..62ae4d0 100644 (file)
@@ -24,8 +24,8 @@
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
     <persistence-unit name="BRMSGW" transaction-type="RESOURCE_LOCAL">
         <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-        <class>org.onap.policy.brmsInterface.jpa.BRMSGroupInfo</class>
-        <class>org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo</class>
+        <class>org.onap.policy.brms.entity.BrmsGroupInfo</class>
+        <class>org.onap.policy.brms.entity.BrmsPolicyInfo</class>
         <property name="javax.persistence.schema-generation.scripts.action"
             value="drop-and-create" />
         <property name="javax.persistence.schema-generation.scripts.create-target"
index 27c0ec1..50f717c 100644 (file)
                        <groupId>com.att.research.xacml</groupId>
                        <artifactId>xacml-pdp</artifactId>
                        <version>1.0.1</version>
-            <exclusions>
-            <!-- The LDAP PIP uses velocity which pulls this insecure jar in. We
-            are not using that PIP and can safely exclude this jar to resolve CLM issue.
-             -->
-              <exclusion>
-                <groupId>commons-collections</groupId>
-                <artifactId>commons-collections</artifactId>
-              </exclusion>
-            </exclusions>
+                       <exclusions>
+                               <!-- The LDAP PIP uses velocity which pulls this insecure jar in. We 
+                                       are not using that PIP and can safely exclude this jar to resolve CLM issue. -->
+                               <exclusion>
+                                       <groupId>commons-collections</groupId>
+                                       <artifactId>commons-collections</artifactId>
+                               </exclusion>
+                       </exclusions>
                </dependency>
                <dependency>
-               <groupId>org.onap.policy.drools-pdp</groupId>
-               <artifactId>policy-endpoints</artifactId>
-               <version>${project.version}</version>
-               <scope>test</scope>
-       </dependency>
+                       <groupId>org.onap.policy.drools-pdp</groupId>
+                       <artifactId>policy-endpoints</artifactId>
+                       <version>${project.version}</version>
+                       <scope>test</scope>
+               </dependency>
        </dependencies>
-
-</project>
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-checkstyle-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <id>onap-java-style</id>
+                                               <goals>
+                                                       <goal>check</goal>
+                                               </goals>
+                                               <phase>process-sources</phase>
+                                               <configuration>
+                                                       <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml 
+                                                               with minor changes -->
+                                                       <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+                                                       <!-- <sourceDirectory> is needed so that checkstyle ignores the generated 
+                                                               sources directory -->
+                                                       <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+                                                       <includeResources>true</includeResources>
+                                                       <includeTestSourceDirectory>true</includeTestSourceDirectory>
+                                                       <includeTestResources>true</includeTestResources>
+                                                       <excludes>
+                                                       </excludes>
+                                                       <consoleOutput>true</consoleOutput>
+                                                       <failOnViolation>true</failOnViolation>
+                                                       <violationSeverity>warning</violationSeverity>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>org.onap.oparent</groupId>
+                                               <artifactId>checkstyle</artifactId>
+                                               <version>0.1.1</version>
+                                               <scope>compile</scope>
+                                       </dependency>
+                               </dependencies>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
\ No newline at end of file
index 5fde0ad..c256626 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.action;
 
+import com.att.research.xacml.api.Advice;
+import com.att.research.xacml.api.Attribute;
+import com.att.research.xacml.api.AttributeAssignment;
+import com.att.research.xacml.api.AttributeValue;
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.api.Obligation;
+import com.att.research.xacml.api.Request;
+import com.att.research.xacml.api.RequestAttributes;
+import com.att.research.xacml.api.Result;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.att.research.xacml.std.StdAdvice;
+import com.att.research.xacml.std.StdAttributeAssignment;
+import com.att.research.xacml.std.StdAttributeValue;
+import com.att.research.xacml.std.StdMutableResponse;
+import com.att.research.xacml.std.StdMutableResult;
+import com.att.research.xacml.std.StdObligation;
+import com.att.research.xacml.util.XACMLProperties;
+
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.net.URL;
@@ -43,329 +62,313 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.rest.XACMLRestProperties;
 
-import com.att.research.xacml.api.Advice;
-import com.att.research.xacml.api.Attribute;
-import com.att.research.xacml.api.AttributeAssignment;
-import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.Obligation;
-import com.att.research.xacml.api.Request;
-import com.att.research.xacml.api.RequestAttributes;
-import com.att.research.xacml.api.Result;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.StdAdvice;
-import com.att.research.xacml.std.StdAttributeAssignment;
-import com.att.research.xacml.std.StdAttributeValue;
-import com.att.research.xacml.std.StdMutableResponse;
-import com.att.research.xacml.std.StdMutableResult;
-import com.att.research.xacml.std.StdObligation;
-import com.att.research.xacml.util.XACMLProperties;
-
 @SuppressWarnings("deprecation")
 public class FindAction {
-       private Logger LOGGER = FlexLogger.getLogger(this.getClass());
-       private Boolean changeIt = false;
-       private String configURL = null;
-       private StdMutableResponse newResponse = new StdMutableResponse();
-       private StdMutableResult addResult = new StdMutableResult();
+    private Logger logger = FlexLogger.getLogger(this.getClass());
+    private Boolean changeIt = false;
+    private String configUrl = null;
+    private StdMutableResponse newResponse = new StdMutableResponse();
+    private StdMutableResult addResult = new StdMutableResult();
 
-       public StdMutableResponse run(StdMutableResponse stdResponse, Request pepRequest) {
-               int count = 0;
-               boolean config = false;
-               boolean decide = false; 
-               Collection<RequestAttributes> requestAttributes =  pepRequest.getRequestAttributes();
-               for(RequestAttributes requestAttribute : requestAttributes){
-                       Collection<Attribute> attributes = requestAttribute.getAttributes();
-                       for(Attribute attribute : attributes){
-                               if(attribute.getAttributeId().stringValue().equals("urn:oasis:names:tc:xacml:1.0:action:action-id")){
-                                       for(AttributeValue<?> attributeValue : attribute.getValues()){
-                                               if(attributeValue.getValue().toString().equalsIgnoreCase("ACCESS")){
-                                                       count++;
-                                               }
-                                               if(attributeValue.getValue().toString().equalsIgnoreCase("DECIDE")){
-                                                       decide = true;
-                                               }
-                                       }
-                               }
-                               if(attribute.getAttributeId().stringValue().equals("urn:oasis:names:tc:xacml:1.0:resource:resource-id")){
-                                       for(AttributeValue<?> attributeValue : attribute.getValues()){
-                                               if(attributeValue.getValue().toString().equalsIgnoreCase("Config")){
-                                                       count++;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               if(count==2){
-                       config = true;
-               }
-               if(!config){
-                       search(stdResponse);
-               }
-               addResults(stdResponse, config , decide);
-               LOGGER.info("Original Result is " + stdResponse.toString());
-               LOGGER.info("Generated Result is " + addResult.toString());
-               return newResponse;
-       }
+    /**
+     * Generate {@link StdMutableResponse} based on input request.
+     *
+     * @param stdResponse the response
+     * @param pepRequest the request
+     * @return {@link StdMutableResponse}
+     */
+    public StdMutableResponse run(final StdMutableResponse stdResponse, final Request pepRequest) {
+        int count = 0;
+        boolean config = false;
+        boolean decide = false;
+        final Collection<RequestAttributes> requestAttributes = pepRequest.getRequestAttributes();
+        for (final RequestAttributes requestAttribute : requestAttributes) {
+            final Collection<Attribute> attributes = requestAttribute.getAttributes();
+            for (final Attribute attribute : attributes) {
+                if (attribute.getAttributeId().stringValue().equals("urn:oasis:names:tc:xacml:1.0:action:action-id")) {
+                    for (final AttributeValue<?> attributeValue : attribute.getValues()) {
+                        if (attributeValue.getValue().toString().equalsIgnoreCase("ACCESS")) {
+                            count++;
+                        }
+                        if (attributeValue.getValue().toString().equalsIgnoreCase("DECIDE")) {
+                            decide = true;
+                        }
+                    }
+                }
+                if (attribute.getAttributeId().stringValue()
+                        .equals("urn:oasis:names:tc:xacml:1.0:resource:resource-id")) {
+                    for (final AttributeValue<?> attributeValue : attribute.getValues()) {
+                        if (attributeValue.getValue().toString().equalsIgnoreCase("Config")) {
+                            count++;
+                        }
+                    }
+                }
+            }
+        }
+        if (count == 2) {
+            config = true;
+        }
+        if (!config) {
+            search(stdResponse);
+        }
+        addResults(stdResponse, config, decide);
+        logger.info("Original Result is " + stdResponse.toString());
+        logger.info("Generated Result is " + addResult.toString());
+        return newResponse;
+    }
 
-       private Collection<Obligation> obligations = new ArrayList<>();
-       private Map<String, String> matchValues = new HashMap<>();
-       private Map<String, String> headers = new HashMap<>();
-       private boolean header = false;
+    private Collection<Obligation> obligations = new ArrayList<>();
+    private Map<String, String> matchValues = new HashMap<>();
+    private Map<String, String> headers = new HashMap<>();
+    private boolean header = false;
 
-       private void search(StdMutableResponse stdResponse) {
-               for (Result result : stdResponse.getResults()) {
-                       if (!result.getObligations().isEmpty()) {
-                               System.out.println("Obligation Received");
-                               // Is there any action that PDP needs to take
-                               for (Obligation obligation : result.getObligations()) {
-                                       int count = 0, uri = 0, PEP = 0;
-                                       header = false;
-                                       changeIt = false;
-                                       Collection<AttributeAssignment> afterRemoveAssignments = new ArrayList<>();
-                                       Identifier oblId = new IdentifierImpl(obligation.getId().stringValue());
-                                       StdAttributeAssignment attributeURI = null;
-                                       for (AttributeAssignment attribute : obligation.getAttributeAssignments()) {
-                                               matchValues.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString());
-                                               if (attribute.getAttributeId().stringValue().equalsIgnoreCase("performer")) {
-                                                       if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("PEPACTION")) {
-                                                               PEP++;
-                                                       } else if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("PDPACTION")) {
-                                                               count++;
-                                                       }
-                                               } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("URL")) {
-                                                       uri++;
-                                                       if (uri == 1) {
-                                                               configURL = attribute.getAttributeValue().getValue().toString();
-                                                               attributeURI = new StdAttributeAssignment(attribute);
-                                                       }
-                                               } else if (attribute.getAttributeId().stringValue().startsWith("headers")) {
-                                                       LOGGER.info("Headers are : "+ attribute.getAttributeValue().getValue().toString());
-                                                       header = true;
-                                                       headers.put(attribute.getAttributeId().stringValue().replaceFirst("(headers).", ""),
-                                                                       attribute.getAttributeValue().getValue().toString());
-                                                       afterRemoveAssignments.add(attribute);
-                                               } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("body")) { 
-                                                       String papPath = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
-                                                       papPath= papPath.replace("/pap", "");
-                                                       matchValues.put("body",attribute.getAttributeValue().getValue().toString().replace("$URL", papPath));
-                                               }else {
-                                                       StdAttributeAssignment attributeObligation = new StdAttributeAssignment(attribute);
-                                                       afterRemoveAssignments.add(attributeObligation);
-                                               }
-                                       }
-                                       if (count == 1 && uri == 1 && PEP == 0) {
-                                               // Remove Obligation and add Advice
-                                               changeIt = true;
-                                               takeAction(stdResponse, oblId, afterRemoveAssignments);
-                                       } else if (PEP == 1 && count == 0) {
-                                               // Strip the PEPACTION if available
-                                               if (uri == 1) {
-                                                       afterRemoveAssignments.add(attributeURI);
-                                               }
-                                               Obligation afterRemoveObligation = new StdObligation(
-                                                               oblId, afterRemoveAssignments);
-                                               obligations.add(afterRemoveObligation);
-                                       } else {
-                                               obligations.add(obligation);
-                                       }
-                               }
-                       }
-               }
-       }
+    private void search(final StdMutableResponse stdResponse) {
+        for (final Result result : stdResponse.getResults()) {
+            if (!result.getObligations().isEmpty()) {
+                System.out.println("Obligation Received");
+                // Is there any action that PDP needs to take
+                for (final Obligation obligation : result.getObligations()) {
+                    int count = 0;
+                    int uri = 0;
+                    int pep = 0;
+                    header = false;
+                    changeIt = false;
+                    final Collection<AttributeAssignment> afterRemoveAssignments = new ArrayList<>();
+                    final Identifier oblId = new IdentifierImpl(obligation.getId().stringValue());
+                    StdAttributeAssignment attributeUri = null;
+                    for (final AttributeAssignment attribute : obligation.getAttributeAssignments()) {
+                        matchValues.put(attribute.getAttributeId().stringValue(),
+                                attribute.getAttributeValue().getValue().toString());
+                        if (attribute.getAttributeId().stringValue().equalsIgnoreCase("performer")) {
+                            if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("PEPACTION")) {
+                                pep++;
+                            } else if (attribute.getAttributeValue().getValue().toString()
+                                    .equalsIgnoreCase("PDPACTION")) {
+                                count++;
+                            }
+                        } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("URL")) {
+                            uri++;
+                            if (uri == 1) {
+                                configUrl = attribute.getAttributeValue().getValue().toString();
+                                attributeUri = new StdAttributeAssignment(attribute);
+                            }
+                        } else if (attribute.getAttributeId().stringValue().startsWith("headers")) {
+                            logger.info("Headers are : " + attribute.getAttributeValue().getValue().toString());
+                            header = true;
+                            headers.put(attribute.getAttributeId().stringValue().replaceFirst("(headers).", ""),
+                                    attribute.getAttributeValue().getValue().toString());
+                            afterRemoveAssignments.add(attribute);
+                        } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("body")) {
+                            String papPath = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+                            papPath = papPath.replace("/pap", "");
+                            matchValues.put("body",
+                                    attribute.getAttributeValue().getValue().toString().replace("$URL", papPath));
+                        } else {
+                            final StdAttributeAssignment attributeObligation = new StdAttributeAssignment(attribute);
+                            afterRemoveAssignments.add(attributeObligation);
+                        }
+                    }
+                    if (count == 1 && uri == 1 && pep == 0) {
+                        // Remove Obligation and add Advice
+                        changeIt = true;
+                        takeAction(stdResponse, oblId, afterRemoveAssignments);
+                    } else if (pep == 1 && count == 0) {
+                        // Strip the PEPACTION if available
+                        if (uri == 1) {
+                            afterRemoveAssignments.add(attributeUri);
+                        }
+                        final Obligation afterRemoveObligation = new StdObligation(oblId, afterRemoveAssignments);
+                        obligations.add(afterRemoveObligation);
+                    } else {
+                        obligations.add(obligation);
+                    }
+                }
+            }
+        }
+    }
 
-       private void takeAction(StdMutableResponse stdResponse, Identifier advId,
-                       Collection<AttributeAssignment> afterRemoveAssignments) {
-               if (changeIt) {
-                       LOGGER.info("the URL is :" + configURL);
-                       // Calling Rest URL..
-                       callRest();
-                       // Including the Results in an Advice
-                       Identifier id = new IdentifierImpl(
-                                       "org.onap.policy:pdp:reply");
-                       Identifier statId = new IdentifierImpl(
-                                       "org:onap:onap:policy:pdp:reply:status");
-                       Identifier statCategory = new IdentifierImpl(
-                                       "urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject");
-                       Identifier strId = new IdentifierImpl(
-                                       "http://www.w3.org/2001/XMLSchema#string");
-                       Identifier resId = new IdentifierImpl(
-                                       "org:onap:onap:policy:pdp:reply:resource");
-                       Identifier resCategory = new IdentifierImpl(
-                                       "urn:oasis:names:tc:xacml:3.0:attribute-category:resource");
-                       Identifier urlId = new IdentifierImpl(
-                                       "http://www.w3.org/2001/XMLSchema#anyURI");
-                       AttributeValue<String> attributeStatusValue = new StdAttributeValue<>(
-                                       strId, status + response);
-                       AttributeValue<String> attributeResourceValue = new StdAttributeValue<>(
-                                       urlId, configURL);
-                       StdAttributeAssignment attributeStatus = new StdAttributeAssignment(
-                                       statCategory, statId, "PDP", attributeStatusValue);
-                       StdAttributeAssignment attributeResouce = new StdAttributeAssignment(
-                                       resCategory, resId, "PDP", attributeResourceValue);
-                       afterRemoveAssignments.add(attributeStatus);
-                       afterRemoveAssignments.add(attributeResouce);
-                       Advice advice = new StdAdvice(id, afterRemoveAssignments);
-                       addResult.addAdvice(advice);
-               }
-       }
+    private void takeAction(final StdMutableResponse stdResponse, final Identifier advId,
+            final Collection<AttributeAssignment> afterRemoveAssignments) {
+        if (changeIt) {
+            logger.info("the URL is :" + configUrl);
+            // Calling Rest URL..
+            callRest();
+            // Including the Results in an Advice
+            final Identifier id = new IdentifierImpl("org.onap.policy:pdp:reply");
+            final Identifier statId = new IdentifierImpl("org:onap:onap:policy:pdp:reply:status");
+            final Identifier statCategory =
+                    new IdentifierImpl("urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject");
+            final Identifier strId = new IdentifierImpl("http://www.w3.org/2001/XMLSchema#string");
+            final Identifier resId = new IdentifierImpl("org:onap:onap:policy:pdp:reply:resource");
+            final Identifier resCategory =
+                    new IdentifierImpl("urn:oasis:names:tc:xacml:3.0:attribute-category:resource");
+            final Identifier urlId = new IdentifierImpl("http://www.w3.org/2001/XMLSchema#anyURI");
+            final AttributeValue<String> attributeStatusValue = new StdAttributeValue<>(strId, status + response);
+            final AttributeValue<String> attributeResourceValue = new StdAttributeValue<>(urlId, configUrl);
+            final StdAttributeAssignment attributeStatus =
+                    new StdAttributeAssignment(statCategory, statId, "PDP", attributeStatusValue);
+            final StdAttributeAssignment attributeResouce =
+                    new StdAttributeAssignment(resCategory, resId, "PDP", attributeResourceValue);
+            afterRemoveAssignments.add(attributeStatus);
+            afterRemoveAssignments.add(attributeResouce);
+            final Advice advice = new StdAdvice(id, afterRemoveAssignments);
+            addResult.addAdvice(advice);
+        }
+    }
 
-       private void addResults(StdMutableResponse stdResponse, boolean config, boolean decide) {
-               if(decide){
-                       newResponse = stdResponse;
-                       return;
-               }
-               for (Result result : stdResponse.getResults()) {
-                       if(config){
-                               addResult.addAdvice(result.getAssociatedAdvice());
-                       }
-                       addResult.addAttributeCategories(result.getAttributes());
-                       addResult.addPolicyIdentifiers(result.getPolicyIdentifiers());
-                       addResult.addPolicySetIdentifiers(result.getPolicySetIdentifiers());
-                       addResult.setStatus(result.getStatus());
-                       addResult.setDecision(result.getDecision());
-                       if(!config){
-                               addResult.addObligations(obligations);
-                       }
-               }
-               newResponse.add(addResult);
-       }
+    private void addResults(final StdMutableResponse stdResponse, final boolean config, final boolean decide) {
+        if (decide) {
+            newResponse = stdResponse;
+            return;
+        }
+        for (final Result result : stdResponse.getResults()) {
+            if (config) {
+                addResult.addAdvice(result.getAssociatedAdvice());
+            }
+            addResult.addAttributeCategories(result.getAttributes());
+            addResult.addPolicyIdentifiers(result.getPolicyIdentifiers());
+            addResult.addPolicySetIdentifiers(result.getPolicySetIdentifiers());
+            addResult.setStatus(result.getStatus());
+            addResult.setDecision(result.getDecision());
+            if (!config) {
+                addResult.addObligations(obligations);
+            }
+        }
+        newResponse.add(addResult);
+    }
 
-       private int status;
-       private String response;
-       private DefaultHttpClient httpClient;
+    private int status;
+    private String response;
+    private DefaultHttpClient httpClient;
 
-       private void callRest() {
-               // Finding the Macros in the URL..
-               Pattern pattern = Pattern.compile("\\$([a-zA-Z0-9.:]*)");
-               Matcher match = pattern.matcher(configURL);
-               StringBuffer sb = new StringBuffer();
-               JsonReader jsonReader = null;
-               while (match.find()) {
-                       LOGGER.info("Found Macro : " + match.group(1));
-                       String replaceValue = matchValues.get(match.group(1));
-                       LOGGER.info("Replacing with :" + replaceValue);
-                       match.appendReplacement(sb, replaceValue);
-               }
-               match.appendTail(sb);
-               LOGGER.info("URL is : " + sb.toString());
-               configURL = sb.toString();
-               // Calling the Requested service. 
-               if (matchValues.get("method").equalsIgnoreCase("GET")) {
-                       httpClient = new DefaultHttpClient();
-                       try {
-                               HttpGet getRequest = new HttpGet(configURL);
-                               // Adding Headers here
-                               if (header) {
-                                       for (String key : headers.keySet()) {
-                                               getRequest.addHeader(key, headers.get(key));
-                                       }
-                               }
-                               HttpResponse result = httpClient.execute(getRequest);
-                               status = result.getStatusLine().getStatusCode();
-                               BufferedReader br = new BufferedReader(new InputStreamReader(
-                                               (result.getEntity().getContent())));
-                               String output = " ";
-                               String out;
-                               while ((out = br.readLine()) != null) {
-                                       output = output + out;
-                               }
-                               response = output;
-                       } catch (Exception e) {
-                               LOGGER.error(e.getMessage()+e);
-                               response = e.getMessage();
-                       } finally {
-                               httpClient.getConnectionManager().shutdown();
-                       }
-               } else if(matchValues.get("method").equalsIgnoreCase("POST")) {
-                       httpClient = new DefaultHttpClient();
-                       try {
-                               HttpPost postRequest = new HttpPost(configURL);
-                               // Adding Headers here
-                               if (header) {
-                                       for (String key : headers.keySet()) {
-                                               postRequest.addHeader(key, headers.get(key));
-                                       }
-                               }
-                               // Adding the Body. 
-                               URL configURL = new URL(matchValues.get("body"));
-                               URLConnection connection = null;
-                               connection = configURL.openConnection();
-                               // InputStream in = connection.getInputStrem();
-                               // LOGGER.info("The Body Content is : " + IOUtils.toString(in));
-                               jsonReader = Json.createReader(connection.getInputStream());
-                               StringEntity input = new StringEntity(jsonReader.readObject().toString());
-                               input.setContentType("application/json");
-                               postRequest.setEntity(input);
-                               // Executing the Request. 
-                               HttpResponse result = httpClient.execute(postRequest);
-                               LOGGER.info("Result Headers are : " + result.getAllHeaders());
-                               status = result.getStatusLine().getStatusCode();
-                               BufferedReader br = new BufferedReader(new InputStreamReader(
-                                               (result.getEntity().getContent())));
-                               String output = " ";
-                               String out;
-                               while ((out = br.readLine()) != null) {
-                                       output = output + out;
-                               }
-                               response = output;
-                       }catch (Exception e) {
-                               LOGGER.error(e.getMessage() +e);
-                               response = e.getMessage();
-                       } finally {
-                               if(jsonReader != null) {
-                                   try {
-                                       jsonReader.close();
-                                   } catch (Exception e) {
-                                       LOGGER.error("Exception Occured while closing the JsonReader"+e);
-                                   }
-                               }
-                               httpClient.getConnectionManager().shutdown();
-                       }
-               } else if(matchValues.get("method").equalsIgnoreCase("PUT")) {
-                       httpClient = new DefaultHttpClient();
-                       try {
-                               HttpPut putRequest = new HttpPut(configURL);
-                               // Adding Headers here
-                               if (header) {
-                                       for (String key : headers.keySet()) {
-                                               putRequest.addHeader(key, headers.get(key));
-                                       }
-                               }
-                               // Adding the Body. 
-                               URL configURL = new URL(matchValues.get("body"));
-                               URLConnection connection = null;
-                               connection = configURL.openConnection();
-                               //InputStream in = connection.getInputStream();
-                               //LOGGER.info("The Body Content is : " + IOUtils.toString(in));
-                               jsonReader = Json.createReader(connection.getInputStream());
-                               StringEntity input = new StringEntity(jsonReader.readObject().toString());
-                               input.setContentType("application/json");
-                               putRequest.setEntity(input);
-                               // Executing the Request. 
-                               HttpResponse result = httpClient.execute(putRequest);
-                               status = result.getStatusLine().getStatusCode();
-                               BufferedReader br = new BufferedReader(new InputStreamReader(
-                                               (result.getEntity().getContent())));
-                               String output = " ";
-                               String out;
-                               while ((out = br.readLine()) != null) {
-                                       output = output + out;
-                               }
-                               response = output;
-                       } catch (Exception e) {
-                               LOGGER.error(e.getMessage() +e);
-                               response = e.getMessage();
-                       }finally {
-                               if(jsonReader != null) {
-                                   try {
-                                       jsonReader.close();
-                                   } catch (Exception e) {
-                                       LOGGER.error("Exception Occured while closing the JsonReader"+e);
-                                   }
-                               }
-                               httpClient.getConnectionManager().shutdown();
-                       }
-               }
-       }
-}
\ No newline at end of file
+    private void callRest() {
+        // Finding the Macros in the URL..
+        final Pattern pattern = Pattern.compile("\\$([a-zA-Z0-9.:]*)");
+        final Matcher match = pattern.matcher(configUrl);
+        final StringBuffer sb = new StringBuffer();
+        JsonReader jsonReader = null;
+        while (match.find()) {
+            logger.info("Found Macro : " + match.group(1));
+            final String replaceValue = matchValues.get(match.group(1));
+            logger.info("Replacing with :" + replaceValue);
+            match.appendReplacement(sb, replaceValue);
+        }
+        match.appendTail(sb);
+        logger.info("URL is : " + sb.toString());
+        configUrl = sb.toString();
+        // Calling the Requested service.
+        if (matchValues.get("method").equalsIgnoreCase("GET")) {
+            httpClient = new DefaultHttpClient();
+            try {
+                final HttpGet getRequest = new HttpGet(configUrl);
+                // Adding Headers here
+                if (header) {
+                    for (final String key : headers.keySet()) {
+                        getRequest.addHeader(key, headers.get(key));
+                    }
+                }
+                final HttpResponse result = httpClient.execute(getRequest);
+                status = result.getStatusLine().getStatusCode();
+                final BufferedReader br = new BufferedReader(new InputStreamReader((result.getEntity().getContent())));
+                String output = " ";
+                String out;
+                while ((out = br.readLine()) != null) {
+                    output = output + out;
+                }
+                response = output;
+            } catch (final Exception e) {
+                logger.error(e.getMessage() + e);
+                response = e.getMessage();
+            } finally {
+                httpClient.getConnectionManager().shutdown();
+            }
+        } else if (matchValues.get("method").equalsIgnoreCase("POST")) {
+            httpClient = new DefaultHttpClient();
+            try {
+                final HttpPost postRequest = new HttpPost(configUrl);
+                // Adding Headers here
+                if (header) {
+                    for (final String key : headers.keySet()) {
+                        postRequest.addHeader(key, headers.get(key));
+                    }
+                }
+                // Adding the Body.
+                final URL configUrl = new URL(matchValues.get("body"));
+                URLConnection connection = null;
+                connection = configUrl.openConnection();
+                // InputStream in = connection.getInputStrem();
+                // LOGGER.info("The Body Content is : " + IOUtils.toString(in));
+                jsonReader = Json.createReader(connection.getInputStream());
+                final StringEntity input = new StringEntity(jsonReader.readObject().toString());
+                input.setContentType("application/json");
+                postRequest.setEntity(input);
+                // Executing the Request.
+                final HttpResponse result = httpClient.execute(postRequest);
+                logger.info("Result Headers are : " + result.getAllHeaders());
+                status = result.getStatusLine().getStatusCode();
+                final BufferedReader br = new BufferedReader(new InputStreamReader((result.getEntity().getContent())));
+                String output = " ";
+                String out;
+                while ((out = br.readLine()) != null) {
+                    output = output + out;
+                }
+                response = output;
+            } catch (final Exception e) {
+                logger.error(e.getMessage() + e);
+                response = e.getMessage();
+            } finally {
+                if (jsonReader != null) {
+                    try {
+                        jsonReader.close();
+                    } catch (final Exception e) {
+                        logger.error("Exception Occured while closing the JsonReader" + e);
+                    }
+                }
+                httpClient.getConnectionManager().shutdown();
+            }
+        } else if (matchValues.get("method").equalsIgnoreCase("PUT")) {
+            httpClient = new DefaultHttpClient();
+            try {
+                final HttpPut putRequest = new HttpPut(configUrl);
+                // Adding Headers here
+                if (header) {
+                    for (final String key : headers.keySet()) {
+                        putRequest.addHeader(key, headers.get(key));
+                    }
+                }
+                // Adding the Body.
+                final URL configUrl = new URL(matchValues.get("body"));
+                URLConnection connection = null;
+                connection = configUrl.openConnection();
+                // InputStream in = connection.getInputStream();
+                // LOGGER.info("The Body Content is : " + IOUtils.toString(in));
+                jsonReader = Json.createReader(connection.getInputStream());
+                final StringEntity input = new StringEntity(jsonReader.readObject().toString());
+                input.setContentType("application/json");
+                putRequest.setEntity(input);
+                // Executing the Request.
+                final HttpResponse result = httpClient.execute(putRequest);
+                status = result.getStatusLine().getStatusCode();
+                final BufferedReader br = new BufferedReader(new InputStreamReader((result.getEntity().getContent())));
+                String output = " ";
+                String out;
+                while ((out = br.readLine()) != null) {
+                    output = output + out;
+                }
+                response = output;
+            } catch (final Exception e) {
+                logger.error(e.getMessage() + e);
+                response = e.getMessage();
+            } finally {
+                if (jsonReader != null) {
+                    try {
+                        jsonReader.close();
+                    } catch (final Exception e) {
+                        logger.error("Exception Occured while closing the JsonReader" + e);
+                    }
+                }
+                httpClient.getConnectionManager().shutdown();
+            }
+        }
+    }
+}
index 82c6182..b4fd050 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
 package org.onap.policy.xacml.action;
 
 /**
- * org.onap.policy.xacml.action contains the implementation of the PDP Actions.
- * Changes: 
- *     Now PDP supports actions based on PUT, GET, POST methods 
- * 
- * @version 0.2 
- * 
+ * org.onap.policy.xacml.action contains the implementation of the PDP Actions. Changes: Now PDP supports actions based
+ * on PUT, GET, POST methods
+ *
+ * @version 0.2
+ *
  */
index ea4e90e..35080d3 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.custom;
 
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.att.research.xacml.std.datatypes.DataTypes;
+import com.att.research.xacmlatt.pdp.policy.FunctionDefinition;
+import com.att.research.xacmlatt.pdp.policy.FunctionDefinitionFactory;
+import com.att.research.xacmlatt.pdp.std.StdFunctions;
+
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
@@ -28,60 +36,53 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.xacml.pdp.std.functions.FunctionDefinitionCustomRegexpMatch;
 
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.FunctionDefinition;
-import com.att.research.xacmlatt.pdp.policy.FunctionDefinitionFactory;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
-
 public class OnapFunctionDefinitionFactory extends FunctionDefinitionFactory {
-       private static Logger logger = FlexLogger.getLogger(OnapFunctionDefinitionFactory.class);
-       private static Map<Identifier,FunctionDefinition>       mapFunctionDefinitions  = new HashMap<>();
-       private static boolean                                                          needMapInit                             = true;
+    private static Logger logger = FlexLogger.getLogger(OnapFunctionDefinitionFactory.class);
+    private static Map<Identifier, FunctionDefinition> mapFunctionDefinitions = new HashMap<>();
+    private static boolean needMapInit = true;
+
+    public static final Identifier ID_FUNCTION_CUSTOM_REGEXP_MATCH =
+            new IdentifierImpl("org.onap.function.regex-match");
+
+    private static final FunctionDefinition FD_CUSTOM_REGEXP_MATCH =
+            new FunctionDefinitionCustomRegexpMatch<>(ID_FUNCTION_CUSTOM_REGEXP_MATCH, DataTypes.DT_STRING);
+
+    private static void register(final FunctionDefinition functionDefinition) {
+        mapFunctionDefinitions.put(functionDefinition.getId(), functionDefinition);
+    }
 
-       public static final Identifier ID_FUNCTION_CUSTOM_REGEXP_MATCH                                          = new IdentifierImpl("org.onap.function.regex-match");
-       
-       private static final FunctionDefinition FD_CUSTOM_REGEXP_MATCH = new FunctionDefinitionCustomRegexpMatch<>(ID_FUNCTION_CUSTOM_REGEXP_MATCH, DataTypes.DT_STRING);
+    private static void initMap() {
 
-       private static void register(FunctionDefinition functionDefinition) {
-               mapFunctionDefinitions.put(functionDefinition.getId(), functionDefinition);
-       }
-               
-       private static void initMap() {
+        synchronized (mapFunctionDefinitions) {
+            if (needMapInit) {
+                needMapInit = false;
+                final Field[] declaredFields = StdFunctions.class.getDeclaredFields();
+                for (final Field field : declaredFields) {
+                    if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith(StdFunctions.FD_PREFIX)
+                            && FunctionDefinition.class.isAssignableFrom(field.getType())
+                            && Modifier.isPublic(field.getModifiers())) {
+                        try {
+                            register((FunctionDefinition) (field.get(null)));
+                        } catch (final IllegalAccessException ex) {
+                            logger.error(ex.getMessage() + ex);
+                        }
+                    }
+                }
+                //
+                // Our custom function
+                //
+                // register(FunctionDefinitionCustomRegexpMatch);
+                register(FD_CUSTOM_REGEXP_MATCH);
+            }
+        }
+    }
 
-                       synchronized(mapFunctionDefinitions) {
-                               if (needMapInit) {
-                                       needMapInit     = false;
-                                       Field[] declaredFields  = StdFunctions.class.getDeclaredFields();
-                                       for (Field field : declaredFields) {
-                                               if (Modifier.isStatic(field.getModifiers()) && 
-                                                       field.getName().startsWith(StdFunctions.FD_PREFIX) &&
-                                                       FunctionDefinition.class.isAssignableFrom(field.getType()) &&
-                                                       Modifier.isPublic(field.getModifiers())
-                                               ) {
-                                                       try {
-                                                               register((FunctionDefinition)(field.get(null)));
-                                                       } catch (IllegalAccessException ex) {
-                                                               logger.error(ex.getMessage() +ex);
-                                                       }
-                                               }
-                                       }
-                                       //
-                                       // Our custom function
-                                       //
-                                       //register(FunctionDefinitionCustomRegexpMatch);
-                                       register(FD_CUSTOM_REGEXP_MATCH);
-                               }
-                       }
-       }
-       
-       public OnapFunctionDefinitionFactory() {
-               initMap();
-       }
+    public OnapFunctionDefinitionFactory() {
+        initMap();
+    }
 
-       @Override
-       public FunctionDefinition getFunctionDefinition(Identifier functionId) {
-               return mapFunctionDefinitions.get(functionId);
-       }
+    @Override
+    public FunctionDefinition getFunctionDefinition(final Identifier functionId) {
+        return mapFunctionDefinitions.get(functionId);
+    }
 }
diff --git a/ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactory.java b/ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactory.java
deleted file mode 100644 (file)
index 2e796bf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-PDP
- * ================================================================================
- * 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.xacml.pdp;
-
-import java.util.Properties;
-
-import org.onap.policy.common.logging.flexlogger.FlexLogger; 
-import org.onap.policy.common.logging.flexlogger.Logger;
-import com.att.research.xacml.api.pdp.PDPEngine;
-import com.att.research.xacml.api.pdp.PDPEngineFactory;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
-
-public class ONAPPDPEngineFactory extends PDPEngineFactory {
-       private Logger logger   = FlexLogger.getLogger(this.getClass());
-
-       @Override
-       public PDPEngine newEngine() throws FactoryException {
-               EvaluationContextFactory evaluationContextFactory       = EvaluationContextFactory.newInstance();
-               if (evaluationContextFactory == null) {
-                       this.logger.error("Null EvaluationContextFactory");
-                       throw new FactoryException("Null EvaluationContextFactory");
-               }
-               return new ONAPPDPEngine(evaluationContextFactory, this.getDefaultBehavior(), this.getScopeResolver());
-       }
-
-       @Override
-       public PDPEngine newEngine(Properties properties) throws FactoryException {
-               EvaluationContextFactory evaluationContextFactory       = EvaluationContextFactory.newInstance(properties);
-               if (evaluationContextFactory == null) {
-                       this.logger.error("Null EvaluationContextFactory");
-                       throw new FactoryException("Null EvaluationContextFactory");
-               }
-               return new ONAPPDPEngine(evaluationContextFactory, this.getDefaultBehavior(), this.getScopeResolver(), properties);
-       }
-
-}
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.policy.xacml.pdp;
-
-import java.util.Properties;
 
-import org.onap.policy.xacml.action.FindAction;
+package org.onap.policy.xacml.pdp;
 
 import com.att.research.xacml.api.Decision;
 import com.att.research.xacml.api.Request;
@@ -32,29 +29,34 @@ import com.att.research.xacml.std.StdMutableResponse;
 import com.att.research.xacmlatt.pdp.ATTPDPEngine;
 import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
 
-public class ONAPPDPEngine extends ATTPDPEngine {
-
-       public ONAPPDPEngine(EvaluationContextFactory evaluationContextFactoryIn, Decision defaultDecisionIn,
-                       ScopeResolver scopeResolverIn, Properties properties) {
-               super(evaluationContextFactoryIn, defaultDecisionIn, scopeResolverIn, properties);
-       }
-
-       public ONAPPDPEngine(EvaluationContextFactory evaluationContextFactoryIn, Decision defaultDecisionIn,
-                       ScopeResolver scopeResolverIn) {
-               super(evaluationContextFactoryIn, defaultDecisionIn, scopeResolverIn);
-       }
-
-       public ONAPPDPEngine(EvaluationContextFactory evaluationContextFactoryIn, ScopeResolver scopeResolverIn) {
-               super(evaluationContextFactoryIn, scopeResolverIn);
-       }
-
-       @Override
-       public Response decide(Request pepRequest) throws PDPException {
-               Response response = super.decide(pepRequest);
-               
-               FindAction findAction = new FindAction();
-               return findAction.run((StdMutableResponse) response, pepRequest);
-       }
+import java.util.Properties;
+
+import org.onap.policy.xacml.action.FindAction;
+
+public class OnapPdpEngine extends ATTPDPEngine {
+
+    public OnapPdpEngine(final EvaluationContextFactory evaluationContextFactoryIn, final Decision defaultDecisionIn,
+            final ScopeResolver scopeResolverIn, final Properties properties) {
+        super(evaluationContextFactoryIn, defaultDecisionIn, scopeResolverIn, properties);
+    }
+
+    public OnapPdpEngine(final EvaluationContextFactory evaluationContextFactoryIn, final Decision defaultDecisionIn,
+            final ScopeResolver scopeResolverIn) {
+        super(evaluationContextFactoryIn, defaultDecisionIn, scopeResolverIn);
+    }
+
+    public OnapPdpEngine(final EvaluationContextFactory evaluationContextFactoryIn,
+            final ScopeResolver scopeResolverIn) {
+        super(evaluationContextFactoryIn, scopeResolverIn);
+    }
+
+    @Override
+    public Response decide(final Request pepRequest) throws PDPException {
+        final Response response = super.decide(pepRequest);
+
+        final FindAction findAction = new FindAction();
+        return findAction.run((StdMutableResponse) response, pepRequest);
+    }
 
 
 }
diff --git a/ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactory.java b/ONAP-PDP/src/main/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactory.java
new file mode 100644 (file)
index 0000000..c19c401
--- /dev/null
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PDP
+ * ================================================================================
+ * 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.xacml.pdp;
+
+import com.att.research.xacml.api.pdp.PDPEngine;
+import com.att.research.xacml.api.pdp.PDPEngineFactory;
+import com.att.research.xacml.util.FactoryException;
+import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
+
+import java.util.Properties;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+public class OnapPdpEngineFactory extends PDPEngineFactory {
+    private Logger logger = FlexLogger.getLogger(this.getClass());
+
+    @Override
+    public PDPEngine newEngine() throws FactoryException {
+        final EvaluationContextFactory evaluationContextFactory = EvaluationContextFactory.newInstance();
+        if (evaluationContextFactory == null) {
+            this.logger.error("Null EvaluationContextFactory");
+            throw new FactoryException("Null EvaluationContextFactory");
+        }
+        return new OnapPdpEngine(evaluationContextFactory, this.getDefaultBehavior(), this.getScopeResolver());
+    }
+
+    @Override
+    public PDPEngine newEngine(final Properties properties) throws FactoryException {
+        final EvaluationContextFactory evaluationContextFactory = EvaluationContextFactory.newInstance(properties);
+        if (evaluationContextFactory == null) {
+            this.logger.error("Null EvaluationContextFactory");
+            throw new FactoryException("Null EvaluationContextFactory");
+        }
+        return new OnapPdpEngine(evaluationContextFactory, this.getDefaultBehavior(), this.getScopeResolver(),
+                properties);
+    }
+
+}
index 590d519..a8b0e9d 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-package org.onap.policy.xacml.pdp.std.functions;
-
-
-import java.util.List;
 
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+package org.onap.policy.xacml.pdp.std.functions;
 
 import com.att.research.xacml.api.DataType;
 import com.att.research.xacml.api.DataTypeException;
@@ -37,94 +32,104 @@ import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
 import com.att.research.xacmlatt.pdp.std.functions.ConvertedArgument;
 import com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionBase;
 
+import java.util.List;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
 /**
  * FunctionDefinitionCustomRegexMatch implements {@link com.att.research.xacmlatt.pdp.policy.FunctionDefinition} to
- * implement the custom 'type'-regex-match predicates as functions taking two arguments, the first of <code>String</code>,
- * and the second of the type for that specific predicate as a regular expression,
- * and returning a <code>Boolean</code> for whether the regular expression matches the string representation of the first argument.
- * 
- * 
+ * implement the custom 'type'-regex-match predicates as functions taking two arguments, the first of
+ * <code>String</code>, and the second of the type for that specific predicate as a regular expression, and returning a
+ * <code>Boolean</code> for whether the regular expression matches the string representation of the first argument.
+ *
+ *
  * @version $Revision: 0.2 $
- * 
+ *
  * @param <I> the java class for the data type of the function Input arguments
  */
 public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBase<Boolean, I> {
-       private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class);
-       
-       /**
-        * Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
-        * 
-        * @param idIn
-        * @param dataTypeArgsIn
-        */
-       public FunctionDefinitionCustomRegexpMatch(Identifier idIn, DataType<I> dataTypeArgsIn) {
-               super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, false);
-       }
-
-
-       @Override
-       public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
-
-               if (arguments == null || arguments.size() != 2) {
-                       return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 2 arguments, got " + 
-                                       ((arguments == null) ? "null" : arguments.size()) ));
-               }
-               
-               // get the regular expression
-               FunctionArgument regexpArgument = arguments.get(0);
-
-               ConvertedArgument<String> convertedArgument = new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false);
-               if ( ! convertedArgument.isOk()) {
-                       return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
-               }
-               
-               // String regexpValue = (String)regexpArgument.getValue().getValue();
-               String regexpValue      = convertedArgument.getValue();
-
-               
-               // now get the element to match
-               FunctionArgument elementArgument = arguments.get(1);
-               
-               ConvertedArgument<I> convertedElement = new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false);
-               if ( ! convertedElement.isOk()) {
-                       return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
-               }
-               
-               I elementValueObject = convertedElement.getValue();
-
-               String elementValueString;
-               try {
-                       elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject);
-               } catch (DataTypeException e) {
-                       logger.error(e.getMessage() +e);
-                       String message = e.getMessage();
-                       if (e.getCause() != null) {
-                               message = e.getCause().getMessage();
-                       }
-                       return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message));
-               }
-               
-               // ConvertedArgument checks for null value, so do not need to do again here
-               
-               // Adding this code will Change the Functionality which allows to retrieve Multiple-policy using single request.
-               elementValueString = elementValueString + regexpValue ;
-               regexpValue = elementValueString.substring(0,(elementValueString.length()- regexpValue.length()));
-               elementValueString = elementValueString.substring(regexpValue.length(),(elementValueString.length()));
-               // 
-               // Supporting multiple values in the element and be able to query them. 
-               if(elementValueString.contains(",")){
-                       String[] elements = elementValueString.split(",");
-                       for(int i=0; i<elements.length; i++){
-                               if(elements[i].trim().matches(regexpValue)) {
-                                       return ER_TRUE;
-                               }
-                       }
-               }
-               if (elementValueString.matches(regexpValue)) {
-                       return ER_TRUE;
-               } else {
-                       return ER_FALSE;
-               }
-
-       }
+    private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class);
+
+    /**
+     * Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
+     *
+     * @param idIn the identifier
+     * @param dataTypeArgsIn the data type
+     */
+    public FunctionDefinitionCustomRegexpMatch(final Identifier idIn, final DataType<I> dataTypeArgsIn) {
+        super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, false);
+    }
+
+
+    @Override
+    public ExpressionResult evaluate(final EvaluationContext evaluationContext,
+            final List<FunctionArgument> arguments) {
+
+        if (arguments == null || arguments.size() != 2) {
+            return ExpressionResult
+                    .newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId()
+                            + " Expected 2 arguments, got " + ((arguments == null) ? "null" : arguments.size())));
+        }
+
+        // get the regular expression
+        final FunctionArgument regexpArgument = arguments.get(0);
+
+        final ConvertedArgument<String> convertedArgument =
+                new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false);
+        if (!convertedArgument.isOk()) {
+            return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
+        }
+
+        // String regexpValue = (String)regexpArgument.getValue().getValue();
+        String regexpValue = convertedArgument.getValue();
+
+
+        // now get the element to match
+        final FunctionArgument elementArgument = arguments.get(1);
+
+        final ConvertedArgument<I> convertedElement =
+                new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false);
+        if (!convertedElement.isOk()) {
+            return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
+        }
+
+        final I elementValueObject = convertedElement.getValue();
+
+        String elementValueString;
+        try {
+            elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject);
+        } catch (final DataTypeException e) {
+            logger.error(e.getMessage() + e);
+            String message = e.getMessage();
+            if (e.getCause() != null) {
+                message = e.getCause().getMessage();
+            }
+            return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+                    this.getShortFunctionId() + " " + message));
+        }
+
+        // ConvertedArgument checks for null value, so do not need to do again here
+
+        // Adding this code will Change the Functionality which allows to retrieve Multiple-policy using single request.
+        elementValueString = elementValueString + regexpValue;
+        regexpValue = elementValueString.substring(0, (elementValueString.length() - regexpValue.length()));
+        elementValueString = elementValueString.substring(regexpValue.length(), (elementValueString.length()));
+        //
+        // Supporting multiple values in the element and be able to query them.
+        if (elementValueString.contains(",")) {
+            final String[] elements = elementValueString.split(",");
+            for (int i = 0; i < elements.length; i++) {
+                if (elements[i].trim().matches(regexpValue)) {
+                    return ER_TRUE;
+                }
+            }
+        }
+        if (elementValueString.matches(regexpValue)) {
+            return ER_TRUE;
+        } else {
+            return ER_FALSE;
+        }
+
+    }
 }
index 794276f..13b517d 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.pdp.std.functions;
 
 import java.util.ArrayList;
 import java.util.List;
+
 /**
  * Creates a list of policy ids.
- * 
+ *
  * @version $Revision: 1.3 $
  */
 public class PolicyList {
-       
-       private static List<String> policyList = new ArrayList<>();
-       
-       
-       public static List<String> getpolicyList(){
-               return policyList;
-       }
-
-       public static void addPolicyID(String policyID){
-               if (!policyList.contains(policyID)){
-                       policyList.add(policyID);
-               }
-       }
-       
-       public static void clearPolicyList(){
-               if (!policyList.isEmpty()){
-                       policyList.clear();
-               }
-       }
+
+    private static List<String> policyList = new ArrayList<>();
+
+
+    public static List<String> getpolicyList() {
+        return policyList;
+    }
+
+    /**
+     * Add policy id in the policy list.
+     *
+     * @param policyId the policy id
+     */
+    public static void addPolicyId(final String policyId) {
+        if (!policyList.contains(policyId)) {
+            policyList.add(policyId);
+        }
+    }
+
+    /**
+     * Clear policy list.
+     */
+    public static void clearPolicyList() {
+        if (!policyList.isEmpty()) {
+            policyList.clear();
+        }
+    }
 }
index 7a7fe54..1a6866c 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,13 +25,13 @@ import javax.ws.rs.Path;
 
 @Path("/")
 public class DummyRest {
-       
-       @GET
-       @Path("/foobar")
-       public String subscribe() {
 
-               return "{\"Foo\":\"bar\"}";
-       }
-       
+    @GET
+    @Path("/foobar")
+    public String subscribe() {
+
+        return "{\"Foo\":\"bar\"}";
+    }
+
 
 }
index 2a36fa2..f8a5e4b 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.action;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.xacml.custom.OnapFunctionDefinitionFactory;
 import com.att.research.xacml.api.Decision;
 import com.att.research.xacml.api.Request;
 import com.att.research.xacml.api.XACML3;
@@ -45,229 +41,196 @@ import com.att.research.xacml.std.datatypes.DataTypes;
 import com.att.research.xacml.std.json.JSONRequest;
 import com.att.research.xacml.util.XACMLProperties;
 
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 import org.onap.policy.drools.http.server.HttpServletServer;
 import org.onap.policy.drools.utils.NetworkUtil;
+import org.onap.policy.xacml.custom.OnapFunctionDefinitionFactory;
 
 public class FindActionTest {
-       
-
-       String xPathExampleFromSpec = "{ " +
-                       "\"Request\" : { " +
-                               "\"Resource\" : { " +
-                                       "\"Attribute\": [ " +
-                                               "{ " +
-                                                       "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
-                                                       "\"DataType\" : \"xpathExpression\", " +
-                                           "\"Value\" : { " +
-                                               "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", " +
-                                               "\"Namespaces\" : [{ " +
-                                                       "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
-                                                       "}, " +
-                                                   "{ " +
-                                                       "\"Prefix\" : \"md\", " +
-                                                       "\"Namespace\" : \"urn:example:med:schemas:record\" " +
-                                                   "} " +
-                                               "], " +
-                                               "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
-                                           "} " +
-                                       "} " +
-                                       "] " +
-                               "} " +
-                       "} " +
-               "} ";
-       
-       String jsonResponse;
-       Request request;
-       private static final int MOCK_SERVER_PORT = 6670;
-       
-       @BeforeClass
-       public static void setUpServer() {
+
+    String xpathexamplefromspec = "{ " + "\"Request\" : { " + "\"Resource\" : { " + "\"Attribute\": [ " + "{ "
+            + "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " + "\"DataType\" : \"xpathExpression\", "
+            + "\"Value\" : { " + "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", "
+            + "\"Namespaces\" : [{ " + "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " + "}, "
+            + "{ " + "\"Prefix\" : \"md\", " + "\"Namespace\" : \"urn:example:med:schemas:record\" " + "} " + "], "
+            + "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " + "} " + "} " + "] " + "} " + "} " + "} ";
+
+    String jsonResponse;
+    Request request;
+    private static final int MOCK_SERVER_PORT = 6670;
+
+    /**
+     * Setup server before test class.
+     */
+    @BeforeClass
+    public static void setUpServer() {
         try {
-               final HttpServletServer testServer = HttpServletServer.factory.build("dmaapSim",
-                               "localhost", MOCK_SERVER_PORT, "/", false, true);
-               testServer.addServletClass("/*", DummyRest.class.getName());
-               testServer.waitedStart(2000);
-               if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L))
-                       throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+            final HttpServletServer testServer =
+                    HttpServletServer.factory.build("dmaapSim", "localhost", MOCK_SERVER_PORT, "/", false, true);
+            testServer.addServletClass("/*", DummyRest.class.getName());
+            testServer.waitedStart(2000);
+            if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
+                throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+            }
         } catch (final Exception e) {
-               fail(e.getMessage());
+            fail(e.getMessage());
         }
-               
-       }
-       
+
+    }
+
     @AfterClass
     public static void tearDownSimulator() {
         HttpServletServer.factory.destroy();
     }
-    
-       @Before
-       public void setUp() throws Exception {
-               new OnapFunctionDefinitionFactory();
-               request = JSONRequest.load(xPathExampleFromSpec);
-
-               try {   
-                       XACMLProperties.reloadProperties();
-                       System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.properties");
-                       XACMLProperties.getProperties();
-                       
-                       assertTrue(true);
-               } catch (Exception e) {
-                       fail();
-                       
-               }
-       }
-       
-
-       @Test
-       public final void testRun() {
-               FindAction action = new FindAction();
-               // fully-loaded multiple response
-               StdMutableResponse response = new StdMutableResponse();
-               // create a Status object
-               StdMutableStatus status = new StdMutableStatus(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
-               status.setStatusMessage("some status message");
-               StdMutableStatusDetail statusDetailIn = new StdMutableStatusDetail();
-               StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PEPACTION"));
-               mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_INTEGER.getId(), "PDPACTION"));
-               mad.setAttributeId(XACML3.ID_ACTION_PURPOSE);
-               mad.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION);
-               mad.setDataTypeId(XACML3.ID_DATATYPE_STRING);
-               mad.setIssuer("an Issuer");
-               statusDetailIn.addMissingAttributeDetail(mad);
-               status.setStatusDetail(statusDetailIn);
-               // create a single result object
-               StdMutableResult result = new StdMutableResult(status);
-               // set the decision
-               result.setDecision(Decision.INDETERMINATE);
-               // put the Result into the Response
-               response.add(result);
-               // create a new Result with a different Decision
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.DENY);
-
-               StdMutableObligation obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "obligation-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Test")));
-               result.addObligation(obligation);
-
-               StdMutableAdvice advice = new StdMutableAdvice();
-               advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               advice.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               XACML3.ID_SUBJECT, 
-                               "advice-issuer1", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Test")));
-               response.add(result);
-               
-                       //      The logic below exercises the  callRest and takeAction methods in FindAction
-                       //      GET request
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.PERMIT);
-               
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("performer"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
-               
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("URL"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("method"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "GET")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("headers"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "foobar")));
-
-               
-               result.addObligation(obligation);
-               response.add(result);
-       
-                       //      POST request
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.PERMIT);
-               
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("performer"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
-               
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("URL"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("method"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "POST")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("body"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT + "/foobar")));
-               
-               result.addObligation(obligation);
-               response.add(result);
-               
-                       //PUT request
-               status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
-               result = new StdMutableResult(status);
-               result.setDecision(Decision.PERMIT);
-               
-               obligation = new StdMutableObligation();
-               obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("performer"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
-               
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("URL"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("method"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PUT")));
-               obligation.addAttributeAssignment(new StdMutableAttributeAssignment(
-                               XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, 
-                               new IdentifierImpl("body"), 
-                               "obligation-issuer", 
-                               new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT + "/foobar")));
-               
-               result.addObligation(obligation);
-               response.add(result);
-               
-               try {
-                       assertTrue(action.run(response, request) != null);
-               } catch (Exception e) {
-                       fail("operation failed, e="+e);
-               }
-       }
+
+    /**
+     * Setup before test case execution.
+     *
+     * @throws Exception if any error occurs
+     */
+    @Before
+    public void setUp() throws Exception {
+        new OnapFunctionDefinitionFactory();
+        request = JSONRequest.load(xpathexamplefromspec);
+
+        try {
+            XACMLProperties.reloadProperties();
+            System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.properties");
+            XACMLProperties.getProperties();
+
+            assertTrue(true);
+        } catch (final Exception e) {
+            fail();
+
+        }
+    }
+
+
+    @Test
+    public final void testRun() {
+        final FindAction action = new FindAction();
+        // fully-loaded multiple response
+        final StdMutableResponse response = new StdMutableResponse();
+        // create a Status object
+        StdMutableStatus status = new StdMutableStatus(StdStatusCode.STATUS_CODE_MISSING_ATTRIBUTE);
+        status.setStatusMessage("some status message");
+        final StdMutableStatusDetail statusDetailIn = new StdMutableStatusDetail();
+        final StdMutableMissingAttributeDetail mad = new StdMutableMissingAttributeDetail();
+        mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PEPACTION"));
+        mad.addAttributeValue(new StdAttributeValue<String>(DataTypes.DT_INTEGER.getId(), "PDPACTION"));
+        mad.setAttributeId(XACML3.ID_ACTION_PURPOSE);
+        mad.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION);
+        mad.setDataTypeId(XACML3.ID_DATATYPE_STRING);
+        mad.setIssuer("an Issuer");
+        statusDetailIn.addMissingAttributeDetail(mad);
+        status.setStatusDetail(statusDetailIn);
+        // create a single result object
+        StdMutableResult result = new StdMutableResult(status);
+        // set the decision
+        result.setDecision(Decision.INDETERMINATE);
+        // put the Result into the Response
+        response.add(result);
+        // create a new Result with a different Decision
+        status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
+        result = new StdMutableResult(status);
+        result.setDecision(Decision.DENY);
+
+        StdMutableObligation obligation = new StdMutableObligation();
+        obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
+        obligation.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, XACML3.ID_SUBJECT,
+                        "obligation-issuer1", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Test")));
+        result.addObligation(obligation);
+
+        final StdMutableAdvice advice = new StdMutableAdvice();
+        advice.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
+        advice.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, XACML3.ID_SUBJECT,
+                        "advice-issuer1", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "Test")));
+        response.add(result);
+
+        // The logic below exercises the callRest and takeAction methods in FindAction
+        // GET request
+        status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
+        result = new StdMutableResult(status);
+        result.setDecision(Decision.PERMIT);
+
+        obligation = new StdMutableObligation();
+        obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("performer"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
+
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("URL"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
+        obligation.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, new IdentifierImpl("method"),
+                        "obligation-issuer", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "GET")));
+        obligation.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, new IdentifierImpl("headers"),
+                        "obligation-issuer", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "foobar")));
+
+
+        result.addObligation(obligation);
+        response.add(result);
+
+        // POST request
+        status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
+        result = new StdMutableResult(status);
+        result.setDecision(Decision.PERMIT);
+
+        obligation = new StdMutableObligation();
+        obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("performer"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
+
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("URL"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
+        obligation.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, new IdentifierImpl("method"),
+                        "obligation-issuer", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "POST")));
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("body"), "obligation-issuer", new StdAttributeValue<String>(
+                        DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT + "/foobar")));
+
+        result.addObligation(obligation);
+        response.add(result);
+
+        // PUT request
+        status = new StdMutableStatus(StdStatusCode.STATUS_CODE_OK);
+        result = new StdMutableResult(status);
+        result.setDecision(Decision.PERMIT);
+
+        obligation = new StdMutableObligation();
+        obligation.setId(XACML3.ID_ACTION_IMPLIED_ACTION);
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("performer"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PDPACTION")));
+
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("URL"), "obligation-issuer",
+                new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT)));
+        obligation.addAttributeAssignment(
+                new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, new IdentifierImpl("method"),
+                        "obligation-issuer", new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), "PUT")));
+        obligation.addAttributeAssignment(new StdMutableAttributeAssignment(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                new IdentifierImpl("body"), "obligation-issuer", new StdAttributeValue<String>(
+                        DataTypes.DT_STRING.getId(), "http://localhost:" + MOCK_SERVER_PORT + "/foobar")));
+
+        result.addObligation(obligation);
+        response.add(result);
+
+        try {
+            assertTrue(action.run(response, request) != null);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
 
 }
diff --git a/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactoryTest.java b/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/ONAPPDPEngineFactoryTest.java
deleted file mode 100644 (file)
index 1bde7dd..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-PDP
- * ================================================================================
- * 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.xacml.pdp;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.util.Properties;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacml.util.FactoryFinder;
-import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
-
-@RunWith(PowerMockRunner.class)
-public class ONAPPDPEngineFactoryTest {
-  @Test
-  public final void testNewEngine() {
-    ONAPPDPEngineFactory pdpEngine = new ONAPPDPEngineFactory();
-    try {
-      assertTrue(pdpEngine.newEngine() != null);
-    } catch (Exception e) {
-      fail("operation failed, e=" + e);
-    }
-  }
-
-  @Test
-  public final void testNewEngineProperties() {
-    ONAPPDPEngineFactory pdpEngine = new ONAPPDPEngineFactory();
-    Properties properties = new Properties();
-    try {
-      assertTrue(pdpEngine.newEngine(properties) != null);
-    } catch (Exception e) {
-      fail("operation failed, e=" + e);
-    }
-  }
-
-  @PrepareForTest({EvaluationContextFactory.class, FactoryFinder.class})
-  @Test(expected = FactoryException.class)
-  public void negTestEngine() throws FactoryException {
-    // Setup test data
-    PowerMockito.mockStatic(FactoryFinder.class);
-    PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any()))
-        .thenReturn(null);
-
-    // Negative test factory
-    ONAPPDPEngineFactory factory = new ONAPPDPEngineFactory();
-    factory.newEngine();
-    fail("Expecting an exception.");
-  }
-
-  @PrepareForTest({EvaluationContextFactory.class, FactoryFinder.class})
-  @Test(expected = FactoryException.class)
-  public void negTestEngine2() throws FactoryException {
-    // Setup test data
-    PowerMockito.mockStatic(FactoryFinder.class);
-    PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any()))
-        .thenReturn(null);
-
-    // Negative test factory
-    ONAPPDPEngineFactory factory = new ONAPPDPEngineFactory();
-    Properties properties = new Properties();
-    factory.newEngine(properties);
-    fail("Expecting an exception.");
-  }
-}
diff --git a/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java b/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java
new file mode 100644 (file)
index 0000000..d3ee544
--- /dev/null
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PDP
+ * ================================================================================
+ * 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.xacml.pdp;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.att.research.xacml.util.FactoryException;
+import com.att.research.xacml.util.FactoryFinder;
+import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class OnapPdpEngineFactoryTest {
+    @Test
+    public final void testNewEngine() {
+        final OnapPdpEngineFactory pdpEngine = new OnapPdpEngineFactory();
+        try {
+            assertTrue(pdpEngine.newEngine() != null);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
+
+    @Test
+    public final void testNewEngineProperties() {
+        final OnapPdpEngineFactory pdpEngine = new OnapPdpEngineFactory();
+        final Properties properties = new Properties();
+        try {
+            assertTrue(pdpEngine.newEngine(properties) != null);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
+
+    @PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class })
+    @Test(expected = FactoryException.class)
+    public void negTestEngine() throws FactoryException {
+        // Setup test data
+        PowerMockito.mockStatic(FactoryFinder.class);
+        PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null);
+
+        // Negative test factory
+        final OnapPdpEngineFactory factory = new OnapPdpEngineFactory();
+        factory.newEngine();
+        fail("Expecting an exception.");
+    }
+
+    @PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class })
+    @Test(expected = FactoryException.class)
+    public void negTestEngine2() throws FactoryException {
+        // Setup test data
+        PowerMockito.mockStatic(FactoryFinder.class);
+        PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null);
+
+        // Negative test factory
+        final OnapPdpEngineFactory factory = new OnapPdpEngineFactory();
+        final Properties properties = new Properties();
+        factory.newEngine(properties);
+        fail("Expecting an exception.");
+    }
+}
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,24 +22,26 @@ package org.onap.policy.xacml.pdp;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import org.junit.Test;
-import org.mockito.Mockito;
+
 import com.att.research.xacml.api.Request;
 import com.att.research.xacml.api.Response;
 import com.att.research.xacml.api.pdp.PDPException;
 import com.att.research.xacml.api.pdp.ScopeResolver;
 import com.att.research.xacmlatt.pdp.eval.EvaluationContextFactory;
 
-public class ONAPPDPEngineTest {
-  @Test
-  public void testEngine() throws PDPException {
-    EvaluationContextFactory factory = Mockito.mock(EvaluationContextFactory.class);
-    ScopeResolver resolver = Mockito.mock(ScopeResolver.class);
-    ONAPPDPEngine engine = new ONAPPDPEngine(factory, resolver);
-    assertNotNull(engine);
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class OnapPdpEngineTest {
+    @Test
+    public void testEngine() throws PDPException {
+        final EvaluationContextFactory factory = Mockito.mock(EvaluationContextFactory.class);
+        final ScopeResolver resolver = Mockito.mock(ScopeResolver.class);
+        final OnapPdpEngine engine = new OnapPdpEngine(factory, resolver);
+        assertNotNull(engine);
 
-    Request pepRequest = Mockito.mock(Request.class);
-    Response response = engine.decide(pepRequest);
-    assertEquals(1, response.getResults().size());
-  }
+        final Request pepRequest = Mockito.mock(Request.class);
+        final Response response = engine.decide(pepRequest);
+        assertEquals(1, response.getResults().size());
+    }
 }
index 5100dc7..da1759a 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.pdp.std.functions;
 
 import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
+
 import com.att.research.xacml.api.Identifier;
 import com.att.research.xacml.api.XACML;
 import com.att.research.xacml.std.IdentifierImpl;
@@ -32,23 +31,29 @@ import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
 import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
 import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
 public class FunctionDefinitionCustomRegexpMatchTest {
-       @Test
-       public final void testRegexp() {
-               // Setup
-               String testVal = "testVal";
-               String testId = "function:testId";
-               IdentifierImpl testFnId = new IdentifierImpl(testId);
-               Identifier identifier = XACML.ID_DATATYPE_STRING;
-               StdAttributeValue<String> attValue = new StdAttributeValue<String>(identifier, testVal);
-               FunctionArgument fArg = new FunctionArgumentAttributeValue(attValue);
-               List<FunctionArgument> listFA = new ArrayList<FunctionArgument>();
-               listFA.add(fArg);
-               listFA.add(fArg);
-               
-               // Try a match
-               FunctionDefinitionCustomRegexpMatch<String> regexpMatch = new FunctionDefinitionCustomRegexpMatch<String>(testFnId, DataTypes.DT_STRING);
-               ExpressionResult result = regexpMatch.evaluate(null, listFA);
-               assertEquals(result.getStatus().isOk(), true);
-       }
+    @Test
+    public final void testRegexp() {
+        // Setup
+        final String testVal = "testVal";
+        final String testId = "function:testId";
+        final IdentifierImpl testFnId = new IdentifierImpl(testId);
+        final Identifier identifier = XACML.ID_DATATYPE_STRING;
+        final StdAttributeValue<String> attValue = new StdAttributeValue<String>(identifier, testVal);
+        final FunctionArgument fArg = new FunctionArgumentAttributeValue(attValue);
+        final List<FunctionArgument> listFa = new ArrayList<FunctionArgument>();
+        listFa.add(fArg);
+        listFa.add(fArg);
+
+        // Try a match
+        final FunctionDefinitionCustomRegexpMatch<String> regexpMatch =
+                new FunctionDefinitionCustomRegexpMatch<String>(testFnId, DataTypes.DT_STRING);
+        final ExpressionResult result = regexpMatch.evaluate(null, listFa);
+        assertEquals(result.getStatus().isOk(), true);
+    }
 }
index 17f509d..ccab704 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * 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.
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.xacml.pdp.std.functions;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.junit.Before;
 import org.junit.Test;
 
 public class PolicyListTest {
 
-       @Before
-       public void setUp() throws Exception {
-               PolicyList.addPolicyID("Test");
-       }
-
-       @Test
-       public final void testGetpolicyList() {
-               try{
-                       assertTrue(PolicyList.getpolicyList().size() ==1);
-               }catch(Exception e){
-                       fail("operation failed, e="+e);
-               }
-       }
-
-       @Test
-       public final void testAddPolicyID() {
-               try{
-                       PolicyList.addPolicyID("Test");
-                       assertTrue(PolicyList.getpolicyList().size() == 1);
-               }catch(Exception e){
-                       fail("operation failed, e="+e);
-               }
-       }
-
-       @Test
-       public final void testClearPolicyList() {
-               try{
-                       PolicyList.clearPolicyList();
-                       assertTrue(PolicyList.getpolicyList().size() == 0);
-               }catch(Exception e){
-                       fail("operation failed, e="+e);
-               }
-       }
+    @Before
+    public void setUp() throws Exception {
+        PolicyList.addPolicyId("Test");
+    }
+
+    @Test
+    public final void testGetpolicyList() {
+        try {
+            assertTrue(PolicyList.getpolicyList().size() == 1);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
+
+    @Test
+    public final void testAddPolicyId() {
+        try {
+            PolicyList.addPolicyId("Test");
+            assertTrue(PolicyList.getpolicyList().size() == 1);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
+
+    @Test
+    public final void testClearPolicyList() {
+        try {
+            PolicyList.clearPolicyList();
+            assertTrue(PolicyList.getpolicyList().size() == 0);
+        } catch (final Exception e) {
+            fail("operation failed, e=" + e);
+        }
+    }
 
 }
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java
new file mode 100644 (file)
index 0000000..f8777d8
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import java.util.Date;
+import org.junit.Test;
+
+public class ActionBodyEntityTest {
+  @Test
+  public void testEntity() {
+    // Set up test data
+    String value = "testVal";
+    Date date = new Date();
+    ActionBodyEntity entity = new ActionBodyEntity();
+    entity.prePersist();
+    ActionBodyEntity entity2 = new ActionBodyEntity();
+    ActionBodyEntity entity3 = new ActionBodyEntity();
+
+    // Test set and get
+    entity3.preUpdate();
+    entity3.setActionBody(value);
+    assertEquals(value, entity3.getActionBody());
+    entity3.setActionBodyName(value);
+    assertEquals(value, entity3.getActionBodyName());
+    entity3.setCreatedBy(value);
+    assertEquals(value, entity3.getCreatedBy());
+    entity3.setModifiedBy(value);
+    assertEquals(value, entity3.getModifiedBy());
+    entity3.setModifiedDate(date);
+    assertEquals(date, entity3.getModifiedDate());
+    assertEquals(0, entity3.getVersion());
+    assertNull(entity3.getCreatedDate());
+    entity3.setDeleted(true);
+    assertEquals(true, entity3.isDeleted());
+    assertEquals(0, entity3.getActionBodyId());
+
+    // Test equals method combinations
+    assertEquals(false, entity.equals(null));
+    assertEquals(true, entity.equals(entity));
+    assertEquals(false, entity.equals(value));
+    assertEquals(false, entity.equals(entity2));
+    assertThat(entity.hashCode(), is(not(0)));
+  }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java
new file mode 100644 (file)
index 0000000..da5dd50
--- /dev/null
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import java.util.Date;
+import org.junit.Test;
+
+public class ConfigurationDataEntityTest {
+  @Test
+  public void testEquals() {
+    // Set up test data
+    String value = "testVal";
+    Date date = new Date();
+    ConfigurationDataEntity entity = new ConfigurationDataEntity();
+    entity.prePersist();
+    ConfigurationDataEntity entity2 = new ConfigurationDataEntity();
+    ConfigurationDataEntity entity3 = new ConfigurationDataEntity();
+
+    // Test set and get
+    entity3.preUpdate();
+    entity3.setConfigBody(value);
+    assertEquals(value, entity3.getConfigBody());
+    entity3.setCreatedBy(value);
+    assertEquals(value, entity3.getCreatedBy());
+    entity3.setModifiedBy(value);
+    assertEquals(value, entity3.getModifiedBy());
+    entity3.setModifiedDate(date);
+    assertEquals(date, entity3.getModifiedDate());
+    assertEquals(0, entity3.getVersion());
+    assertNull(entity3.getCreatedDate());
+    entity3.setDeleted(true);
+    assertEquals(true, entity3.isDeleted());
+    entity3.setDescription(value);
+    assertEquals(value, entity3.getDescription());
+    entity3.setConfigType(value);
+    assertEquals(value, entity3.getConfigType());
+    entity3.setConfigurationName(value);
+    assertEquals(value, entity3.getConfigurationName());
+    assertEquals(0, entity3.getConfigurationDataId());
+
+    // Test method combinations
+    assertEquals(false, entity.equals(null));
+    assertEquals(true, entity.equals(entity));
+    assertEquals(false, entity.equals(value));
+    assertEquals(false, entity.equals(entity2));
+    assertThat(entity.hashCode(), is(not(0)));
+  }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java
new file mode 100644 (file)
index 0000000..62452dc
--- /dev/null
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class MicroserviceHeaderdeFaultsTest {
+  @Test
+  public void testHeader() {
+    // Set up test data
+    String value = "testVal";
+    MicroserviceHeaderdeFaults header = new MicroserviceHeaderdeFaults();
+    header.prePersist();
+    header.preUpdate();
+
+    // Set data
+    header.setGuard(value);
+    header.setId(1);
+    header.setModelName(value);
+    header.setOnapName(value);
+    header.setPriority(value);
+    header.setRiskLevel(value);
+    header.setRiskType(value);
+
+    // Test gets
+    assertEquals(value, header.getGuard());
+    assertEquals(1, header.getId());
+    assertEquals(value, header.getModelName());
+    assertEquals(value, header.getOnapName());
+    assertEquals(value, header.getPriority());
+    assertEquals(value, header.getRiskLevel());
+    assertEquals(value, header.getRiskType());
+  }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java
new file mode 100644 (file)
index 0000000..8d87173
--- /dev/null
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import org.junit.Test;
+import com.att.research.xacml.api.pip.PIPException;
+import com.att.research.xacml.util.XACMLProperties;
+
+public class PIPConfigurationTest {
+  @Test
+  public void testConfig() throws PIPException {
+    String value = "testVal";
+    String id = "1";
+    PIPConfigParam param = new PIPConfigParam();
+    param.setParamName(value);
+    param.setParamValue(value);
+    Set<PIPConfigParam> params = new HashSet<PIPConfigParam>();
+    PIPResolver resolver = new PIPResolver();
+    resolver.setClassname(value);
+    resolver.setName(value);
+    params.add(param);
+    Set<PIPResolver> resolvers = new HashSet<PIPResolver>();
+    resolvers.add(resolver);
+    Properties props = new Properties();
+    props.setProperty(id + ".classname", value);
+    props.setProperty(XACMLProperties.PROP_PIP_ENGINES, id);
+    PIPType type = new PIPType();
+    Date date = new Date();
+
+    // Test constructors
+    PIPConfiguration config = new PIPConfiguration();
+    assertNotNull(config);
+    config.setPipconfigParams(params);
+    config.setPipresolvers(resolvers);
+    PIPConfiguration config2 = new PIPConfiguration(config, value);
+    assertNotNull(config2);
+    config2.prePersist();
+    config2.preUpdate();
+    PIPConfiguration config3 = new PIPConfiguration(id, props);
+    assertNotNull(config3);
+    PIPConfiguration config4 = new PIPConfiguration(id, props, value);
+    assertNotNull(config4);
+
+    // Test set and get
+    config.setId(1);
+    assertEquals(1, config.getId());
+    config.setDescription(value);
+    assertEquals(value, config.getDescription());
+    config.setName(id);
+    assertEquals(id, config.getName());
+    config.setClassname(value);
+    assertEquals(value, config.getClassname());
+    config.setIssuer(value);
+    assertEquals(value, config.getIssuer());
+    config.setReadOnly(true);
+    assertEquals('1', config.getReadOnly());
+    config.setReadOnly('0');
+    assertEquals('0', config.getReadOnly());
+    assertEquals(false, config.isReadOnly());
+    config.setRequiresResolvers('t');
+    assertEquals('t', config.getRequiresResolvers());
+    config.setReadOnly(false);
+    assertEquals('0', config.getReadOnly());
+    config.setPiptype(type);
+    assertEquals(type, config.getPiptype());
+    config.setRequiresResolvers(false);
+    assertEquals('0', config.getRequiresResolvers());
+    config.setCreatedBy(value);
+    assertEquals(value, config.getCreatedBy());
+    config.setCreatedDate(date);
+    assertEquals(date, config.getCreatedDate());
+    config.setModifiedBy(value);
+    assertEquals(value, config.getModifiedBy());
+    config.setModifiedDate(date);
+    assertEquals(date, config.getModifiedDate());
+    config.setRequiresResolvers(true);
+    assertEquals(true, config.requiresResolvers());
+    assertEquals(8, config.getConfiguration(id).size());
+    assertEquals(9, config.generateProperties(id).size());
+
+    // Test remove and clear
+    assertEquals(param, config.removePipconfigParam(param));
+    config.clearConfigParams();
+    assertEquals(0, config.getPipconfigParams().size());
+    config.removePipresolver(resolver);
+    assertEquals(0, config.getPipresolvers().size());
+
+    // Test import
+    assertEquals(1, PIPConfiguration.importPIPConfigurations(props).size());
+    config.readProperties(id, props);
+    assertEquals(id, config.getName());
+
+    // Test toString
+    assertEquals(332, config.toString().length());
+  }
+}