summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authorDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-14 12:32:51 +0100
committerDinh Danh Le <dinh.danh.le@ericsson.com>2018-08-14 14:53:51 +0100
commit3ab54a2340f40d11d9a0a3994f579baeeb6c0ca6 (patch)
treef7438c01cc0023c47b2d15c2eb84254c626ef73b /auth
parent933af17963b47650fe9864d03e63a06aa08e31a9 (diff)
Fix checkstyle warnings in the auth package
Change-Id: I64f783d5325301862e2438ac5d22cfcc0a150579 Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com> Issue-ID: POLICY-1034
Diffstat (limited to 'auth')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java14
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java26
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java5
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java6
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java4
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java9
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java2
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java6
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java12
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java132
10 files changed, 103 insertions, 113 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java
index 50600f99f..dbf8f3844 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java
@@ -35,17 +35,17 @@ public class CgStringRenderer implements AttributeRenderer {
/*
* (non-Javadoc)
- *
+ *
* @see org.stringtemplate.v4.AttributeRenderer#toString(java.lang.Object, java.lang.String,
* java.util.Locale)
*/
@Override
- public String toString(final Object o, final String format, final Locale locale) {
+ public String toString(final Object obj, final String format, final Locale locale) {
if ("doQuotes".equals(format)) {
- if (o == null) {
+ if (obj == null) {
return null;
}
- String ret = o.toString();
+ String ret = obj.toString();
if (ret.length() == 0) {
return "\"\"";
}
@@ -56,16 +56,16 @@ public class CgStringRenderer implements AttributeRenderer {
}
if ("doDescription".equals(format)) {
- String ret = o.toString();
+ String ret = obj.toString();
if (ret.contains("\n") || ret.contains("\"")) {
ret = "LS" + "\n" + ret + "\n" + "LE";
} else {
- ret = this.toString(o, "doQuotes", locale);
+ ret = this.toString(obj, "doQuotes", locale);
}
return ret;
}
// return the default string renderer if we don't know otherwise
- return new StringRenderer().toString(o, format, locale);
+ return new StringRenderer().toString(obj, format, locale);
}
}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java
index ed703da82..28e32bca6 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java
@@ -39,8 +39,8 @@ public class StErrorListener implements STErrorListener {
@Override
public void IOError(final STMessage msg) {
switch (msg.error) {
- default:
- this.registerErrors(msg);
+ default:
+ this.registerErrors(msg);
}
}
@@ -50,8 +50,8 @@ public class StErrorListener implements STErrorListener {
@Override
public void compileTimeError(final STMessage msg) {
switch (msg.error) {
- default:
- this.registerErrors(msg);
+ default:
+ this.registerErrors(msg);
}
}
@@ -61,8 +61,8 @@ public class StErrorListener implements STErrorListener {
@Override
public void internalError(final STMessage msg) {
switch (msg.error) {
- default:
- this.registerErrors(msg);
+ default:
+ this.registerErrors(msg);
}
}
@@ -72,18 +72,18 @@ public class StErrorListener implements STErrorListener {
@Override
public void runTimeError(final STMessage msg) {
switch (msg.error) {
- case NO_SUCH_PROPERTY:
- case ARGUMENT_COUNT_MISMATCH:
- case ANON_ARGUMENT_MISMATCH:
- break;
- default:
- this.registerErrors(msg);
+ case NO_SUCH_PROPERTY:
+ case ARGUMENT_COUNT_MISMATCH:
+ case ANON_ARGUMENT_MISMATCH:
+ break;
+ default:
+ this.registerErrors(msg);
}
}
/**
* Registers an error with the local error listener and increases the error count.
- *
+ *
* @param msg error message
*/
protected void registerErrors(final STMessage msg) {
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/ApexCLIEditorMain.java
index e484ff03f..c7f7c7bb1 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/ApexCLIEditorMain.java
@@ -152,7 +152,8 @@ public class ApexCLIEditorMain {
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);
+ LOGGER.error("execution of Apex command line editor failed: {} command execution failure(s) occurred",
+ errorCount);
}
} catch (final IOException e) {
LOGGER.error("execution of Apex command line editor failed: " + e.getMessage());
@@ -160,7 +161,7 @@ public class ApexCLIEditorMain {
}
/**
- * Get the number of errors encountered in command processing
+ * Get the number of errors encountered in command processing.
*
* @return the number of errors
*/
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/CLIException.java
index 8e1104c3b..94b8c14a6 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/CLIException.java
@@ -41,9 +41,9 @@ public class CLIException extends IllegalArgumentException {
* Create a CLIException with a message and an exception.
*
* @param message the message
- * @param t the t
+ * @param th the throwable
*/
- public CLIException(final String message, final Throwable t) {
- super(message, t);
+ public CLIException(final String message, final Throwable th) {
+ super(message, th);
}
}
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/CLILineParser.java
index bbeface32..70c2f834b 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/CLILineParser.java
@@ -36,9 +36,9 @@ public class CLILineParser {
* single words followed by an '=' character Arguments are single words or a block of quoted
* text following an '=' character.
*
- * Format: command [command....] parameter=argument [parameter = argument]
+ * <p>Format: command [command....] parameter=argument [parameter = argument]
*
- * Examples entity create name=hello description="description of hello" help entity list
+ * <p>Examples entity create name=hello description="description of hello" help entity list
*
* @param line The line to parse
* @param logicBlock A block of logic code to be taken literally
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/CLIParameterParser.java
index 382f23fb0..8a0c6eff3 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/CLIParameterParser.java
@@ -57,7 +57,8 @@ public class CLIParameterParser {
.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")
+ .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")
@@ -74,10 +75,12 @@ public class CLIParameterParser {
+ "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")
+ .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")
+ .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());
}
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/CLIParameters.java
index ebaa6c572..24356d128 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/CLIParameters.java
@@ -522,7 +522,7 @@ public class CLIParameters {
}
/**
- * Check if the command failures flag is set
+ * Check if the command failures flag is set.
*
* @return true if the command failures flag has been set
*/
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/TestCLIEditorOptions.java
index 87618e18d..2056c9239 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/TestCLIEditorOptions.java
@@ -235,7 +235,7 @@ public class TestCLIEditorOptions {
// Generate input model
final String[] cliArgsIn = new String[] {"-c", "src/main/resources/examples/scripts/ShellPolicyModel.apex",
- "-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()};
+ "-l", tempLogFileIn.getAbsolutePath(), "-o", tempModelFileIn.getAbsolutePath()};
final ApexCLIEditorMain cliEditorIn = new ApexCLIEditorMain(cliArgsIn);
assertEquals(0, cliEditorIn.getErrorCount());
@@ -252,8 +252,8 @@ public class TestCLIEditorOptions {
assertEquals(2924, tempModelFileInCharCount);
final String[] cliArgsOut = new String[] {"-i", tempModelFileIn.getAbsolutePath(), "-c",
- "src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l",
- tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()};
+ "src/main/resources/examples/scripts/ShellPolicyModelAddSchema.apex", "-l",
+ tempLogFileOut.getAbsolutePath(), "-o", tempModelFileOut.getAbsolutePath()};
final ApexCLIEditorMain cliEditorOut = new ApexCLIEditorMain(cliArgsOut);
assertEquals(0, cliEditorOut.getErrorCount());
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 3de41e8d4..1b99fce16 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
@@ -45,13 +45,8 @@ public class TestContextAlbums {
public void createTempFiles() throws IOException {
tempModelFile = File.createTempFile("TestPolicyModel", ".json");
- logicBlockArgs = new String[] {
- "-c",
- "src/test/resources/scripts/ContextAlbums.apex",
- "-o",
- tempModelFile.getAbsolutePath(),
- "-nl"
- };
+ logicBlockArgs = new String[] {"-c", "src/test/resources/scripts/ContextAlbums.apex", "-o",
+ tempModelFile.getAbsolutePath(), "-nl"};
}
/**
@@ -81,7 +76,8 @@ public class TestContextAlbums {
final AxPolicyModel writtenModel = modelReader.read(writtenModelURL.openStream());
assertNotNull(writtenModel);
- final URL compareModelURL = ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
+ final URL compareModelURL =
+ ResourceUtils.getLocalFile("src/test/resources/compare/ContextAlbumsModel_Compare.json");
final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
// Ignore key info UUIDs
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 6ff85e71c..eb2f2a46b 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
@@ -41,75 +41,65 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
* Test FileMacro in the CLI.
*/
public class TestFileMacro {
- private String[] fileMacroArgs;
-
- private File tempModelFile;
- private File tempLogFile;
-
- @Before
- public void createTempFiles() throws IOException {
- tempModelFile = File.createTempFile("TestPolicyModel", ".json");
- tempLogFile = File.createTempFile("TestPolicyModel", ".log");
-
- fileMacroArgs = new String[] {
- "-c",
- "src/test/resources/scripts/FileMacro.apex",
- "-l",
- tempLogFile.getCanonicalPath(),
- "-o",
- tempModelFile.getCanonicalPath(),
- "-if",
- "true"
- };
- }
-
- @After
- public void removeGeneratedModels() {
- tempModelFile.delete();
- }
-
- /**
- * Test logic block macro in CLI scripts.
- *
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexModelException if there is an Apex error
- */
- @Test
- public void testLogicBlock() throws IOException, ApexModelException {
- final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs);
- // We expect eight errors
- assertEquals(8, 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 compareModelURL = ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
- final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
-
- // Ignore key info UUIDs
- writtenModel.getKeyInformation().getKeyInfoMap().clear();
- compareModel.getKeyInformation().getKeyInfoMap().clear();
-
- assertTrue(writtenModel.equals(compareModel));
-
- // The output event is in this file
- final File outputLogFile = new File(tempLogFile.getCanonicalPath());
-
- final String outputLogString = TextFileUtils
- .getTextFileAsString(outputLogFile.getCanonicalPath())
- .replace(Paths.get("").toAbsolutePath().toString() + File.separator, "")
- .replaceAll("\\s+", "");
-
- // We compare the log to what we expect to get
- final String outputLogCompareString = TextFileUtils
- .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log")
- .replaceAll("\\s+", "");
-
- // Check what we got is what we expected to get
- assertEquals(outputLogCompareString, outputLogString);
- }
+ private String[] fileMacroArgs;
+
+ private File tempModelFile;
+ private File tempLogFile;
+
+ @Before
+ public void createTempFiles() throws IOException {
+ tempModelFile = File.createTempFile("TestPolicyModel", ".json");
+ tempLogFile = File.createTempFile("TestPolicyModel", ".log");
+
+ fileMacroArgs = new String[] {"-c", "src/test/resources/scripts/FileMacro.apex", "-l",
+ tempLogFile.getCanonicalPath(), "-o", tempModelFile.getCanonicalPath(), "-if", "true"};
+ }
+
+ @After
+ public void removeGeneratedModels() {
+ tempModelFile.delete();
+ }
+
+ /**
+ * Test logic block macro in CLI scripts.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexModelException if there is an Apex error
+ */
+ @Test
+ public void testLogicBlock() throws IOException, ApexModelException {
+ final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(fileMacroArgs);
+ // We expect eight errors
+ assertEquals(8, 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 compareModelURL =
+ ResourceUtils.getLocalFile("src/test/resources/compare/FileMacroModel_Compare.json");
+ final AxPolicyModel compareModel = modelReader.read(compareModelURL.openStream());
+
+ // Ignore key info UUIDs
+ writtenModel.getKeyInformation().getKeyInfoMap().clear();
+ compareModel.getKeyInformation().getKeyInfoMap().clear();
+
+ assertTrue(writtenModel.equals(compareModel));
+
+ // The output event is in this file
+ final File outputLogFile = new File(tempLogFile.getCanonicalPath());
+
+ final String outputLogString = TextFileUtils.getTextFileAsString(outputLogFile.getCanonicalPath())
+ .replace(Paths.get("").toAbsolutePath().toString() + File.separator, "").replaceAll("\\s+", "");
+
+ // We compare the log to what we expect to get
+ final String outputLogCompareString = TextFileUtils
+ .getTextFileAsString("src/test/resources/compare/FileMacro_Compare.log").replaceAll("\\s+", "");
+
+ // Check what we got is what we expected to get
+ assertEquals(outputLogCompareString, outputLogString);
+ }
}