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 static org.hamcrest.CoreMatchers.is;
24 import static org.junit.Assert.*;
26 import java.io.BufferedWriter;
28 import java.io.FileWriter;
29 import java.io.IOException;
30 import java.nio.charset.Charset;
31 import java.nio.file.Files;
32 import java.nio.file.Path;
33 import java.nio.file.Paths;
34 import java.util.SortedSet;
35 import java.util.TreeSet;
37 import org.junit.Before;
38 import org.junit.BeforeClass;
39 import org.junit.Test;
40 import org.onap.aai.AAISetup;
41 import org.onap.aai.config.SwaggerGenerationConfiguration;
42 import org.onap.aai.setup.SchemaVersion;
43 import org.onap.aai.setup.SchemaVersions;
44 import org.junit.runner.RunWith;
45 import org.onap.aai.edges.EdgeIngestor;
46 import org.onap.aai.edges.EdgeRule;
47 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
48 import org.onap.aai.nodes.NodeIngestor;
49 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
50 import org.onap.aai.setup.SchemaLocationsBean;
51 import org.onap.aai.testutils.TestUtilConfigTranslatorforBusiness;
52 import org.onap.aai.util.AAIConstants;
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
55 import org.springframework.beans.factory.annotation.Autowired;
56 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
57 import org.springframework.test.annotation.DirtiesContext;
58 import org.springframework.test.context.ContextConfiguration;
59 import org.springframework.test.context.TestPropertySource;
60 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
61 import org.w3c.dom.Document;
62 import org.w3c.dom.Element;
64 import com.google.common.collect.Multimap;
67 @RunWith(SpringJUnit4ClassRunner.class)
68 @ContextConfiguration(classes = {
70 SchemaLocationsBean.class,
71 TestUtilConfigTranslatorforBusiness.class,
75 SwaggerGenerationConfiguration.class
78 @TestPropertySource(properties = {
79 "schema.uri.base.path = /aai",
80 "schema.xsd.maxoccurs = 5000"
82 public class YAMLfromOXMTest {
84 EdgeIngestor edgeIngestor;
87 NodeIngestor nodeIngestor;
88 private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
89 private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
90 private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
91 public static AnnotationConfigApplicationContext ctx = null;
92 private static String testXML;
93 protected static final String SERVICE_NAME = "JUNIT";
97 YAMLfromOXM yamlFromOxm;
100 SchemaVersions schemaVersions;
103 public static void setUpBeforeClass() throws Exception {
104 System.setProperty("AJSC_HOME", ".");
105 System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
106 System.setProperty("aai.service.name", SERVICE_NAME);
108 QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
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());
127 public void setUp() throws Exception {
132 public void AtestIngestors() throws EdgeRuleNotFoundException {
133 Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
134 SortedSet<String> ss=new TreeSet<String>(results.keySet());
135 for(String key : ss) {
136 results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
138 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
143 public void testGetDocumentHeader() {
144 SchemaVersion v = schemaVersions.getAppRootVersion();
145 String apiVersion = v.toString();
146 String header = null;
148 yamlFromOxm.setXmlVersion(testXML, v);
149 yamlFromOxm.process();
150 header = yamlFromOxm.getDocumentHeader();
151 } catch(Exception e) {
154 assertThat("Header:\n"+header,header, is(YAMLheader()));
158 public void testProcess() {
159 SchemaVersion v = schemaVersions.getAppRootVersion();
160 String apiVersion = v.toString();
161 String fileContent = null;
163 yamlFromOxm.setXmlVersion(testXML, v);
164 fileContent = yamlFromOxm.process();
165 } catch(Exception e) {
168 assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
173 public void testYAMLfromOXMFileVersionFile() throws IOException {
174 String outfileName = "testXML.xml";
175 File XMLfile = new File(outfileName);
176 XMLfile.createNewFile();
177 BufferedWriter bw = null;
178 Charset charset = Charset.forName("UTF-8");
179 Path path = Paths.get(outfileName);
180 bw = Files.newBufferedWriter(path, charset);
183 SchemaVersion v = schemaVersions.getAppRootVersion();
184 String apiVersion = v.toString();
185 String fileContent = null;
187 yamlFromOxm.setXmlVersion(testXML, v);
188 fileContent = yamlFromOxm.process();
189 } catch(Exception e) {
193 assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
197 public void testYAMLfromOXMStringVersionFile() {
198 SchemaVersion v = schemaVersions.getAppRootVersion();
199 String apiVersion = v.toString();
200 String fileContent = null;
202 yamlFromOxm.setXmlVersion(testXML, v);
203 fileContent = yamlFromOxm.process();
204 } catch(Exception e) {
207 assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
211 public void testAppendDefinitions() {
212 SchemaVersion v = schemaVersions.getAppRootVersion();
213 String apiVersion = v.toString();
214 String definitions = null;
216 yamlFromOxm.setXmlVersion(testXML, v);
217 yamlFromOxm.process();
218 definitions = yamlFromOxm.appendDefinitions();
219 } catch(Exception e) {
222 assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLpatchDefs()+YAMLgetDefs()));
226 public void testGetXMLRootElementName() {
227 String target = "RootElement=customer";
228 SchemaVersion v = schemaVersions.getAppRootVersion();
229 String apiVersion = v.toString();
230 Element customer = null;
233 yamlFromOxm.setXmlVersion(testXML, v);
234 yamlFromOxm.process();
235 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
236 root = yamlFromOxm.getXMLRootElementName(customer);
237 } catch(Exception e) {
240 assertThat("RootElement="+root, is(target));
244 public void testGetXmlRootElementName() {
245 String target = "RootElement=customer";
246 SchemaVersion v = schemaVersions.getAppRootVersion();
247 String apiVersion = v.toString();
250 yamlFromOxm.setXmlVersion(testXML, v);
251 yamlFromOxm.process();
252 root = yamlFromOxm.getXmlRootElementName("Customer");
253 } catch(Exception e) {
256 assertThat("RootElement="+root, is(target));
260 public void testGetJavaTypeElementSwagger() {
261 String target = "Element=java-type/Customer";
262 SchemaVersion v = schemaVersions.getAppRootVersion();
263 String apiVersion = v.toString();
264 Element customer = null;
266 yamlFromOxm.setXmlVersion(testXML, v);
267 yamlFromOxm.process();
268 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
269 } catch(Exception e) {
272 assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
275 public String YAMLresult() {
276 StringBuilder sb = new StringBuilder(32368);
277 sb.append(YAMLheader());
278 sb.append(YAMLops());
279 sb.append(YAMLdefs());
280 sb.append(YAMLpatchDefs());
281 sb.append(YAMLgetDefs());
282 return sb.toString();
284 public String YAMLheader() {
285 StringBuilder sb = new StringBuilder(1500);
286 sb.append("swagger: \"2.0\"\n");
287 sb.append("info:\n");
288 sb.append(" description: |\n");
290 sb.append(" [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)\n");
292 sb.append(" Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.\n");
294 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");
296 sb.append(" You may obtain a copy of the License at\n");
298 sb.append(" (https://creativecommons.org/licenses/by/4.0/)\n");
300 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");
302 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");
303 sb.append(" version: \"v11\"\n");
304 sb.append(" title: Active and Available Inventory REST API\n");
305 sb.append(" license:\n");
306 sb.append(" name: Apache 2.0\n");
307 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html\n");
308 sb.append(" contact:\n");
309 sb.append(" name:\n");
310 sb.append(" url:\n");
311 sb.append(" email:\n");
312 sb.append("host:\n");
313 sb.append("basePath: /aai/v11\n");
314 sb.append("schemes:\n");
315 sb.append(" - https\n");
316 sb.append("paths:\n");
317 return sb.toString();
320 public String YAMLops() {
321 StringBuilder sb = new StringBuilder(16384);
322 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
323 sb.append(" get:\n");
324 sb.append(" tags:\n");
325 sb.append(" - Business\n");
326 sb.append(" summary: returns service-subscription\n");
327 sb.append(" description: returns service-subscription\n");
328 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
329 sb.append(" produces:\n");
330 sb.append(" - application/json\n");
331 sb.append(" - application/xml\n");
332 sb.append(" responses:\n");
333 sb.append(" \"200\":\n");
334 sb.append(" description: successful operation\n");
335 sb.append(" schema:\n");
336 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
337 sb.append(" \"default\":\n");
338 sb.append(" null parameters:\n");
339 sb.append(" - name: global-customer-id\n");
340 sb.append(" in: path\n");
341 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
342 sb.append(" required: true\n");
343 sb.append(" type: string\n");
344 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
345 sb.append(" - name: service-type\n");
346 sb.append(" in: path\n");
347 sb.append(" description: Value defined by orchestration to identify this service.\n");
348 sb.append(" required: true\n");
349 sb.append(" type: string\n");
350 sb.append(" example: __SERVICE-TYPE__\n");
351 sb.append(" put:\n");
352 sb.append(" tags:\n");
353 sb.append(" - Business\n");
354 sb.append(" summary: create or update an existing service-subscription\n");
355 sb.append(" description: |\n");
356 sb.append(" Create or update an existing service-subscription.\n");
358 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");
359 sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
360 sb.append(" consumes:\n");
361 sb.append(" - application/json\n");
362 sb.append(" - application/xml\n");
363 sb.append(" produces:\n");
364 sb.append(" - application/json\n");
365 sb.append(" - application/xml\n");
366 sb.append(" responses:\n");
367 sb.append(" \"default\":\n");
368 sb.append(" null parameters:\n");
369 sb.append(" - name: global-customer-id\n");
370 sb.append(" in: path\n");
371 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
372 sb.append(" required: true\n");
373 sb.append(" type: string\n");
374 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
375 sb.append(" - name: service-type\n");
376 sb.append(" in: path\n");
377 sb.append(" description: Value defined by orchestration to identify this service.\n");
378 sb.append(" required: true\n");
379 sb.append(" type: string\n");
380 sb.append(" example: __SERVICE-TYPE__\n");
381 sb.append(" - name: body\n");
382 sb.append(" in: body\n");
383 sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
384 sb.append(" required: true\n");
385 sb.append(" schema:\n");
386 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
387 sb.append(" patch:\n");
388 sb.append(" tags:\n");
389 sb.append(" - Business\n");
390 sb.append(" summary: update an existing service-subscription\n");
391 sb.append(" description: |\n");
392 sb.append(" Update an existing service-subscription\n");
394 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
395 sb.append(" The PUT operation will entirely replace an existing object.\n");
396 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");
398 sb.append(" Other differences between PUT and PATCH are:\n");
400 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
401 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
402 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
403 sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
404 sb.append(" consumes:\n");
405 sb.append(" - application/json\n");
406 sb.append(" produces:\n");
407 sb.append(" - application/json\n");
408 sb.append(" responses:\n");
409 sb.append(" \"default\":\n");
410 sb.append(" null parameters:\n");
411 sb.append(" - name: global-customer-id\n");
412 sb.append(" in: path\n");
413 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
414 sb.append(" required: true\n");
415 sb.append(" type: string\n");
416 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
417 sb.append(" - name: service-type\n");
418 sb.append(" in: path\n");
419 sb.append(" description: Value defined by orchestration to identify this service.\n");
420 sb.append(" required: true\n");
421 sb.append(" type: string\n");
422 sb.append(" example: __SERVICE-TYPE__\n");
423 sb.append(" - name: body\n");
424 sb.append(" in: body\n");
425 sb.append(" description: service-subscription object that needs to be updated.\n");
426 sb.append(" required: true\n");
427 sb.append(" schema:\n");
428 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
429 sb.append(" delete:\n");
430 sb.append(" tags:\n");
431 sb.append(" - Business\n");
432 sb.append(" summary: delete an existing service-subscription\n");
433 sb.append(" description: delete an existing service-subscription\n");
434 sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
435 sb.append(" consumes:\n");
436 sb.append(" - application/json\n");
437 sb.append(" - application/xml\n");
438 sb.append(" produces:\n");
439 sb.append(" - application/json\n");
440 sb.append(" - application/xml\n");
441 sb.append(" responses:\n");
442 sb.append(" \"default\":\n");
443 sb.append(" null parameters:\n");
444 sb.append(" - name: global-customer-id\n");
445 sb.append(" in: path\n");
446 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
447 sb.append(" required: true\n");
448 sb.append(" type: string\n");
449 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
450 sb.append(" - name: service-type\n");
451 sb.append(" in: path\n");
452 sb.append(" description: Value defined by orchestration to identify this service.\n");
453 sb.append(" required: true\n");
454 sb.append(" type: string\n");
455 sb.append(" example: __SERVICE-TYPE__\n");
456 sb.append(" - name: resource-version\n");
457 sb.append(" in: query\n");
458 sb.append(" description: resource-version for concurrency\n");
459 sb.append(" required: true\n");
460 sb.append(" type: string\n");
461 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
462 sb.append(" get:\n");
463 sb.append(" tags:\n");
464 sb.append(" - Business\n");
465 sb.append(" summary: returns service-subscriptions\n");
466 sb.append(" description: returns service-subscriptions\n");
467 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
468 sb.append(" produces:\n");
469 sb.append(" - application/json\n");
470 sb.append(" - application/xml\n");
471 sb.append(" responses:\n");
472 sb.append(" \"200\":\n");
473 sb.append(" description: successful operation\n");
474 sb.append(" schema:\n");
475 sb.append(" $ref: \"#/getDefinitions/service-subscriptions\"\n");
476 sb.append(" \"default\":\n");
477 sb.append(" null parameters:\n");
478 sb.append(" - name: global-customer-id\n");
479 sb.append(" in: path\n");
480 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
481 sb.append(" required: true\n");
482 sb.append(" type: string\n");
483 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
484 sb.append(" - name: service-type\n");
485 sb.append(" in: query\n");
486 sb.append(" description:\n");
487 sb.append(" required: false\n");
488 sb.append(" type: string\n");
489 sb.append(" /business/customers/customer/{global-customer-id}:\n");
490 sb.append(" get:\n");
491 sb.append(" tags:\n");
492 sb.append(" - Business\n");
493 sb.append(" summary: returns customer\n");
494 sb.append(" description: returns customer\n");
495 sb.append(" operationId: getBusinessCustomersCustomer\n");
496 sb.append(" produces:\n");
497 sb.append(" - application/json\n");
498 sb.append(" - application/xml\n");
499 sb.append(" responses:\n");
500 sb.append(" \"200\":\n");
501 sb.append(" description: successful operation\n");
502 sb.append(" schema:\n");
503 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
504 sb.append(" \"default\":\n");
505 sb.append(" null parameters:\n");
506 sb.append(" - name: global-customer-id\n");
507 sb.append(" in: path\n");
508 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
509 sb.append(" required: true\n");
510 sb.append(" type: string\n");
511 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
512 sb.append(" put:\n");
513 sb.append(" tags:\n");
514 sb.append(" - Business\n");
515 sb.append(" summary: create or update an existing customer\n");
516 sb.append(" description: |\n");
517 sb.append(" Create or update an existing customer.\n");
519 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");
520 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
521 sb.append(" consumes:\n");
522 sb.append(" - application/json\n");
523 sb.append(" - application/xml\n");
524 sb.append(" produces:\n");
525 sb.append(" - application/json\n");
526 sb.append(" - application/xml\n");
527 sb.append(" responses:\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(" - name: body\n");
537 sb.append(" in: body\n");
538 sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
539 sb.append(" required: true\n");
540 sb.append(" schema:\n");
541 sb.append(" $ref: \"#/definitions/customer\"\n");
542 sb.append(" patch:\n");
543 sb.append(" tags:\n");
544 sb.append(" - Business\n");
545 sb.append(" summary: update an existing customer\n");
546 sb.append(" description: |\n");
547 sb.append(" Update an existing customer\n");
549 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
550 sb.append(" The PUT operation will entirely replace an existing object.\n");
551 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");
553 sb.append(" Other differences between PUT and PATCH are:\n");
555 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
556 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
557 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
558 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
559 sb.append(" consumes:\n");
560 sb.append(" - application/json\n");
561 sb.append(" produces:\n");
562 sb.append(" - application/json\n");
563 sb.append(" responses:\n");
564 sb.append(" \"default\":\n");
565 sb.append(" null parameters:\n");
566 sb.append(" - name: global-customer-id\n");
567 sb.append(" in: path\n");
568 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
569 sb.append(" required: true\n");
570 sb.append(" type: string\n");
571 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
572 sb.append(" - name: body\n");
573 sb.append(" in: body\n");
574 sb.append(" description: customer object that needs to be updated.\n");
575 sb.append(" required: true\n");
576 sb.append(" schema:\n");
577 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
578 sb.append(" delete:\n");
579 sb.append(" tags:\n");
580 sb.append(" - Business\n");
581 sb.append(" summary: delete an existing customer\n");
582 sb.append(" description: delete an existing customer\n");
583 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
584 sb.append(" consumes:\n");
585 sb.append(" - application/json\n");
586 sb.append(" - application/xml\n");
587 sb.append(" produces:\n");
588 sb.append(" - application/json\n");
589 sb.append(" - application/xml\n");
590 sb.append(" responses:\n");
591 sb.append(" \"default\":\n");
592 sb.append(" null parameters:\n");
593 sb.append(" - name: global-customer-id\n");
594 sb.append(" in: path\n");
595 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
596 sb.append(" required: true\n");
597 sb.append(" type: string\n");
598 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
599 sb.append(" - name: resource-version\n");
600 sb.append(" in: query\n");
601 sb.append(" description: resource-version for concurrency\n");
602 sb.append(" required: true\n");
603 sb.append(" type: string\n");
604 sb.append(" /business/customers:\n");
605 sb.append(" get:\n");
606 sb.append(" tags:\n");
607 sb.append(" - Business\n");
608 sb.append(" summary: returns customers\n");
609 sb.append(" description: returns customers\n");
610 sb.append(" operationId: getBusinessCustomers\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(" \"200\":\n");
616 sb.append(" description: successful operation\n");
617 sb.append(" schema:\n");
618 sb.append(" $ref: \"#/getDefinitions/customers\"\n");
619 sb.append(" \"default\":\n");
620 sb.append(" null parameters:\n");
621 sb.append(" - name: global-customer-id\n");
622 sb.append(" in: query\n");
623 sb.append(" description:\n");
624 sb.append(" required: false\n");
625 sb.append(" type: string\n");
626 sb.append(" - name: subscriber-name\n");
627 sb.append(" in: query\n");
628 sb.append(" description:\n");
629 sb.append(" required: false\n");
630 sb.append(" type: string\n");
631 sb.append(" - name: subscriber-type\n");
632 sb.append(" in: query\n");
633 sb.append(" description:\n");
634 sb.append(" required: false\n");
635 sb.append(" type: string\n");
636 return sb.toString();
638 public String YAMLdefs() {
639 StringBuilder sb = new StringBuilder(8092);
640 sb.append("definitions:\n");
641 sb.append(" business:\n");
642 sb.append(" description: |\n");
643 sb.append(" Namespace for business related constructs\n");
644 sb.append(" properties:\n");
645 sb.append(" customers:\n");
646 sb.append(" type: array\n");
647 sb.append(" items:\n");
648 sb.append(" $ref: \"#/definitions/customer\"\n");
649 sb.append(" customer:\n");
650 sb.append(" description: |\n");
651 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
652 sb.append(" ###### Related Nodes\n");
653 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
655 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
656 sb.append(" required:\n");
657 sb.append(" - global-customer-id\n");
658 sb.append(" - subscriber-name\n");
659 sb.append(" - subscriber-type\n");
660 sb.append(" properties:\n");
661 sb.append(" global-customer-id:\n");
662 sb.append(" type: string\n");
663 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
664 sb.append(" subscriber-name:\n");
665 sb.append(" type: string\n");
666 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
667 sb.append(" subscriber-type:\n");
668 sb.append(" type: string\n");
669 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
670 sb.append(" resource-version:\n");
671 sb.append(" type: string\n");
672 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
673 sb.append(" service-subscriptions:\n");
674 sb.append(" type: array\n");
675 sb.append(" items:\n");
676 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
677 sb.append(" customers:\n");
678 sb.append(" description: |\n");
679 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
680 sb.append(" properties:\n");
681 sb.append(" customer:\n");
682 sb.append(" type: array\n");
683 sb.append(" items: \n");
684 sb.append(" $ref: \"#/definitions/customer\"\n");
685 sb.append(" inventory:\n");
686 sb.append(" properties:\n");
687 sb.append(" business:\n");
688 sb.append(" type: object\n");
689 sb.append(" $ref: \"#/definitions/business\"\n");
690 sb.append(" nodes:\n");
691 sb.append(" properties:\n");
692 sb.append(" inventory-item-data:\n");
693 sb.append(" type: array\n");
694 sb.append(" items:\n");
695 sb.append(" $ref: \"#/definitions/inventory-item-data\"\n");
696 sb.append(" service-subscription:\n");
697 sb.append(" description: |\n");
698 sb.append(" Object that group service instances.\n");
699 sb.append(" ###### Related Nodes\n");
700 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
701 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
702 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
704 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
705 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
706 sb.append(" required:\n");
707 sb.append(" - service-type\n");
708 sb.append(" properties:\n");
709 sb.append(" service-type:\n");
710 sb.append(" type: string\n");
711 sb.append(" description: Value defined by orchestration to identify this service.\n");
712 sb.append(" temp-ub-sub-account-id:\n");
713 sb.append(" type: string\n");
714 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
715 sb.append(" resource-version:\n");
716 sb.append(" type: string\n");
717 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
718 sb.append(" service-subscriptions:\n");
719 sb.append(" description: |\n");
720 sb.append(" Collection of objects that group service instances.\n");
721 sb.append(" properties:\n");
722 sb.append(" service-subscription:\n");
723 sb.append(" type: array\n");
724 sb.append(" items: \n");
725 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
726 return sb.toString();
728 public String YAMLpatchDefs() {
729 StringBuilder sb = new StringBuilder(8092);
730 sb.append("patchDefinitions:\n");
731 sb.append(" business:\n");
732 sb.append(" description: |\n");
733 sb.append(" Namespace for business related constructs\n");
734 sb.append(" properties:\n");
735 sb.append(" customers:\n");
736 sb.append(" type: array\n");
737 sb.append(" items:\n");
738 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
739 sb.append(" customer:\n");
740 sb.append(" description: |\n");
741 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
742 sb.append(" ###### Related Nodes\n");
743 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
745 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
746 sb.append(" required:\n");
747 sb.append(" - global-customer-id\n");
748 sb.append(" - subscriber-name\n");
749 sb.append(" - subscriber-type\n");
750 sb.append(" properties:\n");
751 sb.append(" global-customer-id:\n");
752 sb.append(" type: string\n");
753 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
754 sb.append(" subscriber-name:\n");
755 sb.append(" type: string\n");
756 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
757 sb.append(" subscriber-type:\n");
758 sb.append(" type: string\n");
759 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
760 sb.append(" customers:\n");
761 sb.append(" description: |\n");
762 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
763 sb.append(" properties:\n");
764 sb.append(" customer:\n");
765 sb.append(" type: array\n");
766 sb.append(" items: \n");
767 sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
768 sb.append(" inventory:\n");
769 sb.append(" properties:\n");
770 sb.append(" business:\n");
771 sb.append(" type: object\n");
772 sb.append(" $ref: \"#/patchDefinitions/business\"\n");
773 sb.append(" nodes:\n");
774 sb.append(" properties:\n");
775 sb.append(" inventory-item-data:\n");
776 sb.append(" type: array\n");
777 sb.append(" items:\n");
778 sb.append(" $ref: \"#/patchDefinitions/inventory-item-data\"\n");
779 sb.append(" service-subscription:\n");
780 sb.append(" description: |\n");
781 sb.append(" Object that group service instances.\n");
782 sb.append(" ###### Related Nodes\n");
783 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
784 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
785 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
787 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
788 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
789 sb.append(" required:\n");
790 sb.append(" - service-type\n");
791 sb.append(" properties:\n");
792 sb.append(" service-type:\n");
793 sb.append(" type: string\n");
794 sb.append(" description: Value defined by orchestration to identify this service.\n");
795 sb.append(" temp-ub-sub-account-id:\n");
796 sb.append(" type: string\n");
797 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
798 sb.append(" service-subscriptions:\n");
799 sb.append(" description: |\n");
800 sb.append(" Collection of objects that group service instances.\n");
801 sb.append(" properties:\n");
802 sb.append(" service-subscription:\n");
803 sb.append(" type: array\n");
804 sb.append(" items: \n");
805 sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
806 return sb.toString();
808 public String YAMLgetDefs() {
809 StringBuilder sb = new StringBuilder(8092);
810 sb.append("getDefinitions:\n");
811 sb.append(" business:\n");
812 sb.append(" description: |\n");
813 sb.append(" Namespace for business related constructs\n");
814 sb.append(" properties:\n");
815 sb.append(" customers:\n");
816 sb.append(" type: array\n");
817 sb.append(" items:\n");
818 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
819 sb.append(" customer:\n");
820 sb.append(" description: |\n");
821 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
822 sb.append(" ###### Related Nodes\n");
823 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
825 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
826 sb.append(" required:\n");
827 sb.append(" - global-customer-id\n");
828 sb.append(" - subscriber-name\n");
829 sb.append(" - subscriber-type\n");
830 sb.append(" properties:\n");
831 sb.append(" global-customer-id:\n");
832 sb.append(" type: string\n");
833 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
834 sb.append(" subscriber-name:\n");
835 sb.append(" type: string\n");
836 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
837 sb.append(" subscriber-type:\n");
838 sb.append(" type: string\n");
839 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
840 sb.append(" resource-version:\n");
841 sb.append(" type: string\n");
842 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
843 sb.append(" service-subscriptions:\n");
844 sb.append(" type: array\n");
845 sb.append(" items:\n");
846 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
847 sb.append(" customers:\n");
848 sb.append(" description: |\n");
849 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
850 sb.append(" properties:\n");
851 sb.append(" customer:\n");
852 sb.append(" type: array\n");
853 sb.append(" items: \n");
854 sb.append(" $ref: \"#/getDefinitions/customer\"\n");
855 sb.append(" inventory:\n");
856 sb.append(" properties:\n");
857 sb.append(" business:\n");
858 sb.append(" type: object\n");
859 sb.append(" $ref: \"#/getDefinitions/business\"\n");
860 sb.append(" nodes:\n");
861 sb.append(" properties:\n");
862 sb.append(" inventory-item-data:\n");
863 sb.append(" type: array\n");
864 sb.append(" items:\n");
865 sb.append(" $ref: \"#/getDefinitions/inventory-item-data\"\n");
866 sb.append(" service-subscription:\n");
867 sb.append(" description: |\n");
868 sb.append(" Object that group service instances.\n");
869 sb.append(" ###### Related Nodes\n");
870 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
871 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
872 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
874 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
875 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
876 sb.append(" required:\n");
877 sb.append(" - service-type\n");
878 sb.append(" properties:\n");
879 sb.append(" service-type:\n");
880 sb.append(" type: string\n");
881 sb.append(" description: Value defined by orchestration to identify this service.\n");
882 sb.append(" temp-ub-sub-account-id:\n");
883 sb.append(" type: string\n");
884 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
885 sb.append(" resource-version:\n");
886 sb.append(" type: string\n");
887 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
888 sb.append(" service-subscriptions:\n");
889 sb.append(" description: |\n");
890 sb.append(" Collection of objects that group service instances.\n");
891 sb.append(" properties:\n");
892 sb.append(" service-subscription:\n");
893 sb.append(" type: array\n");
894 sb.append(" items: \n");
895 sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
896 return sb.toString();
898 public static String EdgeDefs() {
899 StringBuilder sb = new StringBuilder(8092);
903 sb.append(" \"from\": \"service-subscription\",\n");
904 sb.append(" \"to\": \"customer\",\n" +
905 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
906 " \"direction\": \"OUT\",\n" +
907 " \"multiplicity\": \"MANY2ONE\",\n" +
908 " \"contains-other-v\": \"!${direction}\",\n" +
909 " \"delete-other-v\": \"!${direction}\",\n" +
910 " \"prevent-delete\": \"NONE\",\n" +
911 " \"default\": \"true\",\n" +
912 " \"description\":\"\"\n");
915 " \"from\": \"service-instance\",\n" +
916 " \"to\": \"service-subscription\",\n" +
917 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
918 " \"direction\": \"OUT\",\n" +
919 " \"multiplicity\": \"MANY2ONE\",\n" +
920 " \"contains-other-v\": \"!${direction}\",\n" +
921 " \"delete-other-v\": \"!${direction}\",\n" +
922 " \"prevent-delete\": \"NONE\",\n" +
923 " \"default\": \"true\",\n" +
924 " \"description\":\"\"\n" +
927 " \"from\": \"service-subscription\",\n" +
928 " \"to\": \"tenant\",\n" +
929 " \"label\": \"org.onap.relationships.inventory.Uses\",\n" +
930 " \"direction\": \"OUT\",\n" +
931 " \"multiplicity\": \"MANY2MANY\",\n" +
932 " \"contains-other-v\": \"NONE\",\n" +
933 " \"delete-other-v\": \"NONE\",\n" +
934 " \"prevent-delete\": \"NONE\",\n" +
935 " \"default\": \"true\",\n" +
936 " \"description\":\"\"\n" +
940 return sb.toString();