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