X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=aai-schema-gen%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fschemagen%2Fgenxsd%2FPatchOperationTest.java;h=d939a748e95ff2bf8cc82fbefe2a8a202195cc9e;hb=7343beeaf260747aef6a6b9c22acd91de67c5ca0;hp=098b33b5489cb365a77d4c39db5a7b6f8811586f;hpb=e0ad4f2890f9f933199bc6f1b3f0e988da471aa9;p=aai%2Fschema-service.git diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java index 098b33b..d939a74 100644 --- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java +++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java @@ -8,7 +8,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,8 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.schemagen.genxsd; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.Collection; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,58 +33,62 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.onap.aai.setup.SchemaVersion; -import java.util.Arrays; -import java.util.Collection; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - @RunWith(Parameterized.class) public class PatchOperationTest { - private String useOpId; - private String xmlRootElementName; - private String tag; - private String path; - private String pathParams; - private String result; - private static SchemaVersion v = new SchemaVersion("v16"); + private String useOpId; + private String xmlRootElementName; + private String tag; + private String path; + private String pathParams; + private String result; + private static SchemaVersion v = new SchemaVersion("v16"); + + @Parameters + public static Collection testConditions() { + String inputs[][] = {{"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__", + " patch:\n tags:\n - Network\n summary: update an existing generic-vnf\n description: |\n Update an existing generic-vnf\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n produces:\n - application/json\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 updated.[See Examples](apidocs/aai/relations/v16/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"}, + // if ( StringUtils.isEmpty(tag) ) + {"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__", + ""}, + // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") ) + {"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__", + ""}, + // {"","ctag-pool","","","",""}, + // {"","pserver","","","",""}, + // {"","oam-network","","","",""}, + // {"","dvs-switch","","","",""}, + // {"","availability-zone","","","",""} + }; + return Arrays.asList(inputs); + } - @Parameters - public static Collection testConditions() { - String inputs [][] = { - {"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__"," patch:\n tags:\n - Network\n summary: update an existing generic-vnf\n description: |\n Update an existing generic-vnf\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n produces:\n - application/json\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 updated.[See Examples](apidocs/aai/relations/v16/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"}, -// if ( StringUtils.isEmpty(tag) ) - {"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__",""}, -// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") ) - {"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__",""}, - // {"","ctag-pool","","","",""}, -// {"","pserver","","","",""}, -// {"","oam-network","","","",""}, -// {"","dvs-switch","","","",""}, -// {"","availability-zone","","","",""} - }; - return Arrays.asList(inputs); - } + public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path, + String pathParams, String result) { + super(); + this.useOpId = useOpId; + this.xmlRootElementName = xmlRootElementName; + this.tag = tag; + this.path = path; + this.pathParams = pathParams; + this.result = result; + } - public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) { - super(); - this.useOpId = useOpId; - this.xmlRootElementName = xmlRootElementName; - this.tag = tag; - this.path = path; - this.pathParams=pathParams; - this.result = result; - } - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeClass + public static void setUpBeforeClass() throws Exception { - } + } - @Test - public void testToString() { - PatchOperation patch = new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai" ); - String modResult = patch.toString(); - assertThat(modResult, is(this.result)); - } + @Test + public void testToString() { + PatchOperation patch = + new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai"); + String modResult = patch.toString(); + assertThat(modResult, is(this.result)); + } }