diff options
author | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-04-13 13:16:29 +0000 |
---|---|---|
committer | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-05-04 06:43:16 +0000 |
commit | 1db7e72d979afa03bca38d3008f55246f8d6a6c1 (patch) | |
tree | 547661ba2a459201a5aa810e92dfa2941bff4f69 /profiles/http/src/main | |
parent | 2bb3344c6b3ec9bd77d1491d5beb579bdabc62f2 (diff) |
Migrate to Yamlbeans
Issue-ID: CLI-248
Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com>
Change-Id: I182c7a2e2f41bf09990e5b1ac0344f49af33e0c5
Diffstat (limited to 'profiles/http/src/main')
3 files changed, 8 insertions, 7 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..2bf1eb16 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 @@ -242,7 +242,7 @@ public class OnapHttpCommand extends OnapCommand { this.output = this.authClient.run(this.getInput()); this.getResult().setOutput(output); - if (!this.getSuccessStatusCodes().contains(output.getStatus())) { + if (!this.getSuccessStatusCodes().contains(String.valueOf(output.getStatus()))) { throw new OnapCommandExecutionFailed(this.getName(), output.getBody(), output.getStatus()); } 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 25cf14a3..a2e025a8 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 @@ -30,7 +30,7 @@ import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.http.conf.OnapCommandHttpConstants; import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils; import org.springframework.core.io.Resource; -import org.yaml.snakeyaml.Yaml; +import com.esotericsoftware.yamlbeans.YamlReader; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -38,6 +38,7 @@ import com.github.dreamhead.moco.HttpServer; import com.github.dreamhead.moco.Moco; import com.github.dreamhead.moco.ResponseHandler; import com.github.dreamhead.moco.Runner; +import java.io.InputStreamReader; public class MocoServer { @@ -56,8 +57,8 @@ public class MocoServer { } List<Map<String, ?>> stringMap = null; - try { - stringMap = (List<Map<String, ?>>) new Yaml().load(resource.getInputStream()); + try(InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());) { + stringMap = (List<Map<String, ?>>) new YamlReader(inputStreamReader).read(); } catch (IOException e) { throw new OnapCommandException("Invalid mocking file" + mockFile, e); } @@ -89,7 +90,7 @@ public class MocoServer { if (mocoServerConfigs.containsKey(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON)) { responseHandlers.add(Moco.with(mocoServerConfigs.get(OnapCommandHttpConstants.VERIFY_RESPONSE_JSON).toString())); } - responseHandlers.add(Moco.status((Integer) mocoServerConfigs.get(OnapCommandHttpConstants.VERIFY_RESPONSE_STATUS))); + responseHandlers.add(Moco.status(Integer.parseInt(String.valueOf(mocoServerConfigs.get(OnapCommandHttpConstants.VERIFY_RESPONSE_STATUS))))); server.request(Moco.by(Moco.uri((String) mocoServerConfigs.get(OnapCommandHttpConstants.VERIFY_REQUEST_URI)))) .response(Moco.header(OnapCommandHttpConstants.VERIFY_CONTENT_TYPE, OnapCommandHttpConstants.VERIFY_CONTENT_TYPE_VALUE), 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 c07a6f7f..a01516fb 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 @@ -164,7 +164,7 @@ public class OnapCommandSchemaHttpLoader { for (String key: context.keySet()) { switch (key) { case OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES: - Boolean flag = (Boolean) context.get(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES); + Boolean flag = Boolean.valueOf(context.get(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES).toString()); cmd.getInput().getContext().put(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES, flag.toString()); break; } @@ -351,7 +351,7 @@ public class OnapCommandSchemaHttpLoader { } for (Object successCode : requestSuccessCodes) { - Integer code = (Integer) successCode; + Integer code = Integer.valueOf(String.valueOf(successCode)); if (code < 200 || code >= 300) { if ( code != 404) { errorList.add(OnapCommandHttpConstants.HTTP_SUCCESS_CODE_INVALID); |