Divide Code into logic. 21/38121/1
authorwasala <przemyslaw.wasala@nokia.com>
Wed, 21 Mar 2018 20:42:36 +0000 (16:42 -0400)
committerwasala <przemyslaw.wasala@nokia.com>
Fri, 23 Mar 2018 15:01:20 +0000 (16:01 +0100)
Load properties for every kind of
endpoint.Also has already
added logic for registering task to consume
messages from DMaap.

Change-Id: I16420b17a0272687f4161967420c80c476385b83
Issue-ID: DCAEGEN2-407
Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
15 files changed:
pom.xml
src/main/java/org/onap/dcaegen2/services/prh/MainApp.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java [deleted file]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java [new file with mode: 0644]
src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java [new file with mode: 0644]
src/main/resources/application.yaml [new file with mode: 0644]
src/test/java/org/onap/dcaegen2/services/prh/ServerPrhAppTest.java

diff --git a/pom.xml b/pom.xml
index 23cc275..089a1a0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
   <dependencies>
     <!--Development tools dependencies-->
     <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-server</artifactId>
-      <version>9.4.8.v20171121</version>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-servlet</artifactId>
-      <version>9.4.8.v20171121</version>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-webflux</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.glassfish.jersey.core</groupId>
-      <artifactId>jersey-server</artifactId>
-      <version>2.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.containers</groupId>
-      <artifactId>jersey-container-servlet-core</artifactId>
-      <version>2.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.containers</groupId>
-      <artifactId>jersey-container-jetty-http</artifactId>
-      <version>2.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.media</groupId>
-      <artifactId>jersey-media-json-jackson</artifactId>
-      <version>2.7</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.media</groupId>
-      <artifactId>jersey-media-moxy</artifactId>
-      <version>2.7</version>
-    </dependency>
+    <groupId>org.immutables</groupId>
+    <artifactId>value</artifactId>
+    <version>2.5.6</version>
+  </dependency>
     <!-- Testing tools dependencies -->
     <dependency>
       <groupId>org.junit.jupiter</groupId>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
   <reporting>
       </plugin>
     </plugins>
   </reporting>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <!-- Import dependency management from Spring Boot -->
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-dependencies</artifactId>
+        <version>2.0.0.RELEASE</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
 </project>
+
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
new file mode 100644 (file)
index 0000000..ca7cc36
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+@SpringBootApplication
+@Configuration
+@ComponentScan
+@EnableScheduling
+public class MainApp {
+
+    public static void main(String[] args) {
+        SpringApplication.run(MainApp.class, args);
+    }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java b/src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java
deleted file mode 100644 (file)
index 5d86512..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.prh;
-
-import java.util.logging.Level;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-
-import java.util.logging.Logger;
-
-public class ServerPrhApp {
-
-    private static int port = 8080;
-    private static Logger logger = Logger.getLogger(ServerPrhApp.class.getName());
-
-    public static void main(String... args) {
-        logger.info("Starting PRH Application Service...");
-        ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        contextHandler.setContextPath("/");
-
-        Server jettyServer = new Server(port);
-        jettyServer.setHandler(contextHandler);
-
-        ServletHolder jerseyServlet = contextHandler
-            .addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
-        jerseyServlet.setInitOrder(0);
-
-        jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", "org.onap.dcaegen2.services.prh");
-
-        try {
-
-            jettyServer.start();
-            logger.info("Server jetty running on port: " + port);
-            jettyServer.join();
-        } catch (Exception ex) {
-            logger.log(Level.ALL, "Error occurred while starting Jetty", ex);
-            System.exit(1);
-        } finally {
-            jettyServer.destroy();
-        }
-
-    }
-
-    private static void parseSettingsFileFromArgs() {
-        //TODO: Definition of for riding file configuration
-    }
-}
\ No newline at end of file
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java
new file mode 100644 (file)
index 0000000..3ea3d21
--- /dev/null
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.consumer.config.dmaap;
+
+import org.immutables.value.Value;
+import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+@Value.Immutable(prehash = true)
+@Value.Style(stagedBuilder = true)
+public abstract class DmaapConsumerConfiguration extends DmaapConfig {
+
+    private static final long serialVersionUID = 1L;
+
+    private String consumerId;
+    private String consumerGroup;
+    private Integer timeoutMS;
+    private Integer messageLimit;
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java
new file mode 100644 (file)
index 0000000..58858b5
--- /dev/null
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.mutual.config;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+public abstract class AAIConfig implements Config {
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java
new file mode 100644 (file)
index 0000000..d078445
--- /dev/null
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.mutual.config;
+
+import java.io.Serializable;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+interface Config extends Serializable {
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java
new file mode 100644 (file)
index 0000000..0a2ee9d
--- /dev/null
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.mutual.config;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+public abstract class DmaapConfig implements Config {
+
+    private String dmmaphostName;
+    private Integer dmmapportNumber;
+    private String dmmaptopicName;
+    private String dmmapprotocol;
+    private String dmmapuserName;
+    private String dmmapuserPassword;
+    private String dmmapcontentType;
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java
new file mode 100644 (file)
index 0000000..214ffa9
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.publisher.config.aai;
+
+import java.net.URL;
+import org.immutables.value.Value;
+import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+@Value.Immutable(prehash = true)
+@Value.Style(stagedBuilder = true)
+public abstract class AAIDmaapProducerConfiguration extends DmaapConfig {
+
+    private static final long serialVersionUID = 1L;
+
+    private String aaiHost;
+    private Integer aaiHostPortNumber;
+    private String aaiProtocol;
+    private String aaiUserName;
+    private String aaiUserPassword;
+    private URL aaiProxyURL;
+    private boolean aaiIgnoreSSLCertificateErrors;
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java
new file mode 100644 (file)
index 0000000..494fad4
--- /dev/null
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.event.executor.publisher.config.dmaap;
+
+import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+
+public class DmaapProducerConfiguration extends DmaapConfig {
+
+    private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java b/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java
new file mode 100644 (file)
index 0000000..61b0c69
--- /dev/null
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.exceptions;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+public class AAINotFoundException extends Exception {
+
+    public AAINotFoundException(String message) {
+        super(message);
+    }
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
new file mode 100644 (file)
index 0000000..5902587
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.tasks;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+@Component
+public class DmaapConsumerTask implements DmaapTask {
+
+    private static final Logger logger = LoggerFactory.getLogger(DmaapConsumerTask.class);
+    private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+    @Override
+    public void execute() {
+        logger.info("Start task DmaapConsumerTask::execute() :: Execution Time - {}", dateTimeFormatter.format(
+            LocalDateTime.now()));
+        //TODO: ADD implementation for executing request to consume topic from dmaap
+
+        logger.info("End task DmaapConsumerTask::execute() :: Execution Time - {}",
+            dateTimeFormatter.format(LocalDateTime.now()));
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java
new file mode 100644 (file)
index 0000000..bb3fdc6
--- /dev/null
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.tasks;
+
+import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+public interface DmaapTask {
+
+    void execute() throws AAINotFoundException;
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java
new file mode 100644 (file)
index 0000000..c06eceb
--- /dev/null
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.prh.tasks;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18
+ * @project pnf-registration-handler
+ */
+@Component
+public class ScheduledTask {
+
+    private static final int FIXED_DELAY = 1000;
+    private static final Logger logger = LoggerFactory.getLogger(ScheduledTask.class);
+    private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+    private final DmaapTask dmaapConsumerTask;
+
+    @Autowired
+    public ScheduledTask(DmaapConsumerTask dmaapConsumerTask) {
+        this.dmaapConsumerTask = dmaapConsumerTask;
+    }
+
+
+    @Scheduled(fixedDelay = FIXED_DELAY)
+    public void scheduledTaskAskingDMaaPOfConsumeEvent() {
+        logger.info("Task scheduledTaskAskingDMaaPOfConsumeEvent() :: Execution Time - {}", dateTimeFormatter.format(
+            LocalDateTime.now()));
+        try {
+            dmaapConsumerTask.execute();
+        } catch (AAINotFoundException e) {
+            logger.warn("Task scheduledTaskAskingDMaaPOfConsumeEvent()::AAINotFoundException :: Execution Time - {}:{}",
+                dateTimeFormatter.format(
+                    LocalDateTime.now()), e.getMessage());
+        }
+    }
+
+}
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
new file mode 100644 (file)
index 0000000..ef147c1
--- /dev/null
@@ -0,0 +1,7 @@
+server:
+    port: 8080
+logging:
+  level:
+    .:  error
+    org.springframework: ERROR
+    org.onap.dcaegen2.services.prg: ERROR
\ No newline at end of file
index b972dd8..4373a50 100644 (file)
@@ -22,8 +22,7 @@ package org.onap.dcaegen2.services.prh;
 
 import org.junit.jupiter.api.Test;
 
-class ServerPrhAppTest {
-
+class MainAppTest {
 
     @Test
     void justAnExample() {