Add DMaaP plugin support 91/91491/4
authorJoeOLeary <joseph.o.leary@est.tech>
Fri, 19 Jul 2019 10:02:12 +0000 (10:02 +0000)
committerJoeOLeary <joseph.o.leary@est.tech>
Fri, 19 Jul 2019 10:02:12 +0000 (10:02 +0000)
- Update blueprint with DMaaP plugin support.
- Update configuration with new DMaaP plugin format.
- Move Configuration tests to correct package.
- Add latest-staging Docker image tag to pom.
- Change file endings in some files to LF.
- Remove publishing to non authenticated topic.
- Fix some tests which were not executing correctly.
- Fix some Sonar smells.

Issue-ID: DCAEGEN2-1581
Change-Id: I37fbb662419179e3fe9fb8bdf710d6a6e8f0308a
Signed-off-by: JoeOLeary <joseph.o.leary@est.tech>
52 files changed:
dpo/blueprints/k8s-pm-mapper.yaml
dpo/spec/dmaap.json
dpo/spec/pmmapper-component-spec.json
pom.xml
src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java
src/main/java/org/onap/dcaegen2/services/pmmapper/config/Configurable.java
src/main/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfiguration.java
src/main/java/org/onap/dcaegen2/services/pmmapper/datarouter/EventReceiver.java
src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java
src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilter.java
src/main/java/org/onap/dcaegen2/services/pmmapper/messagerouter/VESPublisher.java
src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java
src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapter.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/pmmapper/utils/EnvironmentConfig.java [moved from src/main/java/org/onap/dcaegen2/services/pmmapper/model/EnvironmentConfig.java with 75% similarity]
src/main/java/org/onap/dcaegen2/services/pmmapper/utils/RequiredFieldDeserializer.java
src/test/java/org/onap/dcaegen2/pmmapper/config/ConfigHandlerTests.java [deleted file]
src/test/java/org/onap/dcaegen2/pmmapper/messagerouter/VESPublisherTest.java
src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java
src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java [new file with mode: 0644]
src/test/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfigurationTest.java
src/test/java/org/onap/dcaegen2/services/pmmapper/datarouter/DeliveryHandlerTest.java
src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilterTest.java
src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapterTest.java [new file with mode: 0644]
src/test/java/org/onap/dcaegen2/services/pmmapper/utils/EnvironmentConfigTest.java [moved from src/test/java/org/onap/dcaegen2/pmmapper/config/EnvironmentConfigTest.java with 68% similarity]
src/test/java/org/onap/dcaegen2/services/pmmapper/utils/RequestSenderTests.java [moved from src/test/java/org/onap/dcaegen2/pmmapper/config/util/RequestSenderTests.java with 90% similarity]
src/test/java/utils/ConfigUtils.java [new file with mode: 0644]
src/test/java/utils/EventUtils.java
src/test/java/utils/FileUtils.java [new file with mode: 0644]
src/test/resources/invalid_configs/empty_filter_object.json [new file with mode: 0644]
src/test/resources/invalid_configs/invalid_filter_object.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_aaf_identity.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_aaf_password.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_client_role.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_dmaap_dr_delete_endpoint.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_dr_location.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_dr_password.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_dr_subscriber_id.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_dr_username.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_filter.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_filter_array.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_key_store_pass_path.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_key_store_path.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_location.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_topic_url.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_trust_store_pass_path.json [new file with mode: 0644]
src/test/resources/invalid_configs/null_trust_store_path.json [new file with mode: 0644]
src/test/resources/multiple_filter_mapper_config.json
src/test/resources/no_filter_mapper_config.json
src/test/resources/valid_mapper_config.json
version.properties

index c129357..9da07c1 100644 (file)
@@ -2,14 +2,14 @@
 # ============LICENSE_START=======================================================
 #  Copyright (C) 2019 Nordix Foundation.
 # ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
+# 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,
+# 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.
 tosca_definitions_version: cloudify_dsl_1_3
 
 imports:
-  - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
-  - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.13/k8splugin_types.yaml"
+  - 'http://www.getcloudify.org/spec/cloudify/3.4/types.yaml'
+  - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml'
+  - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml'
 
 inputs:
+  filter:
+    type: string
+    description: PM Mapper filter on measInfo, measInfoId, measType, instanceId
+    default: '{ "filters":[]}'
+  enable_http:
+    type: boolean
+    description: Option to turn on HTTP connections
+    default: false
   tag_version:
     type: string
     description: Docker image to be used
-    default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:latest"
+    default: 'nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:latest'
   replicas:
     type: integer
     description: Number of instances
     default: 1
-  aaf_username:
+  feed_name:
     type: string
-    description: AAF user name
-    default: "username"
-  aaf_password:
+    default: 'bulk_pm_feed'
+  topic_name:
     type: string
-    description: AAF password
-    default: "password"
+    default: 'PERFORMANCE_MEASUREMENTS'
   client_role:
     type: string
     description: Client role to request secure access to topic
-    default: "org.onap.dmaap.mr.PM_MAPPER.pub"
+    default: 'org.onap.dcae.pmPublisher'
   client_id:
     type: string
     description: Client id for given AAF client
-    default: "dcae@dcae.onap.org"
+    default: 'dcae@dcae.onap.org'
+  client_password:
+    type: string
+    description: Password for AAF client provided as client_id
   dmaap_dr_username:
     type: string
     description: DMAAP Data Router user name
-    default: "username"
+    default: 'username'
   dmaap_dr_password:
     type: string
     description: DMAAP Data Router password
-    default: "password"
+    default: 'password'
   dcae_location:
     type: string
     description: DCAE location for the subscriber, used to set up routing
-    default: "san-francisco"
-  subscriber_id:
-    type: string
-    description: Subscriber id in Data Router
-    default: "1"
+    default: 'san-francisco'
   pm_mapper_service_protocol:
     type: string
     description: PM Mapper protocol
-    default: "https"
+    default: 'https'
   pm_mapper_service_port:
     type: string
     description: PM Mapper host port
-    default: "8443"
+    default: '8443'
   dmaap_dr_service_host:
     type: string
     description: DMAAP Data Router host address
-    default: "dmaap-dr-node"
+    default: 'dmaap-dr-node'
   dmaap_dr_service_port:
     type: string
     description: DMAAP Data Router host port
-    default: "8443"
+    default: '8443'
   dmaap_mr_service_protocol:
     type: string
     description: DMAAP Message Router protocol
-    default: "https"
+    default: 'https'
   dmaap_mr_service_host:
     type: string
     description: DMAAP Message Router host address
-    default: "message-router"
+    default: 'message-router'
   dmaap_mr_service_port:
     type: string
     description: DMAAP Message Router host port
-    default: "3905"
-  filter:
-    type: string
-    description: PM Mapper filter on measInfo, measInfoId, measType, instanceId
-    default: { "filters":[]}
-  enable_http:
-    type: boolean
-    description: Option to turn on HTTP connections
-    default: false
+    default: '3905'
 
 node_templates:
+  pm-feed:
+    type: ccsdk.nodes.Feed
+    properties:
+      feed_name: { get_input: feed_name }
+
+  pm-topic:
+    type: ccsdk.nodes.Topic
+    properties:
+      topic_name: { get_input: topic_name }
+
   pm-mapper:
+    type: dcae.nodes.ContainerizedServiceComponentUsingDmaap
     interfaces:
       cloudify.interfaces.lifecycle:
-        start:
+        create:
           inputs:
             ports:
               - '8443:0'
               - '8081:0'
+
+    relationships:
+      - type: ccsdk.relationships.subscribe_to_files
+        target: pm-feed
+      - type: ccsdk.relationships.publish_events
+        target: pm-topic
+
     properties:
+      service_component_type: 'dcae-pm-mapper'
+      service_component_name_override: 'dcae-pm-mapper'
       application_config:
-        enable_http:
-          { get_input: enable_http }
-        trust_store_path: "/opt/app/pm-mapper/etc/cert/trust.jks.b64"
-        trust_store_pass_path: "/opt/app/pm-mapper/etc/cert/trust.pass"
-        key_store_path: "/opt/app/pm-mapper/etc/cert/cert.jks.b64"
-        key_store_pass_path: "/opt/app/pm-mapper/etc/cert/jks.pass"
-        dmaap_dr_feed_name: "bulk_pm_feed"
-        dmaap_dr_delete_endpoint:
-          { concat: ["https://", { get_input: dmaap_dr_service_host },
-                     ":", { get_input: dmaap_dr_service_port},"/delete"]}
-        pm-mapper-filter:
-          get_input: filter
+        trust_store_path: '/opt/app/pm-mapper/etc/cert/trust.jks.b64'
+        trust_store_pass_path: '/opt/app/pm-mapper/etc/cert/trust.pass'
+        key_store_path: '/opt/app/pm-mapper/etc/cert/cert.jks.b64'
+        key_store_pass_path: '/opt/app/pm-mapper/etc/cert/jks.pass'
+        pm-mapper-filter: { get_input: filter }
+        enable_http: { get_input: enable_http }
+        dmaap_dr_delete_endpoint: { concat: ['https://',{ get_input: dmaap_dr_service_host },':',{ get_input: dmaap_dr_service_port },'/delete'] }
+        aaf_identity: { get_input: client_id }
+        aaf_password: { get_input: client_password }
         streams_subscribes:
           dmaap_subscriber:
-            type:
-              "data_router"
-            dmaap_info:
-              username:
-                get_input: dmaap_dr_username
-              password:
-                get_input: dmaap_dr_password
-              location:
-                get_input: dcae_location
-              subscriber_id:
-                get_input: subscriber_id
-              delivery_url:
-                { concat: [{ get_input: pm_mapper_service_protocol },"://dcae-pm-mapper:",{ get_input: pm_mapper_service_port },"/delivery"]}
+            type: data_router
+            dmaap_info: <<pm-feed>>
         streams_publishes:
           dmaap_publisher:
-            aaf_username:
-              get_input: aaf_username
-            aaf_password:
-              get_input: aaf_password
-            type:
-              "message_router"
-            dmaap_info:
-              client_role:
-                get_input: client_role
-              client_id:
-                get_input: client_id
-              topic_url:
-                { concat: [{ get_input: dmaap_mr_service_protocol },"://",{ get_input: dmaap_mr_service_host },
-                           ":",{ get_input: dmaap_mr_service_port },"/events/org.onap.dmaap.mr.PM_MAPPER"]}
-              location:
-                get_input: dcae_location
+            type: message_router
+            dmaap_info: <<pm-topic>>
       docker_config:
         healthcheck:
           endpoint: /healthcheck
           interval: 15s
           timeout: 1s
           type: https
-      image:
-        get_input: tag_version
+      streams_publishes:
+        - name: pm-topic
+          location: { get_input: dcae_location }
+          client_role: { get_input: client_role }
+          type: message-router
+      streams_subscribes:
+        - name: pm-feed
+          location: { get_input: dcae_location }
+          client_role: { get_input: client_role }
+          username: { get_input: dmaap_dr_username }
+          password: { get_input: dmaap_dr_password }
+          scheme: { get_input: pm_mapper_service_protocol }
+          route: delivery
+          delivery_url: ''
+          privileged: true
+          decompress: true
+          type: data_router
+      image: { get_input: tag_version }
       replicas: { get_input: replicas }
-      name: "dcae-pm-mapper"
-      dns_name: "dcae-pm-mapper"
       log_info:
-        log_directory: "/var/log/ONAP/dcaegen2/services/pm-mapper"
+        log_directory: '/var/log/ONAP/dcaegen2/services/pm-mapper'
       tls_info:
-        cert_directory: "/opt/app/pm-mapper/etc/cert/"
-        use_tls: true
-    type: dcae.nodes.ContainerizedPlatformComponent
\ No newline at end of file
+        cert_directory: '/opt/app/pm-mapper/etc/cert/'
+        use_tls: true
\ No newline at end of file
index 1830723..2c998eb 100644 (file)
@@ -1,16 +1,16 @@
 {
-  "pm_mapper_publish_mr": {
+  "dmaap_publisher": {
     "aaf_username": "username",
     "aaf_password": "password",
     "type": "message_router",
     "dmaap_info": {
-      "client_role": "org.onap.dmaap.mr.PM_MAPPER.pub",
+      "client_role": "org.dcae.onap.pmPublisher",
       "client_id": "dcae@dcae.onap.org",
       "location": "san-francisco",
-      "topic_url": "https://message-router:3905//events/org.onap.dmaap.mr.PM_MAPPER"
+      "topic_url": "https://message-router:3905//events/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS"
     }
   },
-  "pm_mapper_subscribe_dr": {
+  "dmaap_subscriber": {
     "type": "data_router",
     "dmaap_info": {
       "username": "username",
index d88c71c..6734841 100644 (file)
@@ -9,8 +9,10 @@
     "subscribes": [
       {
         "type": "data_router",
-        "config_key": "pm_mapper_subscribe_dr",
+        "config_key": "dmaap_subscriber",
         "route": "/delivery",
+        "privileged": true,
+        "decompress": true,
         "format": "3GPP_XML",
         "version": "1.0.0"
       }
@@ -18,7 +20,7 @@
     "publishes": [
       {
         "type": "message_router",
-        "config_key": "pm_mapper_publish_mr",
+        "config_key": "dmaap_publisher",
         "format": "VES_specification",
         "version": "7.30.1"
       }
@@ -81,7 +83,7 @@
     },
     {
       "name": "enable_http",
-      "value": "true",
+      "value": "false",
       "description": "Option to turn on HTTP connections",
       "designer_editable": true,
       "sourced_at_deployment": false,
diff --git a/pom.xml b/pom.xml
index 41750d7..2b2b1e1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
 
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>pm-mapper</artifactId>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.1.2-SNAPSHOT</version>
 
     <parent>
         <groupId>org.onap.oparent</groupId>
                             <tag>${project.version}-${timestamp}</tag>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>latest-snapshot</id>
+                        <phase>none</phase>
+                        <goals>
+                            <goal>tag</goal>
+                        </goals>
+                        <configuration>
+                            <tag>latest-snapshot</tag>
+                        </configuration>
+                    </execution>
                     <execution>
                         <id>push-latest</id>
                         <phase>none</phase>
                             <goal>push</goal>
                         </goals>
                         <configuration>
-                            <tag>latest</tag>
+                            <tag>latest-snapshot</tag>
                         </configuration>
                     </execution>
                     <execution>
index e50ec6c..e98849e 100644 (file)
-/*-\r
- * ============LICENSE_START=======================================================\r
- *  Copyright (C) 2019 Nordix Foundation.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * SPDX-License-Identifier: Apache-2.0\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.dcaegen2.services.pmmapper.config;\r
-\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.CBSConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.CBSServerError;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;\r
-import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;\r
-import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;\r
-import org.onap.dcaegen2.services.pmmapper.utils.RequiredFieldDeserializer;\r
-\r
-import org.onap.logging.ref.slf4j.ONAPLogAdapter;\r
-import org.onap.logging.ref.slf4j.ONAPLogConstants;\r
-import org.slf4j.LoggerFactory;\r
-import com.google.gson.GsonBuilder;\r
-\r
-/**\r
- * Handles the retrieval of the component spec-based PM-Mapper Configuration\r
- * from DCAE.\r
- */\r
-\r
-public class ConfigHandler {\r
-    private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(ConfigHandler.class));\r
-    private RequestSender sender;\r
-\r
-    /**\r
-     * Creates a ConfigHandler.\r
-     */\r
-    public ConfigHandler() {\r
-        this(new RequestSender());\r
-    }\r
-\r
-    /**\r
-     * @see ConfigHandler#ConfigHandler()\r
-     * @param sender A RequestSender\r
-     */\r
-    public ConfigHandler(RequestSender sender) {\r
-        this.sender = sender;\r
-    }\r
-\r
-    /**\r
-     * Retrieves PM-Mapper Configuration from DCAE's ConfigBinding Service.\r
-     *\r
-     * @throws EnvironmentConfigException\r
-     * @throws ConsulServerError\r
-     * @throws CBSConfigException\r
-     * @throws CBSServerError\r
-     * @throws MapperConfigException\r
-     */\r
-    public MapperConfig getMapperConfig() throws EnvironmentConfigException,\r
-            CBSServerError, MapperConfigException {\r
-        String mapperConfigJson = "";\r
-        String cbsSocketAddress = EnvironmentConfig.getCBSHostName() + ":" + EnvironmentConfig.getCBSPort();\r
-        String requestURL = "http://" + cbsSocketAddress + "/service_component/" + EnvironmentConfig.getServiceName();\r
-        try {\r
-            logger.unwrap().info(ONAPLogConstants.Markers.ENTRY, "Fetching pm-mapper configuration from Configbinding Service");\r
-            mapperConfigJson = sender.send(requestURL);\r
-        } catch (Exception exception) {\r
-            throw new CBSServerError("Error connecting to Configbinding Service: ", exception);\r
-        } finally {\r
-            logger.unwrap().info(ONAPLogConstants.Markers.EXIT, "Received pm-mapper configuration from ConfigBinding Service:\n{}", mapperConfigJson);\r
-        }\r
-\r
-        return convertMapperConfigToObject(mapperConfigJson);\r
-    }\r
-\r
-    private MapperConfig convertMapperConfigToObject(String mapperConfigJson) throws MapperConfigException {\r
-        MapperConfig mapperConfig;\r
-        try {\r
-            mapperConfig = new GsonBuilder()\r
-                    .registerTypeAdapter(MapperConfig.class, new RequiredFieldDeserializer<MapperConfig>())\r
-                    .create()\r
-                    .fromJson(mapperConfigJson, MapperConfig.class);\r
-        } catch (Exception exception) {\r
-            throw new MapperConfigException("Error parsing mapper configuration:\n{}" + mapperConfigJson, exception);\r
-        }\r
-\r
-        logger.unwrap().debug("Mapper configuration:\n{}", mapperConfig);\r
-        return mapperConfig;\r
-    }\r
-}\r
+/*-
+ * ============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=========================================================
+ */
+package org.onap.dcaegen2.services.pmmapper.config;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import org.onap.dcaegen2.services.pmmapper.exceptions.CBSServerError;
+import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;
+import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;
+import org.onap.dcaegen2.services.pmmapper.utils.EnvironmentConfig;
+import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
+import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;
+import org.onap.dcaegen2.services.pmmapper.utils.RequiredFieldDeserializer;
+
+import org.onap.logging.ref.slf4j.ONAPLogAdapter;
+import org.slf4j.LoggerFactory;
+import com.google.gson.GsonBuilder;
+
+/**
+ * Handles the retrieval of the component spec-based PM-Mapper Configuration
+ * from DCAE.
+ */
+
+public class ConfigHandler {
+    private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(ConfigHandler.class));
+    private RequestSender sender;
+    private EnvironmentConfig environmentConfig;
+
+    /**
+     * Creates a ConfigHandler.
+     */
+    public ConfigHandler() {
+        this(new RequestSender(), new EnvironmentConfig());
+    }
+
+    /**
+     * @see ConfigHandler#ConfigHandler()
+     * @param sender A RequestSender
+     */
+    public ConfigHandler(RequestSender sender, EnvironmentConfig environmentConfig) {
+        this.sender = sender;
+        this.environmentConfig = environmentConfig;
+    }
+
+    /**
+     * Retrieves PM-Mapper Configuration from DCAE's ConfigBinding Service.
+     *
+     * @throws EnvironmentConfigException
+     * @throws CBSServerError
+     * @throws MapperConfigException
+     */
+    public MapperConfig getMapperConfig() throws EnvironmentConfigException,
+            CBSServerError, MapperConfigException {
+        String mapperConfigJson = "";
+        String cbsSocketAddress = this.environmentConfig.getCBSHostName() + ":" + this.environmentConfig.getCBSPort();
+        String requestURL = "http://" + cbsSocketAddress + "/service_component/" + this.environmentConfig.getServiceName();
+        try {
+            logger.unwrap().info("Fetching pm-mapper configuration from Configbinding Service");
+            mapperConfigJson = sender.send(requestURL);
+        } catch (Exception exception) {
+            throw new CBSServerError("Error connecting to Configbinding Service: ", exception);
+        } finally {
+            logger.unwrap().info("Received pm-mapper configuration from ConfigBinding Service:\n{}", mapperConfigJson);
+        }
+
+        return convertMapperConfigToObject(mapperConfigJson);
+    }
+
+    private MapperConfig convertMapperConfigToObject(String mapperConfigJson) throws MapperConfigException {
+        MapperConfig mapperConfig;
+        try {
+            JsonObject config = new Gson().fromJson(mapperConfigJson, JsonObject.class);
+            mapperConfig = new GsonBuilder()
+                    .registerTypeAdapter(MapperConfig.class, new RequiredFieldDeserializer<MapperConfig>())
+                    .create()
+                    .fromJson(config, MapperConfig.class);
+        } catch (Exception exception) {
+            String exceptionMessage = "Error parsing configuration, mapper config:\n" + mapperConfigJson;
+            throw new MapperConfigException(exceptionMessage, exception);
+        }
+
+        logger.unwrap().debug("Mapper configuration:\n{}", mapperConfig);
+        return mapperConfig;
+    }
+}
index ac2fe57..9431cce 100644 (file)
@@ -25,6 +25,7 @@ package org.onap.dcaegen2.services.pmmapper.config;
 import org.onap.dcaegen2.services.pmmapper.exceptions.ReconfigurationException;
 import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
 
+@FunctionalInterface
 public interface Configurable {
 
     void reconfigure(MapperConfig mapperConfig) throws ReconfigurationException;
index 37fa8b5..7e2c894 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.pmmapper.config;
 import io.undertow.server.HttpHandler;
 import io.undertow.server.HttpServerExchange;
 import io.undertow.util.StatusCodes;
+import java.util.List;
 import lombok.Data;
 import org.onap.dcaegen2.services.pmmapper.exceptions.ReconfigurationException;
 import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
@@ -30,10 +31,8 @@ import org.onap.dcaegen2.services.pmmapper.utils.HttpServerExchangeAdapter;
 import org.onap.logging.ref.slf4j.ONAPLogAdapter;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 @Data
-public class DynamicConfiguration implements HttpHandler{
+public class DynamicConfiguration implements HttpHandler {
     private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(DynamicConfiguration.class));
     private List<Configurable> configurables;
     private MapperConfig originalConfig;
@@ -44,7 +43,7 @@ public class DynamicConfiguration implements HttpHandler{
      * @param configurables list of objects to reconfigure
      * @param originalConfig original config to compare against.
      */
-    public DynamicConfiguration(List<Configurable> configurables, MapperConfig originalConfig){
+    public DynamicConfiguration(List<Configurable> configurables, MapperConfig originalConfig) {
         this.configurables = configurables;
         this.originalConfig = originalConfig;
         this.configHandler = new ConfigHandler();
@@ -79,6 +78,7 @@ public class DynamicConfiguration implements HttpHandler{
                 } catch (ReconfigurationException e) {
                     responseCode = StatusCodes.INTERNAL_SERVER_ERROR;
                     responseMessage = StatusCodes.INTERNAL_SERVER_ERROR_STRING;
+                    logger.unwrap().error("Failed to apply configuration update, reverting to original config", e);
                     applyConfiguration(this.originalConfig);
                 }
             }
index 77c8153..42dba87 100644 (file)
@@ -26,6 +26,7 @@ import org.onap.dcaegen2.services.pmmapper.model.Event;
 /**
  * Sink for Events received from the data router subscriber.
  */
+@FunctionalInterface
 public interface EventReceiver {
     void receive(Event event);
 }
index 2dc4ae9..0438530 100644 (file)
 
 package org.onap.dcaegen2.services.pmmapper.filtering;
 
-import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import org.apache.commons.io.FilenameUtils;
index 1fb6019..d647c40 100644 (file)
@@ -99,6 +99,7 @@ public class MetadataFilter {
         return true;
     }
 
+    @FunctionalInterface
     interface Validator<A, B> {
         boolean validate(A filter, B metadata);
     }
index 46d40e4..744696a 100644 (file)
@@ -64,11 +64,10 @@ public class VESPublisher {
         try {\r
             String topicUrl = config.getPublisherTopicUrl();\r
             ves = ves.replaceAll("\n", "");\r
-            String userCredentials =  topicUrl.startsWith("https") ? Base64.getEncoder()\r
+            String userCredentials =  Base64.getEncoder()\r
                 .encodeToString((this.config.getPublisherUserName() + ":" +\r
                     this.config.getPublisherPassword())\r
-                    .getBytes(StandardCharsets.UTF_8))\r
-                : "";\r
+                    .getBytes(StandardCharsets.UTF_8));\r
             sender.send("POST", topicUrl, ves, userCredentials);\r
         } catch (Exception e) {\r
             throw new MRPublisherException(e.getMessage(), e);\r
index 0630d53..385a256 100644 (file)
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.dcaegen2.services.pmmapper.model;
 
-import org.onap.dcaegen2.services.pmmapper.config.Configurable;
-import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
+import com.google.gson.annotations.JsonAdapter;
 import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
-import lombok.AccessLevel;
 import lombok.EqualsAndHashCode;
+import lombok.Getter;
 import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.onap.dcaegen2.services.pmmapper.config.Configurable;
+import org.onap.dcaegen2.services.pmmapper.utils.DMaaPAdapter;
+import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
 
 @Getter
 @EqualsAndHashCode
 @NoArgsConstructor
-public class MapperConfig implements Configurable{
+@ToString
+public class MapperConfig implements Configurable {
 
     public static final String CLIENT_NAME = "pm-mapper";
 
@@ -54,16 +58,6 @@ public class MapperConfig implements Configurable{
     @SerializedName("trust_store_pass_path")
     private String trustStorePassPath;
 
-    @GSONRequired
-    @Getter(AccessLevel.PRIVATE)
-    @SerializedName("streams_subscribes")
-    private StreamsSubscribes streamsSubscribes;
-
-    @GSONRequired
-    @Getter(AccessLevel.PRIVATE)
-    @SerializedName("streams_publishes")
-    private StreamsPublishes streamsPublishes;
-
     @GSONRequired
     @SerializedName("dmaap_dr_delete_endpoint")
     private String dmaapDRDeleteEndpoint;
@@ -72,98 +66,48 @@ public class MapperConfig implements Configurable{
     @SerializedName("pm-mapper-filter")
     private MeasFilterConfig filterConfig;
 
-    public String getSubscriberIdentity(){
-        return this.getStreamsSubscribes().getDmaapSubscriber().getDmaapInfo().getSubscriberId();
-    }
-
-    public String getPublisherTopicUrl() {
-        return this.getStreamsPublishes().getDmaapPublisher().getDmaapInfo().getTopicUrl();
-    }
-
-    public boolean dmaapInfoEquals(MapperConfig mapperConfig){
-        return this
-                .getStreamsSubscribes()
-                .getDmaapSubscriber()
-                .getDmaapInfo()
-                .equals(mapperConfig.getStreamsSubscribes().getDmaapSubscriber().getDmaapInfo());
-    }
-
-    @Getter
-    @EqualsAndHashCode
-    private class StreamsSubscribes {
-        @GSONRequired
-        @SerializedName("dmaap_subscriber")
-        DmaapSubscriber dmaapSubscriber;
-    }
-
-    @Getter
-    @EqualsAndHashCode
-    class DmaapSubscriber {
-        @GSONRequired
-        @SerializedName("dmaap_info")
-        DmaapInfo dmaapInfo;
-    }
+    @GSONRequired
+    @SerializedName("aaf_identity")
+    private String aafUsername;
 
-    @Getter
-    @EqualsAndHashCode
-    private class StreamsPublishes {
-        @GSONRequired
-        @SerializedName("dmaap_publisher")
-        DmaapPublisher dmaapPublisher;
-    }
+    @GSONRequired
+    @SerializedName("aaf_password")
+    private String aafPassword;
 
-    @Getter
-    @EqualsAndHashCode
-    class DmaapPublisher {
-        @GSONRequired
-        @SerializedName("dmaap_info")
-        DmaapInfo dmaapInfo;
+    @GSONRequired
+    @SerializedName("streams_subscribes")
+    @JsonAdapter(DMaaPAdapter.class)
+    private SubscriberConfig subscriberConfig;
 
-        @SerializedName("aaf_username")
-        private String aafUsername;
+    @GSONRequired
+    @SerializedName("streams_publishes")
+    @JsonAdapter(DMaaPAdapter.class)
+    private PublisherConfig publisherConfig;
 
-        @SerializedName("aaf_password")
-        private String aafPassword;
+    public String getSubscriberIdentity() {
+        return this.getSubscriberConfig().getSubscriberId();
     }
 
-    @Getter
-    @EqualsAndHashCode
-    class DmaapInfo {
-        private String location;
-        private String username;
-        private String password;
-
-        @SerializedName("delivery_url")
-        private String deliveryUrl;
-
-        @SerializedName("subscriber_id")
-        private String subscriberId;
-
-        @SerializedName("client_role")
-        private String clientRole;
-
-        @SerializedName("client_id")
-        private String clientId;
-
-        @SerializedName("topic_url")
-        private String topicUrl;
+    public String getPublisherTopicUrl() {
+        return this.getPublisherConfig().getTopicUrl();
     }
 
     public String getPublisherUserName() {
-        return this.getStreamsPublishes().getDmaapPublisher().getAafUsername();
+        return this.getAafUsername();
     }
 
     public String getPublisherPassword() {
-        return this.getStreamsPublishes().getDmaapPublisher().getAafPassword();
+        return this.getAafPassword();
     }
 
-    @Override
     public void reconfigure(MapperConfig mapperConfig) {
-        if(!this.equals(mapperConfig)) {
+        if (!this.equals(mapperConfig)) {
             this.filterConfig = mapperConfig.getFilterConfig();
-            this.streamsSubscribes = mapperConfig.getStreamsSubscribes();
-            this.streamsPublishes = mapperConfig.getStreamsPublishes();
+            this.publisherConfig = mapperConfig.getPublisherConfig();
+            this.subscriberConfig = mapperConfig.getSubscriberConfig();
             this.dmaapDRDeleteEndpoint = mapperConfig.getDmaapDRDeleteEndpoint();
+            this.aafUsername = mapperConfig.getAafUsername();
+            this.aafPassword = mapperConfig.getAafPassword();
         }
     }
 }
\ No newline at end of file
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/PublisherConfig.java
new file mode 100644 (file)
index 0000000..16ab941
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.model;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
+
+@Data
+public class PublisherConfig {
+    @GSONRequired
+    @SerializedName("topic_url")
+    private String topicUrl;
+
+    @GSONRequired
+    @SerializedName("client_role")
+    private String clientRole;
+
+    @GSONRequired
+    @SerializedName("client_id")
+    private String clientId;
+
+    @GSONRequired
+    @SerializedName("location")
+    private String clusterLocation;
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/SubscriberConfig.java
new file mode 100644 (file)
index 0000000..65f680b
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.model;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import org.onap.dcaegen2.services.pmmapper.utils.GSONRequired;
+
+@Data
+public class SubscriberConfig {
+    @GSONRequired
+    @SerializedName("username")
+    private String username;
+
+    @GSONRequired
+    @SerializedName("password")
+    private String password;
+
+    @GSONRequired
+    @SerializedName("location")
+    private String drLocation;
+
+    @SerializedName("delivery_url")
+    private String deliveryUrl;
+
+    @GSONRequired
+    @SerializedName("subscriber_id")
+    private String subscriberId;
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapter.java
new file mode 100644 (file)
index 0000000..fa01740
--- /dev/null
@@ -0,0 +1,81 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonParseException;
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.util.Optional;
+import org.onap.dcaegen2.services.pmmapper.model.PublisherConfig;
+import org.onap.dcaegen2.services.pmmapper.model.SubscriberConfig;
+
+public class DMaaPAdapter extends TypeAdapter<Object> {
+    private static final String PUBLISHER = "dmaap_publisher";
+    private static final String SUBSCRIBER = "dmaap_subscriber";
+    private static final String DMAAP_INFO = "dmaap_info";
+
+    @Override
+    public void write(JsonWriter jsonWriter, Object dmaapObj) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object read(JsonReader jsonReader) throws IOException {
+        jsonReader.beginObject();
+        String rootName = jsonReader.nextName();
+        Class configClass = getConfigClass(rootName);
+
+        Object generatedConfig = null;
+        jsonReader.beginObject();
+        while (jsonReader.hasNext()) {
+            if (jsonReader.nextName().equals(DMAAP_INFO)) {
+                generatedConfig  = new Gson().fromJson(jsonReader, configClass);
+            } else {
+                jsonReader.skipValue();
+            }
+        }
+        if (generatedConfig == null) {
+            throw new JsonParseException("Failed to Identify DMaaP Object");
+        }
+
+        jsonReader.endObject();
+        jsonReader.endObject();
+        return generatedConfig;
+    }
+    private Class getConfigClass(String rootName) {
+        Class configClass;
+        switch (rootName) {
+            case PUBLISHER:
+                configClass = PublisherConfig.class;
+                break;
+            case SUBSCRIBER:
+                configClass = SubscriberConfig.class;
+                break;
+            default:
+                String reason = String.format("This adapter expects one of: [ %s, %s]", PUBLISHER, SUBSCRIBER);
+                throw new IllegalArgumentException(reason);
+        }
+        return configClass;
+    }
+}
  * SPDX-License-Identifier: Apache-2.0\r
  * ============LICENSE_END=========================================================\r
  */\r
-package org.onap.dcaegen2.services.pmmapper.model;\r
+package org.onap.dcaegen2.services.pmmapper.utils;\r
 \r
 import java.util.Optional;\r
 \r
 import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;\r
 \r
 public class EnvironmentConfig {\r
-\r
     public static final int DEFAULT_CBS_PORT = 10000;\r
     public static final String ENV_CBS_HOST_KEY = "CONFIG_BINDING_SERVICE_SERVICE_HOST";\r
     public static final String ENV_CBS_PORT_KEY = "CONFIG_BINDING_SERVICE_SERVICE_PORT";\r
     public static final String ENV_SERVICE_NAME_KEY = "HOSTNAME";\r
 \r
-    public static String getServiceName() throws EnvironmentConfigException {\r
+    public String getServiceName() throws EnvironmentConfigException {\r
         return Optional.ofNullable(System.getenv(ENV_SERVICE_NAME_KEY))\r
                 .orElseThrow(() -> new EnvironmentConfigException(\r
                         ENV_SERVICE_NAME_KEY+ " environment variable must be defined prior to pm-mapper initialization."));\r
     }\r
 \r
-    public static String getCBSHostName() throws EnvironmentConfigException {\r
+    public String getCBSHostName() throws EnvironmentConfigException {\r
         return Optional.ofNullable(System.getenv(ENV_CBS_HOST_KEY))\r
                 .orElseThrow(() -> new EnvironmentConfigException(\r
                         ENV_CBS_HOST_KEY+ " environment variable must be defined prior to pm-mapper initialization."));\r
     }\r
 \r
-    public static Integer getCBSPort() throws EnvironmentConfigException {\r
-        Integer port = DEFAULT_CBS_PORT;\r
-        try {\r
-            port = Optional.ofNullable(System.getenv(ENV_CBS_PORT_KEY))\r
+    public Integer getCBSPort() {\r
+         return Optional.ofNullable(System.getenv(ENV_CBS_PORT_KEY))\r
                     .map(Integer::valueOf).orElse(DEFAULT_CBS_PORT);\r
-        } catch (NumberFormatException e) {\r
-            throw new EnvironmentConfigException(ENV_CBS_PORT_KEY + " must be valid: " + port);\r
-        }\r
-        return port;\r
     }\r
 }\r
index 258b831..3520a19 100644 (file)
@@ -41,7 +41,7 @@ import java.util.stream.Stream;
 public class RequiredFieldDeserializer<T> implements JsonDeserializer<T> {
 
     @Override
-    public T deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
+    public T deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
         T obj = new Gson().fromJson(jsonElement, type);
         validateRequiredFields(obj.getClass().getDeclaredFields(), obj);
         return obj;
diff --git a/src/test/java/org/onap/dcaegen2/pmmapper/config/ConfigHandlerTests.java b/src/test/java/org/onap/dcaegen2/pmmapper/config/ConfigHandlerTests.java
deleted file mode 100644 (file)
index e2bb4f5..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- *  Copyright (C) 2019 Nordix Foundation.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * SPDX-License-Identifier: Apache-2.0\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.dcaegen2.pmmapper.config;\r
-import static org.junit.jupiter.api.Assertions.assertThrows;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.InputStreamReader;\r
-import java.net.UnknownHostException;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-import static org.mockito.Mockito.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.dcaegen2.services.pmmapper.config.ConfigHandler;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.CBSConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.CBSServerError;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;\r
-import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;\r
-import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import com.google.gson.Gson;\r
-import com.google.gson.JsonObject;\r
-import com.google.gson.JsonParser;\r
-\r
-import ch.qos.logback.classic.spi.ILoggingEvent;\r
-import ch.qos.logback.core.read.ListAppender;\r
-import utils.LoggingUtils;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest(EnvironmentConfig.class)\r
-public class ConfigHandlerTests {\r
-    private static String validMapperConfig;\r
-    private static String HOSTNAME = "pm-mapper-service-name";\r
-    private static String CBS_HOST = "cbs_host";\r
-    private static int CBS_PORT = 10000;\r
-    private Gson gson = new Gson();\r
-    @Mock\r
-    private RequestSender sender;\r
-\r
-    @BeforeClass()\r
-    public static void beforeClass() throws Exception {\r
-        validMapperConfig = getFileContents("valid_mapper_config.json");\r
-    }\r
-\r
-\r
-    @Before\r
-    public void before() throws Exception {\r
-        PowerMockito.mockStatic(EnvironmentConfig.class);\r
-        PowerMockito.when(EnvironmentConfig.getCBSHostName()).thenReturn(CBS_HOST);\r
-        PowerMockito.when(EnvironmentConfig.getCBSPort()).thenReturn(CBS_PORT);\r
-        PowerMockito.when(EnvironmentConfig.getServiceName()).thenReturn(HOSTNAME);\r
-    }\r
-\r
-    @Test\r
-    public void getMapperConfig_success() throws Exception {\r
-        ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(ConfigHandler.class);\r
-        String validCbsUrl = "http://" + CBS_HOST + ":" + CBS_PORT +"/service_component/" + HOSTNAME;\r
-        when(sender.send(validCbsUrl)).thenReturn(validMapperConfig);\r
-\r
-        MapperConfig actualConfig = getMapperConfig();\r
-        MapperConfig expectedConfig = gson.fromJson(validMapperConfig, MapperConfig.class);\r
-\r
-        assertEquals(expectedConfig, actualConfig);\r
-        assertEquals(logAppender.list.get(0).getMarker().getName(), "ENTRY");\r
-        assertTrue(logAppender.list.get(1).getMessage().contains("Received pm-mapper configuration from ConfigBinding Service"));\r
-        assertEquals(logAppender.list.get(1).getMarker().getName(), "EXIT");\r
-        logAppender.stop();\r
-    }\r
-\r
-    @Test\r
-    public void configbinding_server_error() throws Exception {\r
-        when(sender.send(anyString())).thenThrow(CBSServerError.class);\r
-        assertThrows(CBSServerError.class, this::getMapperConfig);\r
-    }\r
-\r
-    @Test\r
-    public void configbinding_server_host_missing() throws Exception {\r
-        PowerMockito.when(EnvironmentConfig.getCBSHostName()).thenThrow(EnvironmentConfigException.class);\r
-        assertThrows(EnvironmentConfigException.class, this::getMapperConfig);\r
-    }\r
-\r
-    @Test\r
-    public void mapper_parse_invalid_json() throws Exception {\r
-        when(sender.send(anyString())).thenReturn("mapper config with incorrect format");\r
-        assertThrows(MapperConfigException.class, this::getMapperConfig);\r
-    }\r
-\r
-    @Test\r
-    public void mapper_parse_valid_json_missing_attributes() throws Exception {\r
-        Map<String,String> invalidConfigs = new HashMap<>();\r
-        invalidConfigs.put("streams_subscribes", "{}");\r
-        invalidConfigs.put("streams_publishes", "{}");\r
-        invalidConfigs.put("streams_publishes", null);\r
-        invalidConfigs.remove("streams_publishes");\r
-        invalidConfigs.put("pm-mapper-filter", null);\r
-        invalidConfigs.put("pm-mapper-filter", "{}");\r
-        invalidConfigs.put("pm-mapper-filter", "{ \"filters\": null},");\r
-        invalidConfigs.put("pm-mapper-filter", "{ \"filters\": [{\"pmDefVsn\": \"V9\"}] },");\r
-\r
-        invalidConfigs.forEach( (k,v) -> {\r
-            try {\r
-                when(sender.send(anyString())).thenReturn( getInvalidConfig(k,v));\r
-                assertThrows(MapperConfigException.class, this::getMapperConfig);\r
-            } catch (Exception e) {\r
-                e.printStackTrace();\r
-            }\r
-        });\r
-    }\r
-\r
-    private MapperConfig getMapperConfig()\r
-            throws UnknownHostException, EnvironmentConfigException, CBSConfigException, Exception {\r
-        return new ConfigHandler(sender).getMapperConfig();\r
-    }\r
-\r
-    private static String getFileContents(String fileName) throws IOException {\r
-        ClassLoader classLoader = ConfigHandlerTests.class.getClassLoader();\r
-        String fileAsString = "";\r
-        try (BufferedReader reader = new BufferedReader(\r
-                new InputStreamReader(classLoader.getResourceAsStream(fileName)))) {\r
-            String line;\r
-            while ((line = reader.readLine()) != null) {\r
-                fileAsString += line;\r
-            }\r
-        }\r
-        return fileAsString;\r
-    }\r
-\r
-    private String getInvalidConfig(String validKey, String invalidValue) {\r
-        JsonObject invalidConfigJson = new JsonParser().parse(validMapperConfig).getAsJsonObject();\r
-        invalidConfigJson.addProperty(validKey, invalidValue);\r
-        return invalidConfigJson.toString();\r
-    }\r
-\r
-}\r
index 2244d2d..ef508f3 100644 (file)
@@ -1,90 +1,90 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- *  Copyright (C) 2019 Nordix Foundation.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * SPDX-License-Identifier: Apache-2.0\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.dcaegen2.pmmapper.messagerouter;\r
-import static org.junit.jupiter.api.Assertions.assertThrows;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.times;\r
-import static org.mockito.Mockito.verify;\r
-import static org.mockito.Mockito.when;\r
-import reactor.test.StepVerifier;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mockito;\r
-import org.onap.dcaegen2.services.pmmapper.exceptions.MRPublisherException;\r
-import org.onap.dcaegen2.services.pmmapper.messagerouter.VESPublisher;\r
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;\r
-import org.onap.dcaegen2.services.pmmapper.model.Event;\r
-import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;\r
-import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import reactor.core.publisher.Flux;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest(EnvironmentConfig.class)\r
-public class VESPublisherTest {\r
-\r
-    private static String topicURL = "http://mr/topic";\r
-    private static RequestSender sender;\r
-    private static MapperConfig config;\r
-    private VESPublisher sut;\r
-    private String ves = "{}";\r
-\r
-    @Before\r
-    public void before() throws Exception {\r
-        config = mock(MapperConfig.class);\r
-        sender = mock(RequestSender.class);\r
-        sut = new VESPublisher(config, sender);\r
-        when(config.getPublisherTopicUrl()).thenReturn(topicURL);\r
-    }\r
-\r
-    @Test\r
-    public void publish_multiple_success() throws Exception {\r
-        Event event = mock(Event.class);\r
-        List<Event> events  = Arrays.asList(event,event,event);\r
-        when(event.getVes()).thenReturn(ves);\r
-\r
-        Flux<Event> flux = sut.publish(events);\r
-\r
-        verify(sender, times(3)).send(Mockito.anyString(),Mockito.anyString(), Mockito.anyString(), Mockito.anyString());\r
-        StepVerifier.create(flux)\r
-            .expectNextMatches(event::equals)\r
-            .expectComplete()\r
-            .verify();\r
-    }\r
-\r
-    @Test\r
-    public void publish_multiple_fail() throws Exception {\r
-        Event event = mock(Event.class);\r
-        List<Event> events  = Arrays.asList(event,event,event);\r
-        when(event.getVes()).thenReturn(ves);\r
-        when(sender.send("POST",topicURL,ves,"base64encoded")).thenThrow(Exception.class);\r
-\r
-        Flux<Event> flux = sut.publish(events);\r
-\r
-        StepVerifier.create(flux)\r
-        .expectNext(events.get(0))\r
-            .verifyComplete();\r
-    }\r
-}\r
+/*-
+ * ============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=========================================================
+ */
+package org.onap.dcaegen2.pmmapper.messagerouter;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import reactor.test.StepVerifier;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.dcaegen2.services.pmmapper.exceptions.MRPublisherException;
+import org.onap.dcaegen2.services.pmmapper.messagerouter.VESPublisher;
+import org.onap.dcaegen2.services.pmmapper.utils.EnvironmentConfig;
+import org.onap.dcaegen2.services.pmmapper.model.Event;
+import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
+import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import reactor.core.publisher.Flux;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(EnvironmentConfig.class)
+public class VESPublisherTest {
+
+    private static String topicURL = "http://mr/topic";
+    private static RequestSender sender;
+    private static MapperConfig config;
+    private VESPublisher sut;
+    private String ves = "{}";
+
+    @Before
+    public void before() throws Exception {
+        config = mock(MapperConfig.class);
+        sender = mock(RequestSender.class);
+        sut = new VESPublisher(config, sender);
+        when(config.getPublisherTopicUrl()).thenReturn(topicURL);
+    }
+
+    @Test
+    public void publish_multiple_success() throws Exception {
+        Event event = mock(Event.class);
+        List<Event> events  = Arrays.asList(event,event,event);
+        when(event.getVes()).thenReturn(ves);
+
+        Flux<Event> flux = sut.publish(events);
+
+        verify(sender, times(3)).send(Mockito.anyString(),Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
+        StepVerifier.create(flux)
+            .expectNextMatches(event::equals)
+            .expectComplete()
+            .verify();
+    }
+
+    @Test
+    public void publish_multiple_fail() throws Exception {
+        Event event = mock(Event.class);
+        List<Event> events  = Arrays.asList(event,event,event);
+        when(event.getVes()).thenReturn(ves);
+        when(sender.send("POST",topicURL,ves,"base64encoded")).thenThrow(Exception.class);
+
+        Flux<Event> flux = sut.publish(events);
+
+        StepVerifier.create(flux)
+        .expectNext(events.get(0))
+            .verifyComplete();
+    }
+}
index 2db24b4..11215b3 100644 (file)
@@ -74,8 +74,8 @@ class AppTest {
 
     @BeforeAll
     public static void setup() {
-        mockServer =  startClientAndServer(1080);
-        client = new MockServerClient("127.0.0.1", 1080);
+        mockServer =  startClientAndServer(35454);
+        client = new MockServerClient("127.0.0.1", 35454);
     }
 
     @AfterAll
@@ -210,7 +210,7 @@ class AppTest {
         MeasFilterHandler mockFilter = Mockito.mock(MeasFilterHandler.class);
         MapperConfig mockConfig = Mockito.mock(MapperConfig.class);
 
-        Mockito.when(mockConfig.getDmaapDRDeleteEndpoint()).thenReturn("http://127.0.0.1:1080");
+        Mockito.when(mockConfig.getDmaapDRDeleteEndpoint()).thenReturn("http://127.0.0.1:35454");
         Mockito.when(mockConfig.getSubscriberIdentity()).thenReturn("sid");
         Mockito.when(mockEvent.getPublishIdentity()).thenReturn("pid");
         Mockito.when(mockFilter.filterByMeasType(mockEvent)).thenThrow(RuntimeException.class);
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandlerTests.java
new file mode 100644 (file)
index 0000000..92d2c93
--- /dev/null
@@ -0,0 +1,140 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.config;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.dcaegen2.services.pmmapper.exceptions.CBSConfigException;
+import org.onap.dcaegen2.services.pmmapper.exceptions.CBSServerError;
+import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;
+import org.onap.dcaegen2.services.pmmapper.exceptions.MapperConfigException;
+import org.onap.dcaegen2.services.pmmapper.utils.EnvironmentConfig;
+import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
+import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;
+
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+import utils.FileUtils;
+import utils.LoggingUtils;
+
+@ExtendWith(MockitoExtension.class)
+class ConfigHandlerTests {
+    private static String validMapperConfig;
+    private static String HOSTNAME = "pm-mapper-service-name";
+    private static String CBS_HOST = "cbs_host";
+    private static int CBS_PORT = 10000;
+    private static Path invalidConfigsDirectory = Paths.get("src/test/resources/invalid_configs/");
+
+    private Gson gson = new Gson();
+
+    @Mock
+    private RequestSender sender;
+
+    @Mock
+    private static EnvironmentConfig config;
+
+    @BeforeAll
+    static void beforeAll() throws Exception {
+        validMapperConfig = FileUtils.getFileContents("valid_mapper_config.json");
+        config = mock(EnvironmentConfig.class);
+        when(config.getServiceName()).thenReturn(HOSTNAME);
+        when(config.getCBSPort()).thenReturn(CBS_PORT);
+    }
+
+    @BeforeEach
+    void setup() throws Exception {
+        when(config.getCBSHostName()).thenReturn(CBS_HOST);
+    }
+
+    @Test
+    void getMapperConfig_success() throws Exception {
+        when(config.getCBSHostName()).thenReturn(CBS_HOST);
+        when(config.getServiceName()).thenReturn(HOSTNAME);
+        when(config.getCBSPort()).thenReturn(CBS_PORT);
+
+        ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(ConfigHandler.class);
+        String validCbsUrlMapperConfig = "http://" + CBS_HOST + ":" + CBS_PORT + "/service_component/" + HOSTNAME;
+        when(sender.send(validCbsUrlMapperConfig)).thenReturn(validMapperConfig);
+        MapperConfig actualConfig = getMapperConfig();
+        JsonObject expectedConfigJson = gson.fromJson(validMapperConfig, JsonObject.class);
+        MapperConfig expectedConfig = gson.fromJson(expectedConfigJson, MapperConfig.class);
+        assertEquals(expectedConfig, actualConfig);
+        assertTrue(logAppender.list.get(1).getMessage().contains("Received pm-mapper configuration from ConfigBinding Service"));
+        logAppender.stop();
+    }
+
+    @Test
+    void configbinding_server_error() throws Exception {
+        when(sender.send(anyString())).thenThrow(CBSServerError.class);
+        assertThrows(CBSServerError.class, this::getMapperConfig);
+    }
+
+    @Test
+    void configbinding_server_host_missing() throws Exception {
+        when(config.getCBSHostName()).thenThrow(EnvironmentConfigException.class);
+        assertThrows(EnvironmentConfigException.class, this::getMapperConfig);
+    }
+
+    @Test
+    void mapper_parse_invalid_json_mapper_config() throws Exception {
+        when(sender.send(anyString())).thenReturn("mapper config with incorrect format");
+        assertThrows(MapperConfigException.class, this::getMapperConfig);
+    }
+
+    @ParameterizedTest
+    @MethodSource("getInvalidConfigs")
+    void parse_valid_json_bad_values_mapper_config(String mapperConfig) throws Exception {
+        when(sender.send(anyString())).thenReturn(mapperConfig);
+        assertThrows(MapperConfigException.class, this::getMapperConfig);
+    }
+
+    private MapperConfig getMapperConfig()
+            throws UnknownHostException, EnvironmentConfigException, CBSConfigException, Exception {
+        return new ConfigHandler(sender, config).getMapperConfig();
+    }
+
+    private static List<String> getInvalidConfigs() throws IOException {
+        return FileUtils.getFilesFromDirectory(invalidConfigsDirectory);
+    }
+}
index c900942..905d18a 100644 (file)
 
 package org.onap.dcaegen2.services.pmmapper.config;
 
-
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import io.undertow.server.HttpServerExchange;
 import io.undertow.util.StatusCodes;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.stubbing.Answer;
 
 import org.onap.dcaegen2.services.pmmapper.exceptions.ReconfigurationException;
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;
+import org.onap.dcaegen2.services.pmmapper.utils.EnvironmentConfig;
 import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
 import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import utils.ConfigUtils;
 import java.util.ArrayList;
+import utils.FileUtils;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -55,62 +51,55 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({DynamicConfiguration.class, EnvironmentConfig.class})
-public class DynamicConfigurationTest {
-    private static Path VALID_CONFIG_PATH = Paths.get("src/test/resources/valid_mapper_config.json");
+@ExtendWith(MockitoExtension.class)
+class DynamicConfigurationTest {
+    private static final String VALID_MAPPER_CONFIG_FILE = "valid_mapper_config.json";
 
     private static ArrayList<Configurable> configurables;
     private DynamicConfiguration objUnderTest;
-    private static String config;
+    private static String mapperConfig;
     private MapperConfig originalMapperConfig;
+    private static ConfigHandler configHandler;
+
+    @Mock
+    private static RequestSender sender;
 
     @Mock
-    private RequestSender sender;
+    private static EnvironmentConfig config;
 
-    @BeforeClass()
-    public static void setupBeforeClass() throws Exception {
-        config = new String(Files.readAllBytes(VALID_CONFIG_PATH));
+    @BeforeAll
+     static void setupBeforeAll() throws Exception {
+        mapperConfig = FileUtils.getFileContents(VALID_MAPPER_CONFIG_FILE);
     }
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() throws Exception {
+        configHandler = new ConfigHandler(sender, config);
+        when(sender.send(any())).thenReturn(mapperConfig);
+        originalMapperConfig = ConfigUtils.getMapperConfigFromFile(VALID_MAPPER_CONFIG_FILE);
         configurables = new ArrayList<>();
-        PowerMockito.mockStatic(EnvironmentConfig.class);
-        PowerMockito.when(EnvironmentConfig.getCBSHostName()).thenReturn("");
-        PowerMockito.when(EnvironmentConfig.getCBSPort()).thenReturn(1);
-        PowerMockito.when(EnvironmentConfig.getServiceName()).thenReturn("");
-
-        when(sender.send(any())).thenReturn(config);
-        ConfigHandler configHandler = new ConfigHandler(sender);
-        originalMapperConfig = configHandler.getMapperConfig();
         objUnderTest = new DynamicConfiguration(configurables, originalMapperConfig);
     }
 
     @Test
-    public void testNoChangeResponse() throws Exception {
-        ConfigHandler configHandler = new ConfigHandler(sender);
+    void testNoChangeResponse() throws Exception {
         originalMapperConfig = configHandler.getMapperConfig();
         objUnderTest.setConfigHandler(configHandler);
-
         HttpServerExchange httpServerExchange = mock(HttpServerExchange.class, RETURNS_DEEP_STUBS);
         objUnderTest.handleRequest(httpServerExchange);
-        assertEquals(originalMapperConfig, objUnderTest.getOriginalConfig());
         verify(httpServerExchange, times(1)).setStatusCode(StatusCodes.OK);
+        assertEquals(originalMapperConfig, objUnderTest.getOriginalConfig());
     }
 
     @Test
-    public void testApplyOriginalUponFailure() throws Exception {
-        ConfigHandler configHandler = new ConfigHandler(sender);
+    void testApplyOriginalUponFailure() throws Exception {
         Configurable configurable = mock(Configurable.class);
         configurables.add(configurable);
-        JsonObject modifiedConfig = new JsonParser().parse(config).getAsJsonObject();
+        JsonObject modifiedConfig = new JsonParser().parse(mapperConfig).getAsJsonObject();
         modifiedConfig.addProperty("dmaap_dr_delete_endpoint","http://modified-delete-endpoint/1");
         when(sender.send(any())).thenReturn(modifiedConfig.toString());
         MapperConfig modifiedMapperConfig = configHandler.getMapperConfig();
-
         objUnderTest.setConfigHandler(configHandler);
-
         doAnswer(new Answer() {
             boolean failFirstReconfigure = true;
             @Override
@@ -132,14 +121,14 @@ public class DynamicConfigurationTest {
     }
 
     @Test
-    public void testSuccessfulReconfiguration() throws Exception {
-        ConfigHandler configHandler = new ConfigHandler(sender);
+    void testSuccessfulReconfiguration() throws Exception {
         Configurable configurable = mock(Configurable.class);
         configurables.add(configurable);
-        JsonObject modifiedConfig = new JsonParser().parse(config).getAsJsonObject();
+        JsonObject modifiedConfig = new JsonParser().parse(mapperConfig).getAsJsonObject();
         modifiedConfig.addProperty("dmaap_dr_delete_endpoint","http://modified-delete-endpoint/1");
 
-        when(sender.send(any())).thenReturn(modifiedConfig.toString());
+        when(sender.send(any()))
+                .thenReturn(modifiedConfig.toString());
         MapperConfig modifiedMapperConfig = configHandler.getMapperConfig();
         objUnderTest.setConfigHandler(configHandler);
 
@@ -152,18 +141,21 @@ public class DynamicConfigurationTest {
     }
 
     @Test
-    public void testMapperConfigReconfiguration() throws Exception {
-        ConfigHandler configHandler = new ConfigHandler(sender);
-        JsonObject modifiedConfigJson = new JsonParser().parse(config).getAsJsonObject();
+    void testMapperConfigReconfiguration() throws Exception {
+        JsonObject modifiedConfigJson = new JsonParser().parse(mapperConfig).getAsJsonObject();
         modifiedConfigJson.addProperty("dmaap_dr_delete_endpoint","http://modified-delete-endpoint/1");
-        String newConfig =  modifiedConfigJson.toString();
-
-        when(sender.send(any())).thenReturn(config,newConfig);
-
-        MapperConfig originalConfig = configHandler.getMapperConfig();
+        when(sender.send(any()))
+                .thenReturn(modifiedConfigJson.toString());
         MapperConfig modifiedConfig = configHandler.getMapperConfig();
+        originalMapperConfig.reconfigure(modifiedConfig);
+        assertEquals(originalMapperConfig, modifiedConfig);
+    }
 
-        originalConfig.reconfigure(modifiedConfig);
-        assertEquals(originalConfig, modifiedConfig);
+    @Test
+    void testMapperConfigReconfigurationNoChange() throws Exception {
+        when(sender.send(any())).thenReturn(mapperConfig);
+        MapperConfig inboundConfig = configHandler.getMapperConfig();
+        originalMapperConfig.reconfigure(inboundConfig);
+        assertEquals(originalMapperConfig, inboundConfig);
     }
 }
index 94a2c7d..9b7bc4d 100644 (file)
@@ -44,20 +44,17 @@ import io.undertow.util.StatusCodes;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.stubbing.Answer;
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;
 import org.onap.dcaegen2.services.pmmapper.model.Event;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 import utils.LoggingUtils;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({DeliveryHandler.class, EnvironmentConfig.class})
-public class DeliveryHandlerTest {
+@ExtendWith(MockitoExtension.class)
+class DeliveryHandlerTest {
 
     private Path VALID_METADATA_PATH = Paths.get("src/test/resources/valid_metadata.json");
     private Path INVALID_METADATA_PATH = Paths.get("src/test/resources/invalid_metadata.json");
@@ -67,13 +64,13 @@ public class DeliveryHandlerTest {
 
     private DeliveryHandler objUnderTest;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         objUnderTest = new DeliveryHandler(eventReceiver);
     }
 
     @Test
-    public void testRequestInboundInvalidMetadata() throws Exception {
+    void testRequestInboundInvalidMetadata() throws Exception {
         HttpServerExchange httpServerExchange = mock(HttpServerExchange.class, RETURNS_DEEP_STUBS);
         JsonObject metadata = new JsonParser().parse(new String(Files
                 .readAllBytes(INVALID_METADATA_PATH))).getAsJsonObject();
@@ -87,7 +84,7 @@ public class DeliveryHandlerTest {
     }
 
     @Test
-    public void testRequestInboundNoMetadata() throws Exception {
+    void testRequestInboundNoMetadata() throws Exception {
         HttpServerExchange httpServerExchange = mock(HttpServerExchange.class, RETURNS_DEEP_STUBS);
         Receiver receiver = mock(Receiver.class);
         HeaderMap headers = mock(HeaderMap.class);
@@ -95,17 +92,6 @@ public class DeliveryHandlerTest {
         when(httpServerExchange.setStatusCode(anyInt())).thenReturn(httpServerExchange);
         when(httpServerExchange.getRequestHeaders()).thenReturn(headers);
         when(headers.get(any(String.class))).thenReturn(null);
-
-        doAnswer((Answer<Void>) invocationOnMock -> {
-            Receiver.FullStringCallback callback = invocationOnMock.getArgument(0);
-            callback.handle(httpServerExchange, "");
-            return null;
-        }).when(receiver).receiveFullString(any());
-        doAnswer((Answer<Void>) invocationOnMock -> {
-            Runnable runnable = invocationOnMock.getArgument(0);
-            runnable.run();
-            return null;
-        }).when(httpServerExchange).dispatch(any(Runnable.class));
         objUnderTest.handleRequest(httpServerExchange);
         verify(httpServerExchange, times(1)).setStatusCode(StatusCodes.BAD_REQUEST);
         verify(httpServerExchange.getResponseSender(), times(1)).send("Missing Metadata.");
@@ -113,7 +99,7 @@ public class DeliveryHandlerTest {
     }
 
     @Test
-    public void testRequestInboundSuccess() throws Exception {
+    void testRequestInboundSuccess() throws Exception {
         ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(DeliveryHandler.class);
         HttpServerExchange httpServerExchange = mock(HttpServerExchange.class, RETURNS_DEEP_STUBS);
         Receiver receiver = mock(Receiver.class);
index 47c187a..abe1b39 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.onap.dcaegen2.services.pmmapper.filtering;
 
-import com.google.gson.Gson;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -29,10 +28,10 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.dcaegen2.services.pmmapper.model.Event;
 import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
 import org.powermock.core.classloader.annotations.PrepareForTest;
+import utils.ConfigUtils;
 import utils.EventUtils;
 
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
@@ -44,41 +43,26 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 @PrepareForTest(MapperConfig.class)
 public class MetadataFilterTest {
 
-    private MetadataFilter metadataFilter;
+    private static final String VALID_MAPPER_CONFIG_FILE = "valid_mapper_config.json";
+    private static final String NO_FILTER_CONFIG_FILE = "no_filter_mapper_config.json";
+    private static final String MULTIPLE_FILTER_CONFIG_FILE = "multiple_filter_mapper_config.json";
+    private static final Path DATA_DIRECTORY = Paths.get("src/test/resources/xml_validator_test/test_data/");
+    private static final Path VALID_METADATA = Paths.get("src/test/resources/valid_metadata.json");
+    private static final Path INCORRECT_METADATA = Paths.get("src/test/resources/incorrect_metadata.json");
 
+    private MetadataFilter metadataFilter;
     private static MapperConfig validConfig;
     private static MapperConfig noFilterConfig;
     private static MapperConfig multipleFilterConfig;
 
-    private static String validConfigFileContents;
-    private static String noFilterConfigFileContents;
-    private static String multipleFilterConfigFileContents;
-
-    private static final Path validMetadata = Paths.get("src/test/resources/valid_metadata.json");
-    private static final Path incorrectMetadata = Paths.get("src/test/resources/incorrect_metadata.json");
-
-    private static final Path validConfigPath = Paths.get("src/test/resources/valid_mapper_config.json");
-    private static final Path noFilterConfigPath = Paths.get("src/test/resources/no_filter_mapper_config.json");
-    private static final Path multipleFilterConfigPath = Paths.get("src/test/resources/multiple_filter_mapper_config.json");
-
-    private static final Path dataDirectory = Paths.get("src/test/resources/xml_validator_test/test_data/");
-
-
     @BeforeEach
     void setup() throws Exception {
-        validConfigFileContents = new String(Files.readAllBytes(validConfigPath));
-        noFilterConfigFileContents = new String(Files.readAllBytes(noFilterConfigPath));
-        multipleFilterConfigFileContents = new String(Files.readAllBytes(multipleFilterConfigPath));
-
-        validConfig = new Gson().fromJson(validConfigFileContents, MapperConfig.class);
-        noFilterConfig = new Gson().fromJson(noFilterConfigFileContents, MapperConfig.class);
-        multipleFilterConfig = new Gson().fromJson(multipleFilterConfigFileContents, MapperConfig.class);
-
-
-        metadataFilter = new MetadataFilter(this.validConfig);
+        validConfig = ConfigUtils.getMapperConfigFromFile(VALID_MAPPER_CONFIG_FILE);
+        noFilterConfig = ConfigUtils.getMapperConfigFromFile(NO_FILTER_CONFIG_FILE);
+        multipleFilterConfig = ConfigUtils.getMapperConfigFromFile(MULTIPLE_FILTER_CONFIG_FILE);
+        metadataFilter = new MetadataFilter(validConfig);
     }
 
-
     @ParameterizedTest
     @MethodSource("getEventsWithValidMetadata")
     void testValidMetadataPass(Event testEvent) {
@@ -105,15 +89,13 @@ public class MetadataFilterTest {
         assertFalse(metadataFilter.filter(testEvent));
     }
 
-
-
     private static List<Event> getEventsWithValidMetadata() throws IOException {
-        Path validDataDirectory = Paths.get(dataDirectory.toString() + "/valid/");
-        return EventUtils.eventsFromDirectory(validDataDirectory, validMetadata);
+        Path validDataDirectory = Paths.get(DATA_DIRECTORY.toString() + "/valid/");
+        return EventUtils.eventsFromDirectory(validDataDirectory, VALID_METADATA);
     }
 
     private static List<Event> getEventsWithInvalidMetadata() throws IOException {
-        Path validDataDirectory = Paths.get(dataDirectory.toString() + "/valid/");
-        return EventUtils.eventsFromDirectory(validDataDirectory, incorrectMetadata);
+        Path validDataDirectory = Paths.get(DATA_DIRECTORY.toString() + "/valid/");
+        return EventUtils.eventsFromDirectory(validDataDirectory, INCORRECT_METADATA);
     }
 }
\ No newline at end of file
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapterTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DMaaPAdapterTest.java
new file mode 100644 (file)
index 0000000..9b22b95
--- /dev/null
@@ -0,0 +1,92 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.utils;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import com.google.gson.JsonParseException;
+import com.google.gson.stream.JsonReader;
+import java.io.IOException;
+import java.io.StringReader;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.dcaegen2.services.pmmapper.model.PublisherConfig;
+import org.onap.dcaegen2.services.pmmapper.model.SubscriberConfig;
+
+@ExtendWith(MockitoExtension.class)
+class DMaaPAdapterTest {
+    private DMaaPAdapter objUnderTest;
+
+    @BeforeEach
+    void beforeEach() {
+        objUnderTest = new DMaaPAdapter();
+    }
+
+    @Test
+    void testSuccessfulPublisher() throws IOException {
+        String dmaapPublisher = "{\"dmaap_publisher\": {\"dmaap_info\": {"
+                                        + "\"topic_url\": \"https://message-router:3905/events/org.onap.dmaap.mr.VES_PM\","
+                                        + "\"client_role\": \"org.onap.dcae.pmPublisher\","
+                                        + "\"location\": \"san-francisco\","
+                                        + "\"client_id\": \"1562763644939\"" + "},"
+                                        + "\"something\":\"completely different\"}}";
+        JsonReader reader = new JsonReader(new StringReader(dmaapPublisher));
+        assertTrue(objUnderTest.read(reader) instanceof PublisherConfig);
+    }
+
+    @Test
+    void testSuccessfulSubscriber() throws IOException {
+        String dmaapSubscriber = "{\"dmaap_subscriber\": {\"dmaap_info\": {"
+                                         + "\"username\": \"username\","
+                                         + "\"password\": \"password\","
+                                         + "\"location\": \"san-francisco\","
+                                         + "\"delivery_url\": \"http://dcae-pm-mapper:8443/delivery\","
+                                         + "\"subscriber_id\": 1" + "}}}";
+        JsonReader reader = new JsonReader(new StringReader(dmaapSubscriber));
+        assertTrue(objUnderTest.read(reader) instanceof SubscriberConfig);
+    }
+
+    @Test
+    void testFailedAdaption() {
+        JsonReader reader = new JsonReader(new StringReader("{\"dmaap_subscriber\": {\"dmaap_info\": \"nope\"}"));
+        assertThrows(JsonParseException.class, () -> objUnderTest.read(reader));
+    }
+
+    @Test
+    void testNoAdaptionAttempt() {
+        JsonReader reader = new JsonReader(new StringReader("{\"dmaap_subscriber\": {}"));
+        assertThrows(JsonParseException.class, () -> objUnderTest.read(reader));
+    }
+
+    @Test
+    void testInvalidAdaptionTarget() {
+        JsonReader reader = new JsonReader(new StringReader("{\"A scratch? \": \"Your arm's off!\" }"));
+        assertThrows(IllegalArgumentException.class, () -> objUnderTest.read(reader));
+    }
+
+    @Test
+    void testFailWriting() {
+        assertThrows(UnsupportedOperationException.class, () -> objUnderTest.write(null, null));
+    }
+}
  * SPDX-License-Identifier: Apache-2.0\r
  * ============LICENSE_END=========================================================\r
  */\r
-package org.onap.dcaegen2.pmmapper.config;\r
+\r
+package org.onap.dcaegen2.services.pmmapper.utils;\r
 import static org.junit.jupiter.api.Assertions.assertThrows;\r
 import static org.junit.Assert.assertEquals;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.junit.runner.RunWith;\r
 import org.onap.dcaegen2.services.pmmapper.exceptions.EnvironmentConfigException;\r
-import org.onap.dcaegen2.services.pmmapper.model.EnvironmentConfig;\r
 import org.powermock.api.mockito.PowerMockito;\r
 import org.powermock.core.classloader.annotations.PrepareForTest;\r
 import org.powermock.modules.junit4.PowerMockRunner;\r
@@ -32,40 +32,54 @@ import org.powermock.modules.junit4.PowerMockRunner;
 @RunWith(PowerMockRunner.class)\r
 @PrepareForTest(EnvironmentConfig.class)\r
 public class EnvironmentConfigTest {\r
+    private EnvironmentConfig objUnderTest;\r
 \r
     @Before\r
     public void before() throws Exception {\r
         PowerMockito.mockStatic(System.class);\r
+        objUnderTest = new EnvironmentConfig();\r
     }\r
 \r
     @Test\r
     public void environmentConfig_is_present_success() throws EnvironmentConfigException {\r
         String CBS_HOST = "cbs_host";\r
         PowerMockito.when(System.getenv(EnvironmentConfig.ENV_CBS_HOST_KEY)).thenReturn(CBS_HOST);\r
-        assertEquals(CBS_HOST,EnvironmentConfig.getCBSHostName() );\r
+        assertEquals(CBS_HOST, objUnderTest.getCBSHostName());\r
     }\r
 \r
     @Test\r
     public void environmentConfig_host_not_present() throws EnvironmentConfigException {\r
-        PowerMockito.when(System.getenv(EnvironmentConfig.ENV_CBS_HOST_KEY)).thenCallRealMethod();\r
-        assertThrows(EnvironmentConfigException.class,EnvironmentConfig::getCBSHostName);\r
+        PowerMockito.when(System.getenv(EnvironmentConfig.ENV_CBS_HOST_KEY)).thenReturn(null);\r
+        assertThrows(EnvironmentConfigException.class, objUnderTest::getCBSHostName);\r
     }\r
 \r
     @Test\r
     public void environmentConfig_hostname_present() throws EnvironmentConfigException {\r
         PowerMockito.when(System.getenv(EnvironmentConfig.ENV_SERVICE_NAME_KEY)).thenCallRealMethod();\r
-        assertThrows(EnvironmentConfigException.class,EnvironmentConfig::getCBSHostName);\r
+        assertThrows(EnvironmentConfigException.class, objUnderTest::getCBSHostName);\r
     }\r
 \r
     @Test\r
     public void environmentConfig_default_port_is_used() throws EnvironmentConfigException {\r
         PowerMockito.when(System.getenv(EnvironmentConfig.ENV_CBS_PORT_KEY)).thenReturn(null);\r
-        assertEquals(Integer.valueOf(EnvironmentConfig.DEFAULT_CBS_PORT),EnvironmentConfig.getCBSPort());\r
+        assertEquals(Integer.valueOf(EnvironmentConfig.DEFAULT_CBS_PORT), objUnderTest.getCBSPort());\r
     }\r
 \r
     @Test\r
     public void environmentConfig_port_invalid() throws EnvironmentConfigException {\r
         PowerMockito.when(System.getenv(EnvironmentConfig.ENV_CBS_PORT_KEY)).thenReturn("Invalid_port number");\r
-        assertThrows(EnvironmentConfigException.class,EnvironmentConfig::getCBSHostName);\r
+        assertThrows(EnvironmentConfigException.class, objUnderTest::getCBSHostName);\r
+    }\r
+\r
+    @Test\r
+    public void environmentConfig_service_name_missing() {\r
+        PowerMockito.when(System.getenv(EnvironmentConfig.ENV_SERVICE_NAME_KEY)).thenReturn(null);\r
+        assertThrows(EnvironmentConfigException.class, objUnderTest::getServiceName);\r
+    }\r
+    @Test\r
+    public void environmentConfig_service_name_success() throws EnvironmentConfigException {\r
+        String serviceName = "we the best service";\r
+        PowerMockito.when(System.getenv(EnvironmentConfig.ENV_SERVICE_NAME_KEY)).thenReturn(serviceName);\r
+        assertEquals(serviceName, objUnderTest.getServiceName());\r
     }\r
 }\r
-/*-\r
- * ============LICENSE_START=======================================================\r
- *  Copyright (C) 2019 Nordix Foundation.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * SPDX-License-Identifier: Apache-2.0\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.dcaegen2.pmmapper.config.util;\r
-\r
-import static org.junit.jupiter.api.Assertions.assertEquals;\r
-import static org.junit.jupiter.api.Assertions.assertThrows;\r
-import static org.junit.jupiter.api.Assertions.assertTrue;\r
-import static org.mockserver.integration.ClientAndServer.startClientAndServer;\r
-import static org.mockserver.model.HttpRequest.request;\r
-import static org.mockserver.model.HttpResponse.response;\r
-\r
-import java.net.URL;\r
-import java.net.UnknownHostException;\r
-\r
-import org.junit.AfterClass;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockserver.client.server.MockServerClient;\r
-import org.mockserver.integration.ClientAndServer;\r
-import org.mockserver.model.HttpRequest;\r
-import org.mockserver.model.HttpStatusCode;\r
-import org.mockserver.verify.VerificationTimes;\r
-import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;\r
-import org.onap.logging.ref.slf4j.ONAPLogConstants;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.core.classloader.annotations.PrepareForTest;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-import ch.qos.logback.classic.spi.ILoggingEvent;\r
-import ch.qos.logback.core.read.ListAppender;\r
-import utils.LoggingUtils;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-@PrepareForTest(RequestSender.class)\r
-\r
-public class RequestSenderTests {\r
-    private static ClientAndServer mockServer;\r
-    private MockServerClient client = mockClient();\r
-\r
-    @BeforeClass\r
-    public static void setup() {\r
-        mockServer = startClientAndServer(1080);\r
-    }\r
-\r
-    @AfterClass\r
-    public static void teardown() {\r
-        mockServer.stop();\r
-    }\r
-\r
-    @Test\r
-    public void send_success() throws Exception {\r
-        String url = "http://127.0.0.1:1080/once";\r
-        String uuidRegex = "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$";\r
-        ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RequestSender.class);\r
-        HttpRequest req = HttpRequest.request();\r
-\r
-        client.when(req\r
-                .withHeader(ONAPLogConstants.Headers.REQUEST_ID, uuidRegex)\r
-                .withHeader(ONAPLogConstants.Headers.INVOCATION_ID, uuidRegex))\r
-                .respond(response()\r
-                        .withStatusCode(HttpStatusCode.OK_200.code())\r
-                        .withBody("ResponseBody"));\r
-        String result = new RequestSender().send(url);\r
-\r
-        client.verify(req, VerificationTimes.atLeast(1));\r
-        assertEquals(result, "ResponseBody");\r
-        assertTrue(logAppender.list.get(1).getMessage().contains("Sending"));\r
-        assertTrue(logAppender.list.get(2).getMessage().contains("Received"));\r
-        logAppender.stop();\r
-        client.clear(req);\r
-    }\r
-\r
-    @Test\r
-    public void host_unavailable_retry_mechanism() throws Exception {\r
-        PowerMockito.mockStatic(Thread.class);\r
-\r
-        client.when(request())\r
-                .respond(response().withStatusCode(HttpStatusCode.SERVICE_UNAVAILABLE_503.code()));\r
-\r
-        assertThrows(Exception.class, () -> {\r
-            new RequestSender().send("http://127.0.0.1:1080/anypath");\r
-        });\r
-\r
-        client.verify(request(), VerificationTimes.exactly(5));\r
-        client.clear(request());\r
-    }\r
-\r
-    @Test\r
-    public void host_unknown() throws Exception {\r
-        PowerMockito.mockStatic(Thread.class);\r
-        String unknownHostUrl = "http://unknown-host:1080/host-is-unknown";\r
-        PowerMockito.whenNew(URL.class).withArguments(unknownHostUrl)\r
-            .thenThrow(UnknownHostException.class);\r
-\r
-        assertThrows(Exception.class, () -> {\r
-            new RequestSender().send(unknownHostUrl);\r
-        });\r
-\r
-        client.verify(request(), VerificationTimes.exactly(0));\r
-        client.clear(request());\r
-    }\r
-\r
-    private MockServerClient mockClient() {\r
-        return new MockServerClient("127.0.0.1", 1080);\r
-    }\r
-\r
+/*-
+ * ============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=========================================================
+ */
+package org.onap.dcaegen2.services.pmmapper.utils;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockserver.integration.ClientAndServer.startClientAndServer;
+import static org.mockserver.model.HttpRequest.request;
+import static org.mockserver.model.HttpResponse.response;
+
+import java.net.URL;
+import java.net.UnknownHostException;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockserver.client.server.MockServerClient;
+import org.mockserver.integration.ClientAndServer;
+import org.mockserver.model.HttpRequest;
+import org.mockserver.model.HttpStatusCode;
+import org.mockserver.verify.VerificationTimes;
+import org.onap.dcaegen2.services.pmmapper.utils.RequestSender;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+import utils.LoggingUtils;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(RequestSender.class)
+
+public class RequestSenderTests {
+    private static ClientAndServer mockServer;
+    private MockServerClient client = mockClient();
+
+    @BeforeClass
+    public static void setup() {
+        mockServer = startClientAndServer(35454);
+    }
+
+    @AfterClass
+    public static void teardown() {
+        mockServer.stop();
+    }
+
+    @Test
+    public void send_success() throws Exception {
+        String url = "http://127.0.0.1:35454/once";
+        String uuidRegex = "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$";
+        ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RequestSender.class);
+        HttpRequest req = HttpRequest.request();
+
+        client.when(req
+                .withHeader(ONAPLogConstants.Headers.REQUEST_ID, uuidRegex)
+                .withHeader(ONAPLogConstants.Headers.INVOCATION_ID, uuidRegex))
+                .respond(response()
+                        .withStatusCode(HttpStatusCode.OK_200.code())
+                        .withBody("ResponseBody"));
+        String result = new RequestSender().send(url);
+
+        client.verify(req, VerificationTimes.atLeast(1));
+        assertEquals(result, "ResponseBody");
+        assertTrue(logAppender.list.get(1).getMessage().contains("Sending"));
+        assertTrue(logAppender.list.get(2).getMessage().contains("Received"));
+        logAppender.stop();
+        client.clear(req);
+    }
+
+    @Test
+    public void host_unavailable_retry_mechanism() throws Exception {
+        PowerMockito.mockStatic(Thread.class);
+
+        client.when(request())
+                .respond(response().withStatusCode(HttpStatusCode.SERVICE_UNAVAILABLE_503.code()));
+
+        assertThrows(Exception.class, () -> {
+            new RequestSender().send("http://127.0.0.1:35454/anypath");
+        });
+
+        client.verify(request(), VerificationTimes.exactly(5));
+        client.clear(request());
+    }
+
+    @Test
+    public void host_unknown() throws Exception {
+        PowerMockito.mockStatic(Thread.class);
+        String unknownHostUrl = "http://unknown-host:35454/host-is-unknown";
+        PowerMockito.whenNew(URL.class).withArguments(unknownHostUrl)
+            .thenThrow(UnknownHostException.class);
+
+        assertThrows(Exception.class, () -> {
+            new RequestSender().send(unknownHostUrl);
+        });
+
+        client.verify(request(), VerificationTimes.exactly(0));
+        client.clear(request());
+    }
+
+    private MockServerClient mockClient() {
+        return new MockServerClient("127.0.0.1", 35454);
+    }
+
 }
\ No newline at end of file
diff --git a/src/test/java/utils/ConfigUtils.java b/src/test/java/utils/ConfigUtils.java
new file mode 100644 (file)
index 0000000..8cf6d87
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * ============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=========================================================
+ */
+
+package utils;
+
+import com.google.gson.Gson;
+import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
+
+
+public class ConfigUtils {
+
+    /**
+     * Returns A MapperConfig Object Created from a file.
+     * Fails test in the event of failure to read file.
+     * @param mapperConfigFile Filename for the mapper config
+     * @return A Mapper Config Object
+     */
+    public static MapperConfig getMapperConfigFromFile(String mapperConfigFile) {
+        return new Gson().fromJson(FileUtils.getFileContents(mapperConfigFile), MapperConfig.class);
+    }
+}
index eae050d..f14e080 100644 (file)
@@ -51,13 +51,10 @@ public class EventUtils {
      */
     public static List<Event> eventsFromDirectory(Path eventBodyDirectory, Path metadataPath) throws IOException {
         EventMetadata eventMetadata = new Gson().fromJson(fileContentsToString(metadataPath), EventMetadata.class);
-        try (Stream<Path> eventFileStream = Files.walk(eventBodyDirectory)) {
-            return eventFileStream.filter(Files::isRegularFile)
-                    .filter(Files::isReadable)
-                    .map(EventUtils::fileContentsToString)
-                    .map(body -> EventUtils.makeMockEvent(body, eventMetadata))
-                    .collect(Collectors.toList());
-        }
+        List<String> eventFiles = FileUtils.getFilesFromDirectory(eventBodyDirectory);
+        return eventFiles.stream()
+                       .map(contents -> EventUtils.makeMockEvent(contents, eventMetadata))
+                       .collect(Collectors.toList());
     }
 
     /**
diff --git a/src/test/java/utils/FileUtils.java b/src/test/java/utils/FileUtils.java
new file mode 100644 (file)
index 0000000..8b58618
--- /dev/null
@@ -0,0 +1,82 @@
+/*-
+ * ============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=========================================================
+ */
+
+package utils;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class FileUtils {
+
+    /**
+     * Reads contents of files inside the eventBodyDirectory, combines contents with metadata to make an Event Object.
+     * Fails test in the event of failure to read a file.
+     * @param targetDirectory Path to directory with files.
+     * @return List of Strings containing the body as acquired from files inside targetDirectory.
+     * @throws IOException in the event it fails to read from the files.
+     */
+    public static List<String> getFilesFromDirectory(Path targetDirectory ) throws IOException {
+        try (Stream<Path> eventFileStream = Files.walk(targetDirectory)) {
+            return eventFileStream.filter(Files::isRegularFile)
+                           .filter(Files::isReadable)
+                           .map(FileUtils::getFileContents)
+                           .collect(Collectors.toList());
+        }
+    }
+
+    /**
+     * reads contents of file into a string.
+     * fails a tests in the event failure occurs.
+     * @param path path to file.
+     * @return string containing files contents
+     */
+    public static String getFileContents(Path path) {
+        try {
+            return new String(Files.readAllBytes(path));
+        } catch (IOException exception) {
+            fail("IOException occurred while reading file.");
+        }
+        return null;
+    }
+
+    /**
+     * Reads contents of resource.
+     * fails a test in the event failure occurs.
+     * @param fileName of file in resources to be read.
+     * @return contents of file
+     */
+    public static String getFileContents(String fileName) {
+        try {
+            Path path = Paths.get(ClassLoader.getSystemResource(fileName).toURI());
+            return getFileContents(path);
+        } catch (URISyntaxException exception) {
+            fail("Exception occurred, failed to acquire resource URI.");
+        }
+        return null;
+    }
+}
diff --git a/src/test/resources/invalid_configs/empty_filter_object.json b/src/test/resources/invalid_configs/empty_filter_object.json
new file mode 100644 (file)
index 0000000..8c72b83
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "pm-mapper-filter": {},
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/invalid_filter_object.json b/src/test/resources/invalid_configs/invalid_filter_object.json
new file mode 100644 (file)
index 0000000..1b7b0e3
--- /dev/null
@@ -0,0 +1,41 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9"
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_aaf_identity.json b/src/test/resources/invalid_configs/null_aaf_identity.json
new file mode 100644 (file)
index 0000000..8f9c7ef
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": null,
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_aaf_password.json b/src/test/resources/invalid_configs/null_aaf_password.json
new file mode 100644 (file)
index 0000000..d54d825
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": null,
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_client_role.json b/src/test/resources/invalid_configs/null_client_role.json
new file mode 100644 (file)
index 0000000..40471de
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": null,
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_dmaap_dr_delete_endpoint.json b/src/test/resources/invalid_configs/null_dmaap_dr_delete_endpoint.json
new file mode 100644 (file)
index 0000000..d86de5e
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": null,
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_dr_location.json b/src/test/resources/invalid_configs/null_dr_location.json
new file mode 100644 (file)
index 0000000..79bd05d
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": null,
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_dr_password.json b/src/test/resources/invalid_configs/null_dr_password.json
new file mode 100644 (file)
index 0000000..365b328
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": null,
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_dr_subscriber_id.json b/src/test/resources/invalid_configs/null_dr_subscriber_id.json
new file mode 100644 (file)
index 0000000..c6c2a45
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": null
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_dr_username.json b/src/test/resources/invalid_configs/null_dr_username.json
new file mode 100644 (file)
index 0000000..511dd35
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": null,
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_filter.json b/src/test/resources/invalid_configs/null_filter.json
new file mode 100644 (file)
index 0000000..7eb6af0
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "pm-mapper-filter": null,
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_filter_array.json b/src/test/resources/invalid_configs/null_filter_array.json
new file mode 100644 (file)
index 0000000..3d2df14
--- /dev/null
@@ -0,0 +1,37 @@
+{
+  "pm-mapper-filter": {
+    "filters": null
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_key_store_pass_path.json b/src/test/resources/invalid_configs/null_key_store_pass_path.json
new file mode 100644 (file)
index 0000000..2145e01
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": null,
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_key_store_path.json b/src/test/resources/invalid_configs/null_key_store_path.json
new file mode 100644 (file)
index 0000000..8f6f831
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": null,
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_location.json b/src/test/resources/invalid_configs/null_location.json
new file mode 100644 (file)
index 0000000..b7d9266
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": null,
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_topic_url.json b/src/test/resources/invalid_configs/null_topic_url.json
new file mode 100644 (file)
index 0000000..faea169
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": null,
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_trust_store_pass_path.json b/src/test/resources/invalid_configs/null_trust_store_pass_path.json
new file mode 100644 (file)
index 0000000..c98274e
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",
+  "trust_store_pass_path": null,
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/invalid_configs/null_trust_store_path.json b/src/test/resources/invalid_configs/null_trust_store_path.json
new file mode 100644 (file)
index 0000000..2673fb9
--- /dev/null
@@ -0,0 +1,47 @@
+{
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
+  },
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",
+  "key_store_pass_path": "src/test/resources/password",
+  "trust_store_path": null,
+  "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
+  "enable_http": false,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "san-francisco",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "san-francisco",
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
index 251beb2..72aa1f0 100644 (file)
@@ -1,37 +1,33 @@
 {
-  "pm-mapper-filter": {"filters":[{"pmDefVsn": "V8","nfType": "LTE","vendor": "Ericsson","measTypes": [ "A", "B" ]},{"pmDefVsn": "V9","nfType": "NrRadio","vendor": "Ericsson","measTypes": [ "A", "B" ]}]},
-  "streams_subscribes": {
-    "dmaap_subscriber": {
-      "type": "data_router",
-      "aaf_username": null,
-      "aaf_password": null,
-      "dmaap_info": {
-        "location": "location",
-        "delivery_url": "delivery_url",
-        "username": "username",
-        "password": "password",
-        "subscriber_id": "subscriber_id"
-      }
-    }
-  },
-  "streams_publishes": {
-    "dmaap_publisher": {
-      "type": "message_router",
-      "aaf_password": null,
-      "dmaap_info": {
-        "topic_url": "https://message-router.onap.svc.cluster.local:3904/events/some-topic",
-        "client_role": null,
-        "location": null,
-        "client_id": null
+  "pm-mapper-filter": {
+    "filters": [
+      {
+        "pmDefVsn": "V8",
+        "nfType": "LTE",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
       },
-      "aaf_username": null
-    }
+      {
+        "pmDefVsn": "V9",
+        "nfType": "NrRadio",
+        "vendor": "Ericsson",
+        "measTypes": [
+          "A",
+          "B"
+        ]
+      }
+    ]
   },
-  "dmaap_dr_delete_endpoint": "http://dmaap-dr-node.onap.svc.cluster.local:8443/delete",
-  "services_calls": {},
   "key_store_path": "src/test/resources/testkeystore.jks.b64",
   "key_store_pass_path": "src/test/resources/password",
   "trust_store_path": "src/test/resources/testkeystore.jks.b64",
   "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
   "enable_http": false
 }
\ No newline at end of file
index 87fc021..0f24f90 100644 (file)
@@ -1,37 +1,14 @@
 {
-  "pm-mapper-filter": {"filters":[]},
-  "streams_subscribes": {
-    "dmaap_subscriber": {
-      "type": "data_router",
-      "aaf_username": null,
-      "aaf_password": null,
-      "dmaap_info": {
-        "location": "location",
-        "delivery_url": "delivery_url",
-        "username": "username",
-        "password": "password",
-        "subscriber_id": "subscriber_id"
-      }
-    }
+  "pm-mapper-filter": {
+    "filters": []
   },
-  "streams_publishes": {
-    "dmaap_publisher": {
-      "type": "message_router",
-      "aaf_password": null,
-      "dmaap_info": {
-        "topic_url": "https://message-router.onap.svc.cluster.local:3904/events/some-topic",
-        "client_role": null,
-        "location": null,
-        "client_id": null
-      },
-      "aaf_username": null
-    }
-  },
-  "dmaap_dr_delete_endpoint": "http://dmaap-dr-node.onap.svc.cluster.local:8443/delete",
-  "services_calls": {},
   "key_store_path": "src/test/resources/testkeystore.jks.b64",
   "key_store_pass_path": "src/test/resources/password",
   "trust_store_path": "src/test/resources/testkeystore.jks.b64",
   "trust_store_pass_path": "src/test/resources/password",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "bulk_pm_feed",
+  "aaf_identity": "dcae@dcae.onap.org",
+  "aaf_password": "iheartrainbows44",
   "enable_http": false
 }
\ No newline at end of file
index 3d9d707..39d4ee6 100644 (file)
@@ -1,37 +1,47 @@
 {\r
-    "pm-mapper-filter": {"filters":[{"pmDefVsn": "V9","nfType": "NrRadio","vendor": "Ericsson","measTypes": [ "A", "B" ]}]},\r
-    "streams_subscribes": {\r
-        "dmaap_subscriber": {\r
-            "type": "data_router",\r
-            "aaf_username": null,\r
-            "aaf_password": null,\r
-            "dmaap_info": {\r
-                "location": "location",\r
-                "delivery_url": "delivery_url",\r
-                "username": "username",\r
-                "password": "password",\r
-                "subscriber_id": "subscriber_id"\r
-            }\r
-        }\r
-    },\r
-    "streams_publishes": {\r
-        "dmaap_publisher": {\r
-            "type": "message_router",\r
-            "aaf_password": null,\r
-            "dmaap_info": {\r
-                "topic_url": "https://message-router.onap.svc.cluster.local:3904/events/some-topic",\r
-                "client_role": null,\r
-                "location": null,\r
-                "client_id": null\r
-            },\r
-            "aaf_username": null\r
-        }\r
-    },\r
-    "dmaap_dr_delete_endpoint": "http://dmaap-dr-node.onap.svc.cluster.local:8443/delete",\r
-    "services_calls": {},\r
-    "key_store_path": "src/test/resources/testkeystore.jks.b64",\r
-    "key_store_pass_path": "src/test/resources/password",\r
-    "trust_store_path": "src/test/resources/testkeystore.jks.b64",\r
-    "trust_store_pass_path": "src/test/resources/password",\r
-    "enable_http": false\r
+  "pm-mapper-filter": {\r
+    "filters": [\r
+      {\r
+        "pmDefVsn": "V9",\r
+        "nfType": "NrRadio",\r
+        "vendor": "Ericsson",\r
+        "measTypes": [\r
+          "A",\r
+          "B"\r
+        ]\r
+      }\r
+    ]\r
+  },\r
+  "key_store_path": "src/test/resources/testkeystore.jks.b64",\r
+  "key_store_pass_path": "src/test/resources/password",\r
+  "trust_store_path": "src/test/resources/testkeystore.jks.b64",\r
+  "trust_store_pass_path": "src/test/resources/password",\r
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",\r
+  "dmaap_dr_feed_name": "bulk_pm_feed",\r
+  "aaf_identity": "dcae@dcae.onap.org",\r
+  "aaf_password": "iheartrainbows44",\r
+  "enable_http": false,\r
+  "streams_publishes": {\r
+    "dmaap_publisher": {\r
+      "type": "message_router",\r
+      "dmaap_info": {\r
+        "topic_url": "https://message-router:3905/events/org.onap.dmaap.mr.VES_PM",\r
+        "client_role": "org.onap.dcae.pmPublisher",\r
+        "location": "san-francisco",\r
+        "client_id": "1562763644939"\r
+      }\r
+    }\r
+  },\r
+  "streams_subscribes": {\r
+    "dmaap_subscriber": {\r
+      "type": "data_router",\r
+      "dmaap_info": {\r
+        "username": "username",\r
+        "password": "password",\r
+        "location": "san-francisco",\r
+        "delivery_url": "https://dcae-pm-mapper:8443/delivery",\r
+        "subscriber_id": 1\r
+      }\r
+    }\r
+  }\r
 }
\ No newline at end of file
index b304d19..b2fcf61 100644 (file)
@@ -1,6 +1,6 @@
 major=1
 minor=1
-patch=1
+patch=2
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT
\ No newline at end of file