e7af1aa3868397664da1f3f14e8d917294d6c1a5
[cli.git] / framework / src / test / java / org / onap / cli / fw / cmd / OnapHttpCommandTest.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
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;
18
19 import org.junit.Test;
20 import org.onap.cli.fw.error.OnapCommandException;
21 import org.onap.cli.fw.http.HttpInput;
22 import org.onap.cli.fw.input.OnapCommandParameter;
23 import org.onap.cli.fw.input.ParameterType;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28
29 public class OnapHttpCommandTest {
30
31     @Test(expected = OnapCommandException.class)
32     public void runTest() throws OnapCommandException {
33         OnapCommandParameter param1 = new OnapCommandParameter();
34         param1.setLongOption("onap-username");
35         param1.setName("onap-username");
36         param1.setParameterType(ParameterType.STRING);
37         OnapCommandParameter param2 = new OnapCommandParameter();
38         param2.setLongOption("onap-password");
39         param2.setName("onap-password");
40         param2.setParameterType(ParameterType.STRING);
41         OnapCommandParameter param3 = new OnapCommandParameter();
42         param3.setLongOption("msb-url");
43         param3.setName("msb-url");
44         param3.setParameterType(ParameterType.STRING);
45         OnapCommandParameter param4 = new OnapCommandParameter();
46         param4.setLongOption("string-param");
47         param4.setName("string-param");
48         param4.setParameterType(ParameterType.STRING);
49         OnapCommandParameter param5 = new OnapCommandParameter();
50         param5.setLongOption("long-opt");
51         param5.setName("long-opt");
52         param5.setParameterType(ParameterType.STRING);
53
54         List<OnapCommandParameter> paramslist = new ArrayList<>();
55         paramslist.add(param1);
56         paramslist.add(param2);
57         paramslist.add(param3);
58         paramslist.add(param4);
59         paramslist.add(param5);
60
61         HttpInput inp = new HttpInput();
62         inp.setBody("body");
63         inp.setMethod("method");
64         inp.setReqCookies(new HashMap<String, String>());
65         inp.setReqHeaders(new HashMap<String, String>());
66         inp.setReqQueries(new HashMap<String, String>());
67         inp.setUri("uri");
68
69         OnapHttpCommand com = new OnapHttpCommand();
70         com.setParameters(paramslist);
71         com.getParameters();
72         com.getParametersMap();
73         com.setInput(inp);
74         com.initializeSchema("sample-test-schema.yaml");
75         com.execute();
76
77     }
78
79 }