aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profiles/command/src/test/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmdTest.java51
-rw-r--r--profiles/command/src/test/java/org/onap/cli/fw/cmd/conf/OnapCommandConstantsTest.java37
-rw-r--r--profiles/command/src/test/java/org/onap/cli/fw/cmd/error/OnapCommandFailTest.java49
-rw-r--r--profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java16
4 files changed, 146 insertions, 7 deletions
diff --git a/profiles/command/src/test/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmdTest.java b/profiles/command/src/test/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmdTest.java
new file mode 100644
index 00000000..bd7bcdce
--- /dev/null
+++ b/profiles/command/src/test/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmdTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2022 Samsung Electronics
+ *
+ * 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.cmd.cmd;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.*;
+
+public class OpenCommandShellCmdTest {
+ List<String> command = new ArrayList<>();
+ Map<String, String> envVariable = new HashMap<String, String>();
+ Map<String, String> resultMap = new IdentityHashMap<>();
+
+ @Test
+ public void setCmdTest() {
+ OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
+ command.add("test");
+ cmdShell.setCommand(command);
+ Assert.assertEquals("test", cmdShell.getCommand().get(0));
+ }
+
+ @Test
+ public void setCmdEnvVariable() {
+ OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
+ envVariable.put("variableOne","test");
+ cmdShell.setEnvs(envVariable);
+ Assert.assertEquals("test", cmdShell.getEnvs().get("variableOne"));
+ }
+
+ @Test
+ public void setCmdError() {
+ OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
+ cmdShell.setError("Timeout");
+ Assert.assertEquals("Timeout", cmdShell.getError());
+ }
+}
diff --git a/profiles/command/src/test/java/org/onap/cli/fw/cmd/conf/OnapCommandConstantsTest.java b/profiles/command/src/test/java/org/onap/cli/fw/cmd/conf/OnapCommandConstantsTest.java
new file mode 100644
index 00000000..2c05eb81
--- /dev/null
+++ b/profiles/command/src/test/java/org/onap/cli/fw/cmd/conf/OnapCommandConstantsTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2022 Samsung Electronics
+ *
+ * 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.cmd.conf;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class OnapCommandConstantsTest {
+ @Test
+ public void test() {
+ assertTrue("cmd" == OnapCommandCmdConstants.CMD && "command" == OnapCommandCmdConstants.COMMAND
+ && "environment".equals(OnapCommandCmdConstants.ENVIRONMENT)
+ && "working_directory".equals(OnapCommandCmdConstants.WD)
+ && "result_map".equals(OnapCommandCmdConstants.RESULT_MAP)
+ && "output".equals(OnapCommandCmdConstants.OUTPUT)
+ && "error".equals(OnapCommandCmdConstants.ERROR)
+ && "success_codes".equals(OnapCommandCmdConstants.SUCCESS_EXIT_CODE)
+ && "pass_codes".equals(OnapCommandCmdConstants.PASS_CODE)
+ && "timeout".equals(OnapCommandCmdConstants.TIMEOUT)
+ );
+ }
+}
diff --git a/profiles/command/src/test/java/org/onap/cli/fw/cmd/error/OnapCommandFailTest.java b/profiles/command/src/test/java/org/onap/cli/fw/cmd/error/OnapCommandFailTest.java
new file mode 100644
index 00000000..700e59b2
--- /dev/null
+++ b/profiles/command/src/test/java/org/onap/cli/fw/cmd/error/OnapCommandFailTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2022 Samsung Electronics
+ *
+ * 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.cmd.error;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class OnapCommandFailTest {
+
+ @Test
+ public void OnapCommandCmdFailureTest() {
+ OnapCommandCmdFailure onapCommandCmdFailure = new OnapCommandCmdFailure("Argument value missing");
+ assertEquals("0x18001::Argument value missing", onapCommandCmdFailure.getMessage());
+ }
+
+ @Test
+ public void OnapCommandCmdFailureWithCodeTest() {
+ OnapCommandCmdFailure onapCommandCmdFailure = new OnapCommandCmdFailure("Argument value missing",101);
+ assertEquals("101::0x18001::Argument value missing", onapCommandCmdFailure.getMessage());
+ }
+
+ @Test
+ public void OnapCommandCmdFailureThrowableTest() {
+ OnapCommandCmdFailure onapCommandCmdFailure = new OnapCommandCmdFailure(new Exception("Argument value missing"));
+ assertEquals("0x18001::Argument value missing", onapCommandCmdFailure.getMessage());
+ }
+
+ @Test
+ public void OnapCommandCmdFailureWithCodeThrowableTest() {
+ OnapCommandCmdFailure onapCommandCmdFailure = new OnapCommandCmdFailure(new Exception("Argument value missing"),101);
+ assertEquals("101::0x18001::Argument value missing", onapCommandCmdFailure.getMessage());
+ }
+
+}
diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java
index 89504fb7..17df7f6b 100644
--- a/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java
+++ b/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java
@@ -17,7 +17,6 @@
package org.onap.cli.fw.http.utils;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -104,7 +103,7 @@ public class OnapCommandUtilsTest {
assertEquals(9, map.size());
}
- @Test(expected = OnapCommandHttpHeaderNotFound.class)
+ @Test
public void populateOutputsTest() throws OnapCommandException {
HttpResult output = new HttpResult();
output.setBody(
@@ -135,11 +134,14 @@ public class OnapCommandUtilsTest {
+ "Missing property in path $['{$']",
e.getMessage());
}
- output.setBody("{}");
- input1 = OnapCommandHttpUtils.populateOutputs(params, output);
- params.put("head", "$h{head2}");
- output.setBody("{\"test\"}");
- input1 = OnapCommandHttpUtils.populateOutputs(params, output);
+ try {
+ output.setBody("{}");
+ input1 = OnapCommandHttpUtils.populateOutputs(params, output);
+ params.put("head", "$h{head2}");
+ output.setBody("{\"test\"}");
+ input1 = OnapCommandHttpUtils.populateOutputs(params, output);
+ }catch (OnapCommandHttpHeaderNotFound e) {}
+
}
@Test