4ae3c3b6192f10107eeae689ff9d553d5b7b15a2
[appc.git] / appc-client / code-generator / src / test / java / org / onap / appc / tools / generator / api / CLITest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.tools.generator.api;
26
27 import org.junit.Assert;
28 import org.junit.Test;
29
30 public class CLITest {
31     @Test
32     public void missingSourceFileTest()  {
33         CLI cli = new CLI();
34         try {
35             String[] input = new String[1];
36             cli.main(input);
37         } catch (Exception e) {
38             Assert.assertEquals("Source file is missing. Please add argument 'client <source file> <destination file> <model template>'",e.getMessage());
39         }
40     }
41     @Test
42     public void missingDestinationFileTest()  {
43         CLI cli = new CLI();
44         try {
45             String[] input = {"sourceFilePath",null};
46             cli.main(input);
47         } catch (Exception e) {
48             Assert.assertEquals("Destination file name is missing. Please add argument 'client sourceFilePath <destination> <model template> <builder> <conf file>'",e.getMessage());
49         }
50     }
51     @Test
52     public void missingTemplateFileTest()  {
53         CLI cli = new CLI();
54         try {
55             String[] input = {"sourceFilePath","destinationPath",null};
56             cli.main(input);
57         } catch (Exception e) {
58             Assert.assertEquals("template file name is missing. Please add argument 'client sourceFilePath destinationPath <model template> <builder> <conf file>'",e.getMessage());
59         }
60     }
61     @Test
62     public void missingBuilderNameTest()  {
63         CLI cli = new CLI();
64         try {
65             String[] input = {"sourceFilePath","destinationPath","templateFileName",null};
66             cli.main(input);
67         } catch (Exception e) {
68             Assert.assertEquals("builder FQDN is missing. Please add argument 'client sourceFilePath destinationPath templateFileName <builder> <conf file>'",e.getMessage());
69         }
70     }
71     @Test
72     public void missingContextConfFileNameTest()  {
73         CLI cli = new CLI();
74         try {
75             String[] input = {"sourceFilePath","destinationPath","templateFileName","builderFQDN",null};
76             cli.main(input);
77         } catch (Exception e) {
78             Assert.assertEquals(e.getMessage(),"context conf file is missing. Please add argument 'client sourceFilePath destinationPath templateFileName builderFQDN <conf file>'");
79         }
80     }
81 }