Already fixed Sonar issues 57/39757/1
authorwasala <przemyslaw.wasala@nokia.com>
Wed, 28 Mar 2018 17:04:20 +0000 (19:04 +0200)
committerwasala <przemyslaw.wasala@nokia.com>
Wed, 28 Mar 2018 17:39:28 +0000 (19:39 +0200)
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>
16 files changed:
pom.xml
prh-aai-client/pom.xml
prh-aai-client/src/main/java/services/config/AAIConfig.java
prh-aai-client/src/main/java/services/config/AAIDmaapProducerConfiguration.java
prh-app-server/pom.xml
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java
prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java
prh-dmaap-client/pom.xml
prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapConfig.java
prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapConsumerConfiguration.java
prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapCustomConfig.java [new file with mode: 0644]
prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapProducerConfiguration.java

diff --git a/pom.xml b/pom.xml
index 8abf842..8f9e7cb 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ~ ============LICENSE_START=======================================================
-  ~ PROJECT
+  ~ PNF-REGISTRATION-HANDLER
   ~ ================================================================================
   ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
   ~ ================================================================================
index 52d784a..6ac6484 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ~ ============LICENSE_START=======================================================
-  ~ PROJECT
+  ~ PNF-REGISTRATION-HANDLER
   ~ ================================================================================
   ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
   ~ ================================================================================
index 5d98b6c..ed327fa 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index a7b0aac..dfeafdd 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index 5a62e40..a42caa0 100644 (file)
@@ -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">
index b66af99..18db408 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index 22dd24b..e54d158 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index cb2d133..0762fc8 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index f5f8c28..0032a3e 100644 (file)
@@ -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;
index a3a48b7..277bc70 100644 (file)
@@ -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());
         }
     }
 
index 14e83c6..7a3fac6 100644 (file)
@@ -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();
     }
+
+
 }
 
 
index 080a6f1..8754b0a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ~ ============LICENSE_START=======================================================
-  ~ PROJECT
+  ~ PNF-REGISTRATION-HANDLER
   ~ ================================================================================
   ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
   ~ ================================================================================
index 0d77c05..430a103 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
index f2a2f06..c4acf3a 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
@@ -25,41 +25,35 @@ import org.immutables.value.Value;
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
  */
 @Value.Immutable(prehash = true)
-@Value.Style(stagedBuilder = true)
-public abstract class DmaapConsumerConfiguration implements DmaapConfig {
+@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE)
+public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig {
 
     private static final long serialVersionUID = 1L;
 
-    @Value.Parameter
-    public abstract String consumerId();
 
-    @Value.Parameter
-    public abstract String consumerGroup();
+    abstract String consumerId();
 
-    @Value.Parameter
-    public abstract Integer timeoutMS();
+    abstract String consumerGroup();
 
-    @Value.Parameter
-    public abstract Integer messageLimit();
+    abstract Integer timeoutMS();
 
-    @Value.Parameter
-    public abstract String dmmaphostName();
+    abstract Integer messageLimit();
 
-    @Value.Parameter
-    public abstract Integer dmmapportNumber();
 
-    @Value.Parameter
-    public abstract String dmmaptopicName();
+    public interface Builder extends
+        DmaapCustomConfig.Builder<DmaapConsumerConfiguration, DmaapConsumerConfiguration.Builder> {
 
-    @Value.Parameter
-    public abstract String dmmapprotocol();
+        Builder consumerId(String consumerId);
 
-    @Value.Parameter
-    public abstract String dmmapuserName();
+        Builder consumerGroup(String consumerGroup);
 
-    @Value.Parameter
-    public abstract String dmmapuserPassword();
+        Builder timeoutMS(Integer timeoutMS);
+
+        Builder messageLimit(Integer messageLimit);
+    }
+
+    public static DmaapConsumerConfiguration.Builder builder() {
+        return ImmutableDmaapConsumerConfiguration.builder();
+    }
 
-    @Value.Parameter
-    public abstract String dmmapcontentType();
 }
\ No newline at end of file
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapCustomConfig.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapCustomConfig.java
new file mode 100644 (file)
index 0000000..1026cc3
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.dcaegen2.services.config;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/28/18
+ */
+public interface DmaapCustomConfig extends DmaapConfig {
+
+    String dmmaphostName();
+
+    Integer dmmapportNumber();
+
+    String dmmaptopicName();
+
+    String dmmapprotocol();
+
+    String dmmapuserName();
+
+    String dmmapuserPassword();
+
+    String dmmapcontentType();
+
+
+    interface Builder<T extends DmaapCustomConfig, B extends Builder<T, B>> {
+
+        B dmmaphostName(String dmmaphostName);
+
+        B dmmapportNumber(Integer dmmapportNumber);
+
+        B dmmaptopicName(String dmmaptopicName);
+
+        B dmmapprotocol(String dmmapprotocol);
+
+        B dmmapuserName(String dmmapuserName);
+
+        B dmmapuserPassword(String dmmapuserPassword);
+
+        B dmmapcontentType(String dmmapcontentType);
+
+        T build();
+    }
+}
index a0f29e4..550d979 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * PROJECT
+ * PNF-REGISTRATION-HANDLER
  * ================================================================================
  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
  * ================================================================================
@@ -25,29 +25,16 @@ import org.immutables.value.Value;
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
  */
 @Value.Immutable(prehash = true)
-@Value.Style(stagedBuilder = true)
-public abstract class DmaapProducerConfiguration implements DmaapConfig {
+@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE)
+public abstract class DmaapProducerConfiguration implements DmaapCustomConfig {
 
     private static final long serialVersionUID = 1L;
 
-    @Value.Parameter
-    public abstract String dmmaphostName();
+    public interface Builder extends
+        DmaapCustomConfig.Builder<DmaapProducerConfiguration, DmaapProducerConfiguration.Builder> {
+    }
 
-    @Value.Parameter
-    public abstract Integer dmmapportNumber();
-
-    @Value.Parameter
-    public abstract String dmmaptopicName();
-
-    @Value.Parameter
-    public abstract String dmmapprotocol();
-
-    @Value.Parameter
-    public abstract String dmmapuserName();
-
-    @Value.Parameter
-    public abstract String dmmapuserPassword();
-
-    @Value.Parameter
-    public abstract String dmmapcontentType();
+    public static Builder builder() {
+        return ImmutableDmaapProducerConfiguration.builder();
+    }
 }