Add instructions to invoke the linter and code formatter plugins to the README and...
[aai/schema-service.git] / aai-schema-gen / src / test / java / org / onap / aai / schemagen / genxsd / DeleteOperationTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.aai.schemagen.genxsd;
22
23 import static org.hamcrest.CoreMatchers.is;
24 import static org.junit.Assert.assertThat;
25
26 import java.util.Arrays;
27 import java.util.Collection;
28
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.junit.runners.Parameterized;
33 import org.junit.runners.Parameterized.Parameters;
34
35 @RunWith(Parameterized.class)
36 public class DeleteOperationTest {
37     private String useOpId;
38     private String xmlRootElementName;
39     private String tag;
40     private String path;
41     private String pathParams;
42     private String result;
43
44     @Parameters
45     public static Collection<String[]> testConditions() {
46         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
47             "/network/generic-vnfs/generic-vnf/{vnf-id}",
48             "        - name: vnf-id\n          in: path\n          description: Unique id of VNF.  This is unique across the graph.\n          required: true\n          type: string\n          example: __VNF-ID__\n",
49             "    delete:\n      tags:\n        - Network\n      summary: delete an existing generic-vnf\n      description: delete an existing generic-vnf\n      operationId: deleteNetworkGenericVnfsGenericVnf\n      consumes:\n        - application/json\n        - application/xml\n      produces:\n        - application/json\n        - application/xml\n      responses:\n        \"default\":\n          null      parameters:\n        - name: vnf-id\n          in: path\n          description: Unique id of VNF.  This is unique across the graph.\n          required: true\n          type: string\n          example: __VNF-ID__\n        - name: resource-version\n          in: query\n          description: resource-version for concurrency\n          required: true\n          type: string\n"},
50             // if ( StringUtils.isEmpty(tag) )
51             {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
52                 "        - name: vnf-id\n          in: path\n          description: Unique id of VNF.  This is unique across the graph.\n          required: true\n          type: string\n          example: __VNF-ID__\n",
53                 ""},
54             // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
55             {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
56                 "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
57                 "        - name: hostname\n          in: path\n          description: Value from executing hostname on the compute node.\n          required: true\n          type: string\n          example: __HOSTNAME__",
58                 ""},
59             // {"","ctag-pool","","","",""},
60             // {"","pserver","","","",""},
61             // {"","oam-network","","","",""},
62             // {"","dvs-switch","","","",""},
63             // {"","availability-zone","","","",""}
64         };
65         return Arrays.asList(inputs);
66     }
67
68     public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
69         String pathParams, String result) {
70         super();
71         this.useOpId = useOpId;
72         this.xmlRootElementName = xmlRootElementName;
73         this.tag = tag;
74         this.path = path;
75         this.pathParams = pathParams;
76         this.result = result;
77     }
78
79     @BeforeClass
80     public static void setUpBeforeClass() throws Exception {
81
82     }
83
84     @Test
85     public void testToString() {
86         DeleteOperation delete =
87             new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
88         String modResult = delete.toString();
89         assertThat(modResult, is(this.result));
90     }
91
92 }