Fix sonar issues
[dcaegen2/platform.git] / mod / bpgenerator / onap / src / main / java / org / onap / blueprintgenerator / service / common / StartInputsService.java
index 20c3656..dc7a86e 100644 (file)
@@ -4,6 +4,7 @@
  *  *  org.onap.dcae
  *  *  ================================================================================
  *  *  Copyright (c) 2020  AT&T Intellectual Property. All rights reserved.
+ *  *  Copyright (c) 2021 Nokia. 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.
@@ -38,22 +39,26 @@ import java.util.List;
 
 /**
  * @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Common ONAP Service used by ONAP and DMAAP Blueprint to add Start Inputs Node under Start
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add Start Inputs
+ * Node under Start
  */
-
-
 @Service
 public class StartInputsService {
 
     @Autowired
     private PgaasNodeService pgaasNodeService;
 
-    //Method to create Start Inputs for Start in Interfaces
-    public Map<String, Object> createStartInputs(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec){
-
-        Map<String,Object> response = new HashMap<>();
+    /**
+     * Creates Start Inputs for Start in Interfaces
+     *
+     * @param inputs Inputs
+     * @param onapComponentSpec OnapComponentSpec
+     * @return
+     */
+    public Map<String, Object> createStartInputs(
+        Map<String, Map<String, Object>> inputs, OnapComponentSpec onapComponentSpec) {
+
+        Map<String, Object> response = new HashMap<>();
         StartInputs startInputs = new StartInputs();
 
         int count = 0;
@@ -61,11 +66,13 @@ public class StartInputsService {
         OnapAuxilary aux = onapComponentSpec.getAuxilary();
 
         if (aux.getPorts() != null) {
-            for(Object p : aux.getPorts()) {
+            for (Object p : aux.getPorts()) {
                 String[] ports = p.toString().split(":");
-                portList.add(String.format("concat: [\"%s:\", {get_input: external_port_%d}]" , ports[0], count));
+                portList.add(
+                    String.format("concat: [\"%s:\", {get_input: external_port_%d}]", ports[0],
+                        count));
 
-                LinkedHashMap<String, Object> portType = new LinkedHashMap();
+                Map<String, Object> portType = new LinkedHashMap();
                 portType.put("type", "string");
                 portType.put("default", ports[1]);
                 inputs.put("external_port_" + count, portType);
@@ -75,13 +82,13 @@ public class StartInputsService {
 
         startInputs.setPorts(portList);
 
-        LinkedHashMap<String, Object> envMap = new LinkedHashMap();
-        if(onapComponentSpec.getAuxilary().getDatabases() != null){
-            Map<String, Object> envVars = pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
+        Map<String, Object> envMap = new LinkedHashMap();
+        if (onapComponentSpec.getAuxilary().getDatabases() != null) {
+            Map<String, Object> envVars =
+                pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
             startInputs.setEnvs(envVars);
             envMap.put("default", "&envs {}");
-        }
-        else {
+        } else {
             GetInput env = new GetInput();
             env.setBpInputName("envs");
             startInputs.setEnvs(env);
@@ -93,5 +100,4 @@ public class StartInputsService {
         response.put("inputs", inputs);
         return response;
     }
-
 }