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 / PutOperationTest.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 import org.onap.aai.setup.SchemaVersion;
35
36 @RunWith(Parameterized.class)
37 public class PutOperationTest {
38     private String useOpId;
39     private String xmlRootElementName;
40     private String tag;
41     private String path;
42     private String pathParams;
43     private String result;
44     private static SchemaVersion v = new SchemaVersion("v14");
45
46     @Parameters
47     public static Collection<String[]> testConditions() {
48         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
49             "/network/generic-vnfs/generic-vnf/{vnf-id}",
50             "        - 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__",
51             "    put:\n      tags:\n        - Network\n      summary: create or update an existing generic-vnf\n      description: |\n        Create or update an existing generic-vnf.\n        #\n        Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement.  An example can be found in the [PATCH section] below\n      operationId: createOrUpdateNetworkGenericVnfsGenericVnf\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__        - name: body\n          in: body\n          description: generic-vnf object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/"
52                 + v.toString()
53                 + "/NetworkGenericVnfsGenericVnf.json)\n          required: true\n          schema:\n            $ref: \"#/definitions/generic-vnf\"\n"},
54             // if ( StringUtils.isEmpty(tag) )
55             {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
56                 "        - 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__",
57                 ""},
58             // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
59             {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
60                 "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
61                 "        - name: hostname\n          in: path\n          description: Value from executing hostname on the compute node.\n          required: true\n          type: string\n          example: __HOSTNAME__",
62                 ""},
63             // {"","ctag-pool","","","",""},
64             // {"","pserver","","","",""},
65             // {"","oam-network","","","",""},
66             // {"","dvs-switch","","","",""},
67             // {"","availability-zone","","","",""}
68         };
69         return Arrays.asList(inputs);
70     }
71
72     public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
73         String pathParams, String result) {
74         super();
75         this.useOpId = useOpId;
76         this.xmlRootElementName = xmlRootElementName;
77         this.tag = tag;
78         this.path = path;
79         this.pathParams = pathParams;
80         this.result = result;
81     }
82
83     @BeforeClass
84     public static void setUpBeforeClass() throws Exception {
85
86     }
87
88     @Test
89     public void testToString() {
90         PutOperation put =
91             new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
92         String modResult = put.toString();
93         assertThat(modResult, is(this.result));
94     }
95
96 }