Fix Sonar issues 80/88880/2
authorpwielebs <piotr.wielebski@nokia.com>
Thu, 30 May 2019 12:10:09 +0000 (14:10 +0200)
committerpwielebs <piotr.wielebski@nokia.com>
Thu, 30 May 2019 13:40:37 +0000 (15:40 +0200)
Change-Id: If7134bf3b5aabdba6d057562ae863b40412e2d6b
Issue-ID: DCAEGEN2-1501
Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImpl.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/DmaapPublisherTask.java
prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
prh-app-server/src/test/resources/bbs_action/correct_logical_link.json [deleted file]
prh-app-server/src/test/resources/not_json_object.json [deleted file]
prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/Relationship.java
prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/RelationshipWrapper.java

index 0cf07a0..74de87b 100644 (file)
@@ -52,6 +52,7 @@ import java.util.Optional;
 @Primary
 public class CbsConfiguration extends PrhAppConfig {
     private static final Logger LOGGER = LoggerFactory.getLogger(CbsConfiguration.class);
+    private static final String CBS_CONFIG_MISSING = "CBS config missing";
     private AaiClientConfiguration aaiClientCBSConfiguration;
     private MessageRouterPublisher messageRouterPublisher;
     private MessageRouterSubscriber messageRouterSubscriber;
@@ -111,31 +112,31 @@ public class CbsConfiguration extends PrhAppConfig {
 
     @Override
     public MessageRouterPublisher getMessageRouterPublisher() {
-        return Optional.ofNullable(messageRouterPublisher).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(messageRouterPublisher).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 
     @Override
     public MessageRouterSubscriber getMessageRouterSubscriber() {
-        return Optional.ofNullable(messageRouterSubscriber).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(messageRouterSubscriber).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 
     @Override
     public MessageRouterPublishRequest getMessageRouterPublishRequest() {
-        return Optional.ofNullable(messageRouterCBSPublishRequest).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(messageRouterCBSPublishRequest).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 
     @Override
     public MessageRouterPublishRequest getMessageRouterUpdatePublishRequest() {
-        return Optional.ofNullable(messageRouterCBSUpdatePublishRequest).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(messageRouterCBSUpdatePublishRequest).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 
     @Override
     public AaiClientConfiguration getAaiClientConfiguration() {
-        return Optional.ofNullable(aaiClientCBSConfiguration).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(aaiClientCBSConfiguration).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 
     @Override
     public MessageRouterSubscribeRequest getMessageRouterSubscribeRequest() {
-        return Optional.ofNullable(messageRouterCBSSubscribeRequest).orElseThrow(() -> new RuntimeException("CBS config missing"));
+        return Optional.ofNullable(messageRouterCBSSubscribeRequest).orElseThrow(() -> new RuntimeException(CBS_CONFIG_MISSING));
     }
 }
index b30d199..ed0cbcd 100644 (file)
@@ -35,11 +35,11 @@ import java.util.stream.Stream;
 
 @Component
 public class AaiQueryTaskImpl implements AaiQueryTask {
-    public final static String ACTIVE_STATUS = "Active";
-    public final static String RELATED_TO = "service-instance";
-    public final static String CUSTOMER = "customer.global-customer-id";
-    public final static String SERVICE_TYPE = "service-subscription.service-type";
-    public final static String SERVICE_INSTANCE_ID = "service-instance.service-instance-id";
+    static final String ACTIVE_STATUS = "Active";
+    static final String RELATED_TO = "service-instance";
+    static final String CUSTOMER = "customer.global-customer-id";
+    static final String SERVICE_TYPE = "service-subscription.service-type";
+    static final String SERVICE_INSTANCE_ID = "service-instance.service-instance-id";
 
     private final AaiHttpClient<AaiModel, AaiPnfResultModel> getPnfModelClient;
     private final AaiHttpClient<AaiServiceInstanceQueryModel, AaiServiceInstanceResultModel> getServiceClient;
index 5efeae9..2deafd8 100644 (file)
@@ -27,6 +27,7 @@ import reactor.core.publisher.Flux;
 /**
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
  */
+@FunctionalInterface
 interface DmaapConsumerTask {
     Flux<ConsumerDmaapModel> execute();
 }
index d1a42c4..0cdc40e 100644 (file)
@@ -28,6 +28,7 @@ import reactor.core.publisher.Flux;
 /**
  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
  */
+@FunctionalInterface
 public interface DmaapPublisherTask {
     Flux<MessageRouterPublishResponse> execute(ConsumerDmaapModel consumerDmaapModel) throws PrhTaskException;
 }
index ba18f7b..dbcde5c 100644 (file)
@@ -25,11 +25,7 @@ import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
 import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
 import org.onap.dcaegen2.services.prh.model.logging.MdcVariables;
 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
+import org.slf4j.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.http.HttpStatus;
@@ -90,12 +86,12 @@ public class ScheduledTasks {
     }
 
     static class State {
-        public final ConsumerDmaapModel DmaapModel;
-        public final Boolean ActivationStatus;
+        public final ConsumerDmaapModel dmaapModel;
+        public final Boolean activationStatus;
 
-        public State(final ConsumerDmaapModel DmaapModel, final Boolean ActivationStatus) {
-            this.DmaapModel = DmaapModel;
-            this.ActivationStatus = ActivationStatus;
+        public State(final ConsumerDmaapModel dmaapModel, final Boolean activationStatus) {
+            this.dmaapModel = dmaapModel;
+            this.activationStatus = activationStatus;
         }
     }
 
@@ -169,10 +165,10 @@ public class ScheduledTasks {
 
     private Mono<State> publishToAaiConfiguration(final State state) {
         try {
-            return state.ActivationStatus
+            return state.activationStatus
                     ? Mono.just(state)
                     : aaiProducerTask
-                        .execute(state.DmaapModel)
+                    .execute(state.dmaapModel)
                         .map(x -> state);
         } catch (PrhTaskException | SSLException e) {
             return Mono.error(e);
@@ -180,24 +176,24 @@ public class ScheduledTasks {
     }
 
     private Mono<State> processAdditionalFields(final State state) {
-        if (state.ActivationStatus) {
+        if (state.activationStatus) {
             LOGGER.debug("Re-registration - Logical links won't be updated.");
 
             return Mono.just(state);
         }
 
-        return bbsActionsTask.execute(state.DmaapModel).map(x -> state);
+        return bbsActionsTask.execute(state.dmaapModel).map(x -> state);
     }
 
     private Flux<MessageRouterPublishResponse>
     publishToDmaapConfiguration(final State state) {
         try {
-            if (state.ActivationStatus) {
+            if (state.activationStatus) {
                 LOGGER.debug("Re-registration - Using PNF_UPDATE DMaaP topic.");
-                return dmaapUpdateProducerTask.execute(state.DmaapModel);
+                return dmaapUpdateProducerTask.execute(state.dmaapModel);
             }
 
-            return dmaapReadyProducerTask.execute(state.DmaapModel);
+            return dmaapReadyProducerTask.execute(state.dmaapModel);
         } catch (PrhTaskException e) {
             return Flux.error(e);
         }
diff --git a/prh-app-server/src/test/resources/bbs_action/correct_logical_link.json b/prh-app-server/src/test/resources/bbs_action/correct_logical_link.json
deleted file mode 100644 (file)
index e49a45b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "link-name": "some-link",
-  "link-type": "attachmentPoint",
-  "relationship-list": [
-    {
-      "relationship": {
-        "related-link": "/network/pnfs/pnf/NOKQTFCOC540002E"
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/prh-app-server/src/test/resources/not_json_object.json b/prh-app-server/src/test/resources/not_json_object.json
deleted file mode 100644 (file)
index f50456e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-["a", "d", "d"]
index 17eb600..1abeddf 100644 (file)
@@ -25,6 +25,7 @@ import org.immutables.value.Value;
 
 @Value.Immutable
 @Gson.TypeAdapters(fieldNamingStrategy = true)
+@FunctionalInterface
 public interface Relationship {
 
     @SerializedName(value = "related-link")
index b6e1bad..dcf81c0 100644 (file)
@@ -25,6 +25,7 @@ import org.immutables.value.Value;
 
 @Value.Immutable
 @Gson.TypeAdapters(fieldNamingStrategy = true)
+@FunctionalInterface
 public interface RelationshipWrapper {
 
     @SerializedName(value = "relationship")