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=========================================================
21 package org.onap.aai.schemagen.genxsd;
23 import static org.hamcrest.CoreMatchers.is;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertThat;
26 import static org.junit.Assert.assertTrue;
28 import com.google.common.collect.Multimap;
30 import java.io.BufferedWriter;
32 import java.io.FileWriter;
33 import java.io.IOException;
34 import java.nio.charset.Charset;
35 import java.nio.file.Files;
36 import java.nio.file.Path;
37 import java.nio.file.Paths;
38 import java.util.SortedSet;
39 import java.util.TreeSet;
41 import org.junit.Before;
42 import org.junit.BeforeClass;
43 import org.junit.Test;
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.schemagen.SwaggerGenerationConfiguration;
50 import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
51 import org.onap.aai.setup.SchemaLocationsBean;
52 import org.onap.aai.setup.SchemaVersion;
53 import org.onap.aai.setup.SchemaVersions;
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.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 @RunWith(SpringJUnit4ClassRunner.class)
65 @ContextConfiguration(
66 classes = {SchemaVersions.class, SchemaLocationsBean.class,
67 TestUtilConfigTranslatorforBusiness.class, SchemaVersions.class, EdgeIngestor.class,
68 NodeIngestor.class, SwaggerGenerationConfiguration.class
71 @TestPropertySource(properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000"})
72 public class YAMLfromOXMTest {
74 EdgeIngestor edgeIngestor;
77 NodeIngestor nodeIngestor;
78 private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
79 private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
80 private static final String EDGEFILENAME =
81 "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
82 public static AnnotationConfigApplicationContext ctx = null;
83 private static String testXML;
84 protected static final String SERVICE_NAME = "JUNIT";
88 YAMLfromOXM yamlFromOxm;
91 SchemaVersions schemaVersions;
94 public static void setUpBeforeClass() throws Exception {
95 System.setProperty("AJSC_HOME", ".");
96 System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
97 System.setProperty("aai.service.name", SERVICE_NAME);
101 public void setUp() throws Exception {
102 XSDElementTest x = new XSDElementTest();
105 logger.debug(testXML);
106 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
109 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
110 bw1.write(EdgeDefs());
114 public void setupRelationship() throws Exception {
115 XSDElementTest x = new XSDElementTest();
117 x.setUpRelationship();
120 logger.debug(testXML);
121 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
126 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
127 bw1.write(EdgeDefs());
132 public void AtestIngestors() throws EdgeRuleNotFoundException {
133 Multimap<String, EdgeRule> results =
134 edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
135 SortedSet<String> ss = new TreeSet<String>(results.keySet());
136 for (String key : ss) {
137 results.get(key).stream().filter((i) -> ((!i.isPrivateEdge()))).forEach((i) -> {
138 EdgeDescription ed = new EdgeDescription(i);
139 System.out.println(ed.getRuleKey());
142 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
147 public void testGetDocumentHeader() {
148 SchemaVersion v = schemaVersions.getAppRootVersion();
149 String apiVersion = v.toString();
150 String header = null;
152 yamlFromOxm.setXmlVersion(testXML, v);
153 yamlFromOxm.process();
154 header = yamlFromOxm.getDocumentHeader();
155 } catch (Exception e) {
158 assertThat("Header:\n" + header, header, is(YAMLheader()));
162 public void testProcess() {
163 SchemaVersion v = schemaVersions.getAppRootVersion();
164 String apiVersion = v.toString();
165 String fileContent = null;
167 yamlFromOxm.setXmlVersion(testXML, v);
168 fileContent = yamlFromOxm.process();
169 } catch (Exception e) {
172 assertThat("FileContent-TestProcess:\n" + fileContent, fileContent, is(YAMLresult()));
176 public void testYAMLfromOXMFileVersionFile() throws IOException {
177 String outfileName = "testXML.xml";
178 File XMLfile = new File(outfileName);
179 XMLfile.createNewFile();
180 BufferedWriter bw = null;
181 Charset charset = Charset.forName("UTF-8");
182 Path path = Paths.get(outfileName);
183 bw = Files.newBufferedWriter(path, charset);
186 SchemaVersion v = schemaVersions.getAppRootVersion();
187 String apiVersion = v.toString();
188 String fileContent = null;
190 yamlFromOxm.setXmlVersion(testXML, v);
191 fileContent = yamlFromOxm.process();
192 } catch (Exception e) {
196 assertThat("FileContent-OXMFileVersionFile:\n" + fileContent, fileContent,
201 public void testYAMLfromOXMStringVersionFile() {
202 SchemaVersion v = schemaVersions.getAppRootVersion();
203 String apiVersion = v.toString();
204 String fileContent = null;
206 yamlFromOxm.setXmlVersion(testXML, v);
207 fileContent = yamlFromOxm.process();
208 } catch (Exception e) {
211 assertThat("FileContent-OXMStringVersionFile:\n" + fileContent, fileContent,
216 public void testRelationshipListYAMLfromOXMStringVersionFile() {
219 } catch (Exception e1) {
220 // TODO Auto-generated catch block
221 e1.printStackTrace();
223 SchemaVersion v = schemaVersions.getAppRootVersion();
224 String apiVersion = v.toString();
225 String fileContent = null;
227 yamlFromOxm.setXmlVersion(testXML, v);
228 fileContent = yamlFromOxm.process();
229 } catch (Exception e) {
232 boolean matchFound = fileContent.contains((YAMLRelationshipList()));
233 assertTrue("RelationshipListFormat:\n", matchFound);
237 public void testAppendDefinitions() {
238 SchemaVersion v = schemaVersions.getAppRootVersion();
239 String apiVersion = v.toString();
240 String definitions = null;
242 yamlFromOxm.setXmlVersion(testXML, v);
243 yamlFromOxm.process();
244 definitions = yamlFromOxm.appendDefinitions();
245 } catch (Exception e) {
248 assertThat("Definitions:\n" + definitions, definitions,
249 is(YAMLdefs() + YAMLdefsAddPatch()));
253 public void testGetXMLRootElementName() {
254 String target = "RootElement=customer";
255 SchemaVersion v = schemaVersions.getAppRootVersion();
256 String apiVersion = v.toString();
257 Element customer = null;
260 yamlFromOxm.setXmlVersion(testXML, v);
261 yamlFromOxm.process();
262 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
263 root = yamlFromOxm.getXMLRootElementName(customer);
264 } catch (Exception e) {
267 assertThat("RootElement=" + root, is(target));
271 public void testGetXmlRootElementName() {
272 String target = "RootElement=customer";
273 SchemaVersion v = schemaVersions.getAppRootVersion();
274 String apiVersion = v.toString();
277 yamlFromOxm.setXmlVersion(testXML, v);
278 yamlFromOxm.process();
279 root = yamlFromOxm.getXmlRootElementName("Customer");
280 } catch (Exception e) {
283 assertThat("RootElement=" + root, is(target));
287 public void testGetJavaTypeElementSwagger() {
288 String target = "Element=java-type/Customer";
289 SchemaVersion v = schemaVersions.getAppRootVersion();
290 String apiVersion = v.toString();
291 Element customer = null;
293 yamlFromOxm.setXmlVersion(testXML, v);
294 yamlFromOxm.process();
295 customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
296 } catch (Exception e) {
299 assertThat("Element=" + customer.getNodeName() + "/" + customer.getAttribute("name"),
303 public String YAMLresult() {
304 StringBuilder sb = new StringBuilder(32368);
305 sb.append(YAMLheader());
306 sb.append(YAMLops());
307 sb.append(YAMLdefs());
308 sb.append(YAMLdefsAddPatch());
309 return sb.toString();
312 public String YAMLheader() {
313 StringBuilder sb = new StringBuilder(1500);
314 sb.append("swagger: \"2.0\"\n");
315 sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
316 sb.append(" description: |\n");
319 " [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)"
320 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
322 " Copyright © 2017-18 AT&T Intellectual Property. All rights reserved."
323 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
325 " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License."
326 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
327 sb.append(" You may obtain a copy of the License at\n");
329 sb.append(" (https://creativecommons.org/licenses/by/4.0/)"
330 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
332 " 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."
333 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
335 " This document is best viewed with Firefox or Chrome. Nodes can be found by opening the models link below and finding the node-type. Edge definitions can be found with the node definitions."
336 + OxmFileProcessor.LINE_SEPARATOR);
337 sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
339 " title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
340 sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
341 sb.append(" name: Apache 2.0\n");
342 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html"
343 + OxmFileProcessor.LINE_SEPARATOR);
344 sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
345 sb.append(" name: n/a" + OxmFileProcessor.LINE_SEPARATOR);
346 sb.append(" url: n/a" + OxmFileProcessor.LINE_SEPARATOR);
347 sb.append(" email: n/a" + OxmFileProcessor.LINE_SEPARATOR);
348 sb.append("host: n/a" + OxmFileProcessor.LINE_SEPARATOR);
349 sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
350 sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
351 sb.append(" - https\n");
352 sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
353 return sb.toString();
356 public String YAMLops() {
357 StringBuilder sb = new StringBuilder(16384);
359 " /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
360 sb.append(" get:\n");
361 sb.append(" tags:\n");
362 sb.append(" - Business\n");
363 sb.append(" summary: returns service-subscription\n");
364 sb.append(" description: returns service-subscription\n");
366 " operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
367 sb.append(" produces:\n");
368 sb.append(" - application/json\n");
369 sb.append(" - application/xml\n");
370 sb.append(" responses:\n");
371 sb.append(" \"200\":\n");
372 sb.append(" description: successful operation\n");
373 sb.append(" schema:\n");
374 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
375 sb.append(" \"default\":\n");
376 sb.append(" null parameters:\n");
377 sb.append(" - name: global-customer-id\n");
378 sb.append(" in: path\n");
380 " description: Global customer id used across to uniquely identify customer.\n");
381 sb.append(" required: true\n");
382 sb.append(" type: string\n");
383 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
384 sb.append(" - name: service-type\n");
385 sb.append(" in: path\n");
387 " description: Value defined by orchestration to identify this service.\n");
388 sb.append(" required: true\n");
389 sb.append(" type: string\n");
390 sb.append(" example: __SERVICE-TYPE__\n");
391 sb.append(" put:\n");
392 sb.append(" tags:\n");
393 sb.append(" - Business\n");
394 sb.append(" summary: create or update an existing service-subscription\n");
395 sb.append(" description: |\n");
396 sb.append(" Create or update an existing service-subscription.\n");
399 " 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");
401 " operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
402 sb.append(" consumes:\n");
403 sb.append(" - application/json\n");
404 sb.append(" - application/xml\n");
405 sb.append(" produces:\n");
406 sb.append(" - application/json\n");
407 sb.append(" - application/xml\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");
414 " description: Global customer id used across to uniquely identify customer.\n");
415 sb.append(" required: true\n");
416 sb.append(" type: string\n");
417 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
418 sb.append(" - name: service-type\n");
419 sb.append(" in: path\n");
421 " description: Value defined by orchestration to identify this service.\n");
422 sb.append(" required: true\n");
423 sb.append(" type: string\n");
424 sb.append(" example: __SERVICE-TYPE__\n");
425 sb.append(" - name: body\n");
426 sb.append(" in: body\n");
428 " description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
429 sb.append(" required: true\n");
430 sb.append(" schema:\n");
431 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
432 sb.append(" patch:\n");
433 sb.append(" tags:\n");
434 sb.append(" - Business\n");
435 sb.append(" summary: update an existing service-subscription\n");
436 sb.append(" description: |\n");
437 sb.append(" Update an existing service-subscription\n");
440 " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
441 sb.append(" The PUT operation will entirely replace an existing object.\n");
443 " 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");
445 sb.append(" Other differences between PUT and PATCH are:\n");
448 " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
450 " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
452 " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
454 " operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
455 sb.append(" consumes:\n");
456 sb.append(" - application/json\n");
457 sb.append(" produces:\n");
458 sb.append(" - application/json\n");
459 sb.append(" responses:\n");
460 sb.append(" \"default\":\n");
461 sb.append(" null parameters:\n");
462 sb.append(" - name: global-customer-id\n");
463 sb.append(" in: path\n");
465 " description: Global customer id used across to uniquely identify customer.\n");
466 sb.append(" required: true\n");
467 sb.append(" type: string\n");
468 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
469 sb.append(" - name: service-type\n");
470 sb.append(" in: path\n");
472 " description: Value defined by orchestration to identify this service.\n");
473 sb.append(" required: true\n");
474 sb.append(" type: string\n");
475 sb.append(" example: __SERVICE-TYPE__\n");
476 sb.append(" - name: body\n");
477 sb.append(" in: body\n");
478 sb.append(" description: service-subscription object that needs to be updated.");
480 "[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
481 sb.append(" required: true\n");
482 sb.append(" schema:\n");
483 sb.append(" $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
484 sb.append(" delete:\n");
485 sb.append(" tags:\n");
486 sb.append(" - Business\n");
487 sb.append(" summary: delete an existing service-subscription\n");
488 sb.append(" description: delete an existing service-subscription\n");
490 " operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
491 sb.append(" consumes:\n");
492 sb.append(" - application/json\n");
493 sb.append(" - application/xml\n");
494 sb.append(" produces:\n");
495 sb.append(" - application/json\n");
496 sb.append(" - application/xml\n");
497 sb.append(" responses:\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");
503 " description: Global customer id used across to uniquely identify customer.\n");
504 sb.append(" required: true\n");
505 sb.append(" type: string\n");
506 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
507 sb.append(" - name: service-type\n");
508 sb.append(" in: path\n");
510 " description: Value defined by orchestration to identify this service.\n");
511 sb.append(" required: true\n");
512 sb.append(" type: string\n");
513 sb.append(" example: __SERVICE-TYPE__\n");
514 sb.append(" - name: resource-version\n");
515 sb.append(" in: query\n");
516 sb.append(" description: resource-version for concurrency\n");
517 sb.append(" required: true\n");
518 sb.append(" type: string\n");
519 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
520 sb.append(" get:\n");
521 sb.append(" tags:\n");
522 sb.append(" - Business\n");
523 sb.append(" summary: returns service-subscriptions\n");
524 sb.append(" description: returns service-subscriptions\n");
525 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
526 sb.append(" produces:\n");
527 sb.append(" - application/json\n");
528 sb.append(" - application/xml\n");
529 sb.append(" responses:\n");
530 sb.append(" \"200\":\n");
531 sb.append(" description: successful operation\n");
532 sb.append(" schema:\n");
533 sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
534 sb.append(" \"default\":\n");
535 sb.append(" null parameters:\n");
536 sb.append(" - name: global-customer-id\n");
537 sb.append(" in: path\n");
539 " description: Global customer id used across to uniquely identify customer.\n");
540 sb.append(" required: true\n");
541 sb.append(" type: string\n");
542 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
543 sb.append(" - name: service-type\n");
544 sb.append(" in: query\n");
545 sb.append(" description: n/a\n");
546 sb.append(" required: false\n");
547 sb.append(" type: string\n");
548 sb.append(" /business/customers/customer/{global-customer-id}:\n");
549 sb.append(" get:\n");
550 sb.append(" tags:\n");
551 sb.append(" - Business\n");
552 sb.append(" summary: returns customer\n");
553 sb.append(" description: returns customer\n");
554 sb.append(" operationId: getBusinessCustomersCustomer\n");
555 sb.append(" produces:\n");
556 sb.append(" - application/json\n");
557 sb.append(" - application/xml\n");
558 sb.append(" responses:\n");
559 sb.append(" \"200\":\n");
560 sb.append(" description: successful operation\n");
561 sb.append(" schema:\n");
562 sb.append(" $ref: \"#/definitions/customer\"\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");
568 " 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(" put:\n");
573 sb.append(" tags:\n");
574 sb.append(" - Business\n");
575 sb.append(" summary: create or update an existing customer\n");
576 sb.append(" description: |\n");
577 sb.append(" Create or update an existing customer.\n");
580 " 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");
581 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
582 sb.append(" consumes:\n");
583 sb.append(" - application/json\n");
584 sb.append(" - application/xml\n");
585 sb.append(" produces:\n");
586 sb.append(" - application/json\n");
587 sb.append(" - application/xml\n");
588 sb.append(" responses:\n");
589 sb.append(" \"default\":\n");
590 sb.append(" null parameters:\n");
591 sb.append(" - name: global-customer-id\n");
592 sb.append(" in: path\n");
594 " 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: body\n");
599 sb.append(" in: body\n");
601 " description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
602 sb.append(" required: true\n");
603 sb.append(" schema:\n");
604 sb.append(" $ref: \"#/definitions/customer\"\n");
605 sb.append(" patch:\n");
606 sb.append(" tags:\n");
607 sb.append(" - Business\n");
608 sb.append(" summary: update an existing customer\n");
609 sb.append(" description: |\n");
610 sb.append(" Update an existing customer\n");
613 " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
614 sb.append(" The PUT operation will entirely replace an existing object.\n");
616 " 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");
618 sb.append(" Other differences between PUT and PATCH are:\n");
621 " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
623 " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
625 " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
626 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
627 sb.append(" consumes:\n");
628 sb.append(" - application/json\n");
629 sb.append(" produces:\n");
630 sb.append(" - application/json\n");
631 sb.append(" responses:\n");
632 sb.append(" \"default\":\n");
633 sb.append(" null parameters:\n");
634 sb.append(" - name: global-customer-id\n");
635 sb.append(" in: path\n");
637 " description: Global customer id used across to uniquely identify customer.\n");
638 sb.append(" required: true\n");
639 sb.append(" type: string\n");
640 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
641 sb.append(" - name: body\n");
642 sb.append(" in: body\n");
643 sb.append(" description: customer object that needs to be updated.");
644 sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
645 sb.append(" required: true\n");
646 sb.append(" schema:\n");
647 sb.append(" $ref: \"#/definitions/zzzz-patch-customer\"\n");
648 sb.append(" delete:\n");
649 sb.append(" tags:\n");
650 sb.append(" - Business\n");
651 sb.append(" summary: delete an existing customer\n");
652 sb.append(" description: delete an existing customer\n");
653 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
654 sb.append(" consumes:\n");
655 sb.append(" - application/json\n");
656 sb.append(" - application/xml\n");
657 sb.append(" produces:\n");
658 sb.append(" - application/json\n");
659 sb.append(" - application/xml\n");
660 sb.append(" responses:\n");
661 sb.append(" \"default\":\n");
662 sb.append(" null parameters:\n");
663 sb.append(" - name: global-customer-id\n");
664 sb.append(" in: path\n");
666 " description: Global customer id used across to uniquely identify customer.\n");
667 sb.append(" required: true\n");
668 sb.append(" type: string\n");
669 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
670 sb.append(" - name: resource-version\n");
671 sb.append(" in: query\n");
672 sb.append(" description: resource-version for concurrency\n");
673 sb.append(" required: true\n");
674 sb.append(" type: string\n");
675 sb.append(" /business/customers:\n");
676 sb.append(" get:\n");
677 sb.append(" tags:\n");
678 sb.append(" - Business\n");
679 sb.append(" summary: returns customers\n");
680 sb.append(" description: returns customers\n");
681 sb.append(" operationId: getBusinessCustomers\n");
682 sb.append(" produces:\n");
683 sb.append(" - application/json\n");
684 sb.append(" - application/xml\n");
685 sb.append(" responses:\n");
686 sb.append(" \"200\":\n");
687 sb.append(" description: successful operation\n");
688 sb.append(" schema:\n");
689 sb.append(" $ref: \"#/definitions/customers\"\n");
690 sb.append(" \"default\":\n");
691 sb.append(" null parameters:\n");
692 sb.append(" - name: global-customer-id\n");
693 sb.append(" in: query\n");
694 sb.append(" description: n/a\n");
695 sb.append(" required: false\n");
696 sb.append(" type: string\n");
697 sb.append(" - name: subscriber-name\n");
698 sb.append(" in: query\n");
699 sb.append(" description: n/a\n");
700 sb.append(" required: false\n");
701 sb.append(" type: string\n");
702 sb.append(" - name: subscriber-type\n");
703 sb.append(" in: query\n");
704 sb.append(" description: n/a\n");
705 sb.append(" required: false\n");
706 sb.append(" type: string\n");
707 return sb.toString();
710 public String YAMLdefs() {
711 StringBuilder sb = new StringBuilder(8092);
712 sb.append("definitions:\n");
713 sb.append(" business:\n");
714 sb.append(" description: |\n");
715 sb.append(" Namespace for business related constructs\n");
716 sb.append(" properties:\n");
717 sb.append(" customers:\n");
718 sb.append(" type: array\n");
719 sb.append(" items:\n");
720 sb.append(" $ref: \"#/definitions/customer\"\n");
721 sb.append(" customer:\n");
722 sb.append(" description: |\n");
723 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
724 sb.append(" ###### Related Nodes\n");
726 " - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
728 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
729 sb.append(" required:\n");
730 sb.append(" - global-customer-id\n");
731 sb.append(" - subscriber-name\n");
732 sb.append(" - subscriber-type\n");
733 sb.append(" properties:\n");
734 sb.append(" global-customer-id:\n");
735 sb.append(" type: string\n");
737 " description: Global customer id used across to uniquely identify customer.\n");
738 sb.append(" subscriber-name:\n");
739 sb.append(" type: string\n");
741 " description: Subscriber name, an alternate way to retrieve a customer.\n");
742 sb.append(" subscriber-type:\n");
743 sb.append(" type: string\n");
745 " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
746 sb.append(" resource-version:\n");
747 sb.append(" type: string\n");
749 " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
750 sb.append(" service-subscriptions:\n");
751 sb.append(" type: array\n");
752 sb.append(" items:\n");
753 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
754 sb.append(" customers:\n");
755 sb.append(" description: |\n");
757 " Collection of customer identifiers to provide linkage back to BSS information.\n");
758 sb.append(" properties:\n");
759 sb.append(" customer:\n");
760 sb.append(" type: array\n");
761 sb.append(" items: \n");
762 sb.append(" $ref: \"#/definitions/customer\"\n");
763 sb.append(" inventory:\n");
764 sb.append(" properties:\n");
765 sb.append(" business:\n");
766 sb.append(" type: object\n");
767 sb.append(" $ref: \"#/definitions/business\"\n");
768 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
769 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
770 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
771 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
772 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
773 sb.append(" $ref: \"#/definitions/inventory-item-data\""
774 + OxmFileProcessor.LINE_SEPARATOR);
775 sb.append(" service-subscription:\n");
776 sb.append(" description: |\n");
777 sb.append(" Object that group service instances.\n");
778 sb.append(" ###### Related Nodes\n");
780 " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
781 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
783 " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
786 " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
788 " -(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");
795 " description: Value defined by orchestration to identify this service.\n");
796 sb.append(" temp-ub-sub-account-id:\n");
797 sb.append(" type: string\n");
799 " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
800 sb.append(" resource-version:\n");
801 sb.append(" type: string\n");
803 " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
804 sb.append(" service-subscriptions:\n");
805 sb.append(" description: |\n");
806 sb.append(" Collection of objects that group service instances.\n");
807 sb.append(" properties:\n");
808 sb.append(" service-subscription:\n");
809 sb.append(" type: array\n");
810 sb.append(" items: \n");
811 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
812 return sb.toString();
815 public String YAMLdefsAddPatch() {
816 StringBuilder sb = new StringBuilder(8092);
817 sb.append(" zzzz-patch-customer:\n");
818 sb.append(" description: |\n");
819 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
820 sb.append(" ###### Related Nodes\n");
822 " - 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(" properties:\n");
826 sb.append(" global-customer-id:\n");
827 sb.append(" type: string\n");
829 " description: Global customer id used across to uniquely identify customer.\n");
830 sb.append(" subscriber-name:\n");
831 sb.append(" type: string\n");
833 " description: Subscriber name, an alternate way to retrieve a customer.\n");
834 sb.append(" subscriber-type:\n");
835 sb.append(" type: string\n");
837 " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
838 sb.append(" zzzz-patch-service-subscription:\n");
839 sb.append(" description: |\n");
840 sb.append(" Object that group service instances.\n");
841 sb.append(" ###### Related Nodes\n");
843 " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
844 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
846 " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
849 " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
851 " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
852 sb.append(" properties:\n");
853 sb.append(" service-type:\n");
854 sb.append(" type: string\n");
856 " description: Value defined by orchestration to identify this service.\n");
857 sb.append(" temp-ub-sub-account-id:\n");
858 sb.append(" type: string\n");
860 " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
861 return sb.toString();
864 public String YAMLRelationshipList() {
865 StringBuilder sb = new StringBuilder(8092);
866 sb.append(" relationship-list:\n");
867 sb.append(" properties:\n");
868 sb.append(" relationship:\n");
869 sb.append(" type: object\n");
870 sb.append(" $ref: \"#/definitions/relationship\"\n");
871 return sb.toString();
874 public static String EdgeDefs() {
875 StringBuilder sb = new StringBuilder(8092);
876 sb.append("{\n" + " \"rules\": [\n");
878 sb.append(" \"from\": \"service-subscription\",\n");
879 sb.append(" \"to\": \"customer\",\n"
880 + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
881 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
882 + " \"contains-other-v\": \"!${direction}\",\n"
883 + " \"delete-other-v\": \"!${direction}\",\n"
884 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
885 + " \"description\":\"\"\n");
887 sb.append(" {\n" + " \"from\": \"service-instance\",\n"
888 + " \"to\": \"service-subscription\",\n"
889 + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
890 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
891 + " \"contains-other-v\": \"!${direction}\",\n"
892 + " \"delete-other-v\": \"!${direction}\",\n"
893 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
894 + " \"description\":\"\"\n" + " },\n");
895 sb.append(" {\n" + " \"from\": \"service-subscription\",\n"
896 + " \"to\": \"tenant\",\n"
897 + " \"label\": \"org.onap.relationships.inventory.Uses\",\n"
898 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2MANY\",\n"
899 + " \"contains-other-v\": \"NONE\",\n" + " \"delete-other-v\": \"NONE\",\n"
900 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
901 + " \"description\":\"\"\n" + " }");
902 sb.append(" ]\n" + "}\n");
903 return sb.toString();