Fix sonar issues

Change-Id: I61155448422f0084ac08f294452ac90f5b3454aa
Issue-ID: DCAEGEN2-396
Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
index 99a4a8b..aa4630b 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
@@ -94,7 +94,7 @@
     private ResponseHandler<Optional<String>> aaiResponseHandler() {
         return httpResponse ->  {
             final int responseCode = httpResponse.getStatusLine().getStatusCode();
-            logger.trace("Status code of operation: {}", responseCode);
+            logger.info("Status code of operation: {}", responseCode);
             final HttpEntity responseEntity = httpResponse.getEntity();
 
             if (HttpUtils.isSuccessfulResponseCode(responseCode) ) {
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
index 4f48c1c..bb4d145 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
@@ -44,6 +44,8 @@
 import java.util.Optional;
 
 public class AAIProducerClient implements AAIExtendedHttpClient {
+
+    private static final String EXCEPTION_MESSAGE = "Exception while executing http client: ";
     private Logger logger = LoggerFactory.getLogger(AAIProducerClient.class);
 
     private final CloseableHttpClient closeableHttpClient;
@@ -51,7 +53,7 @@
     private final String aaiProtocol;
     private final Integer aaiHostPortNumber;
     private final String aaiPath;
-    private final Map<String,String> aaiHeaders;
+    private final Map<String, String> aaiHeaders;
 
 
     public AAIProducerClient(AAIClientConfiguration aaiClientConfiguration) {
@@ -66,20 +68,15 @@
 
     @Override
     public Optional<Integer> getHttpResponse(ConsumerDmaapModel consumerDmaapModel) throws
-            URISyntaxException {
-        try {
-            return createRequest(consumerDmaapModel).flatMap(x->{
-                try {
-                    return closeableHttpClient.execute(x, aaiResponseHandler());
-                } catch (IOException e) {
-                    logger.warn("Exception while executing http client: ", e);
-                    return Optional.empty();
-                }
-            });
-        } catch (URISyntaxException e ) {
-            logger.warn("Exception while executing http client: ", e);
-            throw e;
-        }
+        URISyntaxException {
+        return createRequest(consumerDmaapModel).flatMap(x -> {
+            try {
+                return closeableHttpClient.execute(x, aaiResponseHandler());
+            } catch (IOException e) {
+                logger.warn(EXCEPTION_MESSAGE, e);
+                return Optional.empty();
+            }
+        });
     }
 
     private Optional<HttpRequestBase> createRequest(ConsumerDmaapModel consumerDmaapModel) throws URISyntaxException {
@@ -89,16 +86,16 @@
 
     private URI createAAIExtendedURI(final String pnfName) throws URISyntaxException {
         return new URIBuilder()
-                .setScheme(aaiProtocol)
-                .setHost(aaiHost)
-                .setPort(aaiHostPortNumber)
-                .setPath(aaiPath + "/" + pnfName).build();
+            .setScheme(aaiProtocol)
+            .setHost(aaiHost)
+            .setPort(aaiHostPortNumber)
+            .setPath(aaiPath + "/" + pnfName).build();
     }
 
     private ResponseHandler<Optional<Integer>> aaiResponseHandler() {
-        return (HttpResponse httpResponse) ->  {
+        return (HttpResponse httpResponse) -> {
             final Integer responseCode = httpResponse.getStatusLine().getStatusCode();
-            logger.trace("Status code of operation: {}", responseCode);
+            logger.info("Status code of operation: {}", responseCode);
             final HttpEntity responseEntity = httpResponse.getEntity();
 
             if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
@@ -113,19 +110,20 @@
     }
 
     private Optional<HttpRequestBase> createHttpRequest(URI extendedURI, ConsumerDmaapModel consumerDmaapModel) {
-        return Optional.ofNullable(CommonFunctions.createJsonBody(consumerDmaapModel)).filter(x-> !x.isEmpty()).flatMap(myJson -> {
-            try {
-                return Optional.of(createHttpPatch(extendedURI, myJson));
-            } catch (UnsupportedEncodingException e) {
-                logger.warn("Exception while executing http client: ", e);
-            }
-            return Optional.empty();
-        });
+        return Optional.ofNullable(CommonFunctions.createJsonBody(consumerDmaapModel)).filter(x -> !x.isEmpty())
+            .flatMap(myJson -> {
+                try {
+                    return Optional.of(createHttpPatch(extendedURI, myJson));
+                } catch (UnsupportedEncodingException e) {
+                    logger.warn(EXCEPTION_MESSAGE, e);
+                }
+                return Optional.empty();
+            });
     }
 
     private HttpPatch createHttpPatch(URI extendedURI, String jsonBody) throws UnsupportedEncodingException {
         HttpPatch httpPatch = new HttpPatch(extendedURI);
-        httpPatch.setEntity( new StringEntity(jsonBody));
+        httpPatch.setEntity(new StringEntity(jsonBody));
         aaiHeaders.forEach(httpPatch::addHeader);
         httpPatch.addHeader("Content-Type", "application/merge-patch+json");
         return httpPatch;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
index 09de5cc..784bc5a 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
@@ -25,7 +25,7 @@
 import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
 import org.onap.dcaegen2.services.prh.service.AAIConsumerClient;
 
-public abstract class AAIConsumerTask<Request, Response, Conf> extends Task<Request, Response, Conf> {
+public abstract class AAIConsumerTask<R, S, C> extends Task<R, S, C> {
 
     abstract Optional<String> consume(ConsumerDmaapModel message) throws AAINotFoundException;
 
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
index 8236280..c7bde03 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
@@ -26,7 +26,7 @@
 /**
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
  */
-public abstract class AAIProducerTask<Request, Response, Config> extends Task<Request, Response, Config> {
+public abstract class AAIProducerTask<R, S, C> extends Task<R, S, C> {
 
     abstract ConsumerDmaapModel publish(ConsumerDmaapModel message) throws AAINotFoundException;
 
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 4bd8731..fcadc48 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
@@ -26,7 +26,7 @@
 /**
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
  */
-abstract class DmaapConsumerTask<Request, Response, Config> extends Task<Request, Response, Config> {
+abstract class DmaapConsumerTask<R, S, C> extends Task<R, S, C> {
 
     abstract ConsumerDmaapModel consume(String message) throws DmaapNotFoundException;
 
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
index ab3e469..4e95a0d 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
@@ -26,7 +26,7 @@
 /**
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
  */
-abstract class DmaapPublisherTask<Request, Response, Config> extends Task<Request, Response, Config> {
+abstract class DmaapPublisherTask<R, S, C> extends Task<R, S, C> {
 
     abstract String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException;
 
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 1a8f60f..8f2541c 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -24,7 +24,6 @@
 import org.onap.dcaegen2.services.prh.configuration.AppConfig;
 import org.onap.dcaegen2.services.prh.configuration.Config;
 import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
-import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
 import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
 import org.onap.dcaegen2.services.prh.service.producer.ExtendedDmaapProducerHttpClientImpl;
 import org.slf4j.Logger;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
index 46e19da..8aa0144 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
@@ -26,7 +26,7 @@
  */
 
 
-public abstract class Task<Request, Response, Config> {
+public abstract class Task<R, S, C> {
 
     private Task taskProcess;
 
@@ -34,15 +34,15 @@
         this.taskProcess = task;
     }
 
-    public void receiveRequest(Request body) throws PrhTaskException {
+    public void receiveRequest(R body) throws PrhTaskException {
 
-        Response response = execute(body);
+        S response = execute(body);
         if (taskProcess != null) {
             taskProcess.receiveRequest(response);
         }
     }
 
-    abstract Response execute(Request object) throws PrhTaskException;
+    abstract S execute(R object) throws PrhTaskException;
 
-    abstract Config resolveConfiguration();
+    abstract C resolveConfiguration();
 }
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
index 9e272aa..7b48bd8 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
@@ -22,21 +22,27 @@
 
 public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel {
 
-    private final String PNF_NAME = "NOKnhfsadhff";
-    private final String IPv4 = "256.22.33.155";
-    private final String IPv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
+    private final String pnfName;
+    private final String ipv4;
+    private final String ipv6;
 
+    public ConsumerDmaapModelForUnitTest() {
+        this.pnfName = "NOKnhfsadhff";
+        this.ipv4 = "256.22.33.155";
+        this.ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
+
+    }
 
     public String getPnfName() {
-        return PNF_NAME;
+        return pnfName;
     }
 
     public String getIpv4() {
-        return IPv4;
+        return ipv4;
     }
 
     public String getIpv6() {
-        return IPv6;
+        return ipv6;
     }
 
 }
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
index 6f99f1c..3981901 100644
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
@@ -26,7 +26,7 @@
 public class CommonFunctionsTest {
 
     private ConsumerDmaapModel model = new ConsumerDmaapModelForUnitTest();
-    private String expectedResult = "{\"PNF_NAME\":\"NOKnhfsadhff\",\"IPv4\":\"256.22.33.155\",\"IPv6\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
+    private String expectedResult = "{\"pnfName\":\"NOKnhfsadhff\",\"ipv4\":\"256.22.33.155\",\"ipv6\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
 
     @Test
     public void createJsonBody_shouldReturnJsonInString() {
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
index 8d2f82d..053f1a7 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
@@ -115,12 +115,12 @@
             final HttpEntity responseEntity = httpResponse.getEntity();
 
             if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
-                logger.info("HTTP response successful.");
+                logger.trace("HTTP response successful.");
                 final String dmaapResponse = EntityUtils.toString(responseEntity);
                 return Optional.of(dmaapResponse);
             } else {
                 String dmaapResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
-                logger.warn("HTTP response not successful : {}", dmaapResponse);
+                logger.trace("HTTP response not successful : {}", dmaapResponse);
                 return Optional.of(String.valueOf(responseCode));
             }
         };
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
index 2f96b39..72e70b9 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
@@ -123,7 +123,7 @@
             return Optional.of("" + responseCode);
         } else {
             String response = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
-            logger.warn("HTTP response not successful : {}", response);
+            logger.trace("HTTP response not successful : {}", response);
             return Optional.of("" + responseCode);
         }
     }