Add seed code for slice-analysis-ms 36/110836/2
authorReshmasree <reshmasree.chamarthi2@wipro.com>
Mon, 3 Aug 2020 10:38:41 +0000 (16:08 +0530)
committerReshmasree <reshmasree.chamarthi2@wipro.com>
Fri, 7 Aug 2020 12:34:09 +0000 (18:04 +0530)
Issue-ID: DCAEGEN2-2376
Signed-off-by: Reshmasree <reshmasree.chamarthi2@wipro.com>
Change-Id: I946ebb346f8a77c22aa4c7590a077c8b3b7d1aa2

41 files changed:
components/slice-analysis-ms/.checkstyle [new file with mode: 0644]
components/slice-analysis-ms/.gitignore [new file with mode: 0644]
components/slice-analysis-ms/LICENSE.txt [new file with mode: 0644]
components/slice-analysis-ms/README.md [new file with mode: 0644]
components/slice-analysis-ms/pom.xml [new file with mode: 0644]
components/slice-analysis-ms/src/main/docker/config/dmaap/MsgRtrApi.properties [new file with mode: 0755]
components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json [new file with mode: 0644]
components/slice-analysis-ms/src/main/docker/docker-compose.yaml [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/HealthCheck.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotifications.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/repository/PerformanceNotificationsRepository.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumer.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationProducer.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/BeanUtil.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java [new file with mode: 0644]
components/slice-analysis-ms/src/main/resources/application.properties [new file with mode: 0644]
components/slice-analysis-ms/src/main/resources/logback.xml [new file with mode: 0644]
components/slice-analysis-ms/src/main/resources/schema.sql [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/ApplicationTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NewPmNotificationTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationProducerTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallbackTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallbackTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/resources/config_all.json [new file with mode: 0644]
components/slice-analysis-ms/version.properties [new file with mode: 0644]

diff --git a/components/slice-analysis-ms/.checkstyle b/components/slice-analysis-ms/.checkstyle
new file mode 100644 (file)
index 0000000..97b553d
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
+  <local-check-config name="maven-checkstyle-plugin onap-license" location="jar:file:/home/reshma/.m2/repository/org/onap/oparent/checkstyle/2.0.0/checkstyle-2.0.0.jar!/onap-checkstyle/check-license.xml" type="remote" description="maven-checkstyle-plugin configuration onap-license">
+    <property name="checkstyle.header.file" value="/home/reshma/eclipse-workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/slice-analysis-ms/com.basistech.m2e.code.quality.checkstyleConfigurator/checkstyle-header-onap-license.txt"/>
+    <property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/>
+  </local-check-config>
+  <local-check-config name="maven-checkstyle-plugin onap-java-style" location="jar:file:/home/reshma/.m2/repository/org/onap/oparent/checkstyle/2.0.0/checkstyle-2.0.0.jar!/onap-checkstyle/onap-java-style.xml" type="remote" description="maven-checkstyle-plugin configuration onap-java-style">
+    <property name="checkstyle.header.file" value="/home/reshma/eclipse-workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/slice-analysis-ms/com.basistech.m2e.code.quality.checkstyleConfigurator/checkstyle-header-onap-java-style.txt"/>
+    <property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/>
+  </local-check-config>
+  <fileset name="java-sources-onap-license" enabled="true" check-config-name="maven-checkstyle-plugin onap-license" local="true">
+    <file-match-pattern match-pattern="^src/main/java/.*\/.*\.java" include-pattern="true"/>
+    <file-match-pattern match-pattern="^src/test/java/.*\/.*\.java" include-pattern="true"/>
+  </fileset>
+  <fileset name="java-sources-onap-java-style" enabled="true" check-config-name="maven-checkstyle-plugin onap-java-style" local="true">
+    <file-match-pattern match-pattern="^src/main/java/.*\/.*\.java" include-pattern="true"/>
+    <file-match-pattern match-pattern="^src/test/java/.*\/.*\.java" include-pattern="true"/>
+    <file-match-pattern match-pattern="^src/main/resources/.*\.properties" include-pattern="true"/>
+    <file-match-pattern match-pattern="^src/test/resources/.*\.properties" include-pattern="true"/>
+  </fileset>
+</fileset-config>
diff --git a/components/slice-analysis-ms/.gitignore b/components/slice-analysis-ms/.gitignore
new file mode 100644 (file)
index 0000000..a325eaf
--- /dev/null
@@ -0,0 +1,35 @@
+HELP.md
+target/
+.mvn/wrapper/maven-wrapper.jar
+.mvn/
+**/src/main/**/target/
+**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+/bin/
diff --git a/components/slice-analysis-ms/LICENSE.txt b/components/slice-analysis-ms/LICENSE.txt
new file mode 100644 (file)
index 0000000..b91e653
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* ============LICENSE_START==========================================
+* ===================================================================
+* Copyright (c) 2020 WIPRO Intellectual Property. All rights reserved.
+* ===================================================================
+*
+* Unless otherwise specified, all software contained herein is licensed
+* under the Apache License, Version 2.0 (the "License");
+* you may not use this software 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.
+*
+*
+*
+* Unless otherwise specified, all documentation contained herein is licensed
+* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+* you may not use this documentation except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*             https://creativecommons.org/licenses/by/4.0/
+*
+* Unless required by applicable law or agreed to in writing, documentation
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ============LICENSE_END============================================
+*/
diff --git a/components/slice-analysis-ms/README.md b/components/slice-analysis-ms/README.md
new file mode 100644 (file)
index 0000000..c268789
--- /dev/null
@@ -0,0 +1,39 @@
+SLICE-ANALYSIS-MS 
+
+### Build Instructions
+
+This project is organized as a mvn project and is a sub-project of dcaegen2/services (inside components directory). The build generate a jar and package into docker container. 
+
+```
+git clone https://gerrit.onap.org/r/dcaegen2/services
+To build slice-analysis-ms run `mvn clean install` from **components/slice-analysis-ms** directory
+To build docker image run `mvn clean install docker:build`
+```
+
+
+### Environment variables in Docker Container
+
+
+Variables coming from deployment system:
+
+- APP_NAME - slice-analysis-ms application name that will be registered with consul
+- CONSUL_PROTOCOL - Consul protocol by default set to **https**, if it is need to change it then that can be set to different value 
+- CONSUL_HOST - used with conjunction with CBSPOLLTIMER, should be a host address (without port! e.g my-ip-or-host) where Consul service lies
+- CBS_PROTOCOL - Config Binding Service protocol by default set to **https**, if it is need to change it then that can be set to different value
+- CONFIG_BINDING_SERVICE - used with conjunction with CBSPOLLTIMER, should be a name of CBS as it is registered in Consul
+- HOSTNAME - used with conjunction with CBSPOLLTIMER, should be a name of slice-analysis-ms application as it is registered in CBS catalog
+
+
+### Deployment
+
+
+### Standalone deployment
+Slice analysis ms can be deployed standalone using docker-compose.
+
+Navigate to src/main/docker directory. docker-compose.yaml can be found there.
+
+To install :
+    docker-compose up
+
+To uninstall :
+    docker-compose down
diff --git a/components/slice-analysis-ms/pom.xml b/components/slice-analysis-ms/pom.xml
new file mode 100644 (file)
index 0000000..f8eb7fa
--- /dev/null
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+ <parent>
+        <groupId>org.onap.oparent</groupId>
+        <artifactId>oparent</artifactId>
+        <version>2.0.0</version>
+    </parent>
+
+       <groupId>org.onap.dcaegen2.services.components</groupId>
+       <artifactId>slice-analysis-ms</artifactId>
+       <version>1.0.0-SNAPSHOT</version>
+       <name>dcaegen2-services-slice-analysis-ms</name>
+       <description>Network slice PM analyser</description>
+        <packaging>jar</packaging>
+
+       <properties>
+               <java.version>11</java.version>
+               <sdk.version>1.1.4</sdk.version>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <maven.compiler.source>11</maven.compiler.source>
+               <maven.compiler.target>11</maven.compiler.target>
+               <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
+               <!-- NEXUS RELATED SETTINGS -->
+               <nexusproxy>https://nexus.onap.org</nexusproxy>
+               <snapshots.path>content/repositories/snapshots/</snapshots.path>
+               <releases.path>content/repositories/releases/</releases.path>
+               <site.path>content/sites/site/org/onap/dcaegen2/services/${project.artifactId}/${project.version}</site.path>
+               <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+               <sonar.coverage.jacoco.xmlReportPaths>
+               ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml
+               </sonar.coverage.jacoco.xmlReportPaths>
+               
+       </properties>
+
+       <dependencies>
+                <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-util -->
+                <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-util</artifactId>
+                        <version>9.0.37</version>
+                </dependency>
+                <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
+                <dependency>
+                        <groupId>org.springframework.boot</groupId>
+                        <artifactId>spring-boot-autoconfigure</artifactId>
+                        <version>2.3.1.RELEASE</version>
+                </dependency>
+                <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-webmvc</artifactId>
+                       <version>5.2.7.RELEASE</version>
+               </dependency>
+                <dependency>
+                        <groupId>org.springframework</groupId>
+                        <artifactId>spring-core</artifactId>
+                        <version>5.2.7.RELEASE</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-beans</artifactId>
+                       <version>5.2.7.RELEASE</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-expression</artifactId>
+                       <version>5.2.7.RELEASE</version>
+                </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-web</artifactId>
+                       <version>5.2.7.RELEASE</version>
+               </dependency>
+                <dependency>
+                        <groupId>org.springframework</groupId>
+                        <artifactId>spring-tx</artifactId>
+                        <version>5.2.7.RELEASE</version>
+                </dependency>
+                <dependency>
+                        <groupId>org.springframework.data</groupId>
+                        <artifactId>spring-data-commons</artifactId>
+                        <version>2.2.0.RELEASE</version>
+                </dependency>
+               <!-- cbs client -->
+               <dependency>
+                       <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
+                       <artifactId>cbs-client</artifactId>
+                       <version>${sdk.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId>
+                       <artifactId>crypt-password</artifactId>
+                       <version>${sdk.version}</version>
+               </dependency>
+               <dependency>
+                       <!-- Import dependency management from Spring Boot -->
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-dependencies</artifactId>
+                       <version>2.1.3.RELEASE</version>
+                       <type>pom</type>
+                       <scope>import</scope>
+               </dependency>
+               <dependency>
+                       <groupId>com.att.nsa</groupId>
+                       <artifactId>cambriaClient</artifactId>
+                       <version>0.0.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <version>2.11.0</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>2.11.0</version>
+               </dependency>
+               <!-- https://mvnrepository.com/artifact/javax.json/javax.json-api -->
+               <dependency>
+                       <groupId>javax.json</groupId>
+                       <artifactId>javax.json-api</artifactId>
+                       <version>1.1.2</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-web</artifactId>
+                       <version>2.1.3.RELEASE</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.springframework.boot</groupId>
+                                       <artifactId>spring-boot-starter-tomcat</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>org.postgresql</groupId>
+                       <artifactId>postgresql</artifactId>
+                       <version>42.2.5</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-data-jpa</artifactId>
+                       <version>2.1.3.RELEASE</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.hibernate.javax.persistence</groupId>
+                       <artifactId>hibernate-jpa-2.0-api</artifactId>
+                       <version>1.0.1.Final</version>
+               </dependency>
+               <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-test</artifactId>
+                       <version>2.1.3.RELEASE</version>
+                       <scope>test</scope>
+                       <!-- exclusions> <exclusion> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId>
+                               </exclusion> </exclusions -->
+               </dependency>
+               <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <version>2.21.0</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+                       <scope>test</scope>
+               </dependency>
+                <!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito2 -->
+               <dependency>
+                       <groupId>org.powermock</groupId>
+                       <artifactId>powermock-api-mockito2</artifactId>
+                       <version>2.0.2</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.mockito</groupId>
+                                       <artifactId>mockito-all</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 -->
+               <dependency>
+                       <groupId>org.powermock</groupId>
+                       <artifactId>powermock-module-junit4</artifactId>
+                       <version>2.0.2</version>
+                       <scope>test</scope>
+               </dependency>
+
+               <dependency>
+                   <groupId>org.functionaljava</groupId>
+                   <artifactId>functionaljava</artifactId>
+                   <version>3.0</version>
+            </dependency>
+
+           <dependency>
+                   <groupId>org.apache.httpcomponents</groupId>
+                   <artifactId>httpclient</artifactId>
+               <version>4.5.7</version>
+           </dependency>
+
+           <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
+            <dependency>
+                   <groupId>commons-beanutils</groupId>
+                   <artifactId>commons-beanutils</artifactId>
+                   <version>1.9.4</version>
+            </dependency>
+            <!-- mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
+            <dependency>
+                   <groupId>org.eclipse.jetty</groupId>
+                   <artifactId>jetty-server</artifactId>
+                   <version>9.4.17.v20190418</version>
+            </dependency>
+            <!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
+            <dependency>
+                   <groupId>org.webjars</groupId>
+                   <artifactId>bootstrap</artifactId>
+                   <version>4.3.1</version>
+            </dependency>
+            <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
+            <dependency>
+                   <groupId>javax.xml.bind</groupId>
+                   <artifactId>jaxb-api</artifactId>
+                   <version>2.3.0</version>
+            </dependency>
+            <!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
+            <dependency>
+                   <groupId>org.javassist</groupId>
+                   <artifactId>javassist</artifactId>
+                   <version>3.24.1-GA</version>
+            </dependency>
+           <dependency>
+                   <groupId>org.apache.tomcat.embed</groupId>
+                   <artifactId>tomcat-embed-core</artifactId>
+                  <version>9.0.36</version>
+           </dependency>
+       </dependencies>
+
+               <build>
+               <plugins>
+
+                       <plugin>
+                               <groupId>org.springframework.boot</groupId>
+                               <artifactId>spring-boot-maven-plugin</artifactId>
+                               <version>2.3.1.RELEASE</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>repackage</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <plugin>
+                               <groupId>com.spotify</groupId>
+                               <artifactId>docker-maven-plugin</artifactId>
+                               <configuration>
+                                       <serverId>${onap.nexus.dockerregistry.daily}</serverId>
+
+                                       <imageName>${onap.nexus.dockerregistry.daily}/${docker.image.name}</imageName>
+                                       <imageTags>
+                                                <imageTag>${project.version}-${maven.build.timestamp}Z</imageTag>
+                                                <imageTag>${project.version}</imageTag>
+                                                <imageTag>latest</imageTag>
+                                       </imageTags>
+                                       <baseImage>openjdk:11.0.6-jre-slim</baseImage>
+                                       <user>sliceanalysis</user>
+                                       <resources>
+                                               <resource>
+                                                       <targetPath>/bin</targetPath>
+                                                       <directory>${project.build.directory}</directory>
+                                                       <include>${project.artifactId}-${project.version}.jar</include>
+                                               </resource>
+                                       </resources>
+                                       <runs>
+                                               <!-- Maven is loosing file permissions during artifacts copy -->
+                                               <run>adduser --disabled-password sliceanalysis </run>
+                                               <run>mv /bin/*.jar /bin/application.jar</run>
+                                               <run>chmod -R 777 /bin</run>
+                                       </runs>
+                                       <exposes>
+                                               <expose>8080</expose>
+                                       </exposes>
+                                       <entryPoint>java -jar /bin/application.jar</entryPoint>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+</project>
diff --git a/components/slice-analysis-ms/src/main/docker/config/dmaap/MsgRtrApi.properties b/components/slice-analysis-ms/src/main/docker/config/dmaap/MsgRtrApi.properties
new file mode 100755 (executable)
index 0000000..61f3f03
--- /dev/null
@@ -0,0 +1,171 @@
+# LICENSE_START=======================================================
+#  org.onap.dmaap
+#  ================================================================================
+#  Copyright Â© 2017 AT&T Intellectual Property. All rights reserved.
+#  Copyright (C) 2020 Wipro Limited.
+#  ================================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#        http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=========================================================
+#
+#  ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#  
+###############################################################################
+###############################################################################
+##
+## Cambria API Server config
+##
+##     - Default values are shown as commented settings.
+##
+
+###############################################################################
+##
+## HTTP service
+##
+##             - 3904 is standard as of 7/29/14.
+#
+## Zookeeper Connection
+##
+##     Both Cambria and Kafka make use of Zookeeper.
+##
+#config.zk.servers=172.18.1.1
+config.zk.servers=zookeeper:2181
+#config.zk.root=/fe3c/cambria/config
+
+
+###############################################################################
+##
+## Kafka Connection
+##
+##     Items below are passed through to Kafka's producer and consumer
+##     configurations (after removing "kafka.")
+##     if you want to change request.required.acks it can take this one value
+#kafka.metadata.broker.list=localhost:9092,localhost:9093
+kafka.metadata.broker.list=kafka:9092
+##kafka.request.required.acks=-1
+#kafka.client.zookeeper=${config.zk.servers}
+consumer.timeout.ms=100
+zookeeper.connection.timeout.ms=6000
+zookeeper.session.timeout.ms=20000
+zookeeper.sync.time.ms=2000
+auto.commit.interval.ms=1000
+fetch.message.max.bytes =1000000
+auto.commit.enable=false
+
+#(backoff*retries > zksessiontimeout)
+kafka.rebalance.backoff.ms=10000
+kafka.rebalance.max.retries=6
+
+
+###############################################################################
+##
+##     Secured Config
+##
+##     Some data stored in the config system is sensitive -- API keys and secrets,
+##     for example. to protect it, we use an encryption layer for this section
+##     of the config.
+##
+## The key is a base64 encode AES key. This must be created/configured for
+## each installation.
+#cambria.secureConfig.key=
+##
+## The initialization vector is a 16 byte value specific to the secured store.
+## This must be created/configured for each installation.
+#cambria.secureConfig.iv=
+
+## Southfield Sandbox
+cambria.secureConfig.key=b/7ouTn9FfEw2PQwL0ov/Q==
+cambria.secureConfig.iv=wR9xP5k5vbz/xD0LmtqQLw==
+authentication.adminSecret=fe3cCompound
+#cambria.secureConfig.key[pc569h]=YT3XPyxEmKCTLI2NK+Sjbw==
+#cambria.secureConfig.iv[pc569h]=rMm2jhR3yVnU+u2V9Ugu3Q==
+
+
+###############################################################################
+##
+## Consumer Caching
+##
+##     Kafka expects live connections from the consumer to the broker, which
+##     obviously doesn't work over connectionless HTTP requests. The Cambria
+##     server proxies HTTP requests into Kafka consumer sessions that are kept
+##     around for later re-use. Not doing so is costly for setup per request,
+##     which would substantially impact a high volume consumer's performance.
+##
+##     This complicates Cambria server failover, because we often need server
+##     A to close its connection before server B brings up the replacement.    
+##
+
+## The consumer cache is normally enabled.
+#cambria.consumer.cache.enabled=true
+
+## Cached consumers are cleaned up after a period of disuse. The server inspects
+## consumers every sweepFreqSeconds and will clean up any connections that are
+## dormant for touchFreqMs.
+#cambria.consumer.cache.sweepFreqSeconds=15
+cambria.consumer.cache.touchFreqMs=120000
+##stickforallconsumerrequests=false
+## The cache is managed through ZK. The default value for the ZK connection
+## string is the same as config.zk.servers.
+#cambria.consumer.cache.zkConnect=${config.zk.servers}
+
+##
+## Shared cache information is associated with this node's name. The default
+## name is the hostname plus the HTTP service port this host runs on. (The
+## hostname is determined via InetAddress.getLocalHost ().getCanonicalHostName(),
+## which is not always adequate.) You can set this value explicitly here.
+##
+#cambria.api.node.identifier=<use-something-unique-to-this-instance>
+
+#cambria.rateLimit.maxEmptyPollsPerMinute=30
+#cambria.rateLimitActual.delay.ms=10
+
+###############################################################################
+##
+## Metrics Reporting
+##
+##     This server can report its metrics periodically on a topic.
+##
+#metrics.send.cambria.enabled=true
+#metrics.send.cambria.topic=cambria.apinode.metrics                                  #msgrtr.apinode.metrics.dmaap 
+#metrics.send.cambria.sendEverySeconds=60
+
+cambria.consumer.cache.zkBasePath=/fe3c/cambria/consumerCache
+consumer.timeout=17
+default.partitions=3
+default.replicas=3
+##############################################################################
+#100mb
+maxcontentlength=10000
+
+
+##############################################################################
+#AAF Properties
+msgRtr.namespace.aaf=org.onap.dmaap.mr.topic
+msgRtr.topicfactory.aaf=org.onap.dmaap.mr.topicFactory|:org.onap.dmaap.mr.topic:
+enforced.topic.name.AAF=org.onap
+forceAAF=false
+transidUEBtopicreqd=false
+defaultNSforUEB=org.onap.dmaap.mr
+##############################################################################
+#Mirror Maker Agent
+msgRtr.mirrormakeradmin.aaf=com.onap.dmaap.mr.dev.mirrormaker|*|admin
+msgRtr.mirrormakeruser.aaf=com.onap.dmaap.mr.dev.mirrormaker|*|user
+msgRtr.mirrormakeruser.aaf.create=com.onap.dmaap.mr.dev.topicFactory|:com.onap.dmaap.mr.dev.topic:
+msgRtr.mirrormaker.timeout=15000
+msgRtr.mirrormaker.topic=com.onap.dmaap.mr.prod.mm.agent
+msgRtr.mirrormaker.consumergroup=mmagentserver
+msgRtr.mirrormaker.consumerid=1
+
+kafka.max.poll.interval.ms=300000
+kafka.heartbeat.interval.ms=60000
+kafka.session.timeout.ms=240000
+kafka.max.poll.records=1000
+
diff --git a/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json b/components/slice-analysis-ms/src/main/docker/config/sliceanalysisms/config_all.json
new file mode 100644 (file)
index 0000000..21a8234
--- /dev/null
@@ -0,0 +1,59 @@
+{
+  "config": {
+    "streams_subscribes": {
+      "performance_management_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.VES_MEASUREMENT_OUTPUT",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      },
+      "dcae_cl_response_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      }
+    },
+    "streams_publishes": {
+      "CL_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.DCAE_CL_OUTPUT",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      }
+    },
+    "postgres.password": "postgres",
+    "postgres.username": "sliceanalysisms_admin",
+    "postgres.host": "postgres",
+    "postgres.port": "5432",
+    "sliceanalysisms.dmaap.server": [
+      "dmaap"
+    ],
+    "cbsPollingInterval": 60,
+    "sliceanalysisms.cg": "sliceanalysisms-cg",
+    "sliceanalysisms.pollingInterval": 20,
+    "sliceanalysisms.cid": "sliceanalysisms-cid",
+    "sliceanalysisms.configDb.service": "http://sdnc.onap:8181",
+    "service_calls": {
+      "policy-req": []
+    }
+  },
+  "policies": {
+    
+  }
+}
diff --git a/components/slice-analysis-ms/src/main/docker/docker-compose.yaml b/components/slice-analysis-ms/src/main/docker/docker-compose.yaml
new file mode 100644 (file)
index 0000000..0f50394
--- /dev/null
@@ -0,0 +1,91 @@
+#    ============LICENSE_START=======================================================
+#    slice-analysis-ms
+#    ================================================================================
+#     Copyright (C) 2020 Wipro Limited.
+#     ==============================================================================
+#       Licensed under the Apache License, Version 2.0 (the "License");
+#       you may not use this file except in compliance with the License.
+#       You may obtain a copy of the License at
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing, software
+#       distributed under the License is distributed on an "AS IS" BASIS,
+#       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#       See the License for the specific language governing permissions and
+#       limitations under the License.
+#     ============LICENSE_END=========================================================
+
+version: '2.4'
+networks:
+  slice-analysis-ms-default:
+    driver: bridge
+    driver_opts:
+      com.docker.network.driver.mtu: 1400
+services: 
+  zookeeper:
+    image: wurstmeister/zookeeper
+    ports:
+      - "2181:2181"
+    networks:
+      - slice-analysis-ms-default
+  kafka:
+    image: wurstmeister/kafka
+    ports:
+      - "9092:9092"
+    environment:
+      KAFKA_ADVERTISED_HOST_NAME: "kafka"
+      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
+      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
+      KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092"
+    volumes:
+      - /var/run/docker.sock:/var/run/docker.sock
+    depends_on:
+      - zookeeper
+    networks:
+      - slice-analysis-ms-default
+  dmaap:
+    image: nexus3.onap.org:10001/onap/dmaap/dmaap-mr:1.1.8  
+    ports:
+      - "3904:3904"
+      - "3905:3905"
+    volumes:
+      - ./config/dmaap/MsgRtrApi.properties:/appl/dmaapMR1/bundleconfig/etc/appprops/MsgRtrApi.properties
+    depends_on:
+      - zookeeper
+      - kafka
+    networks:
+      - slice-analysis-ms-default
+  postgres:
+    image: 'postgres:12-alpine'
+    container_name: slice-analysis-ms-postgres
+    hostname: postgres
+    environment:
+     - POSTGRES_USER=sliceanalysisms_admin
+     - POSTGRES_PASSWORD=postgres
+     - POSTGRES_DB=sliceanalysisms
+    ports:
+     - 5432
+    healthcheck:
+      test: ["CMD", "nc", "-z", "localhost", "5432"]
+      interval: 30s
+      timeout: 10s
+      retries: 5
+    networks:
+     - slice-analysis-ms-default
+  sliceanalysisms:
+    image: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.components.slice-analysis-ms:latest"
+    container_name: sliceanalysisms
+    hostname: sliceanalysisms
+    environment:
+     - STANDALONE=true
+     - CONFIG_FILE=/etc/config_all.json
+    ports:
+     - "8080:8080"
+    volumes:
+     - ./config/sliceanalysisms/config_all.json:/etc/config_all.json
+    depends_on:
+     - postgres
+    networks:
+     - slice-analysis-ms-default    
+    
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java
new file mode 100644 (file)
index 0000000..f522e00
--- /dev/null
@@ -0,0 +1,139 @@
+
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.lang.reflect.Type;
+import java.time.Duration;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.onap.slice.analysis.ms.beans.ConfigPolicy;
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.controller.ConfigFetchFromCbs;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * 
+ * Entry point for the slice analysis service application 
+ *
+ */
+@EnableScheduling
+@SpringBootApplication
+public class Application {
+
+    private static Logger log = LoggerFactory.getLogger(Application.class);
+
+    /**
+     * Main method where initial configuration and context is set 
+     * @param args
+     */
+       public static void main(String[] args) {
+               getConfig();
+        log.info("Starting spring boot application");
+               SpringApplication.run(Application.class, args);
+       }
+       
+    private static void getConfig() {
+
+        Boolean standalone = Boolean.parseBoolean(System.getenv("STANDALONE"));
+
+        if (standalone) {
+            log.info("Running in standalone mode");
+
+            String configFile = System.getenv("CONFIG_FILE");
+            String configAllJson = readFromFile(configFile);
+
+            JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
+
+            JsonObject config = configAll.getAsJsonObject("config");
+
+            Configuration.getInstance().updateConfigurationFromJsonObject(config);
+
+            ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+            Type mapType = new TypeToken<Map<String, Object>>() {
+            }.getType();
+            if (configAll.getAsJsonObject("policies") != null) {
+                JsonObject policyJson = configAll.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+                        .getAsJsonObject().getAsJsonObject("config");
+                Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+                configPolicy.setConfig(policy);
+                log.info("Config policy {}", configPolicy);
+            }
+            return;
+        }
+
+        ConfigFetchFromCbs configFetchFromCbs = new ConfigFetchFromCbs(Duration.ofSeconds(60));
+        Thread configFetchThread = new Thread(configFetchFromCbs);
+        configFetchThread.start();
+        try {
+            Thread.sleep(10000);
+        } catch (InterruptedException e) {
+            log.debug("InterruptedException : {}", e);
+            Thread.currentThread().interrupt();
+        }
+        log.info("after 10s sleep");
+    }
+
+    /**
+     * DataSource bean.
+     */
+    @Bean
+    public DataSource dataSource() {
+        Configuration configuration = Configuration.getInstance();
+
+        String url = "jdbc:postgresql://" + configuration.getPgHost() + ":" + configuration.getPgPort() + "/sliceanalysisms";
+
+        return DataSourceBuilder.create().url(url).username(configuration.getPgUsername())
+                .password(configuration.getPgPassword()).build();
+    }
+
+    private static String readFromFile(String file) {
+        String content = "";
+        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
+            content = bufferedReader.readLine();
+            String temp;
+            while ((temp = bufferedReader.readLine()) != null) {
+                content = content.concat(temp);
+            }
+            content = content.trim();
+        } catch (Exception e) {
+            content = null;
+        }
+        return content;
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java
new file mode 100644 (file)
index 0000000..d4cd53b
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.beans;
+
+import java.util.Map;
+
+/**
+ * 
+ * Model class for configuration policy
+ *
+ */
+
+public class ConfigPolicy {
+
+    private static ConfigPolicy instance = null;
+    private Map<String, Object> config;
+
+    protected ConfigPolicy() {
+
+    }
+
+    /**
+     * Get instance of class.
+     */
+    public static ConfigPolicy getInstance() {
+        if (instance == null) {
+            instance = new ConfigPolicy();
+        }
+        return instance;
+    }
+
+    /**
+     * Get config param of ConfigPolicy
+     */
+    public Map<String, Object> getConfig() {
+        return config;
+    }
+
+    /**
+     * set config param of ConfigPolicy
+     */
+    public void setConfig(Map<String, Object> config) {
+        this.config = config;
+    }
+
+    /**
+     * Return ConfigPolicy instance as String
+     */
+    @Override
+    public String toString() {
+        return "ConfigPolicy [config=" + config + "]";
+    }
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java
new file mode 100644 (file)
index 0000000..c707234
--- /dev/null
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.beans;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** 
+ * Model class for the application Configuration
+ */
+public class Configuration {
+    private static Logger log = LoggerFactory.getLogger(Configuration.class);
+
+    private static Configuration instance = null;
+    private String pgHost;
+    private int pgPort;
+    private String pgUsername;
+    private String pgPassword;
+    private List<String> dmaapServers;
+    private String configDbService;
+    private String cg;
+    private String cid;
+    private int pollingInterval;
+    private int pollingTimeout;
+    private String aafUsername;
+    private String aafPassword;
+    private Map<String, Object> streamsSubscribes;
+    private Map<String, Object> streamsPublishes;
+
+    /**
+     * Check if topic is secure.
+     */
+    public boolean isSecured() {
+        return (aafUsername != null);
+
+    }
+
+    public String getAafUsername() {
+        return aafUsername;
+    }
+
+    public void setAafUsername(String aafUsername) {
+        this.aafUsername = aafUsername;
+    }
+
+    public String getAafPassword() {
+        return aafPassword;
+    }
+
+    public void setAafPassword(String aafPassword) {
+        this.aafPassword = aafPassword;
+    }
+
+    public Map<String, Object> getStreamsSubscribes() {
+        return streamsSubscribes;
+    }
+
+    public void setStreamsSubscribes(Map<String, Object> streamsSubscribes) {
+        this.streamsSubscribes = streamsSubscribes;
+    }
+
+    public Map<String, Object> getStreamsPublishes() {
+        return streamsPublishes;
+    }
+
+    public void setStreamsPublishes(Map<String, Object> streamsPublishes) {
+        this.streamsPublishes = streamsPublishes;
+    }
+
+    protected Configuration() {
+
+    }
+
+    /**
+     * Get instance of class.
+     */
+    public static Configuration getInstance() {
+        if (instance == null) {
+            instance = new Configuration();
+        }
+        return instance;
+    }
+
+    public String getCg() {
+        return cg;
+    }
+
+    public void setCg(String cg) {
+        this.cg = cg;
+    }
+
+    public String getCid() {
+        return cid;
+    }
+
+    public void setCid(String cid) {
+        this.cid = cid;
+    }
+
+    public int getPollingInterval() {
+        return pollingInterval;
+    }
+
+    public void setPollingInterval(int pollingInterval) {
+        this.pollingInterval = pollingInterval;
+    }
+
+    public int getPollingTimeout() {
+        return pollingTimeout;
+    }
+
+    public void setPollingTimeout(int pollingTimeout) {
+        this.pollingTimeout = pollingTimeout;
+    }
+
+    public String getPgHost() {
+        return pgHost;
+    }
+
+    public void setPgHost(String pgHost) {
+        this.pgHost = pgHost;
+    }
+
+    public int getPgPort() {
+        return pgPort;
+    }
+
+    public void setPgPort(int pgPort) {
+        this.pgPort = pgPort;
+    }
+
+    public String getPgUsername() {
+        return pgUsername;
+    }
+
+    public void setPgUsername(String pgUsername) {
+        this.pgUsername = pgUsername;
+    }
+
+    public String getPgPassword() {
+        return pgPassword;
+    }
+
+    public void setPgPassword(String pgPassword) {
+        this.pgPassword = pgPassword;
+    }
+
+    public List<String> getDmaapServers() {
+        return dmaapServers;
+    }
+
+    public void setDmaapServers(List<String> dmaapServers) {
+        this.dmaapServers = dmaapServers;
+    }
+
+    public String getConfigDbService() {
+        return configDbService;
+    }
+
+    public void setConfigDbService(String configDbService) {
+        this.configDbService = configDbService;
+    }
+
+       
+
+    @Override
+       public String toString() {
+               return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword="
+                               + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cg=" + cg
+                               + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout
+                               + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + ", streamsSubscribes="
+                               + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]";
+       }
+
+       /**
+     * updates application configuration.
+     */
+    public void updateConfigurationFromJsonObject(JsonObject jsonObject) {
+
+        log.info("Updating configuration from CBS");
+
+        Type mapType = new TypeToken<Map<String, Object>>() {
+        }.getType();
+
+        JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes");
+        streamsSubscribes = new Gson().fromJson(subscribes, mapType);
+
+        JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes");
+        streamsPublishes = new Gson().fromJson(publishes, mapType);
+
+        pgPort = jsonObject.get("postgres.port").getAsInt();
+        pollingInterval = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt();
+        pgPassword = jsonObject.get("postgres.password").getAsString();
+        pgUsername = jsonObject.get("postgres.username").getAsString();
+        pgHost = jsonObject.get("postgres.host").getAsString();
+
+        JsonArray servers = jsonObject.getAsJsonArray("sliceanalysisms.dmaap.server");
+        Type listType = new TypeToken<List<String>>() {
+        }.getType();
+        dmaapServers = new Gson().fromJson(servers, listType);
+
+        cg = jsonObject.get("sliceanalysisms.cg").getAsString();
+        cid = jsonObject.get("sliceanalysisms.cid").getAsString();
+        configDbService = jsonObject.get("sliceanalysisms.configDb.service").getAsString();
+
+        pollingTimeout = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt();
+
+        log.info("configuration from CBS {}", this);
+
+    }
+
+
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java
new file mode 100644 (file)
index 0000000..e8e4e11
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.controller;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+import java.time.Duration;
+import java.util.Map;
+
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
+import org.onap.slice.analysis.ms.beans.ConfigPolicy;
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import reactor.core.Disposable;
+
+/**
+ * This class provides method to fetch application Configuration
+ * from CBS
+ */
+public class ConfigFetchFromCbs implements Runnable {
+
+    private static Logger log = LoggerFactory.getLogger(ConfigFetchFromCbs.class);
+
+    private Duration interval;
+
+    public ConfigFetchFromCbs() {
+
+    }
+
+    public ConfigFetchFromCbs(Duration interval) {
+        this.interval = interval;
+    }
+
+    /**
+     * Gets app config from CBS.
+     */
+    private Disposable getAppConfig() {
+
+        // Generate RequestID and InvocationID which will be used when logging and in
+        // HTTP requests
+        log.info("getAppconfig start ..");
+        RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create();
+        // Read necessary properties from the environment
+        final EnvProperties env = EnvProperties.fromEnvironment();
+        log.debug("environments {}", env);
+        ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+
+        // Polling properties
+        final Duration initialDelay = Duration.ofSeconds(5);
+        final Duration period = interval;
+
+        // Create the client and use it to get the configuration
+        final CbsRequest request = CbsRequests.getAll(diagnosticContext);
+        return CbsClientFactory.createCbsClient(env)
+                .flatMapMany(cbsClient -> cbsClient.updates(request, initialDelay, period)).subscribe(jsonObject -> {
+                    log.info("configuration and policy from CBS {}", jsonObject);
+                    JsonObject config = jsonObject.getAsJsonObject("config");
+                    Duration newPeriod = Duration.ofSeconds(config.get("cbsPollingInterval").getAsInt());
+                    if (!newPeriod.equals(period)) {
+                        interval = newPeriod;
+                        synchronized (this) {
+                            this.notifyAll();
+                        }
+
+                    }
+                    Configuration.getInstance().updateConfigurationFromJsonObject(config);
+
+                    Type mapType = new TypeToken<Map<String, Object>>() {
+                    }.getType();
+                    if (jsonObject.getAsJsonObject("policies") != null) {
+                        JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0)
+                                .getAsJsonObject().getAsJsonObject("config");
+                        Map<String, Object> policy = new Gson().fromJson(policyJson, mapType);
+                        configPolicy.setConfig(policy);
+                        log.info("Config policy {}", configPolicy);
+                    }
+                }, throwable -> log.warn("Ooops", throwable));
+    }
+
+
+
+    @Override
+    public void run() {
+        Boolean done = false;
+        while (!done) {
+            try {
+                Disposable disp = getAppConfig();
+                synchronized (this) {
+                    this.wait();
+                }
+                log.info("Polling interval changed");
+                disp.dispose();
+            } catch (Exception e) {
+                done = true;
+            }
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/HealthCheck.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/HealthCheck.java
new file mode 100644 (file)
index 0000000..854bdf4
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.controller;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * This Controller provides the slice-analysis-ms 
+ * application's health
+ */
+@RestController
+public class HealthCheck {
+    @RequestMapping(value = "/healthcheck", method = RequestMethod.GET)
+    public ResponseEntity<HttpStatus> healthCheck() {
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotifications.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotifications.java
new file mode 100644 (file)
index 0000000..2fa06d9
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+package org.onap.slice.analysis.ms.data.beans;
+
+import java.sql.Timestamp;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.CreationTimestamp;
+
+/**
+ * Entity for  PERFORMANCE_NOTIFICATIONS table
+ */
+@Entity
+@Table(name = "PERFORMANCE_NOTIFICATIONS")
+public class PerformanceNotifications {
+
+    @Id
+    @Column(name = "notification", columnDefinition = "text")
+    private String notification;
+
+    @CreationTimestamp
+    @Column(name = "created_at", columnDefinition = "timestamp")
+    private Timestamp createdAt;
+
+    /**
+     * default constructor
+     */
+    public PerformanceNotifications() {
+
+    }
+
+    /**
+     * Constructs PerformanceNotifications instance
+     * @param notification
+     * @param createdAt
+     */
+    public PerformanceNotifications(String notification, Timestamp createdAt) {
+        this.notification = notification;
+        this.createdAt = createdAt;
+    }
+
+    public String getNotification() {
+        return notification;
+    }
+
+    public void setNotification(String notification) {
+        this.notification = notification;
+    }
+
+    public Timestamp getCreatedAt() {
+        return createdAt;
+    }
+
+    public void setCreatedAt(Timestamp createdAt) {
+        this.createdAt = createdAt;
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/repository/PerformanceNotificationsRepository.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/data/repository/PerformanceNotificationsRepository.java
new file mode 100644 (file)
index 0000000..55338c9
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.data.repository;
+
+import org.onap.slice.analysis.ms.data.beans.PerformanceNotifications;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * This interface provides methods to perform CRUD operations
+ * on performance_notifications table
+ */
+@Repository
+public interface PerformanceNotificationsRepository extends CrudRepository<PerformanceNotifications, String> {
+
+         /**
+     * read performanceNotifications from db
+     * @return 
+     */
+    @Query(nativeQuery = true, value = "DELETE FROM performance_notifications "
+            + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY "
+            + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;")
+    public String getPerformanceNotificationFromQueue();
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java
new file mode 100644 (file)
index 0000000..6e0ea40
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.utils.DmaapUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class initializes and starts the dmaap client 
+ * to listen on application required dmaap events
+ */
+@Component
+public class DmaapClient {
+
+    private Configuration configuration;
+    private static Logger log = LoggerFactory.getLogger(DmaapClient.class);
+
+    private DmaapUtils dmaapUtils;
+
+    /**
+     * init dmaap client.
+     */
+    @PostConstruct
+    public void initClient() {
+        log.debug("initializing client");
+        dmaapUtils = new DmaapUtils();
+        configuration = Configuration.getInstance();
+        if (log.isDebugEnabled()) {
+            log.debug(configuration.toString());
+        }
+
+        startClient();
+    }
+
+    /**
+     * start dmaap client.
+     */
+    @SuppressWarnings("unchecked")
+    public synchronized void startClient() {
+
+        Map<String, Object> streamSubscribes = Configuration.getInstance().getStreamsSubscribes();
+       
+        String pmTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamSubscribes
+                .get("performance_management_topic")).get("dmaap_info")).get("topic_url");
+        String[] pmTopicSplit = pmTopicUrl.split("\\/");
+        String pmTopic = pmTopicSplit[pmTopicSplit.length - 1];
+        log.debug("pm topic : {}", pmTopic);
+        String policyResponseTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamSubscribes
+                .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url");
+        String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/");
+        String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1];
+        log.debug("policyResponse Topic : {}", policyResponseTopic);
+        CambriaConsumer pmNotifCambriaConsumer = null;
+        CambriaConsumer policyResponseCambriaConsumer = null;
+
+        pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic);
+        policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic);
+
+        ScheduledExecutorService executorPool;
+
+        // create notification consumers for PM
+        NotificationConsumer pmNotificationConsumer = new NotificationConsumer(pmNotifCambriaConsumer,
+                new PmNotificationCallback());
+        // start pm notification consumer threads
+        executorPool = Executors.newScheduledThreadPool(10);
+        executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(),
+                TimeUnit.SECONDS);
+        
+     // create notification consumers for Policy
+               NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer,
+                               new PolicyNotificationCallback());
+               // start policy notification consumer threads
+               executorPool = Executors.newScheduledThreadPool(10);
+               executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(),
+                               TimeUnit.SECONDS);
+
+
+
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java
new file mode 100644 (file)
index 0000000..5c1f496
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * This class indicates whether new pm notification
+ * is set for the slice-analysis-ms
+ */
+@Component
+public class NewPmNotification {
+
+    private Boolean newNotif;
+
+    /**
+     * Initialize new pm Notification flag
+     */
+    @PostConstruct
+    public void init() {
+        newNotif = false;
+    }
+
+    public Boolean getNewNotif() {
+        return newNotif;
+    }
+
+    public void setNewNotif(Boolean newNotif) {
+        this.newNotif = newNotif;
+    }
+
+    public NewPmNotification(Boolean newNotif) {
+        super();
+        this.newNotif = newNotif;
+    }
+
+    /**
+     * Default constructor
+     */
+    public NewPmNotification() {
+
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java
new file mode 100644 (file)
index 0000000..427b404
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+public abstract class NotificationCallback {
+
+    public abstract void activateCallBack(String msg);
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumer.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumer.java
new file mode 100644 (file)
index 0000000..b605264
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Consume Notifications from DMAAP events
+ */
+public class NotificationConsumer implements Runnable {
+
+    private static Logger log = LoggerFactory.getLogger(NotificationConsumer.class);
+    private CambriaConsumer cambriaConsumer;
+    private NotificationCallback notificationCallback;
+
+    /**
+     * Parameterized Constructor.
+     */
+    public NotificationConsumer(CambriaConsumer cambriaConsumer, NotificationCallback notificationCallback) {
+        super();
+        this.cambriaConsumer = cambriaConsumer;
+        this.notificationCallback = notificationCallback;
+    }
+
+    /**
+     * starts fetching msgs from dmaap events
+     */
+    @Override
+    public void run() {
+        try {
+            Iterable<String> msgs = cambriaConsumer.fetch();
+            for (String msg : msgs) {
+                log.debug(msg);
+                notificationCallback.activateCallBack(msg);
+            }
+        } catch (Exception e) {
+            log.debug("exception when fetching msgs from dmaap", e);
+        }
+
+    }
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationProducer.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationProducer.java
new file mode 100644 (file)
index 0000000..03e1c23
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+
+import java.io.IOException;
+
+/**
+ * Produces Notification on DMAAP events
+ */
+public class NotificationProducer {
+
+    private CambriaBatchingPublisher cambriaBatchingPublisher;
+     
+
+    /**
+     * Parameterized constructor.
+     */
+    public NotificationProducer(CambriaBatchingPublisher cambriaBatchingPublisher) {
+        super();
+        this.cambriaBatchingPublisher = cambriaBatchingPublisher;
+    }
+
+    /**
+     * sends notification to dmaap.
+     */
+    public int sendNotification(String msg) throws IOException {
+    
+        return cambriaBatchingPublisher.send("", msg);
+
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java
new file mode 100644 (file)
index 0000000..17e50ac
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import org.onap.slice.analysis.ms.data.beans.PerformanceNotifications;
+import org.onap.slice.analysis.ms.data.repository.PerformanceNotificationsRepository;
+import org.onap.slice.analysis.ms.utils.BeanUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handles Notification on dmaap for Performance events
+ */
+public class PmNotificationCallback extends NotificationCallback {
+
+    private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class);
+
+    @Override
+    public void activateCallBack(String msg) {
+        handleNotification(msg);
+    }
+
+    /**
+     * Parse Performance dmaap notification and save to DB 
+     * @param msg
+     */
+    private void handleNotification(String msg) {
+
+        PerformanceNotificationsRepository performanceNotificationsRepository = BeanUtil
+                .getBean(PerformanceNotificationsRepository.class);
+        PerformanceNotifications performanceNotification = new PerformanceNotifications();
+        performanceNotification.setNotification(msg);
+        log.info("Performance notification {}", performanceNotification);
+        NewPmNotification newNotification = BeanUtil.getBean(NewPmNotification.class);
+        performanceNotificationsRepository.save(performanceNotification);
+        newNotification.setNewNotif(true);
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java
new file mode 100644 (file)
index 0000000..81ca9ef
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import java.io.IOException;
+import java.util.Map;
+
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.utils.DmaapUtils;
+
+/**
+ * Client class to handle Policy interactions 
+ */
+public class PolicyDmaapClient {
+
+    private DmaapUtils dmaapUtils;
+
+    private Configuration configuration;
+
+    public PolicyDmaapClient(DmaapUtils dmaapUtils, Configuration configuration) {
+        this.dmaapUtils = dmaapUtils;
+        this.configuration = configuration;
+    }
+
+    /**
+     * Method stub for sending notification to policy.
+     */
+    @SuppressWarnings("unchecked")
+    public boolean sendNotificationToPolicy(String msg) {
+        Map<String, Object> streamsPublishes = configuration.getStreamsPublishes();
+        String policyTopicUrl = ((Map<String, String>) ((Map<String, Object>) streamsPublishes.get("CL_topic"))
+                .get("dmaap_info")).get("topic_url");
+        String[] policyTopicSplit = policyTopicUrl.split("\\/");
+        String policyTopic = policyTopicSplit[policyTopicSplit.length - 1];
+        CambriaBatchingPublisher cambriaBatchingPublisher;
+        try {
+
+            cambriaBatchingPublisher = dmaapUtils.buildPublisher(configuration, policyTopic);
+
+            NotificationProducer notificationProducer = new NotificationProducer(cambriaBatchingPublisher);
+            notificationProducer.sendNotification(msg);
+        } catch (IOException e) {
+            return false;
+        }
+        return true;
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java
new file mode 100644 (file)
index 0000000..57aadd1
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import org.slf4j.Logger;
+
+/**
+ * Handles Notification on dmaap for Policy events
+ */
+public class PolicyNotificationCallback extends NotificationCallback {
+
+       private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyNotificationCallback.class);
+
+       /**
+        * Trigger on Notification from policy component
+        */
+       @Override
+       public void activateCallBack(String msg) {
+               handlePolicyNotification(msg);
+       }
+
+       /**
+        * Parse and take actions on reception of Notification from Policy
+        * @param msg
+        */
+       private void handlePolicyNotification(String msg) {
+                log.info("Message received from policy: " +msg);
+                //TBD - actions to perform on reception of notification from policy
+       }
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/BeanUtil.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/BeanUtil.java
new file mode 100644 (file)
index 0000000..5f4006c
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.utils;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Service;
+
+/**
+ * This class is used to get/set bean references
+ */
+@Service
+public class BeanUtil implements ApplicationContextAware {
+    private static ApplicationContext context;
+
+    /**
+     * set ApplicationContext
+     */
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) {
+        context = applicationContext;
+    }
+
+    /**
+     * Get bean class
+     * @param <T>
+     * @param beanClass
+     * @return
+     */
+    public static <T> T getBean(Class<T> beanClass) {
+        return context.getBean(beanClass);
+    }
+}
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java
new file mode 100644 (file)
index 0000000..0952f75
--- /dev/null
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.utils;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaClient;
+import com.att.nsa.cambria.client.CambriaClientBuilders;
+import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
+import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import com.att.nsa.cambria.client.CambriaTopicManager;
+
+import java.net.MalformedURLException;
+import java.security.GeneralSecurityException;
+
+import org.onap.slice.analysis.ms.beans.Configuration;
+
+/**
+ * Utility class to perform actions related to Dmaap
+ */
+public class DmaapUtils {
+
+    /**
+     * Build publisher.
+     */
+    public CambriaBatchingPublisher buildPublisher(Configuration config, String topic) {
+        try {
+            return builder(config, topic).build();
+        } catch (MalformedURLException | GeneralSecurityException e) {
+            return null;
+
+        }
+    }
+
+    /**
+     * Build consumer.
+     */
+    public CambriaConsumer buildConsumer(Configuration config, String topic) {
+
+        try {
+            return builderConsumer(config, topic).build();
+        } catch (MalformedURLException | GeneralSecurityException e) {
+            return null;
+        }
+
+    }
+
+    private static PublisherBuilder builder(Configuration config, String topic) {
+        if (config.isSecured()) {
+            return authenticatedBuilder(config, topic);
+        } else {
+            return unAuthenticatedBuilder(config, topic);
+        }
+    }
+
+    private static PublisherBuilder authenticatedBuilder(Configuration config, String topic) {
+        return unAuthenticatedBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(),
+                config.getAafPassword());
+    }
+
+    private static PublisherBuilder unAuthenticatedBuilder(Configuration config, String topic) {
+        return new CambriaClientBuilders.PublisherBuilder().usingHosts(config.getDmaapServers()).onTopic(topic)
+                .logSendFailuresAfter(5);
+    }
+
+    private static ConsumerBuilder builderConsumer(Configuration config, String topic) {
+        if (config.isSecured()) {
+            return authenticatedConsumerBuilder(config, topic);
+        } else {
+            return unAuthenticatedConsumerBuilder(config, topic);
+        }
+    }
+
+    private static ConsumerBuilder unAuthenticatedConsumerBuilder(Configuration config, String topic) {
+        return new CambriaClientBuilders.ConsumerBuilder().usingHosts(config.getDmaapServers()).onTopic(topic)
+                .knownAs(config.getCg(), config.getCid()).withSocketTimeout(config.getPollingTimeout() * 1000);
+    }
+
+    private static ConsumerBuilder authenticatedConsumerBuilder(Configuration config, String topic) {
+        return unAuthenticatedConsumerBuilder(config, topic).usingHttps().authenticatedByHttp(config.getAafUsername(),
+                config.getAafPassword());
+    }
+
+    /**
+     * Build cambriaClient.
+     */
+    public CambriaTopicManager cambriaCLientBuilder(Configuration configuration) {
+        if (configuration.isSecured()) {
+            return authenticatedCambriaCLientBuilder(configuration);
+        } else {
+            return unAuthenticatedCambriaCLientBuilder(configuration);
+
+        }
+    }
+
+    private static CambriaTopicManager authenticatedCambriaCLientBuilder(Configuration config) {
+        try {
+            return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers())
+                    .authenticatedByHttp(config.getAafUsername(), config.getAafPassword()));
+        } catch (MalformedURLException | GeneralSecurityException e) {
+            return null;
+        }
+    }
+
+    private static CambriaTopicManager unAuthenticatedCambriaCLientBuilder(Configuration config) {
+        try {
+            return buildCambriaClient(new TopicManagerBuilder().usingHosts(config.getDmaapServers()));
+        } catch (MalformedURLException | GeneralSecurityException e) {
+            return null;
+
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T extends CambriaClient> T buildCambriaClient(
+            CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> client)
+            throws MalformedURLException, GeneralSecurityException {
+        return (T) client.build();
+    }
+
+}
diff --git a/components/slice-analysis-ms/src/main/resources/application.properties b/components/slice-analysis-ms/src/main/resources/application.properties
new file mode 100644 (file)
index 0000000..a82e68e
--- /dev/null
@@ -0,0 +1,35 @@
+###############################################################################
+#  ============LICENSE_START=======================================================
+#  slice-analysis-ms
+#  ================================================================================
+#   Copyright (C) 2020 Wipro Limited.
+#   ==============================================================================
+#     Licensed under the Apache License, Version 2.0 (the "License");
+#     you may not use this file except in compliance with the License.
+#     You may obtain a copy of the License at
+#  
+#          http://www.apache.org/licenses/LICENSE-2.0
+#  
+#     Unless required by applicable law or agreed to in writing, software
+#     distributed under the License is distributed on an "AS IS" BASIS,
+#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#     See the License for the specific language governing permissions and
+#     limitations under the License.
+#     ============LICENSE_END=========================================================
+#  
+###############################################################################
+
+
+spring.datasource.initialization-mode=always
+
+spring.datasource.initialize=true
+
+spring.datasource.schema=classpath:/schema.sql
+
+spring.datasource.continue-on-error=true
+
+spring.jpa.hibernate.ddl-auto=validate
+
+spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
+
+spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
diff --git a/components/slice-analysis-ms/src/main/resources/logback.xml b/components/slice-analysis-ms/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..8d79c4e
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *  
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *  
+ *******************************************************************************/
+  -->
+       <configuration>
+
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <Pattern>
+                %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+            </Pattern>
+        </layout>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</configuration>
diff --git a/components/slice-analysis-ms/src/main/resources/schema.sql b/components/slice-analysis-ms/src/main/resources/schema.sql
new file mode 100644 (file)
index 0000000..468e5e3
--- /dev/null
@@ -0,0 +1,4 @@
+CREATE TABLE PERFORMANCE_NOTIFICATIONS(
+       notification TEXT PRIMARY KEY NOT NULL,
+       created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/ApplicationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/ApplicationTest.java
new file mode 100644 (file)
index 0000000..38c2bac
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApplicationTest.class)
+public class ApplicationTest {
+       
+       @Test
+       public void contextLoads() {
+               
+       }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java
new file mode 100644 (file)
index 0000000..66f97d9
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+
+package org.onap.slice.analysis.ms.beans;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+
+public class ConfigPolicyTest {
+
+    @Test
+    public void configPolicyTest() {
+        ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+        Map<String, Object> config = new HashMap<String, Object>();
+        config.put("policyName", "pcims_policy");
+        configPolicy.setConfig(config);
+        assertEquals(config, configPolicy.getConfig());
+    }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java
new file mode 100644 (file)
index 0000000..a348777
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+
+package org.onap.slice.analysis.ms.beans;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+
+public class ConfigurationTest {
+    Configuration configuration = Configuration.getInstance();
+
+    @Test
+    public void configurationTest() {
+
+        List<String> list = new ArrayList<String>();
+        list.add("server");
+        Map<String, Object> subscribes = new HashMap<>();
+        
+        configuration.setStreamsSubscribes(subscribes);
+        configuration.setStreamsPublishes(subscribes);
+        configuration.setDmaapServers(list);
+        configuration.setCg("cg");
+        configuration.setCid("cid");
+        configuration.setAafPassword("password");
+        configuration.setAafUsername("user");
+        configuration.setPgHost("pg");
+        configuration.setPgPort(5432);
+        configuration.setPgPassword("password");
+        configuration.setPgUsername("user");
+        configuration.setPollingInterval(30);
+        configuration.setPollingTimeout(100);
+        configuration.setConfigDbService("sdnrService");
+     
+        assertEquals("cg", configuration.getCg());
+        assertEquals("cid", configuration.getCid());
+        assertEquals("user", configuration.getAafUsername());
+        assertEquals("password", configuration.getAafPassword());
+        assertEquals("user", configuration.getPgUsername());
+        assertEquals("password", configuration.getPgPassword());
+        assertEquals("pg", configuration.getPgHost());
+        assertEquals(5432, configuration.getPgPort());
+        assertEquals(30, configuration.getPollingInterval());
+        assertEquals(100, configuration.getPollingTimeout());
+        assertEquals("sdnrService", configuration.getConfigDbService());
+        assertEquals(list, configuration.getDmaapServers());
+    }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java
new file mode 100644 (file)
index 0000000..e865400
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.data.beans;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+
+public class PerformanceNotificationsTest {
+    private Timestamp createdAt;
+
+       @Test
+       public void test() {
+               
+                PerformanceNotifications performanceNotifications = new PerformanceNotifications();
+                performanceNotifications.setNotification("notification");
+                performanceNotifications.setCreatedAt(createdAt);
+            assertEquals("notification", performanceNotifications.getNotification());
+            assertEquals(createdAt, performanceNotifications.getCreatedAt());  }
+
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java
new file mode 100644 (file)
index 0000000..f2420b0
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import static org.mockito.Mockito.when;
+
+import com.att.nsa.cambria.client.CambriaTopicManager;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = DmaapClientTest.class)
+public class DmaapClientTest {
+
+       @Mock
+       private CambriaTopicManager topicManager;
+
+       
+       @InjectMocks
+       DmaapClient client;
+       
+       @Before
+       public void setup() {
+               MockitoAnnotations.initMocks(this);
+       }
+
+       @Test
+       public void getAllTopicsTest() {
+               Set<String> topics = new HashSet<String>();
+               topics.add("topic1");
+               topics.add("topic2");
+               Configuration configuration = Configuration.getInstance();
+               List<String> list = new ArrayList<String>();
+               list.add("server");
+               configuration.setDmaapServers(list);
+               configuration.setCg("cg");
+               configuration.setCid("cid");
+               configuration.setPollingInterval(30);
+               configuration.setPollingTimeout(100);
+               configuration.setConfigDbService("sdnrService");
+               
+               try {
+                       when(topicManager.getTopics()).thenReturn(topics);
+                       
+                       client=Mockito.mock(DmaapClient.class);
+                       client.initClient();
+                       Mockito.verify(client).initClient();      
+              // Mockito.verifycreateAndConfigureTopics();
+
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       @Test
+       public void startClientTest() {         
+               try {
+                       Configuration configuration = Configuration.getInstance();
+                       String configAllJson = readFromFile("src/test/resources/config_all.json");
+
+            JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
+
+            JsonObject config = configAll.getAsJsonObject("config");
+
+            configuration.updateConfigurationFromJsonObject(config);
+                       DmaapClient client= new DmaapClient();
+                       client.initClient();
+                       //Mockito.verify(client).startClient();      
+              // Mockito.verifycreateAndConfigureTopics();
+
+               } catch ( Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+    private static String readFromFile(String file) {
+        String content = "";
+        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
+            content = bufferedReader.readLine();
+            String temp;
+            while ((temp = bufferedReader.readLine()) != null) {
+                content = content.concat(temp);
+            }
+            content = content.trim();
+        } catch (Exception e) {
+            content = null;
+        }
+        return content;
+    }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NewPmNotificationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NewPmNotificationTest.java
new file mode 100644 (file)
index 0000000..7c11d03
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class NewPmNotificationTest {
+
+       @Test
+       public void testNewPmNotif() {
+               NewPmNotification newPmNotif1 = new NewPmNotification(true);
+               NewPmNotification newPmNotif2 = new NewPmNotification();
+               newPmNotif2.setNewNotif(true);
+               assertTrue(newPmNotif2.getNewNotif());
+               newPmNotif2.init();
+               assertEquals(false, newPmNotif2.getNewNotif());
+               assertTrue(newPmNotif1.getNewNotif());
+
+       }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java
new file mode 100644 (file)
index 0000000..f4b6439
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = NotificationConsumerTest.class)
+public class NotificationConsumerTest {
+       
+       @Mock
+       CambriaConsumer cambriaConsumer;
+       
+       @Mock
+       NotificationCallback notificationCallback;
+
+       @InjectMocks
+       NotificationConsumer notificationConsumer;
+
+       @Test
+       public void testNotificationConsumer() {
+               try {
+                       List<String> notifications = new ArrayList<>();
+                       notifications.add("notification1");
+                       when(cambriaConsumer.fetch()).thenReturn(notifications);
+                       Mockito.doNothing().when(notificationCallback).activateCallBack(Mockito.anyString());
+                       notificationConsumer.run();
+                       
+               }catch(Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationProducerTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationProducerTest.java
new file mode 100644 (file)
index 0000000..9dc5141
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = NotificationProducerTest.class)
+public class NotificationProducerTest {
+
+       @Mock
+       CambriaBatchingPublisher cambriaBatchingPublisher;
+
+       @InjectMocks
+       NotificationProducer notificationProducer;
+
+       @Test
+       public void notificationProducerTest() {
+
+               try {
+
+                       when(cambriaBatchingPublisher.send(Mockito.anyString(), Mockito.anyString())).thenReturn(0);
+                       int result = notificationProducer.sendNotification("msg");
+                       assertEquals(0, result);
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+
+       }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallbackTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallbackTest.java
new file mode 100644 (file)
index 0000000..8b47ba5
--- /dev/null
@@ -0,0 +1,59 @@
+
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+package org.onap.slice.analysis.ms.dmaap;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.onap.slice.analysis.ms.data.repository.PerformanceNotificationsRepository;
+import org.onap.slice.analysis.ms.utils.BeanUtil;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@PowerMockRunnerDelegate(SpringRunner.class)
+@PrepareForTest({ BeanUtil.class })
+@SpringBootTest(classes = PmNotificationCallbackTest.class)
+public class PmNotificationCallbackTest {
+       
+       @Mock
+       PerformanceNotificationsRepository performanceNotificationsRepository;
+       
+       @Mock
+       NewPmNotification newPmNotif;
+       
+       @Test
+       public void testActivateCallBack() {
+               PowerMockito.mockStatic(BeanUtil.class);
+               PowerMockito.when(BeanUtil.getBean(PerformanceNotificationsRepository.class)).thenReturn(performanceNotificationsRepository);
+               PowerMockito.when(BeanUtil.getBean(NewPmNotification.class)).thenReturn(newPmNotif);
+               PmNotificationCallback pmNotificationCallback = new PmNotificationCallback();
+               pmNotificationCallback.activateCallBack("pmNotification");
+       }
+
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java
new file mode 100644 (file)
index 0000000..a458d33
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import static org.junit.Assert.*;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.utils.DmaapUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@RunWith(MockitoJUnitRunner.class)
+@SpringBootTest(classes = PolicyDmaapClient.class)
+public class PolicyDmaapClientTest {
+    
+    @Mock
+    Configuration configurationMock;
+    
+    @Mock
+    DmaapUtils dmaapUtilsMock;
+    
+    @InjectMocks
+    PolicyDmaapClient policyDmaapClient;
+    
+    @Mock
+    CambriaConsumer policyResponseCambriaConsumerMock;
+    
+    @Mock
+    CambriaBatchingPublisher cambriaBatchingPublisherMock;
+    
+    @Mock
+    NotificationProducer notificationProducerMock;
+    
+    @Before
+    public void setup() {
+        policyDmaapClient = new PolicyDmaapClient(dmaapUtilsMock, configurationMock);
+    }
+    
+    @Test
+    public void sendNotificationToPolicyTest() {
+        Map<String, Object> streamsPublishes = new HashMap<>();
+        Map<String, String> topics = new HashMap<>();
+        Map<String, Object> dmaapInfo = new HashMap<>();
+        topics.put("topic_url", "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_OUTPUT");
+        dmaapInfo.put("dmaap_info", topics);
+        streamsPublishes.put("CL_topic", dmaapInfo);
+        Mockito.when(configurationMock.getStreamsPublishes()).thenReturn(streamsPublishes);
+        Mockito.when(dmaapUtilsMock.buildPublisher(configurationMock, "DCAE_CL_OUTPUT")).thenReturn(cambriaBatchingPublisherMock);
+        try {
+            Mockito.when(cambriaBatchingPublisherMock.send("", "hello")).thenReturn(0);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assertTrue(policyDmaapClient.sendNotificationToPolicy("hello"));
+        
+    }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallbackTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallbackTest.java
new file mode 100644 (file)
index 0000000..6793a16
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2020 Wipro Limited.
+ *   ==============================================================================
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ *     ============LICENSE_END=========================================================
+ *
+ *******************************************************************************/
+
+package org.onap.slice.analysis.ms.dmaap;
+
+import org.junit.Test;
+
+public class PolicyNotificationCallbackTest {
+       
+       @Test
+       public void testPolicyActivateCallback() {
+               
+               PolicyNotificationCallback policyNotificationCallback = new PolicyNotificationCallback();
+               policyNotificationCallback.activateCallBack("newPolicyNotificationMsg");
+       }
+
+}
diff --git a/components/slice-analysis-ms/src/test/resources/config_all.json b/components/slice-analysis-ms/src/test/resources/config_all.json
new file mode 100644 (file)
index 0000000..21a8234
--- /dev/null
@@ -0,0 +1,59 @@
+{
+  "config": {
+    "streams_subscribes": {
+      "performance_management_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.VES_MEASUREMENT_OUTPUT",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      },
+      "dcae_cl_response_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/DCAE_CL_RSP",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      }
+    },
+    "streams_publishes": {
+      "CL_topic": {
+        "aaf_password": null,
+        "type": "message-router",
+        "dmaap_info": {
+          "topic_url": "https://message-router.onap.svc.cluster.local:3905/events/unauthenticated.DCAE_CL_OUTPUT",
+          "client_role": "sliceanalysis-subscriber",
+          "location": "onap",
+          "client_id": "sdnr-sliceanalysis-1"
+        },
+        "aaf_username": null
+      }
+    },
+    "postgres.password": "postgres",
+    "postgres.username": "sliceanalysisms_admin",
+    "postgres.host": "postgres",
+    "postgres.port": "5432",
+    "sliceanalysisms.dmaap.server": [
+      "dmaap"
+    ],
+    "cbsPollingInterval": 60,
+    "sliceanalysisms.cg": "sliceanalysisms-cg",
+    "sliceanalysisms.pollingInterval": 20,
+    "sliceanalysisms.cid": "sliceanalysisms-cid",
+    "sliceanalysisms.configDb.service": "http://sdnc.onap:8181",
+    "service_calls": {
+      "policy-req": []
+    }
+  },
+  "policies": {
+    
+  }
+}
diff --git a/components/slice-analysis-ms/version.properties b/components/slice-analysis-ms/version.properties
new file mode 100644 (file)
index 0000000..7bbc2fb
--- /dev/null
@@ -0,0 +1,26 @@
+###############################################################################
+#  ============LICENSE_START=======================================================
+#  slice-analysis-ms
+#  ================================================================================
+#   Copyright (C) 2020 Wipro Limited.
+#   ==============================================================================
+#     Licensed under the Apache License, Version 2.0 (the "License");
+#     you may not use this file except in compliance with the License.
+#     You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#     Unless required by applicable law or agreed to in writing, software
+#     distributed under the License is distributed on an "AS IS" BASIS,
+#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#     See the License for the specific language governing permissions and
+#     limitations under the License.
+#     ============LICENSE_END=========================================================
+#
+###############################################################################
+major=1
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT