aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2017-10-23 14:03:11 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2017-10-26 09:27:02 +0000
commitb0d8aa12fe8f88059f7fcce741913194d72d0d69 (patch)
tree309becc99aaa133a9945f84213e21c81f5af7099 /main/src
parentf3d888a58d5775f015b8c2b1864cde2856dd0376 (diff)
Code refactoring to remove test code generation
Refactor code to remove test code generation code from framework codebase. Issue-ID: CLI-55 Change-Id: I4b45ef50143317586c39cf118a1717be150707da Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java19
1 files changed, 19 insertions, 0 deletions
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 35df0e37..0ed27ea1 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -25,8 +25,10 @@ import org.apache.commons.io.IOUtils;
import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandRegistrar;
import org.onap.cli.fw.conf.Constants;
+import org.onap.cli.fw.conf.OnapCommandConfg;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandHelpFailed;
+import org.onap.cli.fw.error.OnapCommandInvalidSample;
import org.onap.cli.fw.error.OnapCommandWarning;
import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.output.OnapCommandResult;
@@ -37,6 +39,7 @@ import org.onap.cli.fw.output.ResultType;
import org.onap.cli.main.conf.OnapCliConstants;
import org.onap.cli.main.interactive.StringCompleter;
import org.onap.cli.main.utils.OnapCliUtils;
+import org.onap.cli.sample.yaml.SampleYamlGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -355,9 +358,12 @@ public class OnapCli {
OnapCliUtils.populateParams(cmd.getParameters(), args);
OnapCommandResult result = cmd.execute();
+
this.print(result.getDebugInfo());
this.print(result.print());
this.exitSuccessfully();
+
+ generateSmapleYaml(result);
} catch (Exception e) {
this.print(cmd.getResult().getDebugInfo());
if (e instanceof OnapCommandWarning) {
@@ -370,6 +376,19 @@ public class OnapCli {
}
}
+ private void generateSmapleYaml(OnapCommandResult result) throws OnapCommandException {
+ if (OnapCommandConfg.isSampleGenerateEnabled() && this.getExitCode() == OnapCliConstants.EXIT_SUCCESS) {
+ try {
+ SampleYamlGenerator.generateSampleYaml(args, result.print(),
+ OnapCommandRegistrar.getRegistrar().getEnabledProductVersion(),
+ OnapCommandConfg.getSampleGenerateTargetFolder(),
+ result.isDebug());
+ } catch (IOException error) {
+ throw new OnapCommandInvalidSample(args.get(0), error);
+ }
+ }
+ }
+
/**
* Handles all client input.
*/