2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.schemagen.genxsd;
23 import static org.hamcrest.CoreMatchers.is;
24 import static org.junit.Assert.assertThat;
26 import java.util.Arrays;
27 import java.util.Collection;
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;
36 @RunWith(Parameterized.class)
37 public class PutOperationTest {
38 private String useOpId;
39 private String xmlRootElementName;
42 private String pathParams;
43 private String result;
44 private static SchemaVersion v = new SchemaVersion("v14");
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/"
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__",
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__",
63 // {"","ctag-pool","","","",""},
64 // {"","pserver","","","",""},
65 // {"","oam-network","","","",""},
66 // {"","dvs-switch","","","",""},
67 // {"","availability-zone","","","",""}
69 return Arrays.asList(inputs);
72 public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
73 String pathParams, String result) {
75 this.useOpId = useOpId;
76 this.xmlRootElementName = xmlRootElementName;
79 this.pathParams = pathParams;
84 public static void setUpBeforeClass() throws Exception {
89 public void testToString() {
91 new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
92 String modResult = put.toString();
93 assertThat(modResult, is(this.result));