diff options
author | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-08-14 12:32:51 +0100 |
---|---|---|
committer | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-08-14 14:53:51 +0100 |
commit | 3ab54a2340f40d11d9a0a3994f579baeeb6c0ca6 (patch) | |
tree | f7438c01cc0023c47b2d15c2eb84254c626ef73b /auth/cli-editor | |
parent | 933af17963b47650fe9864d03e63a06aa08e31a9 (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/cli-editor')
8 files changed, 83 insertions, 93 deletions
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); + } } |