aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>2018-03-26 06:49:35 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-26 06:49:35 +0000
commitc8114fe928e3a6c48ea02fa8e2a168f7102f770b (patch)
tree44bdeb88ee7642eda8077afefcfd4bbbb98d3f22
parent5c094b10096c629804b9e266d05b74e90512ad8b (diff)
parent8c08476d0b6bffa3230a0e34ff29586eefed38e0 (diff)
Merge "Enable feature to disable mock for verify"
-rw-r--r--framework/src/main/resources/open-cli-schema/default_input_parameters.yaml2
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java13
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java16
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/conf/OnapCommandHttpConstants.java1
-rw-r--r--profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml2
5 files changed, 28 insertions, 6 deletions
diff --git a/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml b/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
index 652401e3..d6a360cd 100644
--- a/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
+++ b/framework/src/main/resources/open-cli-schema/default_input_parameters.yaml
@@ -45,7 +45,7 @@ parameters:
is_default_param: true
- name: verify
type: bool
- description: verify the command using available command sample file and mocking file
+ description: verify the command using available command sample file and mocking file. By default it goes with mock style. To enable the verification in real time, set DISABLE_MOCKING=true in the context param.
short_option: V
long_option: verify
default_value: false
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index 3ba75711..e7fddcd5 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -219,6 +219,13 @@ public class OnapCli {
}
public void verifyCommand(OnapCommand cmd) throws OnapCommandException {
+
+ OnapCliArgsParser.populateParams(cmd.getParameters(), args);
+
+ Optional<OnapCommandParameter> contextOptArg = cmd.getParameters().stream()
+ .filter(e -> e.getName().equals(OnapCommandConstants.VERIFY_CONTEXT_PARAM))
+ .findFirst();
+
List<Map<String, ?>> testSuite = OnapCommandRegistrar.getRegistrar().getTestSuite(cmd.getName());
OnapCommandResult testSuiteResult = new OnapCommandResult();
@@ -254,6 +261,12 @@ public class OnapCli {
if (contextOpt.isPresent()) {
HashMap map = new HashMap();
map.put(OnapCommandConstants.VERIFY_MOCO, sampleTest.get(OnapCommandConstants.VERIFY_MOCO));
+
+ if (contextOptArg.isPresent()) {
+ OnapCommandParameter contextArg = contextOptArg.get();
+ map.putAll((Map) contextArg.getValue());
+ }
+
contextOpt.get().setValue(map);
}
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 9477cfa9..6574552e 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
@@ -68,6 +68,8 @@ public class OnapHttpCommand extends OnapCommand {
boolean shouldVerify = false;
+ boolean mockingEnabled;
+
public OnapHttpCommand() {
super.addDefaultSchemas(OnapCommandHttpConstants.DEFAULT_PARAMETER_HTTP_FILE_NAME);
}
@@ -176,17 +178,23 @@ public class OnapHttpCommand extends OnapCommand {
if (contextOpt.isPresent()) {
OnapCommandParameter context = contextOpt.get();
- String mockedFile = ((Map<String, String>)context.getValue()).get(OnapCommandConstants.VERIFY_MOCO);
+ Map<String, String> map = (Map<String, String>) context.getValue();
+
+ mockingEnabled = map.containsKey(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING)
+ && map.get(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING).equals("true") ? false : true;
- mocoServer = new MocoServer(mockedFile);
- mocoServer.start();
+ if (mockingEnabled) {
+ String mockedFile = ((Map<String, String>) context.getValue()).get(OnapCommandConstants.VERIFY_MOCO);
+ mocoServer = new MocoServer(mockedFile);
+ mocoServer.start();
+ }
}
}
}
@Override
protected void postRun() throws OnapCommandException {
- if (shouldVerify) {
+ if (shouldVerify && mockingEnabled) {
mocoServer.stop();
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/conf/OnapCommandHttpConstants.java b/profiles/http/src/main/java/org/onap/cli/fw/http/conf/OnapCommandHttpConstants.java
index 185582cb..18dde339 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/conf/OnapCommandHttpConstants.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/conf/OnapCommandHttpConstants.java
@@ -108,6 +108,7 @@ public class OnapCommandHttpConstants {
public static final String VERIFY_RESPONSE = "response";
public static final String VERIFY_CONTENT_TYPE = "Content-Type";
public static final String VERIFY_CONTENT_TYPE_VALUE = APPLICATION_JSON;
+ public static final String VERIFY_DISABLE_MOCKING = "DISABLE_MOCKING";
}
diff --git a/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml b/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
index 6ac0ded2..01a4e3fb 100644
--- a/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
+++ b/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
@@ -43,7 +43,7 @@ parameters:
default_value: false
- name: verify
type: bool
- description: verify the command using available command sample file and mocking file
+ description: verify the command using available command sample file and mocking file. By default it goes with mock style. To enable the verification in real time, set DISABLE_MOCKING=true in the context param.
default_value: false
is_include: true
is_optional: true \ No newline at end of file