aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2018-11-29 15:56:19 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-29 15:56:19 +0000
commitfb7c89ebe2e682170b09275a5e531d0a49d70ada (patch)
tree14390442d2ca40754b8b3d30d553a7796656937d /tools
parent9f637618ce0b5a4c893e2b6973096b52c6e564b7 (diff)
parentea736d0c60f042d4e6255136da789724ee178193 (diff)
Merge "Fixing issues in apex documents"
Diffstat (limited to 'tools')
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java62
-rw-r--r--tools/tools-common/src/site-docs/adoc/fragments/example-cli-version.adoc4
-rw-r--r--tools/tools-common/src/site-docs/adoc/fragments/example-cli.adoc18
3 files changed, 38 insertions, 46 deletions
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
index 7e02c7af5..4d2e99b23 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
@@ -34,7 +34,6 @@ import org.apache.commons.lang3.Validate;
import org.onap.policy.apex.auth.clicodegen.CodeGenCliEditorBuilder;
import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor;
import org.onap.policy.apex.auth.clicodegen.EventDeclarationBuilder;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -96,7 +95,7 @@ public class Model2Cli {
public Model2Cli(final String modelFile, final OutputFile outFile, final boolean validate, final String appName) {
Validate.notNull(modelFile, "Model2Cli: given model file name was blank");
Validate.notNull(appName, "Model2Cli: given application name was blank");
-
+
this.modelFile = modelFile;
this.outFile = outFile;
this.appName = appName;
@@ -108,7 +107,6 @@ public class Model2Cli {
*
* @return status of the application execution, 0 for success, positive integer for exit condition (such as help or
* version), negative integer for errors
- * @throws ApexException if any problem occurred in the model
*/
public int runApp() {
final CodeGeneratorCliEditor codeGen = new CodeGeneratorCliEditor();
@@ -118,7 +116,7 @@ public class Model2Cli {
final ApexApiResult result = model.loadFromFile(modelFile);
if (result.isNok()) {
- String message = appName + ": " + result.getMessage();
+ final String message = appName + ": " + result.getMessage();
LOGGER.error(message);
return -1;
}
@@ -130,7 +128,7 @@ public class Model2Cli {
final AxValidationResult val = new AxValidationResult();
policyModel.validate(val);
if (!val.isOk()) {
- String message = "Cannot translate the model. The model is not valid: \n" + val.toString();
+ final String message = "Cannot translate the model. The model is not valid: \n" + val.toString();
LOGGER.error(message);
return -1;
}
@@ -141,6 +139,7 @@ public class Model2Cli {
/**
* Generate the CLI from the model.
+ *
* @param codeGen the code generator
* @param policyModel the policy model
*/
@@ -157,7 +156,7 @@ public class Model2Cli {
final AxArtifactKey key = s.getKey();
codeGen.addSchemaDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- s.getSchemaFlavour(), s.getSchema());
+ s.getSchemaFlavour(), s.getSchema());
}
// 2: tasks
@@ -170,7 +169,7 @@ public class Model2Cli {
final List<ST> contextRefs = getCtxtRefsForTask(codeGen, t);
codeGen.addTaskDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- infields, outfields, logic, parameters, contextRefs);
+ infields, outfields, logic, parameters, contextRefs);
}
// 3: events
@@ -194,16 +193,10 @@ public class Model2Cli {
for (final AxContextAlbum a : policyModel.getAlbums().getAlbumsMap().values()) {
final AxArtifactKey key = a.getKey();
- codeGen.addContextAlbumDeclaration(
- new CodeGenCliEditorBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setScope(a.getScope())
- .setWritable(a.isWritable())
- .setSchemaName(kig.getName(a.getItemSchema()))
- .setSchemaVersion(kig.getVersion(a.getItemSchema())));
+ codeGen.addContextAlbumDeclaration(new CodeGenCliEditorBuilder().setName(kig.getName(key))
+ .setVersion(kig.getVersion(key)).setUuid(kig.getUuid(key)).setDescription(kig.getDesc(key))
+ .setScope(a.getScope()).setWritable(a.isWritable()).setSchemaName(kig.getName(a.getItemSchema()))
+ .setSchemaVersion(kig.getVersion(a.getItemSchema())));
}
// 5: policies
@@ -211,12 +204,12 @@ public class Model2Cli {
final AxArtifactKey key = p.getKey();
final List<ST> states = getStatesForPolicy(codeGen, p);
codeGen.addPolicyDefinition(kig.getName(key), kig.getVersion(key), kig.getUuid(key), kig.getDesc(key),
- p.getTemplate(), p.getFirstState(), states);
+ p.getTemplate(), p.getFirstState(), states);
}
final String out = codeGen.getModel().render();
if (outFile != null) {
- String message = "Error writing output to file " + outFile;
+ final String message = "Error writing output to file " + outFile;
try {
final Writer w = outFile.toWriter();
if (w == null) {
@@ -232,7 +225,7 @@ public class Model2Cli {
} else {
LOGGER.error(out);
}
-
+
return 0;
}
@@ -250,7 +243,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createEventFieldDefinition(kig.getPName(fkey), kig.getPVersion(fkey), kig.getLName(fkey),
- kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
+ kig.getName(f.getSchema()), kig.getVersion(f.getSchema()), f.getOptional());
ret.add(val);
}
@@ -271,7 +264,7 @@ public class Model2Cli {
for (final AxArtifactKey ckey : ctxs) {
final ST val = cg.createTaskDefinitionContextRef(kig.getName(tkey), kig.getVersion(tkey), kig.getName(ckey),
- kig.getVersion(ckey));
+ kig.getVersion(ckey));
ret.add(val);
}
@@ -292,7 +285,7 @@ public class Model2Cli {
final AxReferenceKey pkey = p.getKey();
final ST val = cg.createTaskDefinitionParameters(kig.getPName(pkey), kig.getPVersion(pkey),
- kig.getLName(pkey), p.getTaskParameterValue());
+ kig.getLName(pkey), p.getTaskParameterValue());
ret.add(val);
}
@@ -327,7 +320,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createTaskDefinitionOutfields(kig.getPName(fkey), kig.getPVersion(fkey),
- kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
+ kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
ret.add(val);
}
@@ -348,7 +341,7 @@ public class Model2Cli {
final AxReferenceKey fkey = f.getKey();
final ST val = cg.createTaskDefinitionInfields(kig.getPName(fkey), kig.getPVersion(fkey),
- kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
+ kig.getLName(fkey), kig.getName(f.getSchema()), kig.getVersion(f.getSchema()));
ret.add(val);
}
@@ -374,9 +367,8 @@ public class Model2Cli {
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
final ST val = cg.createPolicyStateDef(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()),
- kig.getName(st.getDefaultTask()), kig.getVersion(st.getDefaultTask()), outputs, tasks,
- tsLogic, finalizerLogics, ctxRefs);
+ kig.getName(st.getTrigger()), kig.getVersion(st.getTrigger()), kig.getName(st.getDefaultTask()),
+ kig.getVersion(st.getDefaultTask()), outputs, tasks, tsLogic, finalizerLogics, ctxRefs);
ret.add(val);
}
@@ -398,7 +390,7 @@ public class Model2Cli {
final AxReferenceKey finkey = fin.getKey();
final ST val = cg.createPolicyStateDefFinalizerLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
+ kig.getLName(skey), kig.getLName(finkey), fin.getLogicFlavour(), fin.getLogic());
ret.add(val);
}
@@ -419,7 +411,7 @@ public class Model2Cli {
for (final AxArtifactKey ctx : ctxs) {
final ST val = cg.createPolicyStateDefContextRef(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
+ kig.getLName(skey), kig.getName(ctx), kig.getVersion(ctx));
ret.add(val);
}
@@ -438,7 +430,7 @@ public class Model2Cli {
if (st.checkSetTaskSelectionLogic()) {
final AxTaskSelectionLogic tsl = st.getTaskSelectionLogic();
final ST val = cg.createPolicyStateDefTaskSelLogic(kig.getPName(skey), kig.getPVersion(skey),
- kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
+ kig.getLName(skey), tsl.getLogicFlavour(), tsl.getLogic());
return Collections.singletonList(val);
} else {
return Collections.emptyList();
@@ -462,8 +454,8 @@ public class Model2Cli {
final AxReferenceKey trkey = tr.getKey();
final ST val = cg.createPolicyStateTask(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey),
- tr.getStateTaskOutputType().name(), kig.getLName(tr.getOutput()));
+ kig.getLName(trkey), kig.getName(tkey), kig.getVersion(tkey), tr.getStateTaskOutputType().name(),
+ kig.getLName(tr.getOutput()));
ret.add(val);
}
@@ -485,8 +477,8 @@ public class Model2Cli {
final AxReferenceKey outkey = out.getKey();
final ST val = cg.createPolicyStateOutput(kig.getPName(skey), kig.getPVersion(skey), kig.getLName(skey),
- kig.getLName(outkey), kig.getName(out.getOutgingEvent()),
- kig.getVersion(out.getOutgingEvent()), kig.getLName(out.getNextState()));
+ kig.getLName(outkey), kig.getName(out.getOutgingEvent()), kig.getVersion(out.getOutgingEvent()),
+ kig.getLName(out.getNextState()));
ret.add(val);
}
diff --git a/tools/tools-common/src/site-docs/adoc/fragments/example-cli-version.adoc b/tools/tools-common/src/site-docs/adoc/fragments/example-cli-version.adoc
index 031a3776d..178799c44 100644
--- a/tools/tools-common/src/site-docs/adoc/fragments/example-cli-version.adoc
+++ b/tools/tools-common/src/site-docs/adoc/fragments/example-cli-version.adoc
@@ -22,14 +22,14 @@ First, create a new CLI Parser object, add some options (in the example an optio
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersion.java[tags=setupParser,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java[tags=setupParser,indent=0]
----
Next, we check if the version option was used in the command line and print application name and version if it was used:
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersion.java[tags=processCliVersion,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleAppVersionTest.java[tags=processCliVersion,indent=0]
----
The output will be:
diff --git a/tools/tools-common/src/site-docs/adoc/fragments/example-cli.adoc b/tools/tools-common/src/site-docs/adoc/fragments/example-cli.adoc
index 32a0e957b..d2edc446d 100644
--- a/tools/tools-common/src/site-docs/adoc/fragments/example-cli.adoc
+++ b/tools/tools-common/src/site-docs/adoc/fragments/example-cli.adoc
@@ -34,7 +34,7 @@ Manually importing means to add the following lines to the start of your applica
[source,java, linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=import,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=import,indent=0]
----
Now, inside your `main()` method, start setting some general application properties.
@@ -43,7 +43,7 @@ For instance:
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=setApp,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=setApp,indent=0]
----
Next, create a new CLI Parser and add a few CLI options from the standard `CliOptions`.
@@ -51,14 +51,14 @@ The following example adds options for help, version, and a model file:
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=setCli,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=setCli,indent=0]
----
Next, parse the given CLI arguments:
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=parseCli,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=parseCli,indent=0]
----
Once the command line is parsed, we can look into the individual options, check if they are set, and then act accordingly.
@@ -67,7 +67,7 @@ If the option is present, we print a help screen and return:
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=processCliHelp,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=processCliHelp,indent=0]
----
Next, we process the option for __version__.
@@ -76,7 +76,7 @@ The CLI Parser already provides a method to obtain the correct version for an AP
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=processCliVersion,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=processCliVersion,indent=0]
----
Once help and version arguments are processed, we can proceed to look at all other options.
@@ -86,7 +86,7 @@ If we cannot load a model, we print an error and return.
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=processCliModel,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=processCliModel,indent=0]
----
With a model file being loadable, we finish parsing command line arguments.
@@ -94,7 +94,7 @@ We also print some status messages to note that the application now is ready to
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=someStartPrint,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=someStartPrint,indent=0]
----
The last action now is to run the actual application.
@@ -102,7 +102,7 @@ The example below is taken from a version of the `Model2Cli` application, which
[source,java,linenums,subs="attributes+"]
----
-include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParser.java[tags=yourApp,indent=0]
+include::{adsite-tools-common-dir}/test/java/org/onap/policy/apex/tools/common/docs/ExampleCliParserTest.java[tags=yourApp,indent=0]
----
If this new application is now called with the command line `-h` or `--help` it will print the following help screen: