2 * Copyright 2022 Samsung Electronics
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.cli.fw.cmd.cmd;
19 import org.junit.Assert;
20 import org.junit.Test;
24 public class OpenCommandShellCmdTest {
25 List<String> command = new ArrayList<>();
26 Map<String, String> envVariable = new HashMap<String, String>();
27 Map<String, String> resultMap = new IdentityHashMap<>();
30 public void setCmdTest() {
31 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
33 cmdShell.setCommand(command);
34 Assert.assertEquals("test", cmdShell.getCommand().get(0));
38 public void setCmdEnvVariableTest() {
39 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
40 envVariable.put("variableOne","test");
41 cmdShell.setEnvs(envVariable);
42 Assert.assertEquals("test", cmdShell.getEnvs().get("variableOne"));
46 public void setCmdErrorTest() {
47 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
48 cmdShell.setError("Timeout");
49 Assert.assertEquals("Timeout", cmdShell.getError());
53 public void setResultMapTest() {
54 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
55 Map<String, String> resultMap = new HashMap<>();
56 resultMap.put("var1","text1");
57 cmdShell.setResultMap(resultMap);
58 Assert.assertEquals("text1", cmdShell.getResultMap().get("var1"));
62 public void setCmdOutputTest() {
63 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
64 cmdShell.setOutput("Timeout");
65 Assert.assertEquals("Timeout", cmdShell.getOutput());
69 public void setPassCodesTest() {
70 OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
71 List<Integer> resultMap = new ArrayList<Integer>();
73 cmdShell.setPassCodes(resultMap);
74 Assert.assertEquals(Optional.ofNullable(200), Optional.ofNullable(cmdShell.getPassCodes().get(0)));