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.schemagen.genxsd;
22 import com.google.common.collect.Multimap;
23 import org.junit.Before;
24 import org.junit.BeforeClass;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.aai.edges.EdgeIngestor;
28 import org.onap.aai.edges.EdgeRule;
29 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
30 import org.onap.aai.nodes.NodeIngestor;
31 import org.onap.aai.schemagen.SwaggerGenerationConfiguration;
32 import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
33 import org.onap.aai.setup.SchemaLocationsBean;
34 import org.onap.aai.setup.SchemaVersion;
35 import org.onap.aai.setup.SchemaVersions;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
40 import org.springframework.test.context.ContextConfiguration;
41 import org.springframework.test.context.TestPropertySource;
42 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
43 import org.w3c.dom.Document;
44 import org.w3c.dom.Element;
46 import java.io.BufferedWriter;
48 import java.io.FileWriter;
49 import java.io.IOException;
50 import java.nio.charset.Charset;
51 import java.nio.file.Files;
52 import java.nio.file.Path;
53 import java.nio.file.Paths;
54 import java.util.SortedSet;
55 import java.util.TreeSet;
57 import static org.hamcrest.CoreMatchers.is;
58 import static org.junit.Assert.assertNotNull;
59 import static org.junit.Assert.assertThat;
60 import static org.junit.Assert.assertTrue;
63 @RunWith(SpringJUnit4ClassRunner.class)
64 @ContextConfiguration(classes = {
66 SchemaLocationsBean.class,
67 TestUtilConfigTranslatorforBusiness.class,
71 SwaggerGenerationConfiguration.class
74 @TestPropertySource(properties = {
75 "schema.uri.base.path = /aai",
76 "schema.xsd.maxoccurs = 5000"
78 public class YAMLfromOXMTest {
80 EdgeIngestor edgeIngestor;
83 NodeIngestor nodeIngestor;
84 private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
85 private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
86 private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
87 public static AnnotationConfigApplicationContext ctx = null;
88 private static String testXML;
89 protected static final String SERVICE_NAME = "JUNIT";
93 YAMLfromOXM yamlFromOxm;
96 SchemaVersions schemaVersions;
99 public static void setUpBeforeClass() throws Exception {
100 System.setProperty("AJSC_HOME", ".");
101 System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
102 System.setProperty("aai.service.name", SERVICE_NAME);
108 public void setUp() throws Exception {
109 XSDElementTest x = new XSDElementTest();
112 logger.debug(testXML);
113 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
116 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
117 bw1.write(EdgeDefs());
121 public void setupRelationship() throws Exception{
122 XSDElementTest x = new XSDElementTest();
124 x.setUpRelationship();
127 logger.debug(testXML);
128 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
133 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
134 bw1.write(EdgeDefs());
139 public void AtestIngestors() throws EdgeRuleNotFoundException {
140 Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
141 SortedSet<String> ss=new TreeSet<String>(results.keySet());
142 for(String key : ss) {
143 results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
145 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
150 public void testGetDocumentHeader() {
151 SchemaVersion v = schemaVersions.getAppRootVersion();
152 String apiVersion = v.toString();
153 String header = null;
155 yamlFromOxm.setXmlVersion(testXML, v);
156 yamlFromOxm.process();
157 header = yamlFromOxm.getDocumentHeader();
158 } catch(Exception e) {
161 assertThat("Header:\n"+header,header, is(YAMLheader()));
165 public void testProcess() {
166 SchemaVersion v = schemaVersions.getAppRootVersion();
167 String apiVersion = v.toString();
168 String fileContent = null;
170 yamlFromOxm.setXmlVersion(testXML, v);
171 fileContent = yamlFromOxm.process();
172 } catch(Exception e) {
175 assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
179 public void testYAMLfromOXMFileVersionFile() throws IOException {
180 String outfileName = "testXML.xml";
181 File XMLfile = new File(outfileName);
182 XMLfile.createNewFile();
183 BufferedWriter bw = null;
184 Charset charset = Charset.forName("UTF-8");
185 Path path = Paths.get(outfileName);
186 bw = Files.newBufferedWriter(path, charset);
189 SchemaVersion v = schemaVersions.getAppRootVersion();
190 String apiVersion = v.toString();
191 String fileContent = null;
193 yamlFromOxm.setXmlVersion(testXML, v);
194 fileContent = yamlFromOxm.process();
195 } catch(Exception e) {
199 assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
203 public void testYAMLfromOXMStringVersionFile() {
204 SchemaVersion v = schemaVersions.getAppRootVersion();
205 String apiVersion = v.toString();
206 String fileContent = null;
208 yamlFromOxm.setXmlVersion(testXML, v);
209 fileContent = yamlFromOxm.process();
210 } catch(Exception e) {
213 assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
217 public void testRelationshipListYAMLfromOXMStringVersionFile() {
220 } catch (Exception e1) {
221 // TODO Auto-generated catch block
222 e1.printStackTrace();
224 SchemaVersion v = schemaVersions.getAppRootVersion();
225 String apiVersion = v.toString();
226 String fileContent = null;
228 yamlFromOxm.setXmlVersion(testXML, v);
229 fileContent = yamlFromOxm.process();
230 } catch(Exception e) {
233 boolean matchFound = fileContent.contains(( YAMLRelationshipList()));
234 assertTrue("RelationshipListFormat:\n", matchFound);
238 public void testAppendDefinitions() {
239 SchemaVersion v = schemaVersions.getAppRootVersion();
240 String apiVersion = v.toString();
241 String definitions = null;
243 yamlFromOxm.setXmlVersion(testXML, v);
244 yamlFromOxm.process();
245 definitions = yamlFromOxm.appendDefinitions();
246 } catch(Exception e) {
249 assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLpatchDefs()+YAMLgetDefs()));
253 public void testGetXMLRootElementName() {
254 String target = "RootElement=customer";
255 SchemaVersion v = schemaVersions.getAppRootVersion();
256 String apiVersion = v.toString();
257 Element customer = null;
260 yamlFromOxm.setXmlVersion(testXML, v);
261 yamlFromOxm.process();
262 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
263 root = yamlFromOxm.getXMLRootElementName(customer);
264 } catch(Exception e) {
267 assertThat("RootElement="+root, is(target));
271 public void testGetXmlRootElementName() {
272 String target = "RootElement=customer";
273 SchemaVersion v = schemaVersions.getAppRootVersion();
274 String apiVersion = v.toString();
277 yamlFromOxm.setXmlVersion(testXML, v);
278 yamlFromOxm.process();
279 root = yamlFromOxm.getXmlRootElementName("Customer");
280 } catch(Exception e) {
283 assertThat("RootElement="+root, is(target));
287 public void testGetJavaTypeElementSwagger() {
288 String target = "Element=java-type/Customer";
289 SchemaVersion v = schemaVersions.getAppRootVersion();
290 String apiVersion = v.toString();
291 Element customer = null;
293 yamlFromOxm.setXmlVersion(testXML, v);
294 yamlFromOxm.process();
295 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
296 } catch(Exception e) {
299 assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
302 public String YAMLresult() {
303 StringBuilder sb = new StringBuilder(32368);
304 sb.append(YAMLheader());
305 sb.append(YAMLops());
306 sb.append(YAMLdefs());
307 sb.append(YAMLpatchDefs());
308 sb.append(YAMLgetDefs());
309 return sb.toString();
311 public String YAMLheader() {
312 StringBuilder sb = new StringBuilder(1500);
313 sb.append("swagger: \"2.0\"\n");
314 sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
315 sb.append(" description: |\n");
317 sb.append(" [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
318 sb.append(" Copyright © 2017-18 AT&T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
319 sb.append(" Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License.\n");
321 sb.append(" You may obtain a copy of the License at\n");
323 sb.append(" (https://creativecommons.org/licenses/by/4.0/)\n");
325 sb.append(" Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
326 sb.append(" This document is best viewed with Firefox or Chrome. Nodes can be found by appending /#/definitions/node-type-to-find to the path to this document. Edge definitions can be found with the node definitions." + OxmFileProcessor.LINE_SEPARATOR);
327 sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
328 sb.append(" title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
329 sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
330 sb.append(" name: Apache 2.0\n");
331 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
332 sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
333 sb.append(" name:" + OxmFileProcessor.LINE_SEPARATOR);
334 sb.append(" url:" + OxmFileProcessor.LINE_SEPARATOR);
335 sb.append(" email:" + OxmFileProcessor.LINE_SEPARATOR);
336 sb.append("host:" + OxmFileProcessor.LINE_SEPARATOR);
337 sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
338 sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
339 sb.append(" - https\n");
340 sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
341 return sb.toString();
344 public String YAMLops() {
345 StringBuilder sb = new StringBuilder(16384);
346 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
347 sb.append(" get:\n");
348 sb.append(" tags:\n");
349 sb.append(" - Business\n");
350 sb.append(" summary: returns service-subscription\n");
351 sb.append(" description: returns service-subscription\n");
352 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
353 sb.append(" produces:\n");
354 sb.append(" - application/json\n");
355 sb.append(" - application/xml\n");
356 sb.append(" responses:\n");
357 sb.append(" \"200\":\n");
358 sb.append(" description: successful operation\n");
359 sb.append(" schema:\n");
360 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
361 sb.append(" \"default\":\n");
362 sb.append(" null parameters:\n");
363 sb.append(" - name: global-customer-id\n");
364 sb.append(" in: path\n");
365 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
366 sb.append(" required: true\n");
367 sb.append(" type: string\n");
368 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
369 sb.append(" - name: service-type\n");
370 sb.append(" in: path\n");
371 sb.append(" description: Value defined by orchestration to identify this service.\n");
372 sb.append(" required: true\n");
373 sb.append(" type: string\n");
374 sb.append(" example: __SERVICE-TYPE__\n");
375 sb.append(" put:\n");
376 sb.append(" tags:\n");
377 sb.append(" - Business\n");
378 sb.append(" summary: create or update an existing service-subscription\n");
379 sb.append(" description: |\n");
380 sb.append(" Create or update an existing service-subscription.\n");
382 sb.append(" 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");
383 sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
384 sb.append(" consumes:\n");
385 sb.append(" - application/json\n");
386 sb.append(" - application/xml\n");
387 sb.append(" produces:\n");
388 sb.append(" - application/json\n");
389 sb.append(" - application/xml\n");
390 sb.append(" responses:\n");
391 sb.append(" \"default\":\n");
392 sb.append(" null parameters:\n");
393 sb.append(" - name: global-customer-id\n");
394 sb.append(" in: path\n");
395 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
396 sb.append(" required: true\n");
397 sb.append(" type: string\n");
398 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
399 sb.append(" - name: service-type\n");
400 sb.append(" in: path\n");
401 sb.append(" description: Value defined by orchestration to identify this service.\n");
402 sb.append(" required: true\n");
403 sb.append(" type: string\n");
404 sb.append(" example: __SERVICE-TYPE__\n");
405 sb.append(" - name: body\n");
406 sb.append(" in: body\n");
407 sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
408 sb.append(" required: true\n");
409 sb.append(" schema:\n");
410 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
411 sb.append(" patch:\n");
412 sb.append(" tags:\n");
413 sb.append(" - Business\n");
414 sb.append(" summary: update an existing service-subscription\n");
415 sb.append(" description: |\n");
416 sb.append(" Update an existing service-subscription\n");
418 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
419 sb.append(" The PUT operation will entirely replace an existing object.\n");
420 sb.append(" 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");
422 sb.append(" Other differences between PUT and PATCH are:\n");
424 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
425 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
426 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
427 sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
428 sb.append(" consumes:\n");
429 sb.append(" - application/json\n");
430 sb.append(" produces:\n");
431 sb.append(" - application/json\n");
432 sb.append(" responses:\n");
433 sb.append(" \"default\":\n");
434 sb.append(" null parameters:\n");
435 sb.append(" - name: global-customer-id\n");
436 sb.append(" in: path\n");
437 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
438 sb.append(" required: true\n");
439 sb.append(" type: string\n");
440 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
441 sb.append(" - name: service-type\n");
442 sb.append(" in: path\n");
443 sb.append(" description: Value defined by orchestration to identify this service.\n");
444 sb.append(" required: true\n");
445 sb.append(" type: string\n");
446 sb.append(" example: __SERVICE-TYPE__\n");
447 sb.append(" - name: body\n");
448 sb.append(" in: body\n");
449 sb.append(" description: service-subscription object that needs to be updated.\n");
450 sb.append(" required: true\n");
451 sb.append(" schema:\n");
452 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
453 sb.append(" delete:\n");
454 sb.append(" tags:\n");
455 sb.append(" - Business\n");
456 sb.append(" summary: delete an existing service-subscription\n");
457 sb.append(" description: delete an existing service-subscription\n");
458 sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
459 sb.append(" consumes:\n");
460 sb.append(" - application/json\n");
461 sb.append(" - application/xml\n");
462 sb.append(" produces:\n");
463 sb.append(" - application/json\n");
464 sb.append(" - application/xml\n");
465 sb.append(" responses:\n");
466 sb.append(" \"default\":\n");
467 sb.append(" null parameters:\n");
468 sb.append(" - name: global-customer-id\n");
469 sb.append(" in: path\n");
470 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
471 sb.append(" required: true\n");
472 sb.append(" type: string\n");
473 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
474 sb.append(" - name: service-type\n");
475 sb.append(" in: path\n");
476 sb.append(" description: Value defined by orchestration to identify this service.\n");
477 sb.append(" required: true\n");
478 sb.append(" type: string\n");
479 sb.append(" example: __SERVICE-TYPE__\n");
480 sb.append(" - name: resource-version\n");
481 sb.append(" in: query\n");
482 sb.append(" description: resource-version for concurrency\n");
483 sb.append(" required: true\n");
484 sb.append(" type: string\n");
485 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
486 sb.append(" get:\n");
487 sb.append(" tags:\n");
488 sb.append(" - Business\n");
489 sb.append(" summary: returns service-subscriptions\n");
490 sb.append(" description: returns service-subscriptions\n");
491 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
492 sb.append(" produces:\n");
493 sb.append(" - application/json\n");
494 sb.append(" - application/xml\n");
495 sb.append(" responses:\n");
496 sb.append(" \"200\":\n");
497 sb.append(" description: successful operation\n");
498 sb.append(" schema:\n");
499 sb.append(" $ref: \"#/getDefinitions/service-subscriptions\"\n");
500 sb.append(" \"default\":\n");
501 sb.append(" null parameters:\n");
502 sb.append(" - name: global-customer-id\n");
503 sb.append(" in: path\n");
504 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
505 sb.append(" required: true\n");
506 sb.append(" type: string\n");
507 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
508 sb.append(" - name: service-type\n");
509 sb.append(" in: query\n");
510 sb.append(" description:\n");
511 sb.append(" required: false\n");
512 sb.append(" type: string\n");
513 sb.append(" /business/customers/customer/{global-customer-id}:\n");
514 sb.append(" get:\n");
515 sb.append(" tags:\n");
516 sb.append(" - Business\n");
517 sb.append(" summary: returns customer\n");
518 sb.append(" description: returns customer\n");
519 sb.append(" operationId: getBusinessCustomersCustomer\n");
520 sb.append(" produces:\n");
521 sb.append(" - application/json\n");
522 sb.append(" - application/xml\n");
523 sb.append(" responses:\n");
524 sb.append(" \"200\":\n");
525 sb.append(" description: successful operation\n");
526 sb.append(" schema:\n");
527 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
528 sb.append(" \"default\":\n");
529 sb.append(" null parameters:\n");
530 sb.append(" - name: global-customer-id\n");
531 sb.append(" in: path\n");
532 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
533 sb.append(" required: true\n");
534 sb.append(" type: string\n");
535 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
536 sb.append(" put:\n");
537 sb.append(" tags:\n");
538 sb.append(" - Business\n");
539 sb.append(" summary: create or update an existing customer\n");
540 sb.append(" description: |\n");
541 sb.append(" Create or update an existing customer.\n");
543 sb.append(" 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");
544 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
545 sb.append(" consumes:\n");
546 sb.append(" - application/json\n");
547 sb.append(" - application/xml\n");
548 sb.append(" produces:\n");
549 sb.append(" - application/json\n");
550 sb.append(" - application/xml\n");
551 sb.append(" responses:\n");
552 sb.append(" \"default\":\n");
553 sb.append(" null parameters:\n");
554 sb.append(" - name: global-customer-id\n");
555 sb.append(" in: path\n");
556 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
557 sb.append(" required: true\n");
558 sb.append(" type: string\n");
559 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
560 sb.append(" - name: body\n");
561 sb.append(" in: body\n");
562 sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
563 sb.append(" required: true\n");
564 sb.append(" schema:\n");
565 sb.append(" $ref: \"#/definitions/customer\"\n");
566 sb.append(" patch:\n");
567 sb.append(" tags:\n");
568 sb.append(" - Business\n");
569 sb.append(" summary: update an existing customer\n");
570 sb.append(" description: |\n");
571 sb.append(" Update an existing customer\n");
573 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
574 sb.append(" The PUT operation will entirely replace an existing object.\n");
575 sb.append(" 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");
577 sb.append(" Other differences between PUT and PATCH are:\n");
579 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
580 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
581 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
582 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
583 sb.append(" consumes:\n");
584 sb.append(" - application/json\n");
585 sb.append(" produces:\n");
586 sb.append(" - application/json\n");
587 sb.append(" responses:\n");
588 sb.append(" \"default\":\n");
589 sb.append(" null parameters:\n");
590 sb.append(" - name: global-customer-id\n");
591 sb.append(" in: path\n");
592 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
593 sb.append(" required: true\n");
594 sb.append(" type: string\n");
595 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
596 sb.append(" - name: body\n");
597 sb.append(" in: body\n");
598 sb.append(" description: customer object that needs to be updated.\n");
599 sb.append(" required: true\n");
600 sb.append(" schema:\n");
601 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
602 sb.append(" delete:\n");
603 sb.append(" tags:\n");
604 sb.append(" - Business\n");
605 sb.append(" summary: delete an existing customer\n");
606 sb.append(" description: delete an existing customer\n");
607 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
608 sb.append(" consumes:\n");
609 sb.append(" - application/json\n");
610 sb.append(" - application/xml\n");
611 sb.append(" produces:\n");
612 sb.append(" - application/json\n");
613 sb.append(" - application/xml\n");
614 sb.append(" responses:\n");
615 sb.append(" \"default\":\n");
616 sb.append(" null parameters:\n");
617 sb.append(" - name: global-customer-id\n");
618 sb.append(" in: path\n");
619 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
620 sb.append(" required: true\n");
621 sb.append(" type: string\n");
622 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
623 sb.append(" - name: resource-version\n");
624 sb.append(" in: query\n");
625 sb.append(" description: resource-version for concurrency\n");
626 sb.append(" required: true\n");
627 sb.append(" type: string\n");
628 sb.append(" /business/customers:\n");
629 sb.append(" get:\n");
630 sb.append(" tags:\n");
631 sb.append(" - Business\n");
632 sb.append(" summary: returns customers\n");
633 sb.append(" description: returns customers\n");
634 sb.append(" operationId: getBusinessCustomers\n");
635 sb.append(" produces:\n");
636 sb.append(" - application/json\n");
637 sb.append(" - application/xml\n");
638 sb.append(" responses:\n");
639 sb.append(" \"200\":\n");
640 sb.append(" description: successful operation\n");
641 sb.append(" schema:\n");
642 sb.append(" $ref: \"#/getDefinitions/customers\"\n");
643 sb.append(" \"default\":\n");
644 sb.append(" null parameters:\n");
645 sb.append(" - name: global-customer-id\n");
646 sb.append(" in: query\n");
647 sb.append(" description:\n");
648 sb.append(" required: false\n");
649 sb.append(" type: string\n");
650 sb.append(" - name: subscriber-name\n");
651 sb.append(" in: query\n");
652 sb.append(" description:\n");
653 sb.append(" required: false\n");
654 sb.append(" type: string\n");
655 sb.append(" - name: subscriber-type\n");
656 sb.append(" in: query\n");
657 sb.append(" description:\n");
658 sb.append(" required: false\n");
659 sb.append(" type: string\n");
660 return sb.toString();
662 public String YAMLdefs() {
663 StringBuilder sb = new StringBuilder(8092);
664 sb.append("definitions:\n");
665 sb.append(" business:\n");
666 sb.append(" description: |\n");
667 sb.append(" Namespace for business related constructs\n");
668 sb.append(" properties:\n");
669 sb.append(" customers:\n");
670 sb.append(" type: array\n");
671 sb.append(" items:\n");
672 sb.append(" $ref: \"#/definitions/customer\"\n");
673 sb.append(" customer:\n");
674 sb.append(" description: |\n");
675 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
676 sb.append(" ###### Related Nodes\n");
677 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
679 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
680 sb.append(" required:\n");
681 sb.append(" - global-customer-id\n");
682 sb.append(" - subscriber-name\n");
683 sb.append(" - subscriber-type\n");
684 sb.append(" properties:\n");
685 sb.append(" global-customer-id:\n");
686 sb.append(" type: string\n");
687 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
688 sb.append(" subscriber-name:\n");
689 sb.append(" type: string\n");
690 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
691 sb.append(" subscriber-type:\n");
692 sb.append(" type: string\n");
693 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
694 sb.append(" resource-version:\n");
695 sb.append(" type: string\n");
696 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
697 sb.append(" service-subscriptions:\n");
698 sb.append(" type: array\n");
699 sb.append(" items:\n");
700 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
701 sb.append(" customers:\n");
702 sb.append(" description: |\n");
703 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
704 sb.append(" properties:\n");
705 sb.append(" customer:\n");
706 sb.append(" type: array\n");
707 sb.append(" items: \n");
708 sb.append(" $ref: \"#/definitions/customer\"\n");
709 sb.append(" inventory:\n");
710 sb.append(" properties:\n");
711 sb.append(" business:\n");
712 sb.append(" type: object\n");
713 sb.append(" $ref: \"#/definitions/business\"\n");
714 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
715 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
716 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
717 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
718 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
719 sb.append(" $ref: \"#/definitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
720 sb.append(" service-subscription:\n");
721 sb.append(" description: |\n");
722 sb.append(" Object that group service instances.\n");
723 sb.append(" ###### Related Nodes\n");
724 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
725 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
726 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
728 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
729 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
730 sb.append(" required:\n");
731 sb.append(" - service-type\n");
732 sb.append(" properties:\n");
733 sb.append(" service-type:\n");
734 sb.append(" type: string\n");
735 sb.append(" description: Value defined by orchestration to identify this service.\n");
736 sb.append(" temp-ub-sub-account-id:\n");
737 sb.append(" type: string\n");
738 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
739 sb.append(" resource-version:\n");
740 sb.append(" type: string\n");
741 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
742 sb.append(" service-subscriptions:\n");
743 sb.append(" description: |\n");
744 sb.append(" Collection of objects that group service instances.\n");
745 sb.append(" properties:\n");
746 sb.append(" service-subscription:\n");
747 sb.append(" type: array\n");
748 sb.append(" items: \n");
749 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
750 return sb.toString();
752 public String YAMLpatchDefs() {
753 StringBuilder sb = new StringBuilder(8092);
754 sb.append("patchDefinitions:\n");
755 sb.append(" business:\n");
756 sb.append(" description: |\n");
757 sb.append(" Namespace for business related constructs\n");
758 sb.append(" properties:\n");
759 sb.append(" customers:\n");
760 sb.append(" type: array\n");
761 sb.append(" items:\n");
762 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
763 sb.append(" customer:\n");
764 sb.append(" description: |\n");
765 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
766 sb.append(" ###### Related Nodes\n");
767 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
769 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
770 sb.append(" required:\n");
771 sb.append(" - global-customer-id\n");
772 sb.append(" - subscriber-name\n");
773 sb.append(" - subscriber-type\n");
774 sb.append(" properties:\n");
775 sb.append(" global-customer-id:\n");
776 sb.append(" type: string\n");
777 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
778 sb.append(" subscriber-name:\n");
779 sb.append(" type: string\n");
780 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
781 sb.append(" subscriber-type:\n");
782 sb.append(" type: string\n");
783 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
784 sb.append(" customers:\n");
785 sb.append(" description: |\n");
786 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
787 sb.append(" properties:\n");
788 sb.append(" customer:\n");
789 sb.append(" type: array\n");
790 sb.append(" items: \n");
791 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
792 sb.append(" inventory:\n");
793 sb.append(" properties:\n");
794 sb.append(" business:\n");
795 sb.append(" type: object\n");
796 sb.append(" $ref: \"#/patchDefinitions/business\"\n");
797 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
798 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
799 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
800 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
801 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
802 sb.append(" $ref: \"#/patchDefinitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
803 sb.append(" service-subscription:\n");
804 sb.append(" description: |\n");
805 sb.append(" Object that group service instances.\n");
806 sb.append(" ###### Related Nodes\n");
807 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
808 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
809 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
811 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
812 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
813 sb.append(" required:\n");
814 sb.append(" - service-type\n");
815 sb.append(" properties:\n");
816 sb.append(" service-type:\n");
817 sb.append(" type: string\n");
818 sb.append(" description: Value defined by orchestration to identify this service.\n");
819 sb.append(" temp-ub-sub-account-id:\n");
820 sb.append(" type: string\n");
821 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
822 sb.append(" service-subscriptions:\n");
823 sb.append(" description: |\n");
824 sb.append(" Collection of objects that group service instances.\n");
825 sb.append(" properties:\n");
826 sb.append(" service-subscription:\n");
827 sb.append(" type: array\n");
828 sb.append(" items: \n");
829 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
830 return sb.toString();
832 public String YAMLgetDefs() {
833 StringBuilder sb = new StringBuilder(8092);
834 sb.append("getDefinitions:\n");
835 sb.append(" business:\n");
836 sb.append(" description: |\n");
837 sb.append(" Namespace for business related constructs\n");
838 sb.append(" properties:\n");
839 sb.append(" customers:\n");
840 sb.append(" type: array\n");
841 sb.append(" items:\n");
842 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
843 sb.append(" customer:\n");
844 sb.append(" description: |\n");
845 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
846 sb.append(" ###### Related Nodes\n");
847 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
849 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
850 sb.append(" required:\n");
851 sb.append(" - global-customer-id\n");
852 sb.append(" - subscriber-name\n");
853 sb.append(" - subscriber-type\n");
854 sb.append(" properties:\n");
855 sb.append(" global-customer-id:\n");
856 sb.append(" type: string\n");
857 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
858 sb.append(" subscriber-name:\n");
859 sb.append(" type: string\n");
860 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
861 sb.append(" subscriber-type:\n");
862 sb.append(" type: string\n");
863 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
864 sb.append(" resource-version:\n");
865 sb.append(" type: string\n");
866 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
867 sb.append(" service-subscriptions:\n");
868 sb.append(" type: array\n");
869 sb.append(" items:\n");
870 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
871 sb.append(" customers:\n");
872 sb.append(" description: |\n");
873 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
874 sb.append(" properties:\n");
875 sb.append(" customer:\n");
876 sb.append(" type: array\n");
877 sb.append(" items: \n");
878 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
879 sb.append(" inventory:\n");
880 sb.append(" properties:\n");
881 sb.append(" business:\n");
882 sb.append(" type: object\n");
883 sb.append(" $ref: \"#/getDefinitions/business\"\n");
884 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
885 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
886 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
887 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
888 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR );
889 sb.append(" $ref: \"#/getDefinitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
890 sb.append(" service-subscription:\n");
891 sb.append(" description: |\n");
892 sb.append(" Object that group service instances.\n");
893 sb.append(" ###### Related Nodes\n");
894 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
895 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
896 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
898 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
899 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
900 sb.append(" required:\n");
901 sb.append(" - service-type\n");
902 sb.append(" properties:\n");
903 sb.append(" service-type:\n");
904 sb.append(" type: string\n");
905 sb.append(" description: Value defined by orchestration to identify this service.\n");
906 sb.append(" temp-ub-sub-account-id:\n");
907 sb.append(" type: string\n");
908 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
909 sb.append(" resource-version:\n");
910 sb.append(" type: string\n");
911 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
912 sb.append(" service-subscriptions:\n");
913 sb.append(" description: |\n");
914 sb.append(" Collection of objects that group service instances.\n");
915 sb.append(" properties:\n");
916 sb.append(" service-subscription:\n");
917 sb.append(" type: array\n");
918 sb.append(" items: \n");
919 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
920 return sb.toString();
923 public String YAMLRelationshipList() {
924 StringBuilder sb = new StringBuilder(8092);
925 sb.append(" relationship-list:\n");
926 sb.append(" properties:\n");
927 sb.append(" relationship:\n");
928 sb.append(" type: object\n");
929 sb.append(" $ref: \"#/getDefinitions/relationship\"\n");
930 return sb.toString();
933 public static String EdgeDefs() {
934 StringBuilder sb = new StringBuilder(8092);
938 sb.append(" \"from\": \"service-subscription\",\n");
939 sb.append(" \"to\": \"customer\",\n" +
940 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
941 " \"direction\": \"OUT\",\n" +
942 " \"multiplicity\": \"MANY2ONE\",\n" +
943 " \"contains-other-v\": \"!${direction}\",\n" +
944 " \"delete-other-v\": \"!${direction}\",\n" +
945 " \"prevent-delete\": \"NONE\",\n" +
946 " \"default\": \"true\",\n" +
947 " \"description\":\"\"\n");
950 " \"from\": \"service-instance\",\n" +
951 " \"to\": \"service-subscription\",\n" +
952 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
953 " \"direction\": \"OUT\",\n" +
954 " \"multiplicity\": \"MANY2ONE\",\n" +
955 " \"contains-other-v\": \"!${direction}\",\n" +
956 " \"delete-other-v\": \"!${direction}\",\n" +
957 " \"prevent-delete\": \"NONE\",\n" +
958 " \"default\": \"true\",\n" +
959 " \"description\":\"\"\n" +
962 " \"from\": \"service-subscription\",\n" +
963 " \"to\": \"tenant\",\n" +
964 " \"label\": \"org.onap.relationships.inventory.Uses\",\n" +
965 " \"direction\": \"OUT\",\n" +
966 " \"multiplicity\": \"MANY2MANY\",\n" +
967 " \"contains-other-v\": \"NONE\",\n" +
968 " \"delete-other-v\": \"NONE\",\n" +
969 " \"prevent-delete\": \"NONE\",\n" +
970 " \"default\": \"true\",\n" +
971 " \"description\":\"\"\n" +
975 return sb.toString();