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;
62 @RunWith(SpringJUnit4ClassRunner.class)
63 @ContextConfiguration(classes = {
65 SchemaLocationsBean.class,
66 TestUtilConfigTranslatorforBusiness.class,
70 SwaggerGenerationConfiguration.class
73 @TestPropertySource(properties = {
74 "schema.uri.base.path = /aai",
75 "schema.xsd.maxoccurs = 5000"
77 public class YAMLfromOXMTest {
79 EdgeIngestor edgeIngestor;
82 NodeIngestor nodeIngestor;
83 private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
84 private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
85 private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
86 public static AnnotationConfigApplicationContext ctx = null;
87 private static String testXML;
88 protected static final String SERVICE_NAME = "JUNIT";
92 YAMLfromOXM yamlFromOxm;
95 SchemaVersions schemaVersions;
98 public static void setUpBeforeClass() throws Exception {
99 System.setProperty("AJSC_HOME", ".");
100 System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
101 System.setProperty("aai.service.name", SERVICE_NAME);
103 XSDElementTest x = new XSDElementTest();
106 logger.debug(testXML);
107 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
110 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
111 bw1.write(EdgeDefs());
121 public void setUp() throws Exception {
126 public void AtestIngestors() throws EdgeRuleNotFoundException {
127 Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
128 SortedSet<String> ss=new TreeSet<String>(results.keySet());
129 for(String key : ss) {
130 results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
132 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
137 public void testGetDocumentHeader() {
138 SchemaVersion v = schemaVersions.getAppRootVersion();
139 String apiVersion = v.toString();
140 String header = null;
142 yamlFromOxm.setXmlVersion(testXML, v);
143 yamlFromOxm.process();
144 header = yamlFromOxm.getDocumentHeader();
145 } catch(Exception e) {
148 assertThat("Header:\n"+header,header, is(YAMLheader()));
152 public void testProcess() {
153 SchemaVersion v = schemaVersions.getAppRootVersion();
154 String apiVersion = v.toString();
155 String fileContent = null;
157 yamlFromOxm.setXmlVersion(testXML, v);
158 fileContent = yamlFromOxm.process();
159 } catch(Exception e) {
162 assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
167 public void testYAMLfromOXMFileVersionFile() throws IOException {
168 String outfileName = "testXML.xml";
169 File XMLfile = new File(outfileName);
170 XMLfile.createNewFile();
171 BufferedWriter bw = null;
172 Charset charset = Charset.forName("UTF-8");
173 Path path = Paths.get(outfileName);
174 bw = Files.newBufferedWriter(path, charset);
177 SchemaVersion v = schemaVersions.getAppRootVersion();
178 String apiVersion = v.toString();
179 String fileContent = null;
181 yamlFromOxm.setXmlVersion(testXML, v);
182 fileContent = yamlFromOxm.process();
183 } catch(Exception e) {
187 assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
191 public void testYAMLfromOXMStringVersionFile() {
192 SchemaVersion v = schemaVersions.getAppRootVersion();
193 String apiVersion = v.toString();
194 String fileContent = null;
196 yamlFromOxm.setXmlVersion(testXML, v);
197 fileContent = yamlFromOxm.process();
198 } catch(Exception e) {
201 assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
205 public void testAppendDefinitions() {
206 SchemaVersion v = schemaVersions.getAppRootVersion();
207 String apiVersion = v.toString();
208 String definitions = null;
210 yamlFromOxm.setXmlVersion(testXML, v);
211 yamlFromOxm.process();
212 definitions = yamlFromOxm.appendDefinitions();
213 } catch(Exception e) {
216 assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLpatchDefs()+YAMLgetDefs()));
220 public void testGetXMLRootElementName() {
221 String target = "RootElement=customer";
222 SchemaVersion v = schemaVersions.getAppRootVersion();
223 String apiVersion = v.toString();
224 Element customer = null;
227 yamlFromOxm.setXmlVersion(testXML, v);
228 yamlFromOxm.process();
229 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
230 root = yamlFromOxm.getXMLRootElementName(customer);
231 } catch(Exception e) {
234 assertThat("RootElement="+root, is(target));
238 public void testGetXmlRootElementName() {
239 String target = "RootElement=customer";
240 SchemaVersion v = schemaVersions.getAppRootVersion();
241 String apiVersion = v.toString();
244 yamlFromOxm.setXmlVersion(testXML, v);
245 yamlFromOxm.process();
246 root = yamlFromOxm.getXmlRootElementName("Customer");
247 } catch(Exception e) {
250 assertThat("RootElement="+root, is(target));
254 public void testGetJavaTypeElementSwagger() {
255 String target = "Element=java-type/Customer";
256 SchemaVersion v = schemaVersions.getAppRootVersion();
257 String apiVersion = v.toString();
258 Element customer = null;
260 yamlFromOxm.setXmlVersion(testXML, v);
261 yamlFromOxm.process();
262 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
263 } catch(Exception e) {
266 assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
269 public String YAMLresult() {
270 StringBuilder sb = new StringBuilder(32368);
271 sb.append(YAMLheader());
272 sb.append(YAMLops());
273 sb.append(YAMLdefs());
274 sb.append(YAMLpatchDefs());
275 sb.append(YAMLgetDefs());
276 return sb.toString();
278 public String YAMLheader() {
279 StringBuilder sb = new StringBuilder(1500);
280 sb.append("swagger: \"2.0\"\n");
281 sb.append("info:\n");
282 sb.append(" description: |\n");
284 sb.append(" [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)\n");
286 sb.append(" Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.\n");
288 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");
290 sb.append(" You may obtain a copy of the License at\n");
292 sb.append(" (https://creativecommons.org/licenses/by/4.0/)\n");
294 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.\n");
296 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.\n");
297 sb.append(" version: \"v11\"\n");
298 sb.append(" title: Active and Available Inventory REST API\n");
299 sb.append(" license:\n");
300 sb.append(" name: Apache 2.0\n");
301 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html\n");
302 sb.append(" contact:\n");
303 sb.append(" name:\n");
304 sb.append(" url:\n");
305 sb.append(" email:\n");
306 sb.append("host:\n");
307 sb.append("basePath: /aai/v11\n");
308 sb.append("schemes:\n");
309 sb.append(" - https\n");
310 sb.append("paths:\n");
311 return sb.toString();
314 public String YAMLops() {
315 StringBuilder sb = new StringBuilder(16384);
316 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
317 sb.append(" get:\n");
318 sb.append(" tags:\n");
319 sb.append(" - Business\n");
320 sb.append(" summary: returns service-subscription\n");
321 sb.append(" description: returns service-subscription\n");
322 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
323 sb.append(" produces:\n");
324 sb.append(" - application/json\n");
325 sb.append(" - application/xml\n");
326 sb.append(" responses:\n");
327 sb.append(" \"200\":\n");
328 sb.append(" description: successful operation\n");
329 sb.append(" schema:\n");
330 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
331 sb.append(" \"default\":\n");
332 sb.append(" null parameters:\n");
333 sb.append(" - name: global-customer-id\n");
334 sb.append(" in: path\n");
335 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
336 sb.append(" required: true\n");
337 sb.append(" type: string\n");
338 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
339 sb.append(" - name: service-type\n");
340 sb.append(" in: path\n");
341 sb.append(" description: Value defined by orchestration to identify this service.\n");
342 sb.append(" required: true\n");
343 sb.append(" type: string\n");
344 sb.append(" example: __SERVICE-TYPE__\n");
345 sb.append(" put:\n");
346 sb.append(" tags:\n");
347 sb.append(" - Business\n");
348 sb.append(" summary: create or update an existing service-subscription\n");
349 sb.append(" description: |\n");
350 sb.append(" Create or update an existing service-subscription.\n");
352 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");
353 sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
354 sb.append(" consumes:\n");
355 sb.append(" - application/json\n");
356 sb.append(" - application/xml\n");
357 sb.append(" produces:\n");
358 sb.append(" - application/json\n");
359 sb.append(" - application/xml\n");
360 sb.append(" responses:\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(" - name: body\n");
376 sb.append(" in: body\n");
377 sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
378 sb.append(" required: true\n");
379 sb.append(" schema:\n");
380 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
381 sb.append(" patch:\n");
382 sb.append(" tags:\n");
383 sb.append(" - Business\n");
384 sb.append(" summary: update an existing service-subscription\n");
385 sb.append(" description: |\n");
386 sb.append(" Update an existing service-subscription\n");
388 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
389 sb.append(" The PUT operation will entirely replace an existing object.\n");
390 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");
392 sb.append(" Other differences between PUT and PATCH are:\n");
394 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
395 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
396 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
397 sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
398 sb.append(" consumes:\n");
399 sb.append(" - application/json\n");
400 sb.append(" produces:\n");
401 sb.append(" - application/json\n");
402 sb.append(" responses:\n");
403 sb.append(" \"default\":\n");
404 sb.append(" null parameters:\n");
405 sb.append(" - name: global-customer-id\n");
406 sb.append(" in: path\n");
407 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
408 sb.append(" required: true\n");
409 sb.append(" type: string\n");
410 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
411 sb.append(" - name: service-type\n");
412 sb.append(" in: path\n");
413 sb.append(" description: Value defined by orchestration to identify this service.\n");
414 sb.append(" required: true\n");
415 sb.append(" type: string\n");
416 sb.append(" example: __SERVICE-TYPE__\n");
417 sb.append(" - name: body\n");
418 sb.append(" in: body\n");
419 sb.append(" description: service-subscription object that needs to be updated.\n");
420 sb.append(" required: true\n");
421 sb.append(" schema:\n");
422 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
423 sb.append(" delete:\n");
424 sb.append(" tags:\n");
425 sb.append(" - Business\n");
426 sb.append(" summary: delete an existing service-subscription\n");
427 sb.append(" description: delete an existing service-subscription\n");
428 sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
429 sb.append(" consumes:\n");
430 sb.append(" - application/json\n");
431 sb.append(" - application/xml\n");
432 sb.append(" produces:\n");
433 sb.append(" - application/json\n");
434 sb.append(" - application/xml\n");
435 sb.append(" responses:\n");
436 sb.append(" \"default\":\n");
437 sb.append(" null parameters:\n");
438 sb.append(" - name: global-customer-id\n");
439 sb.append(" in: path\n");
440 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
441 sb.append(" required: true\n");
442 sb.append(" type: string\n");
443 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
444 sb.append(" - name: service-type\n");
445 sb.append(" in: path\n");
446 sb.append(" description: Value defined by orchestration to identify this service.\n");
447 sb.append(" required: true\n");
448 sb.append(" type: string\n");
449 sb.append(" example: __SERVICE-TYPE__\n");
450 sb.append(" - name: resource-version\n");
451 sb.append(" in: query\n");
452 sb.append(" description: resource-version for concurrency\n");
453 sb.append(" required: true\n");
454 sb.append(" type: string\n");
455 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
456 sb.append(" get:\n");
457 sb.append(" tags:\n");
458 sb.append(" - Business\n");
459 sb.append(" summary: returns service-subscriptions\n");
460 sb.append(" description: returns service-subscriptions\n");
461 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\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(" \"200\":\n");
467 sb.append(" description: successful operation\n");
468 sb.append(" schema:\n");
469 sb.append(" $ref: \"#/getDefinitions/service-subscriptions\"\n");
470 sb.append(" \"default\":\n");
471 sb.append(" null parameters:\n");
472 sb.append(" - name: global-customer-id\n");
473 sb.append(" in: path\n");
474 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
475 sb.append(" required: true\n");
476 sb.append(" type: string\n");
477 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
478 sb.append(" - name: service-type\n");
479 sb.append(" in: query\n");
480 sb.append(" description:\n");
481 sb.append(" required: false\n");
482 sb.append(" type: string\n");
483 sb.append(" /business/customers/customer/{global-customer-id}:\n");
484 sb.append(" get:\n");
485 sb.append(" tags:\n");
486 sb.append(" - Business\n");
487 sb.append(" summary: returns customer\n");
488 sb.append(" description: returns customer\n");
489 sb.append(" operationId: getBusinessCustomersCustomer\n");
490 sb.append(" produces:\n");
491 sb.append(" - application/json\n");
492 sb.append(" - application/xml\n");
493 sb.append(" responses:\n");
494 sb.append(" \"200\":\n");
495 sb.append(" description: successful operation\n");
496 sb.append(" schema:\n");
497 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
498 sb.append(" \"default\":\n");
499 sb.append(" null parameters:\n");
500 sb.append(" - name: global-customer-id\n");
501 sb.append(" in: path\n");
502 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
503 sb.append(" required: true\n");
504 sb.append(" type: string\n");
505 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
506 sb.append(" put:\n");
507 sb.append(" tags:\n");
508 sb.append(" - Business\n");
509 sb.append(" summary: create or update an existing customer\n");
510 sb.append(" description: |\n");
511 sb.append(" Create or update an existing customer.\n");
513 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");
514 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
515 sb.append(" consumes:\n");
516 sb.append(" - application/json\n");
517 sb.append(" - application/xml\n");
518 sb.append(" produces:\n");
519 sb.append(" - application/json\n");
520 sb.append(" - application/xml\n");
521 sb.append(" responses:\n");
522 sb.append(" \"default\":\n");
523 sb.append(" null parameters:\n");
524 sb.append(" - name: global-customer-id\n");
525 sb.append(" in: path\n");
526 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
527 sb.append(" required: true\n");
528 sb.append(" type: string\n");
529 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
530 sb.append(" - name: body\n");
531 sb.append(" in: body\n");
532 sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
533 sb.append(" required: true\n");
534 sb.append(" schema:\n");
535 sb.append(" $ref: \"#/definitions/customer\"\n");
536 sb.append(" patch:\n");
537 sb.append(" tags:\n");
538 sb.append(" - Business\n");
539 sb.append(" summary: update an existing customer\n");
540 sb.append(" description: |\n");
541 sb.append(" Update an existing customer\n");
543 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
544 sb.append(" The PUT operation will entirely replace an existing object.\n");
545 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");
547 sb.append(" Other differences between PUT and PATCH are:\n");
549 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
550 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
551 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
552 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
553 sb.append(" consumes:\n");
554 sb.append(" - application/json\n");
555 sb.append(" produces:\n");
556 sb.append(" - application/json\n");
557 sb.append(" responses:\n");
558 sb.append(" \"default\":\n");
559 sb.append(" null parameters:\n");
560 sb.append(" - name: global-customer-id\n");
561 sb.append(" in: path\n");
562 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
563 sb.append(" required: true\n");
564 sb.append(" type: string\n");
565 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
566 sb.append(" - name: body\n");
567 sb.append(" in: body\n");
568 sb.append(" description: customer object that needs to be updated.\n");
569 sb.append(" required: true\n");
570 sb.append(" schema:\n");
571 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
572 sb.append(" delete:\n");
573 sb.append(" tags:\n");
574 sb.append(" - Business\n");
575 sb.append(" summary: delete an existing customer\n");
576 sb.append(" description: delete an existing customer\n");
577 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
578 sb.append(" consumes:\n");
579 sb.append(" - application/json\n");
580 sb.append(" - application/xml\n");
581 sb.append(" produces:\n");
582 sb.append(" - application/json\n");
583 sb.append(" - application/xml\n");
584 sb.append(" responses:\n");
585 sb.append(" \"default\":\n");
586 sb.append(" null parameters:\n");
587 sb.append(" - name: global-customer-id\n");
588 sb.append(" in: path\n");
589 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
590 sb.append(" required: true\n");
591 sb.append(" type: string\n");
592 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
593 sb.append(" - name: resource-version\n");
594 sb.append(" in: query\n");
595 sb.append(" description: resource-version for concurrency\n");
596 sb.append(" required: true\n");
597 sb.append(" type: string\n");
598 sb.append(" /business/customers:\n");
599 sb.append(" get:\n");
600 sb.append(" tags:\n");
601 sb.append(" - Business\n");
602 sb.append(" summary: returns customers\n");
603 sb.append(" description: returns customers\n");
604 sb.append(" operationId: getBusinessCustomers\n");
605 sb.append(" produces:\n");
606 sb.append(" - application/json\n");
607 sb.append(" - application/xml\n");
608 sb.append(" responses:\n");
609 sb.append(" \"200\":\n");
610 sb.append(" description: successful operation\n");
611 sb.append(" schema:\n");
612 sb.append(" $ref: \"#/getDefinitions/customers\"\n");
613 sb.append(" \"default\":\n");
614 sb.append(" null parameters:\n");
615 sb.append(" - name: global-customer-id\n");
616 sb.append(" in: query\n");
617 sb.append(" description:\n");
618 sb.append(" required: false\n");
619 sb.append(" type: string\n");
620 sb.append(" - name: subscriber-name\n");
621 sb.append(" in: query\n");
622 sb.append(" description:\n");
623 sb.append(" required: false\n");
624 sb.append(" type: string\n");
625 sb.append(" - name: subscriber-type\n");
626 sb.append(" in: query\n");
627 sb.append(" description:\n");
628 sb.append(" required: false\n");
629 sb.append(" type: string\n");
630 return sb.toString();
632 public String YAMLdefs() {
633 StringBuilder sb = new StringBuilder(8092);
634 sb.append("definitions:\n");
635 sb.append(" business:\n");
636 sb.append(" description: |\n");
637 sb.append(" Namespace for business related constructs\n");
638 sb.append(" properties:\n");
639 sb.append(" customers:\n");
640 sb.append(" type: array\n");
641 sb.append(" items:\n");
642 sb.append(" $ref: \"#/definitions/customer\"\n");
643 sb.append(" customer:\n");
644 sb.append(" description: |\n");
645 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
646 sb.append(" ###### Related Nodes\n");
647 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
649 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
650 sb.append(" required:\n");
651 sb.append(" - global-customer-id\n");
652 sb.append(" - subscriber-name\n");
653 sb.append(" - subscriber-type\n");
654 sb.append(" properties:\n");
655 sb.append(" global-customer-id:\n");
656 sb.append(" type: string\n");
657 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
658 sb.append(" subscriber-name:\n");
659 sb.append(" type: string\n");
660 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
661 sb.append(" subscriber-type:\n");
662 sb.append(" type: string\n");
663 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
664 sb.append(" resource-version:\n");
665 sb.append(" type: string\n");
666 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
667 sb.append(" service-subscriptions:\n");
668 sb.append(" type: array\n");
669 sb.append(" items:\n");
670 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
671 sb.append(" customers:\n");
672 sb.append(" description: |\n");
673 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
674 sb.append(" properties:\n");
675 sb.append(" customer:\n");
676 sb.append(" type: array\n");
677 sb.append(" items: \n");
678 sb.append(" $ref: \"#/definitions/customer\"\n");
679 sb.append(" inventory:\n");
680 sb.append(" properties:\n");
681 sb.append(" business:\n");
682 sb.append(" type: object\n");
683 sb.append(" $ref: \"#/definitions/business\"\n");
684 sb.append(" nodes:\n");
685 sb.append(" properties:\n");
686 sb.append(" inventory-item-data:\n");
687 sb.append(" type: array\n");
688 sb.append(" items:\n");
689 sb.append(" $ref: \"#/definitions/inventory-item-data\"\n");
690 sb.append(" service-subscription:\n");
691 sb.append(" description: |\n");
692 sb.append(" Object that group service instances.\n");
693 sb.append(" ###### Related Nodes\n");
694 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
695 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
696 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
698 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
699 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
700 sb.append(" required:\n");
701 sb.append(" - service-type\n");
702 sb.append(" properties:\n");
703 sb.append(" service-type:\n");
704 sb.append(" type: string\n");
705 sb.append(" description: Value defined by orchestration to identify this service.\n");
706 sb.append(" temp-ub-sub-account-id:\n");
707 sb.append(" type: string\n");
708 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
709 sb.append(" resource-version:\n");
710 sb.append(" type: string\n");
711 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
712 sb.append(" service-subscriptions:\n");
713 sb.append(" description: |\n");
714 sb.append(" Collection of objects that group service instances.\n");
715 sb.append(" properties:\n");
716 sb.append(" service-subscription:\n");
717 sb.append(" type: array\n");
718 sb.append(" items: \n");
719 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
720 return sb.toString();
722 public String YAMLpatchDefs() {
723 StringBuilder sb = new StringBuilder(8092);
724 sb.append("patchDefinitions:\n");
725 sb.append(" business:\n");
726 sb.append(" description: |\n");
727 sb.append(" Namespace for business related constructs\n");
728 sb.append(" properties:\n");
729 sb.append(" customers:\n");
730 sb.append(" type: array\n");
731 sb.append(" items:\n");
732 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
733 sb.append(" customer:\n");
734 sb.append(" description: |\n");
735 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
736 sb.append(" ###### Related Nodes\n");
737 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
739 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
740 sb.append(" required:\n");
741 sb.append(" - global-customer-id\n");
742 sb.append(" - subscriber-name\n");
743 sb.append(" - subscriber-type\n");
744 sb.append(" properties:\n");
745 sb.append(" global-customer-id:\n");
746 sb.append(" type: string\n");
747 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
748 sb.append(" subscriber-name:\n");
749 sb.append(" type: string\n");
750 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
751 sb.append(" subscriber-type:\n");
752 sb.append(" type: string\n");
753 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
754 sb.append(" customers:\n");
755 sb.append(" description: |\n");
756 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
757 sb.append(" properties:\n");
758 sb.append(" customer:\n");
759 sb.append(" type: array\n");
760 sb.append(" items: \n");
761 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
762 sb.append(" inventory:\n");
763 sb.append(" properties:\n");
764 sb.append(" business:\n");
765 sb.append(" type: object\n");
766 sb.append(" $ref: \"#/patchDefinitions/business\"\n");
767 sb.append(" nodes:\n");
768 sb.append(" properties:\n");
769 sb.append(" inventory-item-data:\n");
770 sb.append(" type: array\n");
771 sb.append(" items:\n");
772 sb.append(" $ref: \"#/patchDefinitions/inventory-item-data\"\n");
773 sb.append(" service-subscription:\n");
774 sb.append(" description: |\n");
775 sb.append(" Object that group service instances.\n");
776 sb.append(" ###### Related Nodes\n");
777 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
778 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
779 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
781 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
782 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
783 sb.append(" required:\n");
784 sb.append(" - service-type\n");
785 sb.append(" properties:\n");
786 sb.append(" service-type:\n");
787 sb.append(" type: string\n");
788 sb.append(" description: Value defined by orchestration to identify this service.\n");
789 sb.append(" temp-ub-sub-account-id:\n");
790 sb.append(" type: string\n");
791 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
792 sb.append(" service-subscriptions:\n");
793 sb.append(" description: |\n");
794 sb.append(" Collection of objects that group service instances.\n");
795 sb.append(" properties:\n");
796 sb.append(" service-subscription:\n");
797 sb.append(" type: array\n");
798 sb.append(" items: \n");
799 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
800 return sb.toString();
802 public String YAMLgetDefs() {
803 StringBuilder sb = new StringBuilder(8092);
804 sb.append("getDefinitions:\n");
805 sb.append(" business:\n");
806 sb.append(" description: |\n");
807 sb.append(" Namespace for business related constructs\n");
808 sb.append(" properties:\n");
809 sb.append(" customers:\n");
810 sb.append(" type: array\n");
811 sb.append(" items:\n");
812 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
813 sb.append(" customer:\n");
814 sb.append(" description: |\n");
815 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
816 sb.append(" ###### Related Nodes\n");
817 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
819 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
820 sb.append(" required:\n");
821 sb.append(" - global-customer-id\n");
822 sb.append(" - subscriber-name\n");
823 sb.append(" - subscriber-type\n");
824 sb.append(" properties:\n");
825 sb.append(" global-customer-id:\n");
826 sb.append(" type: string\n");
827 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
828 sb.append(" subscriber-name:\n");
829 sb.append(" type: string\n");
830 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
831 sb.append(" subscriber-type:\n");
832 sb.append(" type: string\n");
833 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
834 sb.append(" resource-version:\n");
835 sb.append(" type: string\n");
836 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
837 sb.append(" service-subscriptions:\n");
838 sb.append(" type: array\n");
839 sb.append(" items:\n");
840 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
841 sb.append(" customers:\n");
842 sb.append(" description: |\n");
843 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
844 sb.append(" properties:\n");
845 sb.append(" customer:\n");
846 sb.append(" type: array\n");
847 sb.append(" items: \n");
848 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
849 sb.append(" inventory:\n");
850 sb.append(" properties:\n");
851 sb.append(" business:\n");
852 sb.append(" type: object\n");
853 sb.append(" $ref: \"#/getDefinitions/business\"\n");
854 sb.append(" nodes:\n");
855 sb.append(" properties:\n");
856 sb.append(" inventory-item-data:\n");
857 sb.append(" type: array\n");
858 sb.append(" items:\n");
859 sb.append(" $ref: \"#/getDefinitions/inventory-item-data\"\n");
860 sb.append(" service-subscription:\n");
861 sb.append(" description: |\n");
862 sb.append(" Object that group service instances.\n");
863 sb.append(" ###### Related Nodes\n");
864 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
865 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
866 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
868 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
869 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
870 sb.append(" required:\n");
871 sb.append(" - service-type\n");
872 sb.append(" properties:\n");
873 sb.append(" service-type:\n");
874 sb.append(" type: string\n");
875 sb.append(" description: Value defined by orchestration to identify this service.\n");
876 sb.append(" temp-ub-sub-account-id:\n");
877 sb.append(" type: string\n");
878 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
879 sb.append(" resource-version:\n");
880 sb.append(" type: string\n");
881 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
882 sb.append(" service-subscriptions:\n");
883 sb.append(" description: |\n");
884 sb.append(" Collection of objects that group service instances.\n");
885 sb.append(" properties:\n");
886 sb.append(" service-subscription:\n");
887 sb.append(" type: array\n");
888 sb.append(" items: \n");
889 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
890 return sb.toString();
892 public static String EdgeDefs() {
893 StringBuilder sb = new StringBuilder(8092);
897 sb.append(" \"from\": \"service-subscription\",\n");
898 sb.append(" \"to\": \"customer\",\n" +
899 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
900 " \"direction\": \"OUT\",\n" +
901 " \"multiplicity\": \"MANY2ONE\",\n" +
902 " \"contains-other-v\": \"!${direction}\",\n" +
903 " \"delete-other-v\": \"!${direction}\",\n" +
904 " \"prevent-delete\": \"NONE\",\n" +
905 " \"default\": \"true\",\n" +
906 " \"description\":\"\"\n");
909 " \"from\": \"service-instance\",\n" +
910 " \"to\": \"service-subscription\",\n" +
911 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
912 " \"direction\": \"OUT\",\n" +
913 " \"multiplicity\": \"MANY2ONE\",\n" +
914 " \"contains-other-v\": \"!${direction}\",\n" +
915 " \"delete-other-v\": \"!${direction}\",\n" +
916 " \"prevent-delete\": \"NONE\",\n" +
917 " \"default\": \"true\",\n" +
918 " \"description\":\"\"\n" +
921 " \"from\": \"service-subscription\",\n" +
922 " \"to\": \"tenant\",\n" +
923 " \"label\": \"org.onap.relationships.inventory.Uses\",\n" +
924 " \"direction\": \"OUT\",\n" +
925 " \"multiplicity\": \"MANY2MANY\",\n" +
926 " \"contains-other-v\": \"NONE\",\n" +
927 " \"delete-other-v\": \"NONE\",\n" +
928 " \"prevent-delete\": \"NONE\",\n" +
929 " \"default\": \"true\",\n" +
930 " \"description\":\"\"\n" +
934 return sb.toString();