aboutsummaryrefslogtreecommitdiffstats
path: root/profiles/http/src/main
diff options
context:
space:
mode:
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>2020-07-01 04:48:14 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-01 04:48:14 +0000
commit022ee4b8daa1b852d72c1083658d1efb254f9dd5 (patch)
tree3acfd05d04321b7684579b0259c2f9303f35868c /profiles/http/src/main
parent29308f5f904e6bfd92204137357fe350d40cf083 (diff)
parent268be523fb1142138a3f710642b5773453841eeb (diff)
Merge "code improvements"
Diffstat (limited to 'profiles/http/src/main')
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java30
4 files changed, 18 insertions, 18 deletions
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java b/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
index 53a2d042..387ec3be 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
@@ -253,7 +253,7 @@ public class OnapHttpCommand extends OnapCommand {
this.resultMap.put(resultMapEntry.getKey(), value);
}
- Map<String, ArrayList<String>> results = OnapCommandHttpUtils.populateOutputs(this.getResultMap(), output);
+ Map<String, List<String>> results = OnapCommandHttpUtils.populateOutputs(this.getResultMap(), output);
//results = OnapCommandUtils.populateOutputsFromInputParameters(results, this.getParametersMap());
for (OnapCommandResultAttribute attr : this.getResult().getRecords()) {
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
index a2e025a8..9c4185b7 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
@@ -43,7 +43,7 @@ import java.io.InputStreamReader;
public class MocoServer {
private Runner runner;
- private Map<String, Object> mocoServerConfigs = new HashMap();
+ private Map<String, Object> mocoServerConfigs = new HashMap<>();
private static Gson gson = new GsonBuilder().serializeNulls().create();
public MocoServer(String mockFile) throws OnapCommandException {
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index df9c84fc..33f58060 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -92,7 +92,7 @@ public class OnapCommandSchemaHttpLoader {
* @throws OnapCommandException
* on error
*/
- public static ArrayList<String> parseHttpSchema(OnapHttpCommand cmd,
+ public static List<String> parseHttpSchema(OnapHttpCommand cmd,
final Map<String, ?> values,
boolean validate) throws OnapCommandException {
ArrayList<String> errorList = new ArrayList<>();
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
index a592ac79..fcd25c24 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
@@ -145,9 +145,9 @@ public class OnapCommandHttpUtils {
* @throws OnapCommandResultMapProcessingFailed
* map processing failed exception
*/
- public static Map<String, ArrayList<String>> populateOutputs(Map<String, String> resultMap, HttpResult resultHttp)
+ public static Map<String, List<String>> populateOutputs(Map<String, String> resultMap, HttpResult resultHttp)
throws OnapCommandException {
- Map<String, ArrayList<String>> resultsProcessed = new HashMap<>();
+ Map<String, List<String>> resultsProcessed = new HashMap<>();
for (Entry<String, String> entry : resultMap.entrySet()) {
String key = entry.getKey();
@@ -161,10 +161,10 @@ public class OnapCommandHttpUtils {
return resultsProcessed;
}
- public static ArrayList<String> replaceLineFromOutputResults(String line, HttpResult resultHttp)
+ public static List<String> replaceLineFromOutputResults(String line, HttpResult resultHttp)
throws OnapCommandHttpHeaderNotFound, OnapCommandHttpInvalidResponseBody,
OnapCommandResultMapProcessingFailed, OnapCommandResultEmpty {
- String headerProcessedLine = "";
+ StringBuilder headerProcessedLine = new StringBuilder();
ArrayList<String> result = new ArrayList<>();
if (!line.contains("$b{") && !line.contains("$h{")) {
@@ -187,7 +187,7 @@ public class OnapCommandHttpUtils {
while (currentIdx < line.length()) {
int idxS = line.indexOf("$h{", currentIdx);
if (idxS == -1) {
- headerProcessedLine += line.substring(currentIdx);
+ headerProcessedLine.append(line.substring(currentIdx));
break;
}
int idxE = line.indexOf("}", idxS);
@@ -198,19 +198,19 @@ public class OnapCommandHttpUtils {
}
String value = resultHttp.getRespHeaders().get(headerName);
- headerProcessedLine += line.substring(currentIdx, idxS) + value;
+ headerProcessedLine.append(line.substring(currentIdx, idxS) + value);
currentIdx = idxE + 1;
}
// Process body jsonpath macros
List<Object> values = new ArrayList<>();
- String bodyProcessedPattern = "";
+ StringBuilder bodyProcessedPattern = new StringBuilder();
currentIdx = 0;
int maxRows = 1; // in normal case, only one row will be there
while (currentIdx < headerProcessedLine.length()) {
int idxS = headerProcessedLine.indexOf("$b{", currentIdx);
if (idxS == -1) {
- bodyProcessedPattern += headerProcessedLine.substring(currentIdx);
+ bodyProcessedPattern.append(headerProcessedLine.substring(currentIdx));
break;
}
int idxE = headerProcessedLine.indexOf("}", idxS);
@@ -233,23 +233,23 @@ public class OnapCommandHttpUtils {
maxRows = arr.size();
}
}
- bodyProcessedPattern += headerProcessedLine.substring(currentIdx, idxS) + "%s";
+ bodyProcessedPattern.append(headerProcessedLine.substring(currentIdx, idxS) + "%s");
values.add(value);
currentIdx = idxE + 1;
}
- if (bodyProcessedPattern.isEmpty()) {
- result.add(headerProcessedLine);
+ if (bodyProcessedPattern.toString().isEmpty()) {
+ result.add(headerProcessedLine.toString());
return result;
} else {
for (int i = 0; i < maxRows; i++) {
currentIdx = 0;
- String bodyProcessedLine = "";
+ StringBuilder bodyProcessedLine = new StringBuilder();
int positionalIdx = 0; // %s positional idx
while (currentIdx < bodyProcessedPattern.length()) {
int idxS = bodyProcessedPattern.indexOf("%s", currentIdx);
if (idxS == -1) {
- bodyProcessedLine += bodyProcessedPattern.substring(currentIdx);
+ bodyProcessedLine.append(bodyProcessedPattern.substring(currentIdx));
break;
}
int idxE = idxS + 2; // %s
@@ -265,7 +265,7 @@ public class OnapCommandHttpUtils {
}
}
- bodyProcessedLine += bodyProcessedPattern.substring(currentIdx, idxS) + valueS;
+ bodyProcessedLine.append(bodyProcessedPattern.substring(currentIdx, idxS) + valueS);
currentIdx = idxE;
positionalIdx++;
} catch (OnapCommandResultEmpty e) {
@@ -274,7 +274,7 @@ public class OnapCommandHttpUtils {
throw new OnapCommandResultMapProcessingFailed(line, e);
}
}
- result.add(bodyProcessedLine);
+ result.add(bodyProcessedLine.toString());
}
return result;