summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-03-28 19:04:20 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-03-28 19:39:28 +0200
commit9292dd2aa89214957fc72980f58026324ca75a4f (patch)
treee9635d6456369d56e4aac912aaa17c1f37c67a52 /prh-app-server
parentd8e4e88b6080dfd701ea7aa64d033c38899e77c6 (diff)
Already fixed Sonar issues
We have fixed Sonar issue with critical and minor tag Change-Id: Iccc343654686ba87f71d57382b68ddf9c54caeea Issue-ID: DCAEGEN2-407 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/pom.xml19
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java12
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java15
7 files changed, 43 insertions, 12 deletions
diff --git a/prh-app-server/pom.xml b/prh-app-server/pom.xml
index 5a62e40e..a42caa02 100644
--- a/prh-app-server/pom.xml
+++ b/prh-app-server/pom.xml
@@ -1,4 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ PNF-REGISTRATION-HANDLER
+ ~ ================================================================================
+ ~ 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=========================================================
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
index b66af993..18db4082 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
* ================================================================================
* Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java
index 22dd24bd..e54d158e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
* ================================================================================
* Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
index cb2d1331..0762fc81 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
* ================================================================================
* Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java
index f5f8c284..0032a3e1 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
* ================================================================================
* Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
@@ -24,6 +24,7 @@ import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
+@FunctionalInterface
public interface DmaapTask {
void execute() throws AAINotFoundException;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java
index a3a48b79..277bc707 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
* ================================================================================
* Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
@@ -52,11 +52,11 @@ public class ScheduledTask {
LocalDateTime.now()));
try {
dmaapConsumerTask.execute();
-
- } catch (AAINotFoundException | RuntimeException e) {
- logger.warn("Task scheduledTaskAskingDMaaPOfConsumeEvent()::AAINotFoundException :: Execution Time - {}:{}",
- dateTimeFormatter.format(
- LocalDateTime.now()), e.getMessage());
+ } catch (AAINotFoundException e) {
+ logger
+ .error("Task scheduledTaskAskingDMaaPOfConsumeEvent()::AAINotFoundException :: Execution Time - {}:{}",
+ dateTimeFormatter.format(
+ LocalDateTime.now()), e.getMessage());
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java
index 14e83c62..7a3fac63 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java
@@ -22,6 +22,11 @@ package org.onap.dcaegen2.services.prh.tasks;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.verify;
+import java.time.Duration;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
@@ -44,7 +49,7 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@ContextConfiguration(locations = {"classpath:scheduled-context.xml"})
public class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
- private static final int WAIT_FOR_SCHEDULING = 1000;
+ private static final int WAIT_FOR_SCHEDULING = 1;
@Autowired
private DmaapConsumerTask dmaapConsumerTaskSpy;
@@ -52,9 +57,15 @@ public class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
@Test
public void testScheduling() throws InterruptedException {
- Thread.sleep(WAIT_FOR_SCHEDULING);
+ final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.scheduleWithFixedDelay(this::verifyDmaapConsumerTask, 0, WAIT_FOR_SCHEDULING, TimeUnit.SECONDS);
+ }
+
+ private void verifyDmaapConsumerTask() {
verify(dmaapConsumerTaskSpy, atLeast(2)).execute();
}
+
+
}