Fix checkstyle warnings in the auth package 31/60531/2
authorDinh Danh Le <dinh.danh.le@ericsson.com>
Tue, 14 Aug 2018 11:32:51 +0000 (12:32 +0100)
committerDinh Danh Le <dinh.danh.le@ericsson.com>
Tue, 14 Aug 2018 13:53:51 +0000 (14:53 +0100)
Change-Id: I64f783d5325301862e2438ac5d22cfcc0a150579
Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com>
Issue-ID: POLICY-1034

auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CgStringRenderer.java
auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/StErrorListener.java
auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCLIEditorMain.java
auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIException.java
auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLILineParser.java
auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameterParser.java
auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CLIParameters.java
auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestCLIEditorOptions.java
auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestContextAlbums.java
auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/TestFileMacro.java

index 50600f9..dbf8f38 100644 (file)
@@ -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);
     }
 }
index ed703da..28e32bc 100644 (file)
@@ -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) {
index e484ff0..c7f7c7b 100644 (file)
@@ -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
      */
index 8e1104c..94b8c14 100644 (file)
@@ -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);
     }
 }
index bbeface..70c2f83 100644 (file)
@@ -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
index 382f23f..8a0c6ef 100644 (file)
@@ -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());
     }
 
index ebaa6c5..24356d1 100644 (file)
@@ -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
      */
index 87618e1..2056c92 100644 (file)
@@ -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());
index 3de41e8..1b99fce 100644 (file)
@@ -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
index 6ff85e7..eb2f2a4 100644 (file)
@@ -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);
+    }
 }