summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 15:25:32 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 15:26:47 +0100
commit4cfa2e2d98f6877d54da304ef17f096284430908 (patch)
treec9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /auth
parent0e23f7634e1e1fb31454c516974613335fcea1a4 (diff)
Sonar/Checkstyle in service/plugins
Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'auth')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java (renamed from auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java)4
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java (renamed from auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestSTG.java)12
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java)57
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java60
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java)12
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java)8
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java)22
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommands.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java)6
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java)111
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineException.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java)6
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameterParser.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java)72
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java)27
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java (renamed from auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java)10
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java12
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorEventsContext.java (renamed from auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java)54
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorOptions.java (renamed from auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java)18
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorScripting.java (renamed from auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorScripting.java)30
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java18
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java18
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java32
20 files changed, 318 insertions, 271 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
index 30e883aae..75ac1fe03 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CGCliEditor.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
@@ -84,7 +84,7 @@ import org.stringtemplate.v4.STGroupFile;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class CGCliEditor {
+public class CodeGeneratorCliEditor {
// CHECKSTYLE:OFF: ParameterNumber
@@ -103,7 +103,7 @@ public class CGCliEditor {
/**
* Creates a new code generator.
*/
- public CGCliEditor() {
+ public CodeGeneratorCliEditor() {
stg = new STGroupFile(STG_FILE);
stg.registerRenderer(String.class, new CgStringRenderer(), true);
model = stg.getInstanceOf("policyModel");
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestSTG.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java
index 1fbc78de9..851c06631 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestSTG.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/TestGeneration.java
@@ -30,7 +30,7 @@ import java.util.Set;
import java.util.TreeSet;
import org.junit.Test;
-import org.onap.policy.apex.auth.clicodegen.CGCliEditor;
+import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile;
@@ -39,7 +39,7 @@ import org.stringtemplate.v4.STGroupFile;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class TestSTG {
+public class TestGeneration {
/**
* Get the chunks for the codegen.
@@ -89,9 +89,9 @@ public class TestSTG {
/** Test STG load. */
@Test
- public void testSTGLoad() {
+ public void testGenerationLoad() {
final StErrorListener errListener = new StErrorListener();
- final STGroupFile stg = new STGroupFile(CGCliEditor.STG_FILE);
+ final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE);
stg.setListener(errListener);
stg.getTemplateNames(); // dummy to compile group and get errors
@@ -100,9 +100,9 @@ public class TestSTG {
/** Test STG chunks. */
@Test
- public void testSTGChunks() {
+ public void testGenerationChunks() {
final StErrorListener errListener = new StErrorListener();
- final STGroupFile stg = new STGroupFile(CGCliEditor.STG_FILE);
+ final STGroupFile stg = new STGroupFile(CodeGeneratorCliEditor.STG_FILE);
stg.setListener(errListener);
stg.getTemplateNames(); // dummy to compile group and get errors
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java
index 718c75a96..0df8ac629 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java
@@ -34,15 +34,15 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexCLIEditorMain {
+public class ApexCommandLineEditorMain {
// Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexCLIEditorMain.class);
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexCommandLineEditorMain.class);
// The editor parameters
- private CLIParameters parameters;
+ private CommandLineParameters parameters;
// The CLI commands read in from JSON
- private CLICommands commands;
+ private CommandLineCommands commands;
// The Apex model properties read in from JSON
private ApexModelProperties apexModelProperties;
@@ -55,15 +55,16 @@ public class ApexCLIEditorMain {
*
* @param args the command line arguments
*/
- public ApexCLIEditorMain(final String[] args) {
- LOGGER.info("Starting Apex CLI editor {} . . .", Arrays.toString(args));
+ public ApexCommandLineEditorMain(final String[] args) {
+ String startMessage = "Starting Apex CLI editor " + Arrays.toString(args) + " . . .";
+ LOGGER.info(startMessage);
try {
- final CLIParameterParser parser = new CLIParameterParser();
+ final CommandLineParameterParser parser = new CommandLineParameterParser();
parameters = parser.parse(args);
if (parameters.isHelpSet()) {
- parser.help(ApexCLIEditorMain.class.getCanonicalName());
+ parser.help(ApexCommandLineEditorMain.class.getCanonicalName());
return;
}
parameters.validate();
@@ -73,14 +74,16 @@ public class ApexCLIEditorMain {
return;
}
- LOGGER.debug("parameters are: {}", parameters.toString());
+ String message = "parameters are: " + parameters.toString();
+ LOGGER.debug(message);
// Read the command definitions
try {
- commands = new JsonHandler<CLICommands>().read(CLICommands.class, parameters.getMetadataStream());
+ commands = new JsonHandler<CommandLineCommands>().read(CommandLineCommands.class,
+ parameters.getMetadataStream());
} catch (final Exception e) {
LOGGER.error("start of Apex command line editor failed, error reading command metadata from {}",
- parameters.getMetadataLocation(), e);
+ parameters.getMetadataLocation(), e);
errorCount++;
return;
}
@@ -88,7 +91,7 @@ public class ApexCLIEditorMain {
// The JSON processing returns null if there is an empty file
if (commands == null || commands.getCommandSet().isEmpty()) {
LOGGER.error("start of Apex command line editor failed, no commands found in {}",
- parameters.getApexPropertiesLocation());
+ parameters.getApexPropertiesLocation());
errorCount++;
return;
}
@@ -98,10 +101,10 @@ public class ApexCLIEditorMain {
// Read the Apex properties
try {
apexModelProperties = new JsonHandler<ApexModelProperties>().read(ApexModelProperties.class,
- parameters.getApexPropertiesStream());
+ parameters.getApexPropertiesStream());
} catch (final Exception e) {
LOGGER.error("start of Apex command line editor failed, error reading Apex model properties from "
- + parameters.getApexPropertiesLocation());
+ + parameters.getApexPropertiesLocation());
LOGGER.error(e.getMessage());
errorCount++;
return;
@@ -110,16 +113,17 @@ public class ApexCLIEditorMain {
// The JSON processing returns null if there is an empty file
if (apexModelProperties == null) {
LOGGER.error("start of Apex command line editor failed, no Apex model properties found in {}",
- parameters.getApexPropertiesLocation());
+ parameters.getApexPropertiesLocation());
errorCount++;
return;
}
- LOGGER.debug("model properties are: {}", apexModelProperties.toString());
+ String modelPropertiesString = "model properties are: " + apexModelProperties.toString();
+ LOGGER.debug(modelPropertiesString);
// Find the system commands
final Set<KeywordNode> systemCommandNodes = new TreeSet<>();
- for (final CLICommand command : commands.getCommandSet()) {
+ for (final CommandLineCommand command : commands.getCommandSet()) {
if (command.isSystemCommand()) {
systemCommandNodes.add(new KeywordNode(command.getName(), command));
}
@@ -127,7 +131,7 @@ public class ApexCLIEditorMain {
// Read in the command hierarchy, this builds a tree of commands
final KeywordNode rootKeywordNode = new KeywordNode("root");
- for (final CLICommand command : commands.getCommandSet()) {
+ for (final CommandLineCommand command : commands.getCommandSet()) {
rootKeywordNode.processKeywords(command.getKeywordlist(), command);
}
rootKeywordNode.addSystemCommandNodes(systemCommandNodes);
@@ -135,25 +139,25 @@ public class ApexCLIEditorMain {
// Create the model we will work towards
ApexModelHandler modelHandler = null;
try {
- modelHandler =
- new ApexModelHandler(apexModelProperties.getProperties(), parameters.getInputModelFileName());
+ modelHandler = new ApexModelHandler(apexModelProperties.getProperties(),
+ parameters.getInputModelFileName());
} catch (final Exception e) {
LOGGER.error("execution of Apex command line editor failed: ", e);
errorCount++;
return;
}
- final CLIEditorLoop cliEditorLoop =
- new CLIEditorLoop(apexModelProperties.getProperties(), modelHandler, rootKeywordNode);
+ final CommandLineEditorLoop cliEditorLoop = new CommandLineEditorLoop(apexModelProperties.getProperties(),
+ modelHandler, rootKeywordNode);
try {
- errorCount =
- cliEditorLoop.runLoop(parameters.getCommandInputStream(), parameters.getOutputStream(), parameters);
+ errorCount = cliEditorLoop.runLoop(parameters.getCommandInputStream(), parameters.getOutputStream(),
+ parameters);
if (errorCount == 0) {
LOGGER.info("Apex CLI editor completed execution");
} else {
LOGGER.error("execution of Apex command line editor failed: {} command execution failure(s) occurred",
- errorCount);
+ errorCount);
}
} catch (final IOException e) {
LOGGER.error("execution of Apex command line editor failed: " + e.getMessage());
@@ -178,14 +182,13 @@ public class ApexCLIEditorMain {
this.errorCount = errorCount;
}
-
/**
* The main method, kicks off the editor.
*
* @param args the arguments
*/
public static void main(final String[] args) {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(args);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(args);
// Only call system.exit on errors as it brings the JVM down
if (cliEditor.getErrorCount() > 0) {
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
index 2cf2633b2..2e1a4732b 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelHandler.java
@@ -24,7 +24,7 @@ import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;
-import java.util.TreeMap;
+import java.util.SortedMap;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexModel;
@@ -64,7 +64,7 @@ public class ApexModelHandler {
final ApexApiResult result = apexModel.loadFromFile(modelFileName);
if (result.isNok()) {
- throw new CLIException(result.getMessages().get(0));
+ throw new CommandLineException(result.getMessages().get(0));
}
}
@@ -76,8 +76,8 @@ public class ApexModelHandler {
* @param writer A writer to which to write output
* @return the result of the executed command
*/
- public ApexApiResult executeCommand(final CLICommand command,
- final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) {
+ public ApexApiResult executeCommand(final CommandLineCommand command,
+ final SortedMap<String, CommandLineArgumentValue> argumentValues, final PrintWriter writer) {
// Get the method
final Method apiMethod = getCommandMethod(command);
@@ -92,22 +92,22 @@ public class ApexModelHandler {
writer.println(result);
return result;
} else {
- throw new CLIException(
- INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\" the returned object is not an instance of ApexAPIResult");
+ throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod()
+ + FAILED_FOR_COMMAND + command.getName()
+ + "\" the returned object is not an instance of ApexAPIResult");
}
} catch (IllegalAccessException | IllegalArgumentException e) {
writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"");
+ + command.getName() + "\"");
e.printStackTrace(writer);
- throw new CLIException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod()
- + FAILED_FOR_COMMAND + command.getName() + "\"", e);
+ throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
+ + command.getName() + "\"", e);
} catch (final InvocationTargetException e) {
writer.println(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
- + command.getName() + "\"");
+ + command.getName() + "\"");
e.getCause().printStackTrace(writer);
- throw new CLIException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod()
- + FAILED_FOR_COMMAND + command.getName() + "\"", e);
+ throw new CommandLineException(INVOCATION_OF_SPECIFIED_METHOD + command.getApiMethod() + FAILED_FOR_COMMAND
+ + command.getName() + "\"", e);
}
}
@@ -117,9 +117,9 @@ public class ApexModelHandler {
* @param command The command
* @return the API method
*/
- private Method getCommandMethod(final CLICommand command) {
- final String className = command.getAPIClassName();
- final String methodName = command.getAPIMethodName();
+ private Method getCommandMethod(final CommandLineCommand command) {
+ final String className = command.getApiClassName();
+ final String methodName = command.getApiMethodName();
try {
final Class<? extends Object> apiClass = Class.forName(className);
@@ -128,11 +128,11 @@ public class ApexModelHandler {
return apiMethod;
}
}
- throw new CLIException("specified method \"" + command.getApiMethod() + "\" not found for command \""
- + command.getName() + "\"");
+ throw new CommandLineException("specified method \"" + command.getApiMethod()
+ + "\" not found for command \"" + command.getName() + "\"");
} catch (final ClassNotFoundException e) {
- throw new CLIException("specified class \"" + command.getApiMethod() + "\" not found for command \""
- + command.getName() + "\"");
+ throw new CommandLineException("specified class \"" + command.getApiMethod() + "\" not found for command \""
+ + command.getName() + "\"");
}
}
@@ -144,26 +144,26 @@ public class ApexModelHandler {
* @param apiMethod the method itself
* @return the argument list
*/
- private Object[] getParameterArray(final CLICommand command, final TreeMap<String, CLIArgumentValue> argumentValues,
- final Method apiMethod) {
+ private Object[] getParameterArray(final CommandLineCommand command,
+ final SortedMap<String, CommandLineArgumentValue> argumentValues, final Method apiMethod) {
final Object[] parameterArray = new Object[argumentValues.size()];
- int i = 0;
+ int item = 0;
try {
for (final Class<?> parametertype : apiMethod.getParameterTypes()) {
- final String parameterValue =
- argumentValues.get(command.getArgumentList().get(i).getArgumentName()).getValue();
+ final String parameterValue = argumentValues.get(command.getArgumentList().get(item).getArgumentName())
+ .getValue();
if (parametertype.equals(boolean.class)) {
- parameterArray[i] = Boolean.valueOf(parameterValue);
+ parameterArray[item] = Boolean.valueOf(parameterValue);
} else {
- parameterArray[i] = parameterValue;
+ parameterArray[item] = parameterValue;
}
- i++;
+ item++;
}
} catch (final Exception e) {
- throw new CLIException("number of argument mismatch on method \"" + command.getApiMethod()
- + "\" for command \"" + command.getName() + "\"");
+ throw new CommandLineException("number of argument mismatch on method \"" + command.getApiMethod()
+ + "\" for command \"" + command.getName() + "\"");
}
return parameterArray;
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java
index b215f69e4..f1a6e7867 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgument.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java
@@ -27,7 +27,7 @@ import org.onap.policy.apex.model.utilities.Assertions;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIArgument implements Comparable<CLIArgument> {
+public class CommandLineArgument implements Comparable<CommandLineArgument> {
private final String argumentName;
private final boolean nullable;
private final String description;
@@ -36,7 +36,7 @@ public class CLIArgument implements Comparable<CLIArgument> {
* This Constructor constructs a non nullable command line argument with a blank name and
* description.
*/
- public CLIArgument() {
+ public CommandLineArgument() {
this("", false, "");
}
@@ -46,7 +46,7 @@ public class CLIArgument implements Comparable<CLIArgument> {
*
* @param incomingArgumentName the argument name
*/
- public CLIArgument(final String incomingArgumentName) {
+ public CommandLineArgument(final String incomingArgumentName) {
this(incomingArgumentName, false, "");
}
@@ -58,7 +58,7 @@ public class CLIArgument implements Comparable<CLIArgument> {
* @param nullable the nullable
* @param description the description
*/
- public CLIArgument(final String argumentName, final boolean nullable, final String description) {
+ public CommandLineArgument(final String argumentName, final boolean nullable, final String description) {
this.argumentName = argumentName;
this.nullable = nullable;
this.description = description;
@@ -121,7 +121,7 @@ public class CLIArgument implements Comparable<CLIArgument> {
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo(final CLIArgument otherArgument) {
+ public int compareTo(final CommandLineArgument otherArgument) {
Assertions.argumentNotNull(otherArgument, "comparison object may not be null");
if (this == otherArgument) {
@@ -131,7 +131,7 @@ public class CLIArgument implements Comparable<CLIArgument> {
return this.hashCode() - otherArgument.hashCode();
}
- final CLIArgument other = otherArgument;
+ final CommandLineArgument other = otherArgument;
if (!argumentName.equals(other.argumentName)) {
return argumentName.compareTo(other.argumentName);
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java
index d87a8dc5b..64059e31b 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIArgumentValue.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java
@@ -25,8 +25,8 @@ package org.onap.policy.apex.auth.clieditor;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIArgumentValue {
- private final CLIArgument cliArgument;
+public class CommandLineArgumentValue {
+ private final CommandLineArgument cliArgument;
private boolean specified;
private String value;
@@ -36,7 +36,7 @@ public class CLIArgumentValue {
*
* @param cliArgument the argument for which this object is a value
*/
- public CLIArgumentValue(final CLIArgument cliArgument) {
+ public CommandLineArgumentValue(final CommandLineArgument cliArgument) {
this.cliArgument = cliArgument;
specified = false;
value = null;
@@ -47,7 +47,7 @@ public class CLIArgumentValue {
*
* @return the argument for which this object is a value
*/
- public CLIArgument getCliArgument() {
+ public CommandLineArgument getCliArgument() {
return cliArgument;
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java
index 40c0a40a5..6c651cb6b 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommand.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java
@@ -31,10 +31,10 @@ import org.onap.policy.apex.model.utilities.Assertions;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLICommand implements Comparable<CLICommand> {
+public class CommandLineCommand implements Comparable<CommandLineCommand> {
private String name = "";
private final List<String> keywordlist = new ArrayList<>();
- private final List<CLIArgument> argumentList = new ArrayList<>();
+ private final List<CommandLineArgument> argumentList = new ArrayList<>();
private String apiMethod = "";
private boolean systemCommand = false;
private String description = "";
@@ -44,10 +44,10 @@ public class CLICommand implements Comparable<CLICommand> {
*
* @return the class name of the class that executes this command in the Java API
*/
- public String getAPIClassName() {
+ public String getApiClassName() {
final int lastDotPos = apiMethod.lastIndexOf('.');
if (lastDotPos == -1) {
- throw new CLIException("invalid API method name specified on command \"" + name
+ throw new CommandLineException("invalid API method name specified on command \"" + name
+ "\", class name not found: " + apiMethod);
}
return apiMethod.substring(0, lastDotPos);
@@ -58,14 +58,14 @@ public class CLICommand implements Comparable<CLICommand> {
*
* @return the the method name of the method that executes this command in the Java API
*/
- public String getAPIMethodName() {
+ public String getApiMethodName() {
final int lastDotPos = apiMethod.lastIndexOf('.');
if (lastDotPos == -1) {
- throw new CLIException("invalid API method name specified on command \"" + name
+ throw new CommandLineException("invalid API method name specified on command \"" + name
+ "\", class name not found: " + apiMethod);
}
if (lastDotPos == apiMethod.length() - 1) {
- throw new CLIException("no API method name specified on command \"" + name + "\": " + apiMethod);
+ throw new CommandLineException("no API method name specified on command \"" + name + "\": " + apiMethod);
}
return apiMethod.substring(lastDotPos + 1);
}
@@ -102,7 +102,7 @@ public class CLICommand implements Comparable<CLICommand> {
*
* @return the list of arguments for this command
*/
- public List<CLIArgument> getArgumentList() {
+ public List<CommandLineArgument> getArgumentList() {
return argumentList;
}
@@ -176,7 +176,7 @@ public class CLICommand implements Comparable<CLICommand> {
builder.append("}: ");
builder.append(description);
- for (final CLIArgument argument : argumentList) {
+ for (final CommandLineArgument argument : argumentList) {
if (argument == null) {
continue;
}
@@ -204,7 +204,7 @@ public class CLICommand implements Comparable<CLICommand> {
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo(final CLICommand otherCommand) {
+ public int compareTo(final CommandLineCommand otherCommand) {
Assertions.argumentNotNull(otherCommand, "comparison object may not be null");
if (this == otherCommand) {
@@ -214,7 +214,7 @@ public class CLICommand implements Comparable<CLICommand> {
return this.hashCode() - otherCommand.hashCode();
}
- final CLICommand other = otherCommand;
+ final CommandLineCommand other = otherCommand;
for (int i = 0, j = 0;; i++, j++) {
if (i < keywordlist.size() && j < otherCommand.keywordlist.size()) {
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommands.java
index 4c9bab045..45d8a4bd3 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLICommands.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommands.java
@@ -28,15 +28,15 @@ import java.util.TreeSet;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLICommands {
- private final Set<CLICommand> commandList = new TreeSet<>();
+public class CommandLineCommands {
+ private final Set<CommandLineCommand> commandList = new TreeSet<>();
/**
* Gets the command set.
*
* @return the command set
*/
- public Set<CLICommand> getCommandSet() {
+ public Set<CommandLineCommand> getCommandSet() {
return commandList;
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java
index a574099bf..7a34ce7c1 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIEditorLoop.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineEditorLoop.java
@@ -45,12 +45,12 @@ import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.model.utilities.TreeMapUtils;
/**
- * This class implements the editor loop, the loop of execution that continuously executes commands
- * until the quit command is issued or EOF is detected on input.
+ * This class implements the editor loop, the loop of execution that continuously executes commands until the quit
+ * command is issued or EOF is detected on input.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIEditorLoop {
+public class CommandLineEditorLoop {
// The model handler that is handling the API towards the Apex model being editied
private final ApexModelHandler modelHandler;
@@ -71,8 +71,8 @@ public class CLIEditorLoop {
* @param modelHandler the model handler that will handle commands
* @param rootKeywordNode The root keyword node tree
*/
- public CLIEditorLoop(final Properties properties, final ApexModelHandler modelHandler,
- final KeywordNode rootKeywordNode) {
+ public CommandLineEditorLoop(final Properties properties, final ApexModelHandler modelHandler,
+ final KeywordNode rootKeywordNode) {
this.modelHandler = modelHandler;
keywordNodeDeque.push(rootKeywordNode);
@@ -90,14 +90,14 @@ public class CLIEditorLoop {
* @return the exit code from command processing
* @throws IOException Thrown on exceptions on IO
*/
- public int runLoop(final InputStream inputStream, final OutputStream outputStream, final CLIParameters parameters)
- throws IOException {
+ public int runLoop(final InputStream inputStream, final OutputStream outputStream,
+ final CommandLineParameters parameters) throws IOException {
// Readers and writers for input and output
final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
final PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream));
// The parser parses the input lines into commands and arguments
- final CLILineParser parser = new CLILineParser();
+ final CommandLineParser parser = new CommandLineParser();
// The main loop for command handing, it continues until EOF on the input stream or until a
// quit command
@@ -123,7 +123,7 @@ public class CLIEditorLoop {
}
}
// Print any error messages from command parsing and finding
- catch (final CLIException e) {
+ catch (final CommandLineException e) {
writer.println(e.getMessage());
errorCount++;
continue;
@@ -151,7 +151,7 @@ public class CLIEditorLoop {
}
}
// Print any error messages from command parsing and finding
- catch (final CLIException e) {
+ catch (final CommandLineException e) {
writer.println(e.getMessage());
errorCount++;
continue;
@@ -176,10 +176,11 @@ public class CLIEditorLoop {
// Find the command, if the command is null, then we are simply changing position in
// the hierarchy
- final CLICommand command = findCommand(commandWords);
+ final CommandLineCommand command = findCommand(commandWords);
if (command != null) {
// Check the arguments of the command
- final TreeMap<String, CLIArgumentValue> argumentValues = getArgumentValues(command, commandWords);
+ final TreeMap<String, CommandLineArgumentValue> argumentValues = getArgumentValues(command,
+ commandWords);
// Execute the command, a FINISHED result means a command causes the loop to
// leave execution
@@ -190,7 +191,7 @@ public class CLIEditorLoop {
}
}
// Print any error messages from command parsing and finding
- catch (final CLIException e) {
+ catch (final CommandLineException e) {
writer.println(e.getMessage());
errorCount++;
} catch (final Exception e) {
@@ -234,16 +235,15 @@ public class CLIEditorLoop {
}
/**
- * Finds a command for the given input command words. Command words need only ne specified
- * enough to uniquely identify them. Therefore, "p s o c" will find the command "policy state
- * output create"
+ * Finds a command for the given input command words. Command words need only ne specified enough to uniquely
+ * identify them. Therefore, "p s o c" will find the command "policy state output create"
*
* @param commandWords The commands and arguments parsed from the command line by the parser
* @return The found command
*/
- private CLICommand findCommand(final List<String> commandWords) {
- CLICommand command = null;
+ private CommandLineCommand findCommand(final List<String> commandWords) {
+ CommandLineCommand command = null;
final KeywordNode startKeywordNode = keywordNodeDeque.peek();
@@ -254,20 +254,20 @@ public class CLIEditorLoop {
// We have got to the arguments, time to stop looking
if (commandWords.get(i).indexOf('=') > 0) {
unwindStack(startKeywordNode);
- throw new CLIException("command not found: " + stringAL2String(commandWords));
+ throw new CommandLineException("command not found: " + stringAL2String(commandWords));
}
// If the node entries found is not equal to one, then we have either no command or more
// than one command matching
- final List<Entry<String, KeywordNode>> foundNodeEntries =
- findMatchingEntries(searchKeywordNode.getChildren(), commandWords.get(i));
+ final List<Entry<String, KeywordNode>> foundNodeEntries = findMatchingEntries(
+ searchKeywordNode.getChildren(), commandWords.get(i));
if (foundNodeEntries.isEmpty()) {
unwindStack(startKeywordNode);
- throw new CLIException("command not found: " + stringAL2String(commandWords));
+ throw new CommandLineException("command not found: " + stringAL2String(commandWords));
} else if (foundNodeEntries.size() > 1) {
unwindStack(startKeywordNode);
- throw new CLIException("multiple commands matched: " + stringAL2String(commandWords) + " ["
- + nodeAL2String(foundNodeEntries) + ']');
+ throw new CommandLineException("multiple commands matched: " + stringAL2String(commandWords) + " ["
+ + nodeAL2String(foundNodeEntries) + ']');
}
// Record the fully expanded command word
@@ -312,25 +312,25 @@ public class CLIEditorLoop {
* @param commandWords The command words entered
* @return the argument values
*/
- private TreeMap<String, CLIArgumentValue> getArgumentValues(final CLICommand command,
- final List<String> commandWords) {
- final TreeMap<String, CLIArgumentValue> argumentValues = new TreeMap<>();
- for (final CLIArgument argument : command.getArgumentList()) {
+ private TreeMap<String, CommandLineArgumentValue> getArgumentValues(final CommandLineCommand command,
+ final List<String> commandWords) {
+ final TreeMap<String, CommandLineArgumentValue> argumentValues = new TreeMap<>();
+ for (final CommandLineArgument argument : command.getArgumentList()) {
if (argument != null) {
- argumentValues.put(argument.getArgumentName(), new CLIArgumentValue(argument));
+ argumentValues.put(argument.getArgumentName(), new CommandLineArgumentValue(argument));
}
}
// Set the value of the arguments
for (final Entry<String, String> argument : getCommandArguments(commandWords)) {
- final List<Entry<String, CLIArgumentValue>> foundArguments =
- TreeMapUtils.findMatchingEntries(argumentValues, argument.getKey());
+ final List<Entry<String, CommandLineArgumentValue>> foundArguments = TreeMapUtils
+ .findMatchingEntries(argumentValues, argument.getKey());
if (foundArguments.size() == 0) {
- throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument \""
- + argument.getKey() + "\" not allowed on command");
+ throw new CommandLineException("command " + stringAL2String(commandWords) + ": " + " argument \""
+ + argument.getKey() + "\" not allowed on command");
} else if (foundArguments.size() > 1) {
- throw new CLIException("command " + stringAL2String(commandWords) + ": " + " argument " + argument
- + " matches multiple arguments [" + argumentAL2String(foundArguments) + ']');
+ throw new CommandLineException("command " + stringAL2String(commandWords) + ": " + " argument "
+ + argument + " matches multiple arguments [" + argumentAL2String(foundArguments) + ']');
}
// Set the value of the argument, stripping off any quotes
@@ -339,12 +339,13 @@ public class CLIEditorLoop {
}
// Now check all mandatory arguments are set
- for (final CLIArgumentValue argumentValue : argumentValues.values()) {
+ for (final CommandLineArgumentValue argumentValue : argumentValues.values()) {
// Argument values are null by default so if this argument is not nullable it is
// mandatory
if (!argumentValue.isSpecified() && !argumentValue.getCliArgument().isNullable()) {
- throw new CLIException("command " + stringAL2String(commandWords) + ": " + " mandatory argument \""
- + argumentValue.getCliArgument().getArgumentName() + "\" not specified");
+ throw new CommandLineException("command " + stringAL2String(commandWords) + ": "
+ + " mandatory argument \"" + argumentValue.getCliArgument().getArgumentName()
+ + "\" not specified");
}
}
@@ -352,8 +353,8 @@ public class CLIEditorLoop {
}
/**
- * Get the arguments of the command, the command words have already been conditioned into an
- * array starting with the command words and ending with the arguments as name=value tuples.
+ * Get the arguments of the command, the command words have already been conditioned into an array starting with the
+ * command words and ending with the arguments as name=value tuples.
*
* @param commandWords The command words entered by the user
* @return the arguments as an entry array list
@@ -365,8 +366,8 @@ public class CLIEditorLoop {
for (final String word : commandWords) {
final int equalsPos = word.indexOf('=');
if (equalsPos > 0) {
- arguments.add(
- new SimpleEntry<>(word.substring(0, equalsPos), word.substring(equalsPos + 1, word.length())));
+ arguments.add(new SimpleEntry<>(word.substring(0, equalsPos),
+ word.substring(equalsPos + 1, word.length())));
}
}
@@ -381,8 +382,8 @@ public class CLIEditorLoop {
* @param writer The writer to use for any output from the command
* @return the result of execution of the command
*/
- private ApexApiResult executeCommand(final CLICommand command,
- final TreeMap<String, CLIArgumentValue> argumentValues, final PrintWriter writer) {
+ private ApexApiResult executeCommand(final CommandLineCommand command,
+ final TreeMap<String, CommandLineArgumentValue> argumentValues, final PrintWriter writer) {
if (command.isSystemCommand()) {
return exceuteSystemCommand(command, writer);
} else {
@@ -397,7 +398,7 @@ public class CLIEditorLoop {
* @param writer The writer to use for any output from the command
* @return the result of execution of the command
*/
- private ApexApiResult exceuteSystemCommand(final CLICommand command, final PrintWriter writer) {
+ private ApexApiResult exceuteSystemCommand(final CommandLineCommand command, final PrintWriter writer) {
if ("back".equals(command.getName())) {
return executeBackCommand();
} else if ("help".equals(command.getName())) {
@@ -437,7 +438,7 @@ public class CLIEditorLoop {
* @return the result of execution of the command
*/
private ApexApiResult executeHelpCommand(final PrintWriter writer) {
- for (final CLICommand command : keywordNodeDeque.peek().getCommands()) {
+ for (final CommandLineCommand command : keywordNodeDeque.peek().getCommands()) {
writer.println(command.getHelp());
}
return new ApexApiResult(Result.SUCCESS);
@@ -464,9 +465,9 @@ public class CLIEditorLoop {
* @param argumentArrayList the argument array list
* @return the string
*/
- private String argumentAL2String(final List<Entry<String, CLIArgumentValue>> argumentArrayList) {
+ private String argumentAL2String(final List<Entry<String, CommandLineArgumentValue>> argumentArrayList) {
final ArrayList<String> stringArrayList = new ArrayList<>();
- for (final Entry<String, CLIArgumentValue> argument : argumentArrayList) {
+ for (final Entry<String, CommandLineArgumentValue> argument : argumentArrayList) {
stringArrayList.add(argument.getValue().getCliArgument().getArgumentName());
}
@@ -495,14 +496,14 @@ public class CLIEditorLoop {
}
/**
- * This method reads in the file from a file macro statement, expands the macro, and replaces
- * the Macro tag in the line with the file contents.
+ * This method reads in the file from a file macro statement, expands the macro, and replaces the Macro tag in the
+ * line with the file contents.
*
* @param parameters The parameters for the CLI editor
* @param line The line with the macro keyword in it
* @return the expanded line
*/
- private String expandMacroFile(final CLIParameters parameters, final String line) {
+ private String expandMacroFile(final CommandLineParameters parameters, final String line) {
final int macroTagPos = line.indexOf(macroFileTag);
// Get the line before and after the macro tag
@@ -513,7 +514,7 @@ public class CLIEditorLoop {
final String[] lineWords = lineAfterMacroTag.split("\\s+");
if (lineWords.length == 0) {
- throw new CLIException("no file name specified for Macro File Tag");
+ throw new CommandLineException("no file name specified for Macro File Tag");
}
// Get the macro file name and the remainder of the line after the file name
@@ -523,8 +524,8 @@ public class CLIEditorLoop {
if (macroFileName.length() > 2 && macroFileName.startsWith("\"") && macroFileName.endsWith("\"")) {
macroFileName = macroFileName.substring(1, macroFileName.length() - 1);
} else {
- throw new CLIException(
- "macro file name \"" + macroFileName + "\" must exist and be quoted with double quotes \"\"");
+ throw new CommandLineException("macro file name \"" + macroFileName
+ + "\" must exist and be quoted with double quotes \"\"");
}
// Append the working directory to the macro file name
@@ -535,7 +536,7 @@ public class CLIEditorLoop {
try {
macroFileContents = TextFileUtils.getTextFileAsString(macroFileName);
} catch (final IOException e) {
- throw new CLIException("file \"" + macroFileName + "\" specified in Macro File Tag not found", e);
+ throw new CommandLineException("file \"" + macroFileName + "\" specified in Macro File Tag not found", e);
}
return lineBeforeMacroTag + macroFileContents + lineAfterMacroFileName;
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineException.java
index 94b8c14a6..4ff17458e 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineException.java
@@ -25,7 +25,7 @@ package org.onap.policy.apex.auth.clieditor;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIException extends IllegalArgumentException {
+public class CommandLineException extends IllegalArgumentException {
private static final long serialVersionUID = 6520231162404452427L;
/**
@@ -33,7 +33,7 @@ public class CLIException extends IllegalArgumentException {
*
* @param message the message
*/
- public CLIException(final String message) {
+ public CommandLineException(final String message) {
super(message);
}
@@ -43,7 +43,7 @@ public class CLIException extends IllegalArgumentException {
* @param message the message
* @param th the throwable
*/
- public CLIException(final String message, final Throwable th) {
+ public CommandLineException(final String message, final Throwable th) {
super(message, th);
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameterParser.java
index 8a0c6eff3..a37d07fab 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameterParser.java
@@ -35,7 +35,7 @@ import org.apache.commons.cli.ParseException;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIParameterParser {
+public class CommandLineParameterParser {
private static final int MAX_HELP_LINE_LENGTH = 120;
// Apache Commons CLI options
@@ -44,44 +44,45 @@ public class CLIParameterParser {
/**
* Construct the options for the CLI editor.
*/
- public CLIParameterParser() {
+ public CommandLineParameterParser() {
options = new Options();
options.addOption(Option.builder("h").longOpt("help").desc("outputs the usage of this command").required(false)
- .type(Boolean.class).build());
+ .type(Boolean.class).build());
options.addOption(Option.builder("m").longOpt("metadata-file").desc("name of the command metadata file to use")
- .hasArg().argName("CMD_METADATA_FILE").required(false).type(String.class).build());
- options.addOption(
- Option.builder("a").longOpt("model-props-file").desc("name of the apex model properties file to use")
- .hasArg().argName("MODEL_PROPS_FILE").required(false).type(String.class).build());
+ .hasArg().argName("CMD_METADATA_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("a").longOpt("model-props-file")
+ .desc("name of the apex model properties file to use").hasArg().argName("MODEL_PROPS_FILE")
+ .required(false).type(String.class).build());
options.addOption(Option.builder("c").longOpt("command-file")
- .desc("name of a file containing editor commands to run into the editor").hasArg()
- .argName("COMMAND_FILE").required(false).type(String.class).build());
- options.addOption(Option.builder("l").longOpt("log-file")
- .desc("name of a file that will contain command logs from the editor, will log to standard output "
- + "if not specified or suppressed with \"-nl\" flag")
- .hasArg().argName("LOG_FILE").required(false).type(String.class).build());
- options.addOption(Option.builder("nl").longOpt("no-log")
- .desc("if specified, no logging or output of commands to standard output or log file is carried out")
- .required(false).type(Boolean.class).build());
- options.addOption(Option.builder("nm").longOpt("no-model-output")
- .desc("if specified, no output of a model to standard output or model output file is carried out, "
- + "the user can use the \"save\" command in a script to save a model")
- .required(false).type(Boolean.class).build());
+ .desc("name of a file containing editor commands to run into the editor").hasArg()
+ .argName("COMMAND_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("l").longOpt("log-file").desc(
+ "name of a file that will contain command logs from the editor, will log to standard output "
+ + "if not specified or suppressed with \"-nl\" flag")
+ .hasArg().argName("LOG_FILE").required(false).type(String.class).build());
+ options.addOption(Option.builder("nl").longOpt("no-log").desc(
+ "if specified, no logging or output of commands to standard output or log file is carried out")
+ .required(false).type(Boolean.class).build());
+ options.addOption(Option.builder("nm").longOpt("no-model-output").desc(
+ "if specified, no output of a model to standard output or model output file is carried out, "
+ + "the user can use the \"save\" command in a script to save a model")
+ .required(false).type(Boolean.class).build());
options.addOption(Option.builder("i").longOpt("input-model-file")
- .desc("name of a file that contains an input model for the editor").hasArg().argName("INPUT_MODEL_FILE")
- .required(false).type(String.class).build());
+ .desc("name of a file that contains an input model for the editor").hasArg()
+ .argName("INPUT_MODEL_FILE").required(false).type(String.class).build());
options.addOption(Option.builder("o").longOpt("output-model-file")
- .desc("name of a file that will contain the output model for the editor, "
- + "will output model to standard output if not specified or suppressed with \"-nm\" flag")
- .hasArg().argName("OUTPUT_MODEL_FILE").required(false).type(String.class).build());
+ .desc("name of a file that will contain the output model for the editor, "
+ + "will output model to standard output if not specified "
+ + "or suppressed with \"-nm\" flag")
+ .hasArg().argName("OUTPUT_MODEL_FILE").required(false).type(String.class).build());
options.addOption(Option.builder("if").longOpt("ignore-failures")
- .desc("true or false, ignore failures of commands in command files and continue executing the "
- + "command file")
- .hasArg().argName("IGNORE_FAILURES_FLAG").required(false).type(Boolean.class).build());
+ .desc("true or false, ignore failures of commands in command files and continue executing the "
+ + "command file")
+ .hasArg().argName("IGNORE_FAILURES_FLAG").required(false).type(Boolean.class).build());
options.addOption(Option.builder("wd").longOpt("working-directory")
- .desc("the working directory that is the root for the CLI editor and is the root from which to "
- + "look for included macro files")
- .hasArg().argName("WORKING_DIRECTORY").required(false).type(String.class).build());
+ .desc("the working directory that is the root for the CLI editor and is the root from which to "
+ + "look for included macro files")
+ .hasArg().argName("WORKING_DIRECTORY").required(false).type(String.class).build());
}
/**
@@ -90,19 +91,20 @@ public class CLIParameterParser {
* @param args The arguments
* @return the CLI parameters
*/
- public CLIParameters parse(final String[] args) {
+ public CommandLineParameters parse(final String[] args) {
CommandLine commandLine = null;
try {
commandLine = new DefaultParser().parse(options, args);
} catch (final ParseException e) {
- throw new CLIException("invalid command line arguments specified : " + e.getMessage());
+ throw new CommandLineException("invalid command line arguments specified : " + e.getMessage());
}
- final CLIParameters parameters = new CLIParameters();
+ final CommandLineParameters parameters = new CommandLineParameters();
final String[] remainingArgs = commandLine.getArgs();
if (remainingArgs.length > 0) {
- throw new CLIException("too many command line arguments specified : " + Arrays.toString(remainingArgs));
+ throw new CommandLineException(
+ "too many command line arguments specified : " + Arrays.toString(remainingArgs));
}
if (commandLine.hasOption('h')) {
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java
index 24356d128..9a03dcfde 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java
@@ -35,7 +35,10 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLIParameters {
+public class CommandLineParameters {
+ // Recurring string constants
+ private static final String OF_TYPE_TAG = "of type ";
+
// Default location of the command definition meta data in JSON
private static final String JSON_COMMAND_METADATA_RESOURCE = "etc/editor/Commands.json";
private static final String APEX_MODEL_PROPERTIES_RESOURCE = "etc/editor/ApexModelProperties.json";
@@ -182,16 +185,16 @@ public class CLIParameters {
return;
}
final File theFile = new File(fileName);
- final String prefixExceptionMessage = "File " + fileName + "of type " + fileTag;
+ final String prefixExceptionMessage = "File " + fileName + OF_TYPE_TAG + fileTag;
if (!theFile.exists()) {
- throw new CLIException(prefixExceptionMessage + " does not exist");
+ throw new CommandLineException(prefixExceptionMessage + " does not exist");
}
if (!theFile.isFile()) {
- throw new CLIException(prefixExceptionMessage + " is not a normal file");
+ throw new CommandLineException(prefixExceptionMessage + " is not a normal file");
}
if (!theFile.canRead()) {
- throw new CLIException(prefixExceptionMessage + " is ureadable");
+ throw new CommandLineException(prefixExceptionMessage + " is ureadable");
}
}
@@ -206,19 +209,19 @@ public class CLIParameters {
return;
}
final File theFile = new File(fileName);
- final String prefixExceptionMessage = "File " + fileName + "of type " + fileTag;
+ final String prefixExceptionMessage = "File " + fileName + OF_TYPE_TAG + fileTag;
if (theFile.exists()) {
if (!theFile.isFile()) {
- throw new CLIException(prefixExceptionMessage + " is not a normal file");
+ throw new CommandLineException(prefixExceptionMessage + " is not a normal file");
}
if (!theFile.canWrite()) {
- throw new CLIException(prefixExceptionMessage + " cannot be written");
+ throw new CommandLineException(prefixExceptionMessage + " cannot be written");
}
} else {
try {
theFile.createNewFile();
} catch (final IOException e) {
- throw new CLIException(prefixExceptionMessage + " cannot be created: ", e);
+ throw new CommandLineException(prefixExceptionMessage + " cannot be created: ", e);
}
}
}
@@ -234,14 +237,14 @@ public class CLIParameters {
return;
}
final File theDirectory = new File(directoryName);
- final String prefixExceptionMessage = "directory " + directoryName + "of type " + directoryTag;
+ final String prefixExceptionMessage = "directory " + directoryName + OF_TYPE_TAG + directoryTag;
if (theDirectory.exists()) {
if (!theDirectory.isDirectory()) {
- throw new CLIException(prefixExceptionMessage + " is not a directory");
+ throw new CommandLineException(prefixExceptionMessage + " is not a directory");
}
if (!theDirectory.canWrite()) {
- throw new CLIException(prefixExceptionMessage + " cannot be written");
+ throw new CommandLineException(prefixExceptionMessage + " cannot be written");
}
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java
index 70c2f834b..aa74f4ba3 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParser.java
@@ -28,7 +28,7 @@ import java.util.List;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CLILineParser {
+public class CommandLineParser {
/**
* This method breaks a line of input up into commands, parameters, and arguments. Commands are
@@ -93,7 +93,7 @@ public class CLILineParser {
if (quotedWordToString.matches("^\".*\"$")) {
wordsWithQuotesMerged.add(quotedWordToString);
} else {
- throw new CLIException("trailing quote found in input " + wordsSplitOnQuotes);
+ throw new CommandLineException("trailing quote found in input " + wordsSplitOnQuotes);
}
} else {
wordsWithQuotesMerged.add(wordsSplitOnQuotes.get(i++));
@@ -281,7 +281,7 @@ public class CLILineParser {
// The first word must be alphanumeric, that is a command
if (!commandWords.get(0).matches("^[a-zA-Z0-9]*$")) {
- throw new CLIException(
+ throw new CommandLineException(
"first command word is not alphanumeric or is not a command: " + commandWords.get(0));
}
@@ -303,7 +303,7 @@ public class CLILineParser {
if (commandWords.get(currentWordPos).matches("^[a-zA-Z0-9]+=[a-zA-Z0-9/\"].*$")) {
currentWordPos++;
} else {
- throw new CLIException(
+ throw new CommandLineException(
"command argument is not properly formed: " + commandWords.get(currentWordPos));
}
} else {
@@ -312,7 +312,7 @@ public class CLILineParser {
commandWords.set(currentWordPos, commandWords.get(currentWordPos) + logicBlock);
currentWordPos++;
} else {
- throw new CLIException(
+ throw new CommandLineException(
"command argument is not properly formed: " + commandWords.get(currentWordPos));
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
index 6be5c6846..c8bc7a083 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
@@ -37,7 +37,7 @@ import org.onap.policy.apex.model.utilities.Assertions;
public class KeywordNode implements Comparable<KeywordNode> {
private final String keyword;
private final TreeMap<String, KeywordNode> children;
- private CLICommand command;
+ private CommandLineCommand command;
/**
* This Constructor creates a keyword node with the given keyword and no command.
@@ -54,7 +54,7 @@ public class KeywordNode implements Comparable<KeywordNode> {
* @param keyword the keyword of the keyword node
* @param command the command associated with this keyword
*/
- public KeywordNode(final String keyword, final CLICommand command) {
+ public KeywordNode(final String keyword, final CommandLineCommand command) {
Assertions.argumentNotNull(keyword, "commands may not be null");
this.keyword = keyword;
@@ -70,7 +70,7 @@ public class KeywordNode implements Comparable<KeywordNode> {
* @param keywordList the list of keywords to process on this keyword node
* @param incomingCommand the command
*/
- public void processKeywords(final List<String> keywordList, final CLICommand incomingCommand) {
+ public void processKeywords(final List<String> keywordList, final CommandLineCommand incomingCommand) {
if (keywordList.isEmpty()) {
this.command = incomingCommand;
return;
@@ -128,7 +128,7 @@ public class KeywordNode implements Comparable<KeywordNode> {
*
* @return the command of this keyword node
*/
- public CLICommand getCommand() {
+ public CommandLineCommand getCommand() {
return command;
}
@@ -147,8 +147,8 @@ public class KeywordNode implements Comparable<KeywordNode> {
*
* @return the commands
*/
- public Set<CLICommand> getCommands() {
- final Set<CLICommand> commandSet = new TreeSet<>();
+ public Set<CommandLineCommand> getCommands() {
+ final Set<CommandLineCommand> commandSet = new TreeSet<>();
for (final KeywordNode child : children.values()) {
if (child.getCommand() != null) {
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorEventsContext.java
index bd75ddf76..b0d82b6fa 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorEventsContext.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorEventsContext.java
@@ -36,7 +36,7 @@ import org.onap.policy.apex.model.utilities.TextFileUtils;
/**
* The Class TestCLIEditorEventsContext.
*/
-public class TestCLIEditorEventsContext {
+public class TestCommandLineEditorEventsContext {
// CHECKSTYLE:OFF: MagicNumber
private static final Path SRC_MAIN_FOLDER = Paths.get("src/main/resources/");
@@ -54,7 +54,6 @@ public class TestCLIEditorEventsContext {
private static final String JSON_FILE = FILE_NAME + ".json";
private static final String LOG_FILE = FILE_NAME + ".log";
-
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -70,10 +69,11 @@ public class TestCLIEditorEventsContext {
final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
- final String[] cliArgs = new String[] {"-c", APEX_JAVA_POLICY_FILE.toString(), "-l",
- tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()};
+ final String[] cliArgs = new String[]
+ { "-c", APEX_JAVA_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
+ tempModelFile.getAbsolutePath() };
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -100,10 +100,11 @@ public class TestCLIEditorEventsContext {
final File tempLogFile = temporaryFolder.newFile(LOG_FILE);
final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
- final String[] cliArgs = new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l",
- tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()};
+ final String[] cliArgs = new String[]
+ { "-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
+ tempModelFile.getAbsolutePath() };
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -126,14 +127,14 @@ public class TestCLIEditorEventsContext {
final File tempModelFile = temporaryFolder.newFile(JSON_FILE);
final String modelFile = SRC_TEST_FOLDER.resolve("model").resolve("empty_commands.json").toString();
- final String apexPropertiesLocation =
- SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
+ final String apexPropertiesLocation = SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json")
+ .toString();
- final String[] cliArgs =
- new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
- tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation};
+ final String[] cliArgs = new String[]
+ { "-c", APEX_AVRO_POLICY_FILE.toString(), "-l", tempLogFile.getAbsolutePath(), "-o",
+ tempModelFile.getAbsolutePath(), "-m", modelFile, "-a", apexPropertiesLocation };
- final ApexCLIEditorMain objUnderTest = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs);
assertEquals(1, objUnderTest.getErrorCount());
}
@@ -146,14 +147,23 @@ public class TestCLIEditorEventsContext {
final File modelFile = temporaryFolder.newFile("empty_commands.json");
- final String apexPropertiesLocation =
- SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json").toString();
-
- final String[] cliArgs = new String[] {"-c", APEX_AVRO_POLICY_FILE.toString(), "-l",
- tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-m", modelFile.getAbsolutePath(),
- "-a", apexPropertiesLocation};
-
- final ApexCLIEditorMain objUnderTest = new ApexCLIEditorMain(cliArgs);
+ final String apexPropertiesLocation = SRC_MAIN_FOLDER.resolve("etc/editor").resolve("ApexModelProperties.json")
+ .toString();
+
+ final String[] cliArgs = new String[] {
+ "-c",
+ APEX_AVRO_POLICY_FILE.toString(),
+ "-l",
+ tempLogFile.getAbsolutePath(),
+ "-o",
+ tempModelFile.getAbsolutePath(),
+ "-m",
+ modelFile.getAbsolutePath(),
+ "-a",
+ apexPropertiesLocation
+ };
+
+ final ApexCommandLineEditorMain objUnderTest = new ApexCommandLineEditorMain(cliArgs);
assertEquals(1, objUnderTest.getErrorCount());
}
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorOptions.java
index 2056c9239..5ff87c01b 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorOptions.java
@@ -38,7 +38,7 @@ import org.onap.policy.apex.model.utilities.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestCLIEditorOptions {
+public class TestCommandLineEditorOptions {
// CHECKSTYLE:OFF: MagicNumber
/**
@@ -55,7 +55,7 @@ public class TestCLIEditorOptions {
final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath()};
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -87,7 +87,7 @@ public class TestCLIEditorOptions {
final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nl", "-nm"};
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -119,7 +119,7 @@ public class TestCLIEditorOptions {
final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nm"};
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -152,7 +152,7 @@ public class TestCLIEditorOptions {
final String[] cliArgs = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex", "-l",
tempLogFile.getAbsolutePath(), "-o", tempModelFile.getAbsolutePath(), "-nl"};
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Get the model and log into strings
@@ -184,7 +184,7 @@ public class TestCLIEditorOptions {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos));
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Cursor for log
@@ -208,7 +208,7 @@ public class TestCLIEditorOptions {
final PrintStream stdout = System.out;
System.setOut(new PrintStream(baos));
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(cliArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(cliArgs);
assertEquals(0, cliEditor.getErrorCount());
// Cursor for log
@@ -237,7 +237,7 @@ public class TestCLIEditorOptions {
final String[] cliArgsIn = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex",
"-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()};
- final ApexCLIEditorMain cliEditorIn = new ApexCLIEditorMain(cliArgsIn);
+ final ApexCommandLineEditorMain cliEditorIn = new ApexCommandLineEditorMain(cliArgsIn);
assertEquals(0, cliEditorIn.getErrorCount());
// Get the model and log into strings
@@ -255,7 +255,7 @@ public class TestCLIEditorOptions {
"src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l",
tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()};
- final ApexCLIEditorMain cliEditorOut = new ApexCLIEditorMain(cliArgsOut);
+ final ApexCommandLineEditorMain cliEditorOut = new ApexCommandLineEditorMain(cliArgsOut);
assertEquals(0, cliEditorOut.getErrorCount());
// Get the model and log into strings
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorScripting.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorScripting.java
index 44cc5c702..1b49fb362 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorScripting.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCommandLineEditorScripting.java
@@ -41,14 +41,14 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestCLIEditorScripting {
+public class TestCommandLineEditorScripting {
private File tempModelFile;
private File tempLogFile;
- private String[] sampleLBPolicyArgs;
+ private String[] samplePolicyArgs;
- private String[] sampleLBPolicyMapArgs;
+ private String[] samplePolicyMapArgs;
/**
* Initialise args.
@@ -60,10 +60,10 @@ public class TestCLIEditorScripting {
tempModelFile = File.createTempFile("SampleLBPolicyMap", ".json");
tempLogFile = File.createTempFile("SampleLBPolicyMap", ".log");
- sampleLBPolicyArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy.apex", "-o",
+ samplePolicyArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy.apex", "-o",
tempModelFile.getAbsolutePath(), "-l", tempLogFile.getAbsolutePath()};
- sampleLBPolicyMapArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy_WithMap.apex", "-o",
+ samplePolicyMapArgs = new String[] {"-c", "src/test/resources/scripts/SampleLBPolicy_WithMap.apex", "-o",
tempModelFile.getAbsolutePath(), "-l", tempLogFile.getAbsolutePath()};
}
@@ -83,19 +83,19 @@ public class TestCLIEditorScripting {
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testSampleLBPolicyScript() throws IOException, ApexModelException {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(sampleLBPolicyArgs);
+ public void testSamplePolicyScript() throws IOException, ApexModelException {
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyArgs);
assertEquals(0, cliEditor.getErrorCount());
// Read the file from disk
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
- final URL compareModelURL =
+ final URL compareModelUrl =
ResourceUtils.getLocalFile("src/test/resources/compare/FuzzyPolicyModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+ final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
writtenModel.getKeyInformation().getKeyInfoMap().clear();
@@ -111,10 +111,10 @@ public class TestCLIEditorScripting {
* @throws ApexModelException if there is an Apex error
*/
@Test
- public void testSampleLBMapPolicyScript() throws IOException, ApexModelException {
+ public void testSampleMapPolicyScript() throws IOException, ApexModelException {
tempModelFile.delete();
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(sampleLBPolicyMapArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(samplePolicyMapArgs);
assertEquals(0, cliEditor.getErrorCount());
assertTrue(tempModelFile.isFile());
@@ -122,8 +122,8 @@ public class TestCLIEditorScripting {
// Read the file from disk
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
final AxValidationResult validationResult = new AxValidationResult();
writtenModel.validate(validationResult);
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java
index 1b99fce16..a45212007 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java
@@ -36,11 +36,19 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.utils.resources.ResourceUtils;
+/**
+ * The Class TestContextAlbums.
+ */
public class TestContextAlbums {
private String[] logicBlockArgs;
private File tempModelFile;
+ /**
+ * Creates the temp files.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Before
public void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
@@ -65,20 +73,20 @@ public class TestContextAlbums {
*/
@Test
public void testLogicBlock() throws IOException, ApexModelException {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(logicBlockArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(logicBlockArgs);
assertEquals(1, cliEditor.getErrorCount());
// Read the file from disk
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
modelReader.setValidateFlag(false);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
assertNotNull(writtenModel);
- final URL compareModelURL =
+ final URL compareModelUrl =
ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+ final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
writtenModel.getKeyInformation().getKeyInfoMap().clear();
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java
index eb2f2a46b..3195bf025 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java
@@ -46,6 +46,11 @@ public class TestFileMacro {
private File tempModelFile;
private File tempLogFile;
+ /**
+ * Creates the temp files.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Before
public void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
@@ -55,6 +60,9 @@ public class TestFileMacro {
tempLogFile.getCanonicalPath(), "-o", tempModelFile.getCanonicalPath(), "-if", "true"};
}
+ /**
+ * Removes the generated models.
+ */
@After
public void removeGeneratedModels() {
tempModelFile.delete();
@@ -68,7 +76,7 @@ public class TestFileMacro {
*/
@Test
public void testLogicBlock() throws IOException, ApexModelException {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs);
+ final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(fileMacroArgs);
// We expect eight errors
assertEquals(8, cliEditor.getErrorCount());
@@ -76,12 +84,12 @@ public class TestFileMacro {
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
modelReader.setValidateFlag(false);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
- final URL compareModelURL =
+ final URL compareModelUrl =
ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+ final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
writtenModel.getKeyInformation().getKeyInfoMap().clear();
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java
index 591acb29a..1a4f75576 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestLogicBlock.java
@@ -34,6 +34,10 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.utils.resources.ResourceUtils;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class TestLogicBlock.
+ */
public class TestLogicBlock {
private String[] logicBlockArgs;
private String[] avroSchemaArgs;
@@ -41,6 +45,11 @@ public class TestLogicBlock {
private File tempLogicModelFile;
private File tempAvroModelFile;
+ /**
+ * Creates the temp files.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
@Before
public void createTempFiles() throws IOException {
tempLogicModelFile = File.createTempFile("TestLogicPolicyModel", ".json");
@@ -53,6 +62,9 @@ public class TestLogicBlock {
tempAvroModelFile.getCanonicalPath(), "-nl"};
}
+ /**
+ * Removes the temp files.
+ */
@After
public void removeTempFiles() {
tempLogicModelFile.delete();
@@ -67,18 +79,18 @@ public class TestLogicBlock {
*/
@Test
public void testLogicBlock() throws IOException, ApexModelException {
- new ApexCLIEditorMain(logicBlockArgs);
+ new ApexCommandLineEditorMain(logicBlockArgs);
// Read the file from disk
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
modelReader.setValidateFlag(false);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempLogicModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempLogicModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
- final URL compareModelURL =
+ final URL compareModelUrl =
ResourceUtils.getLocalFile("src/test/resources/compare/LogicBlockModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+ final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
writtenModel.getKeyInformation().getKeyInfoMap().clear();
@@ -95,18 +107,18 @@ public class TestLogicBlock {
*/
@Test
public void testAvroSchema() throws IOException, ApexModelException {
- new ApexCLIEditorMain(avroSchemaArgs);
+ new ApexCommandLineEditorMain(avroSchemaArgs);
// Read the file from disk
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
modelReader.setValidateFlag(false);
- final URL writtenModelURL = ResourceUtils.getLocalFile(tempAvroModelFile.getCanonicalPath());
- final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
+ final URL writtenModelUrl = ResourceUtils.getLocalFile(tempAvroModelFile.getCanonicalPath());
+ final AxPolicyModel writtenModel = modelReader.read(writtenModelUrl.openStream());
- final URL compareModelURL =
+ final URL compareModelUrl =
ResourceUtils.getLocalFile("src/test/resources/compare/AvroSchemaModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+ final AxPolicyModel compareModel = modelReader.read(compareModelUrl.openStream());
// Ignore key info UUIDs
writtenModel.getKeyInformation().getKeyInfoMap().clear();