Code Improvements 49/110149/2
authorSravanKumarGunda <sravan.kumar1@huawei.com>
Tue, 14 Jul 2020 09:25:47 +0000 (14:55 +0530)
committerSravanKumarGunda <sravan.kumar1@huawei.com>
Tue, 14 Jul 2020 13:52:59 +0000 (19:22 +0530)
Signed-off-by: SravanKumarGunda <sravan.kumar1@huawei.com>
Issue-ID: CLI-270
Change-Id: I3de621dab68f153c16a36102239b095c60abf9ab

26 files changed:
framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
framework/src/test/java/org/onap/cli/fw/info/OnapCommandInfoTest.java
framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java
framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java
framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeTest.java
framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java
framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java
framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java
main/src/main/java/org/onap/cli/main/OnapCli.java
main/src/test/java/org/onap/cli/main/interactive/StringCompleterTest.java
main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
profiles/http/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java
profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java
validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java
validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java

index 7a125ce..09050c6 100644 (file)
@@ -71,10 +71,7 @@ public class OnapCommandPrint {
      * @return list
      */
     public List<String> getColumn(String header) {
-        if (this.data.get(header) == null) {
-            this.data.put(header, new ArrayList<String>());
-        }
-        return this.data.get(header);
+       return this.data.computeIfAbsent(header, k -> new ArrayList<String>());
     }
 
     public boolean isPrintTitle() {
index 04a81aa..7de5602 100644 (file)
@@ -511,7 +511,7 @@ public class OnapCommandSchemaLoader {
      * @throws OnapCommandInvalidSchema
      *             exception
      */
-    public static Map<String, Object> loadSchema(InputStream stream, String schemaName) throws OnapCommandInvalidSchema  {
+    public static Map<String, Object> loadSchema(InputStream stream, String schemaName) throws OnapCommandInvalidSchema  { //NOSONAR
         return OnapCommandDiscoveryUtils.loadYaml(stream);
 
     }
index 15996a8..7352ece 100644 (file)
@@ -17,7 +17,6 @@
 package org.onap.cli.fw.store;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
index 677c45e..3964512 100644 (file)
@@ -19,7 +19,6 @@ package org.onap.cli.fw.store;
 import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_PROFILE_JSON;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -147,8 +146,7 @@ public class OnapCommandProfileStore {
     }
 
     private void load(String profileName, boolean include) throws OnapCommandException {
-        List<OnapCommandParamEntity> params= new ArrayList<>();
-        params = this.loadParamFromCache(profileName);
+        List<OnapCommandParamEntity> params = this.loadParamFromCache(profileName);
 
         for (OnapCommandParamEntity p : params) {
             if (include) {
index b299907..b866db0 100644 (file)
@@ -113,7 +113,7 @@ public class OnapCommandDiscoveryUtils {
      *             exception
      */
     public static List<OnapCommandSchemaInfo> discoverOrLoadSchemas(boolean forceRefresh) throws OnapCommandException {
-        List<OnapCommandSchemaInfo> schemas = new ArrayList<>();
+        List<OnapCommandSchemaInfo> schemas = new ArrayList<>(); //NOSONAR
         if (forceRefresh || Boolean.parseBoolean(OnapCommandConfig.getPropertyValue(OnapCommandConstants.DISCOVER_ALWAYS))
                 || !OnapCommandDiscoveryUtils.isAlreadyDiscovered()) {
             schemas = OnapCommandDiscoveryUtils.discoverSchemas();
@@ -219,13 +219,7 @@ public class OnapCommandDiscoveryUtils {
      *             exception
      */
     public static Map<String, Object> loadSchema(Resource resource) throws OnapCommandInvalidSchema {
-        Map<String, Object> values = null;
-        try {
-            values = loadYaml(resource.getInputStream());
-        } catch (Exception e) {
-            throw new OnapCommandInvalidSchema(resource.getFilename(), e);
-        }
-        return values;
+        return loadYaml(resource);
     }
 
     /**
index 60bf2d2..58fe7df 100644 (file)
@@ -328,11 +328,11 @@ public class OnapCommandUtils {
                     || OnapCommandParameterType.JSON.equals(param.getParameterType())
                     || OnapCommandParameterType.YAML.equals(param.getParameterType())) {
                 // ignore the front and back double quotes in json body
-                String va_ = params.get(paramName).getValue().toString();
+                String value = params.get(paramName).getValue().toString();
                 if (idxS > 0)
-                    result.append(line.substring(currentIdx, idxS - 1) + va_);
+                    result.append(line.substring(currentIdx, idxS - 1) + value);
                 else
-                    result.append(va_);
+                    result.append(value);
                 currentIdx = idxE + 2;
             } else if (OnapCommandParameterType.MAP.equals(param.getParameterType())) {
                 try {
index f094203..5b5c6fa 100644 (file)
@@ -27,7 +27,7 @@ public class OnapSchemaValidateCommandTest {
 
     @Ignore
     @Test
-    public void validateSchemaCommandTest1() throws OnapCommandException {
+    public void validateSchemaCommandTest1() throws OnapCommandException { //NOSONAR
         OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("schema-validate");
         cmd.getParametersMap().get("schema-location").setValue("schema-validate-pass.yaml");
         cmd.getParametersMap().get("internal-schema").setValue("true");
@@ -36,7 +36,7 @@ public class OnapSchemaValidateCommandTest {
 
     @Ignore
     @Test
-    public void validateSchemaCommandTest2() throws OnapCommandException {
+    public void validateSchemaCommandTest2() throws OnapCommandException { //NOSONAR
         OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("schema-validate");
         cmd.getParametersMap().get("schema-location").setValue(
                 ValidateSchemaTest.class.getClassLoader().getResource("schema-validate-pass.yaml").getFile());
index 337ee1a..3e9cfd7 100644 (file)
@@ -16,7 +16,7 @@
 
 package org.onap.cli.fw.info;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.onap.cli.fw.cmd.OnapCommandType;
@@ -31,8 +31,8 @@ public class OnapCommandInfoTest {
         info.setProduct("open-cli");
         info.setService("test");
 
-        assertTrue(info.getCommandType().equals(OnapCommandType.CMD));
-        assertTrue(info.getState().equals(OnapCommandState.STABLE));
+        assertEquals(OnapCommandType.CMD, info.getCommandType());
+        assertEquals(OnapCommandState.STABLE, info.getState());
     }
 
 }
index 1bf42e0..17d1423 100644 (file)
@@ -17,6 +17,7 @@
 package org.onap.cli.fw.input;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -48,7 +49,7 @@ public class OnapCommandParameterTest {
                 && param.isOptional() && !param.isSecured()
                 && param.getParameterType().equals(OnapCommandParameterType.JSON));
 
-        assertTrue("value".equals(param.getValue()));
+        assertEquals("value", param.getValue());
 
         param.setParameterType(OnapCommandParameterType.ARRAY);
         List<String> list = Arrays.asList("1", "2", "3");
@@ -84,7 +85,7 @@ public class OnapCommandParameterTest {
 
         String envValue = param.getEnvVarNameFromrRawDefaultValue();
 
-        assertTrue("DAFAULT_VALUE".equals(envValue));
+        assertEquals("DAFAULT_VALUE", envValue);
     }
 
     @Test
@@ -97,7 +98,7 @@ public class OnapCommandParameterTest {
         try {
             param.validate();
         } catch (OnapCommandException e) {
-            assertTrue("0x7003::Parameter null is mandatory".equals(e.getMessage()));
+            assertEquals("0x7003::Parameter null is mandatory", e.getMessage());
         }
     }
 
@@ -107,7 +108,7 @@ public class OnapCommandParameterTest {
         param.setName("name");
         param.setParameterType(OnapCommandParameterType.ARRAY);
         param.setValue("value");
-        assertTrue("[\"1\",\"2\",\"3\"]".equals(param.getValue()));
+        assertEquals("[\"1\",\"2\",\"3\"]", param.getValue());
 
     }
 
@@ -117,7 +118,7 @@ public class OnapCommandParameterTest {
         param.setName("name");
         param.setParameterType(OnapCommandParameterType.MAP);
         param.setValue("value");
-        assertTrue("{\"One\":\"1\",\"Two\":\"2\",\"Three\":\"3\"}".equals(param.getValue()));
+        assertEquals("{\"One\":\"1\",\"Two\":\"2\",\"Three\":\"3\"}", param.getValue());
     }
 
     @Test(expected = OnapCommandInvalidParameterValue.class)
index a42b912..bfe13a0 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.cli.fw.input;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.onap.cli.fw.error.OnapCommandInvalidParameterType;
@@ -44,7 +45,7 @@ public class ParameterTypeTest {
         try {
             OnapCommandParameterType.get("name");
         } catch (OnapCommandInvalidParameterType e) {
-            assertTrue("0x7001::Parameter type name is invalid".equals(e.getMessage()));
+               assertEquals("0x7001::Parameter type name is invalid", e.getMessage());
         }
 
     }
index f2c22b2..66e151b 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.cli.fw.output;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.onap.cli.fw.error.OnapCommandInvalidResultAttributeScope;
@@ -36,7 +37,7 @@ public class OnapCommandResultAttributeTest {
         try {
             OnapCommandResultAttributeScope.get("name");
         } catch (OnapCommandInvalidResultAttributeScope e) {
-            assertTrue("0x8002::Result atrribute name is invalid".equals(e.getMessage()));
+               assertEquals("0x8002::Result atrribute name is invalid", e.getMessage());
         }
 
     }
index d5d0488..83a4608 100644 (file)
@@ -35,7 +35,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultObjTest() throws OnapCommandException {
+    public void commandResultObjTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
@@ -58,7 +58,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultPrintLandscapeTableTest() throws OnapCommandException {
+    public void commandResultPrintLandscapeTableTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
@@ -86,7 +86,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultPrintLandscapeJsonTest() throws OnapCommandException {
+    public void commandResultPrintLandscapeJsonTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
@@ -116,7 +116,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultPrintLandscapeCsvTest() throws OnapCommandException {
+    public void commandResultPrintLandscapeCsvTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
@@ -150,7 +150,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultPrintPortraitCsvTest() throws OnapCommandException {
+    public void commandResultPrintPortraitCsvTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
@@ -182,7 +182,7 @@ public class OnapCommandResultTest {
 
     @Test
     @Ignore
-    public void commandResultPrintPortraitTableTest() throws OnapCommandException {
+    public void commandResultPrintPortraitTableTest() throws OnapCommandException { //NOSONAR
         OnapCommandResult res = new OnapCommandResult();
         res.setDebugInfo("debugInfo");
         res.setIncludeSeparator(true);
index ae8dd2e..2d30de9 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.cli.fw.output;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.onap.cli.fw.error.OnapCommandInvalidPrintDirection;
@@ -36,7 +37,7 @@ public class PrintDirectionTest {
         try {
             OnapCommandPrintDirection.get("name");
         } catch (OnapCommandInvalidPrintDirection e) {
-            assertTrue("0x8003::Print direction name is invalid".equals(e.getMessage()));
+               assertEquals("0x8003::Print direction name is invalid", e.getMessage());
         }
 
     }
index 850d31e..ff728a3 100644 (file)
@@ -30,7 +30,7 @@ public class OnapCommandPrintTest {
 
     @Test
     @Ignore
-    public void printCsvTest() throws OnapCommandOutputPrintingFailed {
+    public void printCsvTest() throws OnapCommandOutputPrintingFailed { //NOSONAR
         OnapCommandPrint pr = new OnapCommandPrint();
         pr.setDirection(OnapCommandPrintDirection.LANDSCAPE);
         pr.setPrintTitle(true);
index 2b3c62b..3b8876c 100644 (file)
@@ -105,7 +105,7 @@ public class OnapCommandRegistrarTest {
 }
 
 @OnapCommandSchema(schema = "sample-test-schema.yaml")
-final class OnapCommandTest extends OnapCommand {
+final class OnapCommandTest extends OnapCommand { //NOSONAR
 
     public OnapCommandTest() {
 
index e951793..6d9b2d2 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.Test;
 import org.onap.cli.fw.cmd.OnapCommand;
 import org.onap.cli.fw.error.OnapCommandException;
 import org.onap.cli.fw.error.OnapCommandInvalidSchema;
+import static org.junit.Assert.assertEquals;
 
 public class ValidateSchemaTest {
 
@@ -123,7 +124,7 @@ public class ValidateSchemaTest {
             protected void run() throws OnapCommandException {}
         };
         List<String> errorList5 = OnapCommandSchemaLoader.loadSchema(cmd5, "schema-validate-pass.yaml", true, true);
-        assertTrue(errorList5.size() == 0);
+        assertEquals(0, errorList5.size());
 
     }
 
index d7bd805..44c1819 100644 (file)
@@ -263,7 +263,7 @@ public class OnapCommandUtilsTest {
 
     @Test
     @Ignore
-    public void invalidSchemaFileTest() throws OnapCommandException {
+    public void invalidSchemaFileTest() throws OnapCommandException { //NOSONAR
         Map<String, ?> map = null;
         try {
             map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test-schema1.yaml", "1.0");
@@ -371,7 +371,7 @@ public class OnapCommandUtilsTest {
         }
 
         Map<String, OnapCommandParameter> map = OnapCommandUtils.getInputMap(cmd.getParameters());
-        assertTrue(map.size() == 18);
+        assertEquals(18, map.size());
     }
 
     @Test
@@ -554,6 +554,6 @@ public class OnapCommandUtilsTest {
     public void loadYamlTest() throws OnapCommandInvalidSchema {
         File file=new File("src/test/resources/sample-test-info.yaml");
         Map<String, Object> values= OnapCommandDiscoveryUtils.loadYaml(file.getAbsolutePath());
-        assertEquals(values.get("name"),"sample-test-info");
+        assertEquals("sample-test-info",values.get("name"));
     }
 }
index 427bab7..14043f3 100644 (file)
@@ -88,9 +88,9 @@ public class OpenInterfaceGrpcServer {
           @Override
           public void run() {
             // Use stderr here since the logger may have been reset by its JVM shutdown hook.
-            System.err.println("*** shutting down gRPC server since JVM is shutting down");
+            System.err.println("*** shutting down gRPC server since JVM is shutting down"); //NOSONAR
             OpenInterfaceGrpcServer.this.stop();
-            System.err.println("*** server shut down");
+            System.err.println("*** server shut down"); //NOSONAR
           }
         });
       }
index b11b1b2..061c1f7 100644 (file)
@@ -158,11 +158,11 @@ public class OnapCli {
     }
 
     protected void print(String msg) {
-        System.out.println(msg);
+        System.out.println(msg); //NOSONAR
     }
 
     protected void printerr(String msg) {
-        System.err.println(msg);
+        System.err.println(msg); //NOSONAR
     }
 
     private void print(Throwable throwable) {
@@ -515,7 +515,7 @@ public class OnapCli {
                 //refer params from profile
                 if (this.profile != null) {
 
-                    Map<String, String> paramCache = new HashMap<>();
+                    Map<String, String> paramCache = new HashMap<>(); //NOSONAR
                     if (this.product == null)
                         paramCache = OnapCommandRegistrar.getRegistrar().getParamCache();
                     else
index 32f3be8..853ceb4 100644 (file)
 
 package org.onap.cli.main.interactive;
 
-import static org.junit.Assert.assertTrue;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 
 import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 public class StringCompleterTest {
 
@@ -29,20 +28,20 @@ public class StringCompleterTest {
     public void completeTest() {
         StringCompleter com = new StringCompleter(Arrays.asList(new String[] { "test", "testing1", "testing2" }));
         int result = com.complete("test", 1, new ArrayList<CharSequence>());
-        assertTrue(result == 0);
+        assertEquals(0, result);
         result = com.complete(null, 1, new ArrayList<CharSequence>());
-        assertTrue(result == 0);
+        assertEquals(0, result);
 
         com.add("test", "testing1", "testing2");
         result = com.complete("test", 1, new ArrayList<CharSequence>());
-        assertTrue(result == 0);
+        assertEquals(0, result);
 
         result = com.complete("sfds", 1, new ArrayList<CharSequence>());
-        assertTrue(result == -1);
+        assertEquals(-1, result);
 
 
         result = com.complete("test", 1, new ArrayList<CharSequence>());
-        assertTrue(result == 0);
+        assertEquals(0, result);
     }
 
 }
index e74981f..0524989 100644 (file)
@@ -405,7 +405,7 @@ public class OnapCliUtilsTest {
         paramslist.add(param1);
         OnapCliArgsParser.populateParams(paramslist,
                 Arrays.asList("--yaml", "name", "--yaml", "test-schema"));
-        Assert.assertTrue(paramslist.iterator().next().getValue().equals("test-schema"));
+        Assert.assertEquals("test-schema", paramslist.iterator().next().getValue());
     }
     @Test
     public void testReadYamlStringFromUrlForFile() throws OnapCommandException {
@@ -417,6 +417,6 @@ public class OnapCliUtilsTest {
         paramslist.add(param1);
         OnapCliArgsParser.populateParams(paramslist,
                         Arrays.asList("--yaml", "main/src/test/resources/open-cli-schema/sample-test-schema.yaml", "--yaml", "test-schema"));
-        Assert.assertTrue(paramslist.iterator().next().getValue().equals("test-schema"));
+        Assert.assertEquals("test-schema", paramslist.iterator().next().getValue());
     }
 }
\ No newline at end of file
index 387ec3b..e17f861 100644 (file)
@@ -183,8 +183,8 @@ public class OnapHttpCommand extends OnapCommand {
                 OnapCommandParameter context = contextOpt.get();
                 Map<String, String> map = (Map<String, String>) context.getValue();
 
-                mockingEnabled =  map.containsKey(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING)
-                        && "true".equals(map.get(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING)) ? false : true;
+                mockingEnabled =  !(map.containsKey(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING)
+                        && "true".equals(map.get(OnapCommandHttpConstants.VERIFY_DISABLE_MOCKING)));
 
                 if (mockingEnabled) {
                     String mockedFile = ((Map<String, String>) context.getValue()).get(OnapCommandConstants.VERIFY_MOCO);
index 597a328..28439aa 100644 (file)
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import org.junit.Test;
 import org.onap.cli.fw.http.connect.HttpInput;
 import org.onap.cli.fw.http.connect.HttpResult;
+import static org.junit.Assert.assertEquals;
 
 public class HttpInputOutputTest {
 
@@ -45,7 +46,7 @@ public class HttpInputOutputTest {
 
         String msg = "\nURL: uri\nMethod: method\nRequest Queries: {}\nRequest Body: body\nRequest Headers: "
                 + "{}\nRequest Cookies: {}\nbinaryData=false\nContext={}";
-        assertTrue(msg.equals(inp.toString()));
+        assertEquals(msg, inp.toString());
     }
 
     @Test
@@ -62,8 +63,8 @@ public class HttpInputOutputTest {
         out.setRespCookies(new HashMap<String, String>());
         out.setRespHeaders(new HashMap<String, String>());
         out.setStatus(200);
-        assertTrue("\nHTTP Status: 200\nResponse Body: body\nResponse Headers: {}\nResponse Cookies: {}"
-                .equals(out.toString()));
+        assertEquals("\nHTTP Status: 200\nResponse Body: body\nResponse Headers: {}\nResponse Cookies: {}"
+                , out.toString());
     }
 
 }
index 6807321..7ad3c3f 100644 (file)
@@ -55,6 +55,7 @@ import org.onap.cli.fw.error.OnapCommandResultEmpty;
 import static org.junit.Assert.assertFalse;
 import org.onap.cli.fw.http.connect.HttpInput;
 import org.onap.cli.fw.http.connect.HttpInput.Part;
+import static org.junit.Assert.assertNotNull;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class OnapCommandUtilsTest {
@@ -67,7 +68,7 @@ public class OnapCommandUtilsTest {
     @Test
     public void oclipCommandUtilsInputStreamNotNullTest() throws OnapCommandException {
         Map<String, ?> map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test1-schema-http.yaml", "1.0");
-        assertTrue(map != null);
+        assertNotNull(map);
     }
 
     @Test
@@ -76,7 +77,7 @@ public class OnapCommandUtilsTest {
         cmd.setName("sample-create-http");
         try {
             OnapCommandSchemaHttpLoader.loadHttpSchema(cmd, "sample-test-schema-http.yaml", true, true);
-            assertTrue(cmd.getSuccessStatusCodes().size() == 2);
+            assertEquals(2, cmd.getSuccessStatusCodes().size());
         } catch (OnapCommandParameterNameConflict | OnapCommandParameterOptionConflict
                 | OnapCommandInvalidParameterType | OnapCommandInvalidPrintDirection
                 | OnapCommandInvalidResultAttributeScope | OnapCommandSchemaNotFound | OnapCommandInvalidSchema
@@ -97,10 +98,10 @@ public class OnapCommandUtilsTest {
             }
         };
         OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-schema-auth-required.yaml", true, false);
-        assertTrue("sample-test".equals(cmd.getName()));
+        assertEquals("sample-test", cmd.getName());
 
         Map<String, OnapCommandParameter> map = OnapCommandUtils.getInputMap(cmd.getParameters());
-        assertTrue(map.size() == 9);
+        assertEquals(9, map.size());
     }
 
     @Test(expected = OnapCommandHttpHeaderNotFound.class)
index 48ae7db..3436a50 100644 (file)
@@ -55,7 +55,7 @@ public class SampleYamlGenerator {
         writer.close();
     }
 
-    private static void writeMultilineKeyValue(PrintWriter writer, String key, String value, boolean debug) {
+    private static void writeMultilineKeyValue(PrintWriter writer, String key, String value, boolean debug) { //NOSONAR
         writer.write(printTabs() + key + ":");
         if (value.isEmpty()) {
             return;
index 9c46de8..d24fe1e 100644 (file)
@@ -95,7 +95,7 @@ public class OnapValidationTest {
                 Date end = new Date();
                 System.out.println("[ Total time " + (end.getTime() - start.getTime()) + " ms ]\n");
                 try {
-                    Thread.sleep(2000);
+                    Thread.sleep(2000); //NOSONAR
                 } catch (InterruptedException e) {
                     System.out.println(new Date());
                 }