Fixed Sonar Bug and Code Smell Blockers
[cli.git] / main / src / test / java / org / onap / cli / main / OnapCommandSampleTest.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.main;
18
19 import org.onap.cli.fw.cmd.OnapCommand;
20 import org.onap.cli.fw.error.OnapCommandException;
21 import org.onap.cli.fw.schema.OnapCommandSchema;
22 import org.onap.cli.fw.input.OnapCommandParameter;
23 import org.onap.cli.fw.registrar.OnapCommandRegistrar;
24 import java.util.HashSet;
25 import java.util.Set;
26 import org.junit.Test;
27 import org.onap.cli.fw.conf.OnapCommandConstants;
28 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
29
30 /**
31  * This command helps to test the Command functionalities.
32  *
33  */
34 @OnapCommandSchema(schema = "sample-test-schema.yaml")
35 public class OnapCommandSampleTest extends OnapCommand {
36
37     @Override
38     protected void run() throws OnapCommandException {
39
40     }
41
42     @Test
43     public void sampleTestVersion() throws OnapCommandException {
44
45         Set < OnapCommandParameter > parameters = new HashSet < > ();
46         OnapCommandParameter version = new OnapCommandParameter();
47         version.setName(OnapCommandConstants.DEFAULT_PARAMETER_VERSION);
48         version.setValue(true);
49         parameters.add(version);
50         OnapCommandParameter hlp = new OnapCommandParameter();
51         hlp.setName(OnapCommandConstants.DEFAULT_PARAMETER_HELP);
52         hlp.setValue(false);
53         parameters.add(hlp);
54
55         OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
56         sample.setParameters(parameters);
57         assertDoesNotThrow(() -> sample.execute());
58     }
59
60 }