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
}
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();
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);
}
boolean shouldVerify = false;
+ boolean mockingEnabled;
+
public OnapHttpCommand() {
super.addDefaultSchemas(OnapCommandHttpConstants.DEFAULT_PARAMETER_HTTP_FILE_NAME);
}
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();
}
}
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";
}
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