2 * Copyright 2017 Huawei Technologies Co., Ltd.
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.main;
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;
26 import org.junit.Test;
27 import org.onap.cli.fw.conf.OnapCommandConstants;
28 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
31 * This command helps to test the Command functionalities.
34 @OnapCommandSchema(schema = "sample-test-schema.yaml")
35 public class OnapCommandSampleTest extends OnapCommand {
38 protected void run() throws OnapCommandException {
43 public void sampleTestVersion() throws OnapCommandException {
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);
55 OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
56 sample.setParameters(parameters);
57 assertDoesNotThrow(() -> sample.execute());