Remove topic.properties and incorporate into overall config file 34/90734/1
authora.sreekumar <ajith.sreekumar@est.tech>
Mon, 1 Jul 2019 14:50:01 +0000 (14:50 +0000)
committera.sreekumar <ajith.sreekumar@est.tech>
Mon, 1 Jul 2019 14:50:01 +0000 (14:50 +0000)
1) The properties in the topic.properties file is moved into overall
config json file and the topic.properties file is removed.
2) Common parameters such as RestServer and Topic related parameters
from policy-common is used.

Change-Id: I390bbe3cda101a69e7ce614404ecdfbf98598dd2
Issue-ID: POLICY-1744
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
22 files changed:
main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
main/src/main/java/org/onap/policy/pap/main/parameters/RestServerParameters.java [deleted file]
main/src/main/java/org/onap/policy/pap/main/rest/PapRestServer.java
main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
main/src/main/java/org/onap/policy/pap/main/startstop/PapCommandLineArguments.java
main/src/test/java/org/onap/policy/pap/main/comm/PublisherTest.java
main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
main/src/test/java/org/onap/policy/pap/main/rest/CommonPapRestServer.java
main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java
main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
main/src/test/resources/e2e/PapConfigParameters.json
main/src/test/resources/parameters/MinimumParameters.json
main/src/test/resources/parameters/PapConfigParameters.json
main/src/test/resources/parameters/PapConfigParametersStd.json
main/src/test/resources/parameters/PapConfigParameters_sim.json
main/src/test/resources/parameters/topic.properties [deleted file]
main/src/test/resources/parameters/topic_sim.properties [deleted file]
packages/policy-pap-tarball/src/main/resources/etc/defaultConfig.json
packages/policy-pap-tarball/src/main/resources/etc/s3pConfig.json
packages/policy-pap-tarball/src/main/resources/etc/topic.properties [deleted file]
testsuites/stability/src/main/resources/simulatorsetup/config/pdp/OnapPfConfig.json
testsuites/stability/src/main/resources/simulatorsetup/config/pdp/topic.properties [deleted file]

index 0690fad..ed1b4ad 100644 (file)
@@ -22,7 +22,8 @@
 package org.onap.policy.pap.main.parameters;
 
 import lombok.Getter;
-
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.ParameterGroupImpl;
 import org.onap.policy.common.parameters.annotations.NotBlank;
 import org.onap.policy.common.parameters.annotations.NotNull;
@@ -40,6 +41,7 @@ public class PapParameterGroup extends ParameterGroupImpl {
     private RestServerParameters restServerParameters;
     private PdpParameters pdpParameters;
     private PolicyModelsProviderParameters databaseProviderParameters;
+    private TopicParameterGroup topicParameterGroup;
 
     /**
      * Create the pap parameter group.
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/RestServerParameters.java b/main/src/main/java/org/onap/policy/pap/main/parameters/RestServerParameters.java
deleted file mode 100644 (file)
index 99b346e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.parameters;
-
-import lombok.Getter;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
-
-/**
- * Class to hold all parameters needed for pap rest server.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-@NotNull
-@NotBlank
-@Getter
-public class RestServerParameters extends ParameterGroupImpl {
-    private String host;
-
-    @Min(value = 1)
-    private int port;
-
-    private String userName;
-    private String password;
-    private boolean https;
-    private boolean aaf;
-
-    public RestServerParameters() {
-        super("RestServerParameters");
-    }
-}
index 85c6f3c..c86cb81 100644 (file)
@@ -27,9 +27,9 @@ import java.util.Properties;
 
 import org.onap.policy.common.capabilities.Startable;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.pap.main.parameters.RestServerParameters;
 import org.onap.policy.pap.main.rest.depundep.PdpGroupDeleteControllerV1;
 import org.onap.policy.pap.main.rest.depundep.PdpGroupDeployControllerV1;
 import org.slf4j.Logger;
index 6351fa8..ba73d35 100644 (file)
 
 package org.onap.policy.pap.main.startstop;
 
-import java.io.FileInputStream;
 import java.util.Arrays;
 import java.util.Properties;
-
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.pap.main.PapConstants;
 import org.onap.policy.pap.main.PolicyPapException;
@@ -81,16 +80,7 @@ public class Main {
         }
 
         // Read the properties
-        final Properties props = new Properties();
-        try {
-            final String propFile = arguments.getFullPropertyFilePath();
-            try (FileInputStream stream = new FileInputStream(propFile)) {
-                props.load(stream);
-            }
-        } catch (final Exception e) {
-            LOGGER.error(START_FAILED, e);
-            return;
-        }
+        Properties props = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
 
         // Initialize database
         try {
index fd728d2..c917082 100644 (file)
@@ -163,7 +163,6 @@ public class PapCommandLineArguments {
      */
     public void validate() throws PolicyPapException {
         validateReadableFile("policy pap configuration", configurationFilePath);
-        validateReadableFile("policy pap properties", propertyFilePath);
     }
 
     /**
index f15b2a0..cadae12 100644 (file)
@@ -26,8 +26,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Semaphore;
@@ -40,14 +38,17 @@ import org.junit.Test;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicListener;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.pdp.concepts.PdpMessage;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.pap.main.PapConstants;
 import org.onap.policy.pap.main.PolicyPapException;
+import org.onap.policy.pap.main.parameters.PapParameterGroup;
+import org.onap.policy.pap.main.parameters.PapParameterHandler;
+import org.onap.policy.pap.main.startstop.PapCommandLineArguments;
 
 public class PublisherTest extends Threaded {
 
@@ -86,12 +87,10 @@ public class PublisherTest extends Threaded {
      */
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        Properties props = new Properties();
-        File propFile = new File(ResourceUtils.getFilePath4Resource("parameters/topic.properties"));
-        try (FileInputStream inp = new FileInputStream(propFile)) {
-            props.load(inp);
-        }
-
+        final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
+        final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);
+        final PapParameterGroup parameterGroup = new PapParameterHandler().getParameters(arguments);
+        Properties props = ParameterUtils.getTopicProperties(parameterGroup.getTopicParameterGroup());
         TopicEndpoint.manager.shutdown();
 
         TopicEndpoint.manager.addTopics(props);
index 6a1fbba..c22f5e1 100644 (file)
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
+import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.GroupValidationResult;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.StandardCoder;
@@ -50,6 +52,7 @@ public class TestPapParameterGroup {
     public void testPapParameterGroup() {
         final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(1);
         final RestServerParameters restServerParameters = papParameters.getRestServerParameters();
+        final TopicParameterGroup topicParameterGroup = papParameters.getTopicParameterGroup();
         final GroupValidationResult validationResult = papParameters.validate();
         assertTrue(validationResult.isValid());
         assertEquals(CommonTestData.PAP_GROUP_NAME, papParameters.getName());
@@ -59,6 +62,8 @@ public class TestPapParameterGroup {
         assertEquals(restServerParameters.getPassword(), papParameters.getRestServerParameters().getPassword());
         assertTrue(papParameters.getRestServerParameters().isHttps());
         assertFalse(papParameters.getRestServerParameters().isAaf());
+        assertEquals(topicParameterGroup.getTopicSinks(), papParameters.getTopicParameterGroup().getTopicSinks());
+        assertEquals(topicParameterGroup.getTopicSources(), papParameters.getTopicParameterGroup().getTopicSources());
     }
 
     @Test
@@ -99,7 +104,7 @@ public class TestPapParameterGroup {
         final GroupValidationResult validationResult = papParameters.validate();
         assertFalse(validationResult.isValid());
         assertTrue(validationResult.getResult()
-                .contains("\"org.onap.policy.pap.main.parameters.RestServerParameters\" INVALID, "
+                .contains("\"org.onap.policy.common.endpoints.parameters.RestServerParameters\" INVALID, "
                         + "parameter group has status INVALID"));
     }
 }
index d4b69f2..4abe6f1 100644 (file)
@@ -185,12 +185,7 @@ public class CommonPapRestServer {
         systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
         System.setProperties(systemProps);
 
-        // @formatter:off
-        final String[] papConfigParameters = {
-            "-c", "src/test/resources/parameters/TestConfigParams.json",
-            "-p", "src/test/resources/parameters/topic.properties"
-        };
-        // @formatter:on
+        final String[] papConfigParameters = { "-c", "src/test/resources/parameters/TestConfigParams.json" };
 
         main = new Main(papConfigParameters);
 
index 5ed94a3..016e120 100644 (file)
@@ -66,8 +66,7 @@ public class TestMain {
 
     @Test
     public void testMain() throws PolicyPapException {
-        final String[] papConfigParameters =
-            {"-c", "parameters/PapConfigParameters.json", "-p", "parameters/topic.properties"};
+        final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
         main = new Main(papConfigParameters);
         assertTrue(main.getParameters().isValid());
         assertEquals(CommonTestData.PAP_GROUP_NAME, main.getParameters().getName());
index f369488..fe2e837 100644 (file)
@@ -28,12 +28,12 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileInputStream;
 import java.util.Properties;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.utils.ParameterUtils;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.pap.main.PapConstants;
 import org.onap.policy.pap.main.PolicyPapException;
@@ -63,16 +63,11 @@ public class TestPapActivator {
         Registry.newRegistry();
         HttpServletServer.factory.destroy();
 
-        final String[] papConfigParameters =
-            {"-c", "parameters/PapConfigParameters.json", "-p", "parameters/topic.properties"};
+        final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters.json"};
         final PapCommandLineArguments arguments = new PapCommandLineArguments(papConfigParameters);
         final PapParameterGroup parGroup = new PapParameterHandler().getParameters(arguments);
 
-        Properties props = new Properties();
-        String propFile = arguments.getFullPropertyFilePath();
-        try (FileInputStream stream = new FileInputStream(propFile)) {
-            props.load(stream);
-        }
+        Properties props = ParameterUtils.getTopicProperties(parGroup.getTopicParameterGroup());
 
         activator = new PapActivator(parGroup, props);
     }
index 871077c..0c86e8f 100644 (file)
         "databaseUser": "policy",
         "databasePassword": "UDAxaWNZ",
         "persistenceUnit": "ToscaConceptTest"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }]
     }
 }
index 99c8a3a..6b21b4d 100644 (file)
         "databaseUser": "policy",
         "databasePassword": "P01icY",
         "persistenceUnit": "PdpGroupTest"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
     }
 }
index 16b22ae..f3dc775 100644 (file)
         "databaseUser": "policy",
         "databasePassword": "UDAxaWNZ",
         "persistenceUnit": "ToscaConceptTest"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }]
     }
 }
index 853249e..309bdb0 100644 (file)
         "databaseUser": "policy",
         "databasePassword": "UDAxaWNZ",
         "persistenceUnit": "ToscaConceptTest"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "noop"
+        }]
     }
 }
index 96bbedd..84b88e3 100644 (file)
         "databaseUser": "policy",
         "databasePassword": "UDAxaWNZ",
         "persistenceUnit": "PolicyMariaDb"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "localhost:6845" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "localhost:6845" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
     }
 }
diff --git a/main/src/test/resources/parameters/topic.properties b/main/src/test/resources/parameters/topic.properties
deleted file mode 100644 (file)
index 11c17da..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# ONAP PAP
-# ================================================================================
-# Copyright (C) 2019 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=========================================================
-
-noop.sink.topics=POLICY-PDP-PAP
-noop.sink.topics.POLICY-PDP-PAP.servers=anyserver
-noop.source.topics=POLICY-PDP-PAP
-noop.source.topics.POLICY-PDP-PAP.servers=anyserver
diff --git a/main/src/test/resources/parameters/topic_sim.properties b/main/src/test/resources/parameters/topic_sim.properties
deleted file mode 100644 (file)
index de5ae10..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# ONAP PAP
-# ================================================================================
-# Copyright (C) 2019 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=========================================================
-
-dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.sink.topics.POLICY-PDP-PAP.servers=localhost:6845
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers=localhost:6845
index 519060d..d21556f 100644 (file)
         "databaseUser": "policy_user",
         "databasePassword": "cG9saWN5X3VzZXI=",
         "persistenceUnit": "PolicyMariaDb"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
     }
 }
index 11bd507..cc06793 100644 (file)
@@ -7,5 +7,17 @@
         "password": "zb!XztG34",
         "https": true,
         "aaf": false
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
     }
 }
\ No newline at end of file
diff --git a/packages/policy-pap-tarball/src/main/resources/etc/topic.properties b/packages/policy-pap-tarball/src/main/resources/etc/topic.properties
deleted file mode 100644 (file)
index 5d36bdb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# ONAP PAP
-# ================================================================================
-# Copyright (C) 2019 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=========================================================
-
-dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.sink.topics.POLICY-PDP-PAP.servers=message-router
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers=message-router
index cbb4978..de31d50 100644 (file)
@@ -5,5 +5,17 @@
         "pdpType":"apex",
         "description":"Pdp Heartbeat",
         "supportedPolicyTypes":[{"name":"onap.policies.controlloop.operational.Apex","version":"1.0.0"}]
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "message-router" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
     }
 }
diff --git a/testsuites/stability/src/main/resources/simulatorsetup/config/pdp/topic.properties b/testsuites/stability/src/main/resources/simulatorsetup/config/pdp/topic.properties
deleted file mode 100644 (file)
index f659a4d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2019 Nordix Foundation.
-# ================================================================================
-# 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.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers= 10.2.0.41:3904
-dmaap.sink.topics.POLICY-PDP-PAP.servers= 10.2.0.41:3904