Merge "AAI-1523 Tweak onap-java-formatter.xml"
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / util / 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 package org.onap.aai.util.genxsd;
21
22 import static org.junit.Assert.*;
23
24 import java.util.Arrays;
25 import java.util.Collection;
26
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.junit.runners.Parameterized;
31 import org.junit.runners.Parameterized.Parameters;
32
33 import static org.hamcrest.CoreMatchers.is;
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 [][] = {
47                 {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}","        - 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","    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"},
48 //              if ( StringUtils.isEmpty(tag) )
49                 {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}","        - 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",""},
50 //              Test: if ( !path.endsWith("/relationship")  &&  !path.endsWith("}") )
51                 {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces","        - name: hostname\n          in: path\n          description: Value from executing hostname on the compute node.\n          required: true\n          type: string\n          example: __HOSTNAME__",""},
52 //              {"","ctag-pool","","","",""},
53 //              {"","pserver","","","",""},
54 //              {"","oam-network","","","",""},
55 //              {"","dvs-switch","","","",""},
56 //              {"","availability-zone","","","",""}
57                 };
58                 return Arrays.asList(inputs);
59         }
60         
61         public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
62                 super();
63                 this.useOpId = useOpId;
64                 this.xmlRootElementName = xmlRootElementName;
65                 this.tag = tag;
66                 this.path = path;
67                 this.pathParams=pathParams;
68                 this.result = result;
69         }
70         @BeforeClass
71         public static void setUpBeforeClass() throws Exception {
72
73         }
74
75         @Test
76         public void testToString() {
77                 DeleteOperation delete = new DeleteOperation(useOpId, xmlRootElementName, tag, path,  pathParams);
78                 String modResult = delete.toString();
79                 assertThat(modResult, is(this.result));
80         }
81
82 }