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=========================================================
20 package org.onap.aai.util.genxsd;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.junit.runners.Parameterized;
26 import org.junit.runners.Parameterized.Parameters;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import java.util.Arrays;
31 import java.util.Collection;
32 import java.util.Vector;
34 import static org.hamcrest.CoreMatchers.is;
35 import static org.junit.Assert.assertThat;
37 @RunWith(Parameterized.class)
38 public class GetOperationTest {
39 private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
40 private String useOpId;
41 private String xmlRootElementName;
44 private String pathParams;
45 private String result;
48 public static Collection<String []> testConditions() {
49 String inputs [][] = {
50 {"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__"," /network/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Network\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/generic-vnf\"\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__"},
51 {"CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver","vserver","CloudInfrastructure","/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}"," - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"," /cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}:\n get:\n tags:\n - CloudInfrastructure\n summary: returns vserver\n description: returns vserver\n operationId: getCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/vserver\"\n \"default\":\n null parameters:\n - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"},
52 {"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__",""},
53 {"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__"," /cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces:\n get:\n tags:\n - CloudInfrastructure\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/p-interfaces\"\n \"default\":\n null parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__ - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
54 // {"","ctag-pool","","","",""},
55 // {"","pserver","","","",""},
56 // {"","oam-network","","","",""},
57 // {"","dvs-switch","","","",""},
58 // {"","availability-zone","","","",""}
60 return Arrays.asList(inputs);
63 public GetOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
65 this.useOpId = useOpId;
66 this.xmlRootElementName = xmlRootElementName;
69 this.pathParams=pathParams;
73 public static void setUpBeforeClass() throws Exception {
74 String container = "p-interfaces";
75 String queryProps[] = {
76 " - name: interface-name\n in: query\n description:\n required: false\n type: string",
77 " - name: prov-status\n in: query\n description:\n required: false\n type: string"
79 Vector<String> containerProps = new Vector<String>();
80 for(String prop : queryProps) {
81 containerProps.add(prop);
83 GetOperation.addContainerProps(container, containerProps);
87 public void testAddContainerProps() {
88 String container = this.xmlRootElementName;
89 String prop = " - name: "+container+"\n in: query\n description:\n required: false\n type: string";
90 Vector<String> queryProps = new Vector<String>();
92 for(String p : queryProps) {
93 logger.debug("qProp="+p);
95 logger.debug("Done="+this.xmlRootElementName);
96 GetOperation.addContainerProps(container, queryProps);
97 assertThat(GetOperation.containers.get(container).get(0), is(prop));
101 public void testToString() {
102 GetOperation get = new GetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
103 String modResult = get.toString();
104 assertThat(modResult, is(this.result));