CliProfileCmd unit test cases added
[cli.git] / profiles / command / src / test / java / org / onap / cli / fw / cmd / cmd / OpenCommandShellCmdTest.java
1 /*
2  * Copyright 2022 Samsung Electronics
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.cli.fw.cmd.cmd;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21
22 import java.util.*;
23
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<>();
28
29     @Test
30     public void setCmdTest() {
31         OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
32         command.add("test");
33         cmdShell.setCommand(command);
34         Assert.assertEquals("test", cmdShell.getCommand().get(0));
35     }
36
37     @Test
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"));
43     }
44
45     @Test
46     public void setCmdErrorTest() {
47         OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
48         cmdShell.setError("Timeout");
49         Assert.assertEquals("Timeout", cmdShell.getError());
50     }
51
52     @Test
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"));
59     }
60
61     @Test
62     public void setCmdOutputTest() {
63         OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
64         cmdShell.setOutput("Timeout");
65         Assert.assertEquals("Timeout", cmdShell.getOutput());
66     }
67
68     @Test
69     public void setPassCodesTest() {
70         OpenCommandShellCmd cmdShell = new OpenCommandShellCmd();
71         List<Integer> resultMap = new ArrayList<Integer>();
72         resultMap.add(200);
73         cmdShell.setPassCodes(resultMap);
74         Assert.assertEquals(Optional.ofNullable(200), Optional.ofNullable(cmdShell.getPassCodes().get(0)));
75     }
76 }
77