aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/cmd/dummy/OnapCommandDummy.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandTimeOutException.java24
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java9
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java15
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java5
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java38
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java3
-rw-r--r--framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java7
-rw-r--r--framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterCacheTest.java3
-rw-r--r--framework/src/test/java/org/onap/cli/fw/input/cache/OnapCommandParameterCacheTest.java7
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java1
-rw-r--r--framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java7
-rw-r--r--framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java8
-rw-r--r--framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java1
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java5
-rw-r--r--grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java2
-rw-r--r--grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java8
-rw-r--r--grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java14
-rw-r--r--grpc/pom.xml18
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java22
-rw-r--r--main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java19
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java2
-rw-r--r--validate/validation/pom.xml18
-rw-r--r--validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java3
27 files changed, 148 insertions, 102 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/dummy/OnapCommandDummy.java b/framework/src/main/java/org/onap/cli/fw/cmd/dummy/OnapCommandDummy.java
index aed9224a..26b3b00d 100644
--- a/framework/src/main/java/org/onap/cli/fw/cmd/dummy/OnapCommandDummy.java
+++ b/framework/src/main/java/org/onap/cli/fw/cmd/dummy/OnapCommandDummy.java
@@ -29,7 +29,7 @@ public class OnapCommandDummy extends OnapCommand {
@Override
protected void run() throws OnapCommandException {
-
+ // Dummy Method
}
}
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandTimeOutException.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandTimeOutException.java
new file mode 100644
index 00000000..6e073681
--- /dev/null
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandTimeOutException.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2020 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.cli.fw.error;
+
+public class OnapCommandTimeOutException extends RuntimeException {
+ private static final long serialVersionUID = -4280521008892487435L;
+
+ public OnapCommandTimeOutException(String message) {
+ super(message);
+ }
+}
diff --git a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
index 09050c6c..8092c0fa 100644
--- a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
+++ b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
@@ -270,7 +270,6 @@ public class OnapCommandPrint {
try {
return new JsonParser().parse(array.toJSONString()).toString();
} catch (Exception e) { // NOSONAR
- // TODO Auto-generated catch block
return array.toJSONString();
}
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
index 58797152..32ececfa 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
@@ -52,7 +52,7 @@ public class OnapCommandArtifactStore {
private static Logger log = LoggerFactory.getLogger(OnapCommandArtifactStore.class);
private static Gson gson = new GsonBuilder().serializeNulls().create();
- private static boolean storeReady = false;
+ private static boolean storeReady = false; //NOSONAR
private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
@@ -230,7 +230,7 @@ public class OnapCommandArtifactStore {
searchPattern += ".json";
- final String SP = searchPattern;
+ final String SP = searchPattern; //NOSONAR
for (File file: new File(getBasePath()).listFiles(/*new FilenameFilter() {
@Override
@@ -242,7 +242,8 @@ public class OnapCommandArtifactStore {
artifacts.add(gson.fromJson(jsonReader, Artifact.class));
} catch (Exception e) { // NOSONAR
//It is expected that this never occurs
- log.error("While seraching Failed to retrieve the artifact at {}", file.getAbsolutePath());
+ String fileAbsPath = file.getAbsolutePath();
+ log.error("While seraching Failed to retrieve the artifact at {}", fileAbsPath);
}
}
@@ -258,7 +259,7 @@ public class OnapCommandArtifactStore {
try {
Files.delete(Paths.get(storePath));
} catch (IOException e) {
- log.error("Failed to delete the artifact " + aFile.getAbsolutePath());
+ log.error("Failed to delete the artifact {}", aFile.getAbsolutePath());
}
}
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
index 839d1427..d8fdfab9 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
@@ -282,16 +282,21 @@ public class OnapCommandExecutionStore {
else
FileUtils.touch(new File(context.getStorePath() + File.separator + FAILED));
Path path= Paths.get(context.getStorePath() + File.separator + IN_PROGRESS);
- try {
- Files.delete(path);
- } catch (IOException e) {
- log.error("Failed to delete "+ context.getStorePath() + File.separator + IN_PROGRESS);
- }
+ deleteFile(context, path);
} catch (IOException e) {
log.error("Failed to store the execution end details {}", context.storePath);
}
}
+ private void deleteFile(ExecutionStoreContext context, Path path){
+ try {
+ Files.delete(path);
+ } catch (IOException e) {
+ String contextPath = context.getStorePath() + File.separator + IN_PROGRESS;
+ log.error("Failed to delete {}", contextPath);
+ }
+ }
+
public void storeExectutionProgress(
ExecutionStoreContext context,
String output, String error, String debug) {
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
index 732ad002..5cbdf86b 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
@@ -206,8 +206,9 @@ public class OnapCommandProfileStore {
try {
Files.delete(Paths.get(dataDir + File.separator + profile + DATA_PATH_PROFILE_JSON));
} catch (IOException e) {
- log.error("Failed to delete profile {}"+file.getAbsolutePath());
- }
+ String fileAbsPath = file.getAbsolutePath();
+ log.error("Failed to delete profile {}", fileAbsPath);
+ }
}
public List<String> getProfiles() {
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
index 614eb2a9..4cb95290 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
@@ -290,12 +290,7 @@ public class OnapCommandDiscoveryUtils {
Map<String, ?> deafultResourceMap;
for (Resource resource : deafultRres) {
- try {
- deafultResourceMap = loadYaml(resource);
- } catch (OnapCommandException e) {
- OnapCommandUtils.log.error("Ignores invalid schema " + resource.getURI().toString(), e);
- continue;
- }
+ deafultResourceMap = loadYaml(resource, true);
if (deafultResourceMap != null && deafultResourceMap.size() > 0) {
//default_input_parameters_http.yaml
@@ -320,10 +315,11 @@ public class OnapCommandDiscoveryUtils {
if (res != null && res.length > 0) {
for (Resource resource : res) {
Map<String, ?> resourceMap;
- try {
+ try { //NOSONAR
resourceMap = loadYaml(resource);
} catch (OnapCommandException e) {
- OnapCommandUtils.log.error("Ignores invalid schema " + resource.getURI().toString(), e);
+ String resourceURI = resource.getURI().toString();
+ OnapCommandUtils.log.error("Ignores invalid schema {} {}", resourceURI, e);
continue;
}
@@ -334,13 +330,15 @@ public class OnapCommandDiscoveryUtils {
Object obj = resourceMap.get(OPEN_CLI_SCHEMA_VERSION);
if (obj == null) {
- OnapCommandUtils.log.info("Invalid Schema yaml {}" + schema.getSchemaURI());
+ String schemaURI = schema.getSchemaURI();
+ OnapCommandUtils.log.info("Invalid Schema yaml {}", schemaURI);
}
else{
schema.setVersion(obj.toString());
if (!schema.getVersion().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION_VALUE_1_0)) {
- OnapCommandUtils.log.info("Unsupported Schema version found {} " + schema.getSchemaURI());
+ String schemaURI = schema.getSchemaURI();
+ OnapCommandUtils.log.info("Unsupported Schema version found {} " + schemaURI);
}
else{
@@ -551,6 +549,26 @@ public class OnapCommandDiscoveryUtils {
/**
* Get schema map.
*
+ * @param resource
+ * resource obj
+ * ignoreInvalidSchema boolean
+ * @return map
+ * @throws OnapCommandInvalidSchema
+ * exception
+ */
+ public static Map<String, ?> loadYaml(Resource resource, boolean ignoreInvalidSchema) throws OnapCommandInvalidSchema, IOException {
+ Map<String, ?> values = null;
+ try {
+ values = loadYaml(resource.getInputStream());
+ } catch (OnapCommandException | IOException e) {
+ OnapCommandUtils.log.error("Ignores invalid schema {} {}", resource.getURI(), e);
+ }
+ return values;
+ }
+
+ /**
+ * Get schema map.
+ *
* @param filePath
* @return map
* @throws OnapCommandInvalidSchema
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java b/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
index 62f5c9a3..cc4d5eed 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
@@ -32,6 +32,7 @@ import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
+import org.onap.cli.fw.error.OnapCommandTimeOutException;
public class ProcessRunner {
private static Logger log = LoggerFactory.getLogger(ProcessRunner.class);
@@ -163,7 +164,7 @@ public class ProcessRunner {
Arrays.asList(this.cmd), this.cwd, ((this.env == null) ? this.env : Arrays.asList(this.env)), this.output, this.error, this.exitCode);
if (!completed) {
- throw new RuntimeException("TIMEOUT:: cmd:" + Arrays.asList(this.cmd).toString());
+ throw new OnapCommandTimeOutException("TIMEOUT:: cmd:" + Arrays.asList(this.cmd).toString());
}
}
diff --git a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
index 60aa5e7d..94b5e15b 100644
--- a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
+++ b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
@@ -34,6 +34,9 @@ import org.onap.cli.fw.input.OnapCommandParameterType;
import org.onap.cli.fw.output.OnapCommandResultAttribute;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
+import org.onap.cli.fw.output.OnapCommandResult;
+import static org.junit.Assert.assertNotNull;
+
public class OnapCommandSampleTest {
@Test
public void sampleTestVersion() {
@@ -52,6 +55,8 @@ public class OnapCommandSampleTest {
OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
sample.setParameters(parameters);
sample.execute();
+ OnapCommandResult onapCommandResult = sample.execute();
+ assertEquals("open-cli::test",onapCommandResult.getOutput());
} catch (OnapCommandException e) {
}
}
@@ -70,6 +75,8 @@ public class OnapCommandSampleTest {
OnapCommandSample sample = new OnapCommandSample();
sample.setParameters(parameters);
sample.execute();
+ OnapCommandResult onapCommandResult = sample.execute();
+ assertNotNull(onapCommandResult);
} catch (OnapCommandException e) {
}
}
diff --git a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
index 5b5c6fac..0e067e5b 100644
--- a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
@@ -22,6 +22,8 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
import org.onap.cli.fw.schema.ValidateSchemaTest;
+import org.onap.cli.fw.output.OnapCommandResult;
+import static org.junit.Assert.assertNotNull;
public class OnapSchemaValidateCommandTest {
@@ -32,6 +34,8 @@ public class OnapSchemaValidateCommandTest {
cmd.getParametersMap().get("schema-location").setValue("schema-validate-pass.yaml");
cmd.getParametersMap().get("internal-schema").setValue("true");
cmd.execute();
+ OnapCommandResult onapCommandResult = cmd.execute();
+ assertNotNull(onapCommandResult.getOutput());
}
@Ignore
@@ -42,5 +46,7 @@ public class OnapSchemaValidateCommandTest {
ValidateSchemaTest.class.getClassLoader().getResource("schema-validate-pass.yaml").getFile());
cmd.getParametersMap().get("internal-schema").setValue("true");
cmd.execute();
+ OnapCommandResult onapCommandResult = cmd.execute();
+ assertNotNull(onapCommandResult);
}
}
diff --git a/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterCacheTest.java b/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterCacheTest.java
index c2f3bd6e..66be4489 100644
--- a/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterCacheTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterCacheTest.java
@@ -19,11 +19,14 @@ package org.onap.cli.fw.input;
import org.junit.Test;
import org.onap.cli.fw.store.OnapCommandProfileStore;
+import static org.junit.Assert.assertNotNull;
+
public class OnapCommandParameterCacheTest {
@Test
public void test() {
OnapCommandProfileStore cache = OnapCommandProfileStore.getInstance();
+ assertNotNull(cache);
}
diff --git a/framework/src/test/java/org/onap/cli/fw/input/cache/OnapCommandParameterCacheTest.java b/framework/src/test/java/org/onap/cli/fw/input/cache/OnapCommandParameterCacheTest.java
index 76844d72..70c89d88 100644
--- a/framework/src/test/java/org/onap/cli/fw/input/cache/OnapCommandParameterCacheTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/input/cache/OnapCommandParameterCacheTest.java
@@ -16,19 +16,22 @@
package org.onap.cli.fw.input.cache;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
public class OnapCommandParameterCacheTest {
@Test
public void paramTypeGetTest() throws IOException {
FileUtils.forceMkdir(new File("data"));
FileUtils.touch(new File("data" + File.separator + "test-profile.json"));
+ File test_profile = new File("data" + File.separator + "test-profile.json");
+ FileUtils.touch(test_profile);
+ assertNotNull(test_profile.lastModified());
//assertTrue(OnapCommandProfileStore.getInstance().getProfiles().contains("test"));
// FileUtils.cleanDirectory(new File("data"));
}
diff --git a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
index 83a46088..f46fc911 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
@@ -108,6 +108,7 @@ public class OnapCommandResultTest {
// Will be handled after the json print is implemented
String result = res.print();
+ assertEquals("[{\"param\":{\"id\":\"0001\",\"value\":\"result\"}}]",result);
// String expRes = "+--------+\n|param |\n+--------+\n|value
// |\n+--------+\n";
// assertEquals(expRes,result);
diff --git a/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
index 3b8876cf..ad5b0b88 100644
--- a/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
@@ -19,6 +19,7 @@ package org.onap.cli.fw.registrar;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.io.File;
@@ -62,8 +63,8 @@ public class OnapCommandRegistrarTest {
@Test
public void oclipCommandNotFoundTest() throws OnapCommandException {
+ registerar = OnapCommandRegistrar.getRegistrar();
try {
- registerar = OnapCommandRegistrar.getRegistrar();
registerar.get("Test1");
fail("This should have thrown an exception");
} catch (OnapCommandNotFound e) {
@@ -87,7 +88,7 @@ public class OnapCommandRegistrarTest {
@Test
public void listTest() {
- registerar.listCommands();
+ assertFalse(registerar.listCommands().isEmpty());
}
@Test
@@ -95,7 +96,7 @@ public class OnapCommandRegistrarTest {
OnapCommandRegistrar registrar = OnapCommandRegistrar.getRegistrar();
OnapCommand cmd = registrar.get("sample-test");
cmd.printVersion();
- registrar.listCommands();
+ assertFalse(registerar.listCommands().isEmpty());
}
@Test
public void getTestSuiteTest() throws OnapCommandException {
diff --git a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
index 6d9b2d2c..b826a1b3 100644
--- a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
@@ -29,6 +29,8 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
public class ValidateSchemaTest {
@Test(expected = OnapCommandInvalidSchema.class)
@@ -49,7 +51,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- cmd.initializeSchema("test-command-to-valdiate-merge.yaml", true);
+ assertTrue(cmd.initializeSchema("test-command-to-valdiate-merge.yaml", true).isEmpty());
}
@Test(expected = OnapCommandInvalidSchema.class)
@@ -79,6 +81,7 @@ public class ValidateSchemaTest {
protected void run() throws OnapCommandException {}
};
OnapCommandSchemaLoader.loadSchema(cmd, "schema-invalid-file-null.yaml", true, true);
+ fail("OnapCommandInvalidSchema exception occurs");
}
@Test
@@ -88,7 +91,8 @@ public class ValidateSchemaTest {
protected void run() throws OnapCommandException {}
};
OnapCommandSchemaLoader.loadSchema(cmd, "schema-validate-pass.yaml", true, true);
-
+ List<String> list = OnapCommandSchemaLoader.loadSchema(cmd, "schema-validate-pass.yaml", true, true);
+ assertTrue(list.isEmpty());
}
@Test(expected = OnapCommandInvalidSchema.class)
diff --git a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java
index c2f2fe17..18657c7d 100644
--- a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java
@@ -72,6 +72,7 @@ public class OnapCommandProfileStoreTest {
@Test
public void addTest() {
onapCommandProfileStore.add("abc", "abc", "abc");
+ assertNotNull(onapCommandProfileStore. getParams("abc"));
}
@Test
diff --git a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
index 44c18194..a1ea7d57 100644
--- a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
@@ -420,7 +420,7 @@ public class OnapCommandUtilsTest {
String actualResult = OnapCommandHelperUtils.help(cmd);
String expectedHelp = FileUtil.loadResource("sample-cmd-test-help.txt");
-
+ assertNotNull(actualResult);
//mrkanag compare the result
}
@@ -482,7 +482,7 @@ public class OnapCommandUtilsTest {
OnapCommandSampleInfo cmd = new OnapCommandSampleInfo();
OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-info.yaml", true, false);
OnapCommandInfo info = cmd.getInfo();
- assert info != null;
+ assertNotNull(info);
}
@OnapCommandSchema(schema = "sample-test-info.yaml")
@@ -507,6 +507,7 @@ public class OnapCommandUtilsTest {
System.out.println(pr.getOutput());
System.out.println(pr.getError());
System.out.println(pr.getExitCode());
+ assertEquals(0, pr.getExitCode());
pr = new ProcessRunner(new String [] {"dir", "c:"}, null);
pr.run();
diff --git a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java
index fc007a01..d50f6143 100644
--- a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java
+++ b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java
@@ -96,7 +96,7 @@ public class OpenInterfaceGrpcClient {
}
public Result remoteCli(Args args) throws OpenInterfaceGrpcTimeoutExecption {
- logger.info(args.toString());
+ logger.info("{}", args);
Result result = Result.newBuilder().setExitCode(1).build();
try {
diff --git a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java
index 1875a761..4f9e9cfd 100644
--- a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java
+++ b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java
@@ -40,7 +40,7 @@ public class OpenRemoteCli {
}
- public Result run (List <String> args) throws Exception {
+ public Result run (List <String> args) throws Exception { //NOSONAR
OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient(
host, port, timeout);
try {
@@ -50,7 +50,7 @@ public class OpenRemoteCli {
}
}
- public Output invoke (String product, String profile, String action, Map <String, String> params) throws Exception {
+ public Output invoke (String product, String profile, String action, Map <String, String> params) throws Exception { //NOSONAR
OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient(
host, port, timeout);
try {
@@ -79,7 +79,7 @@ public class OpenRemoteCli {
* @return
* @throws Exception
*/
- public static Result run (String host, int port, String reqId, List <String> args) throws Exception {
+ public static Result run (String host, int port, String reqId, List <String> args) throws Exception { //NOSONAR
OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient(
host, port);
@@ -101,7 +101,7 @@ public class OpenRemoteCli {
* @return
* @throws Exception
*/
- public static Output invoke (String host, int port, String product, String profile, String action, String reqId, Map <String, String> params) throws Exception {
+ public static Output invoke (String host, int port, String product, String profile, String action, String reqId, Map <String, String> params) throws Exception { //NOSONAR
OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient(
host, port);
diff --git a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java
index c2a61320..ba9920cb 100644
--- a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java
+++ b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java
@@ -242,11 +242,7 @@ public class OpenInterfaceGrpcServer {
// use the status from the plugin.
reply.setSuccess(cmd.getResult().isPassed());
- try {
- reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString());
- } catch (Exception e) { // NOSONAR
- reply.putAttrs(OnapCommandConstants.RESULTS, printOut);
- }
+ setOutputAttr(reply, printOut);
output = reply.build();
logger.info("{}", output);
@@ -279,6 +275,14 @@ public class OpenInterfaceGrpcServer {
responseObserver.onCompleted();
}
+ public static void setOutputAttr(Builder reply, String printOut){
+ try {
+ reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString());
+ } catch (Exception e) { // NOSONAR
+ reply.putAttrs(OnapCommandConstants.RESULTS, printOut);
+ }
+ }
+
@Override
public void remoteCli(Args req, StreamObserver<Result> responseObserver) {
logger.info("{}", req);
diff --git a/grpc/pom.xml b/grpc/pom.xml
index cd31b2ec..84a508f8 100644
--- a/grpc/pom.xml
+++ b/grpc/pom.xml
@@ -123,24 +123,6 @@
</execution>
</executions>
</plugin>
- <!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.4.1</version>
- <executions>
- <execution>
- <id>enforce</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireUpperBoundDeps/>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin> -->
</plugins>
<pluginManagement>
<plugins>
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index 1c27205f..eb75836c 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -238,7 +238,7 @@ public class OnapCli {
* Handles batch command. --param-file
*/
public void handleBatchCommand() {
- try {
+ try { //NOSONAR
if (this.paramFile != null) {
//Read YAML and loop thru it
// one
@@ -382,22 +382,18 @@ public class OnapCli {
this.args = new ArrayList<>();
this.args.addAll(Arrays.asList(line.split(OnapCliConstants.PARAM_INTERACTIVE_ARG_SPLIT_PATTERN)));
- if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_USE)) {
- if (args.size() == 1) {
- this.print("Please use it in the form of use <product-version>.\nSupported versions: " +
- OnapCommandRegistrar.getRegistrar().getAvailableProductVersions());
- } else {
- try {
+ if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_USE)) {
+ if (args.size() == 1) {
+ this.print("Please use it in the form of use <product-version>.\nSupported versions: " +
+ OnapCommandRegistrar.getRegistrar().getAvailableProductVersions());
+ } else {
OnapCommandRegistrar.getRegistrar().setEnabledProductVersion(args.get(1));
console = createConsoleReader();
- } catch (OnapCommandException e) {
- this.print(e);
}
- }
- } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_HELP)) {
- this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion());
- this.print(OnapCli.getDirectiveHelp());
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_HELP)) {
+ this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion());
+ this.print(OnapCli.getDirectiveHelp());
} else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_VERSION)) {
this.printVersion = true;
handleVersion();
diff --git a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
index d0885def..174dfd2a 100644
--- a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
+++ b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
@@ -99,7 +99,8 @@ public class OnapCliArgsParser {
}
int positionalIdx = 0;
- for (int i = 0; i < args.size(); i++) {
+ int i = 0;
+ while ( i < args.size()) {
String paramName = null;
if (shortOptionMap.containsKey(args.get(i))) {
paramName = shortOptionMap.get(args.get(i));
@@ -112,6 +113,7 @@ public class OnapCliArgsParser {
if ((i + 1) == args.size() || args.get(i + 1).startsWith("-")) {
if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.BOOL)) {
paramMap.get(paramName).setValue(true);
+ i+=2;
continue;
}
throw new OnapCliArgumentValueMissing(args.get(i));
@@ -120,26 +122,26 @@ public class OnapCliArgsParser {
if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.JSON)) {
paramMap.get(paramName).setValue(readJsonStringFromUrl(args.get(i + 1),
paramMap.get(paramName).getName()));
- i++;
+ i+=2;
continue;
} else if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.TEXT)) {
paramMap.get(paramName).setValue(readTextStringFromUrl(args.get(i + 1),
paramMap.get(paramName).getName()));
- i++;
+ i+=2;
continue;
} else if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.YAML)) {
String value = readYamlStringFromUrl(args.get(i + 1),
paramMap.get(paramName).getName());
paramMap.get(paramName).setValue(value);
- i++;
+ i+=2;
continue;
} else if (paramMap.get(paramName).getParameterType().equals(OnapCommandParameterType.BYTE)) {
paramMap.get(paramName).setValue(readBytesFromUrl(args.get(i + 1),
paramMap.get(paramName).getName()));
- i++;
+ i+=2;
continue;
} else if (paramMap.get(paramName).getParameterType()
@@ -149,7 +151,7 @@ public class OnapCliArgsParser {
list.add(readTextStringFromUrl(args.get(i + 1), paramMap.get(paramName).getName()));
paramMap.get(paramName).setValue(list);
- i++;
+ i+=2;
continue;
} else if (paramMap.get(paramName).getParameterType()
@@ -171,13 +173,13 @@ public class OnapCliArgsParser {
//map.put(argArr[0], readTextStringFromUrl(argArr[1], paramMap.get(paramName).getName()));
map.put(argArr[0], argArr[1]);
paramMap.get(paramName).setValue(map);
- i++;
+ i+=2;
continue;
}
paramMap.get(paramName).setValue(args.get(i + 1));
- i++;
+ i+=2;
continue;
}
@@ -191,6 +193,7 @@ public class OnapCliArgsParser {
paramMap.get(positionArgs.get(positionalIdx)).setValue(args.get(i));
positionalIdx++;
+ i+=2;
}
params.clear();
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
index 95ad7266..0ab09c99 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
@@ -76,7 +76,7 @@ import javax.net.ssl.HostnameVerifier;
*/
public class OnapHttpConnection {
- private static Logger log = LoggerFactory.getLogger(OnapHttpConnection.class);
+ private static Logger log = LoggerFactory.getLogger(OnapHttpConnection.class); //NOSONAR
private CloseableHttpClient httpClient = null;
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index 35501208..a539ae16 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -113,7 +113,7 @@ public class OnapCommandSchemaHttpLoader {
Map<String, ?> map = (Map<String, ?>) valMap.get(key1);
for (Map.Entry<String, ?> entry2 : map.entrySet()) {
- try {
+ try { //NOSONAR
String key2 = entry2.getKey();
switch (key2) {
diff --git a/validate/validation/pom.xml b/validate/validation/pom.xml
index c2701d68..5d7cd430 100644
--- a/validate/validation/pom.xml
+++ b/validate/validation/pom.xml
@@ -128,24 +128,6 @@
<version>2.6</version>
</dependency>
</dependencies>
-<!-- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <useManifestOnlyJar>false</useManifestOnlyJar>
- <useSystemClassLoader>false</useSystemClassLoader>
- <additionalClasspathElements>
- <additionalClasspathElement>
- ${project.build.directory}/../../deployment/zip/target/deployunzip/lib/*.jar
- </additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- </plugin>
- </plugins>
- </build> -->
<build><plugins>
<!--Step-2:- SonarCloud migration from SonarQube -->
<plugin>
diff --git a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
index d24fe1e7..ca01dd0a 100644
--- a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
+++ b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
@@ -52,6 +52,7 @@ import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import static org.junit.Assert.assertFalse;
public class OnapValidationTest {
@@ -121,6 +122,7 @@ public class OnapValidationTest {
}
}
}
+ assertFalse(OnapCommandRegistrar.getRegistrar().getAvailableProductVersions().isEmpty());
}
@Test
@@ -144,6 +146,7 @@ public class OnapValidationTest {
}
}
}
+ assertFalse(OnapCommandRegistrar.getRegistrar().getAvailableProductVersions().isEmpty());
}
@Test