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.SchemaConfigVersions;
52 import org.onap.aai.setup.SchemaLocationsBean;
53 import org.onap.aai.setup.SchemaVersion;
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 = {SchemaConfigVersions.class, SchemaLocationsBean.class,
67 TestUtilConfigTranslatorforBusiness.class, EdgeIngestor.class, NodeIngestor.class,
68 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 SchemaConfigVersions schemaConfigVersions;
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(schemaConfigVersions.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(schemaConfigVersions.getDefaultVersion());
147 public void testGetDocumentHeader() {
148 SchemaVersion v = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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 = schemaConfigVersions.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("#").append(OxmFileProcessor.LINE_SEPARATOR).append(
315 "# ============LICENSE_START=======================================================")
316 .append(OxmFileProcessor.LINE_SEPARATOR).append("# org.onap.aai")
317 .append(OxmFileProcessor.LINE_SEPARATOR)
319 "# ================================================================================")
320 .append(OxmFileProcessor.LINE_SEPARATOR)
321 .append("# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.")
322 .append(OxmFileProcessor.LINE_SEPARATOR)
324 "# ================================================================================")
325 .append(OxmFileProcessor.LINE_SEPARATOR)
327 "# Licensed under the Creative Commons License, Attribution 4.0 Intl. (the \"License\");")
328 .append(OxmFileProcessor.LINE_SEPARATOR)
329 .append("# you may not use this file except in compliance with the License.")
330 .append(OxmFileProcessor.LINE_SEPARATOR)
331 .append("# You may obtain a copy of the License at")
332 .append(OxmFileProcessor.LINE_SEPARATOR).append("# <p>")
333 .append(OxmFileProcessor.LINE_SEPARATOR)
334 .append("# https://creativecommons.org/licenses/by/4.0/")
335 .append(OxmFileProcessor.LINE_SEPARATOR).append("# <p>")
336 .append(OxmFileProcessor.LINE_SEPARATOR)
337 .append("# Unless required by applicable law or agreed to in writing, software")
338 .append(OxmFileProcessor.LINE_SEPARATOR)
339 .append("# distributed under the License is distributed on an \"AS IS\" BASIS,")
340 .append(OxmFileProcessor.LINE_SEPARATOR)
341 .append("# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.")
342 .append(OxmFileProcessor.LINE_SEPARATOR)
343 .append("# See the License for the specific language governing permissions and")
344 .append(OxmFileProcessor.LINE_SEPARATOR).append("# limitations under the License.")
345 .append(OxmFileProcessor.LINE_SEPARATOR)
347 "# ============LICENSE_END=========================================================")
348 .append(OxmFileProcessor.LINE_SEPARATOR).append("#")
349 .append(OxmFileProcessor.LINE_SEPARATOR).append(OxmFileProcessor.LINE_SEPARATOR);
350 sb.append("swagger: \"2.0\"\n");
351 sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
352 sb.append(" description: |\n");
354 " [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)"
355 + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
357 " 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."
358 + OxmFileProcessor.LINE_SEPARATOR);
359 sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
361 " title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
362 sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
363 sb.append(" name: Apache 2.0\n");
364 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html"
365 + OxmFileProcessor.LINE_SEPARATOR);
366 sb.append("host: localhost" + OxmFileProcessor.LINE_SEPARATOR);
367 sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
368 sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
369 sb.append(" - https\n");
370 sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
371 return sb.toString();
374 public String YAMLops() {
375 StringBuilder sb = new StringBuilder(16384);
377 " /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
378 sb.append(" get:\n");
379 sb.append(" tags:\n");
380 sb.append(" - Business\n");
381 sb.append(" summary: returns service-subscription\n");
382 sb.append(" description: returns service-subscription\n");
384 " operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
385 sb.append(" produces:\n");
386 sb.append(" - application/json\n");
387 sb.append(" - application/xml\n");
388 sb.append(" responses:\n");
389 sb.append(" \"200\":\n");
390 sb.append(" description: successful operation\n");
391 sb.append(" schema:\n");
392 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
393 sb.append(" \"default\":\n");
394 sb.append(" null parameters:\n");
395 sb.append(" - name: global-customer-id\n");
396 sb.append(" in: path\n");
398 " description: Global customer id used across to uniquely identify customer.\n");
399 sb.append(" required: true\n");
400 sb.append(" type: string\n");
401 sb.append(" - name: service-type\n");
402 sb.append(" in: path\n");
404 " description: Value defined by orchestration to identify this service.\n");
405 sb.append(" required: true\n");
406 sb.append(" type: string\n");
407 sb.append(" put:\n");
408 sb.append(" tags:\n");
409 sb.append(" - Business\n");
410 sb.append(" summary: create or update an existing service-subscription\n");
411 sb.append(" description: |\n");
412 sb.append(" Create or update an existing service-subscription.\n");
415 " 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");
417 " operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
418 sb.append(" consumes:\n");
419 sb.append(" - application/json\n");
420 sb.append(" - application/xml\n");
421 sb.append(" produces:\n");
422 sb.append(" - application/json\n");
423 sb.append(" - application/xml\n");
424 sb.append(" responses:\n");
425 sb.append(" \"default\":\n");
426 sb.append(" null parameters:\n");
427 sb.append(" - name: global-customer-id\n");
428 sb.append(" in: path\n");
430 " description: Global customer id used across to uniquely identify customer.\n");
431 sb.append(" required: true\n");
432 sb.append(" type: string\n");
433 sb.append(" - name: service-type\n");
434 sb.append(" in: path\n");
436 " description: Value defined by orchestration to identify this service.\n");
437 sb.append(" required: true\n");
438 sb.append(" type: string\n");
439 sb.append(" - name: body\n");
440 sb.append(" in: body\n");
442 " description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
443 sb.append(" required: true\n");
444 sb.append(" schema:\n");
445 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
446 sb.append(" patch:\n");
447 sb.append(" tags:\n");
448 sb.append(" - Business\n");
449 sb.append(" summary: update an existing service-subscription\n");
450 sb.append(" description: |\n");
451 sb.append(" Update an existing service-subscription\n");
454 " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
455 sb.append(" The PUT operation will entirely replace an existing object.\n");
457 " 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");
459 sb.append(" Other differences between PUT and PATCH are:\n");
462 " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
464 " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
466 " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
468 " operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
469 sb.append(" consumes:\n");
470 sb.append(" - application/json\n");
471 sb.append(" produces:\n");
472 sb.append(" - application/json\n");
473 sb.append(" responses:\n");
474 sb.append(" \"default\":\n");
475 sb.append(" null parameters:\n");
476 sb.append(" - name: global-customer-id\n");
477 sb.append(" in: path\n");
479 " 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(" - name: service-type\n");
483 sb.append(" in: path\n");
485 " description: Value defined by orchestration to identify this service.\n");
486 sb.append(" required: true\n");
487 sb.append(" type: string\n");
488 sb.append(" - name: body\n");
489 sb.append(" in: body\n");
490 sb.append(" description: service-subscription object that needs to be updated.");
492 "[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
493 sb.append(" required: true\n");
494 sb.append(" schema:\n");
495 sb.append(" $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
496 sb.append(" delete:\n");
497 sb.append(" tags:\n");
498 sb.append(" - Business\n");
499 sb.append(" summary: delete an existing service-subscription\n");
500 sb.append(" description: delete an existing service-subscription\n");
502 " operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
503 sb.append(" consumes:\n");
504 sb.append(" - application/json\n");
505 sb.append(" - application/xml\n");
506 sb.append(" produces:\n");
507 sb.append(" - application/json\n");
508 sb.append(" - application/xml\n");
509 sb.append(" responses:\n");
510 sb.append(" \"default\":\n");
511 sb.append(" null parameters:\n");
512 sb.append(" - name: global-customer-id\n");
513 sb.append(" in: path\n");
515 " description: Global customer id used across to uniquely identify customer.\n");
516 sb.append(" required: true\n");
517 sb.append(" type: string\n");
518 sb.append(" - name: service-type\n");
519 sb.append(" in: path\n");
521 " description: Value defined by orchestration to identify this service.\n");
522 sb.append(" required: true\n");
523 sb.append(" type: string\n");
524 sb.append(" - name: resource-version\n");
525 sb.append(" in: query\n");
526 sb.append(" description: resource-version for concurrency\n");
527 sb.append(" required: true\n");
528 sb.append(" type: string\n");
529 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
530 sb.append(" get:\n");
531 sb.append(" tags:\n");
532 sb.append(" - Business\n");
533 sb.append(" summary: returns service-subscriptions\n");
534 sb.append(" description: returns service-subscriptions\n");
535 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
536 sb.append(" produces:\n");
537 sb.append(" - application/json\n");
538 sb.append(" - application/xml\n");
539 sb.append(" responses:\n");
540 sb.append(" \"200\":\n");
541 sb.append(" description: successful operation\n");
542 sb.append(" schema:\n");
543 sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
544 sb.append(" \"default\":\n");
545 sb.append(" null parameters:\n");
546 sb.append(" - name: global-customer-id\n");
547 sb.append(" in: path\n");
549 " description: Global customer id used across to uniquely identify customer.\n");
550 sb.append(" required: true\n");
551 sb.append(" type: string\n");
552 sb.append(" - name: service-type\n");
553 sb.append(" in: query\n");
554 sb.append(" required: false\n");
555 sb.append(" type: string\n");
556 sb.append(" /business/customers/customer/{global-customer-id}:\n");
557 sb.append(" get:\n");
558 sb.append(" tags:\n");
559 sb.append(" - Business\n");
560 sb.append(" summary: returns customer\n");
561 sb.append(" description: returns customer\n");
562 sb.append(" operationId: getBusinessCustomersCustomer\n");
563 sb.append(" produces:\n");
564 sb.append(" - application/json\n");
565 sb.append(" - application/xml\n");
566 sb.append(" responses:\n");
567 sb.append(" \"200\":\n");
568 sb.append(" description: successful operation\n");
569 sb.append(" schema:\n");
570 sb.append(" $ref: \"#/definitions/customer\"\n");
571 sb.append(" \"default\":\n");
572 sb.append(" null parameters:\n");
573 sb.append(" - name: global-customer-id\n");
574 sb.append(" in: path\n");
576 " description: Global customer id used across to uniquely identify customer.\n");
577 sb.append(" required: true\n");
578 sb.append(" type: string\n");
579 sb.append(" put:\n");
580 sb.append(" tags:\n");
581 sb.append(" - Business\n");
582 sb.append(" summary: create or update an existing customer\n");
583 sb.append(" description: |\n");
584 sb.append(" Create or update an existing customer.\n");
587 " 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");
588 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
589 sb.append(" consumes:\n");
590 sb.append(" - application/json\n");
591 sb.append(" - application/xml\n");
592 sb.append(" produces:\n");
593 sb.append(" - application/json\n");
594 sb.append(" - application/xml\n");
595 sb.append(" responses:\n");
596 sb.append(" \"default\":\n");
597 sb.append(" null parameters:\n");
598 sb.append(" - name: global-customer-id\n");
599 sb.append(" in: path\n");
601 " description: Global customer id used across to uniquely identify customer.\n");
602 sb.append(" required: true\n");
603 sb.append(" type: string\n");
604 sb.append(" - name: body\n");
605 sb.append(" in: body\n");
607 " description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
608 sb.append(" required: true\n");
609 sb.append(" schema:\n");
610 sb.append(" $ref: \"#/definitions/customer\"\n");
611 sb.append(" patch:\n");
612 sb.append(" tags:\n");
613 sb.append(" - Business\n");
614 sb.append(" summary: update an existing customer\n");
615 sb.append(" description: |\n");
616 sb.append(" Update an existing customer\n");
619 " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
620 sb.append(" The PUT operation will entirely replace an existing object.\n");
622 " 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");
624 sb.append(" Other differences between PUT and PATCH are:\n");
627 " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
629 " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
631 " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
632 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
633 sb.append(" consumes:\n");
634 sb.append(" - application/json\n");
635 sb.append(" produces:\n");
636 sb.append(" - application/json\n");
637 sb.append(" responses:\n");
638 sb.append(" \"default\":\n");
639 sb.append(" null parameters:\n");
640 sb.append(" - name: global-customer-id\n");
641 sb.append(" in: path\n");
643 " description: Global customer id used across to uniquely identify customer.\n");
644 sb.append(" required: true\n");
645 sb.append(" type: string\n");
646 sb.append(" - name: body\n");
647 sb.append(" in: body\n");
648 sb.append(" description: customer object that needs to be updated.");
649 sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
650 sb.append(" required: true\n");
651 sb.append(" schema:\n");
652 sb.append(" $ref: \"#/definitions/zzzz-patch-customer\"\n");
653 sb.append(" delete:\n");
654 sb.append(" tags:\n");
655 sb.append(" - Business\n");
656 sb.append(" summary: delete an existing customer\n");
657 sb.append(" description: delete an existing customer\n");
658 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
659 sb.append(" consumes:\n");
660 sb.append(" - application/json\n");
661 sb.append(" - application/xml\n");
662 sb.append(" produces:\n");
663 sb.append(" - application/json\n");
664 sb.append(" - application/xml\n");
665 sb.append(" responses:\n");
666 sb.append(" \"default\":\n");
667 sb.append(" null parameters:\n");
668 sb.append(" - name: global-customer-id\n");
669 sb.append(" in: path\n");
671 " description: Global customer id used across to uniquely identify customer.\n");
672 sb.append(" required: true\n");
673 sb.append(" type: string\n");
674 sb.append(" - name: resource-version\n");
675 sb.append(" in: query\n");
676 sb.append(" description: resource-version for concurrency\n");
677 sb.append(" required: true\n");
678 sb.append(" type: string\n");
679 sb.append(" /business/customers:\n");
680 sb.append(" get:\n");
681 sb.append(" tags:\n");
682 sb.append(" - Business\n");
683 sb.append(" summary: returns customers\n");
684 sb.append(" description: returns customers\n");
685 sb.append(" operationId: getBusinessCustomers\n");
686 sb.append(" produces:\n");
687 sb.append(" - application/json\n");
688 sb.append(" - application/xml\n");
689 sb.append(" responses:\n");
690 sb.append(" \"200\":\n");
691 sb.append(" description: successful operation\n");
692 sb.append(" schema:\n");
693 sb.append(" $ref: \"#/definitions/customers\"\n");
694 sb.append(" \"default\":\n");
695 sb.append(" null parameters:\n");
696 sb.append(" - name: global-customer-id\n");
697 sb.append(" in: query\n");
698 sb.append(" required: false\n");
699 sb.append(" type: string\n");
700 sb.append(" - name: subscriber-name\n");
701 sb.append(" in: query\n");
702 sb.append(" required: false\n");
703 sb.append(" type: string\n");
704 sb.append(" - name: subscriber-type\n");
705 sb.append(" in: query\n");
706 sb.append(" required: false\n");
707 sb.append(" type: string\n");
708 return sb.toString();
711 public String YAMLdefs() {
712 StringBuilder sb = new StringBuilder(8092);
713 sb.append("definitions:\n");
714 sb.append(" business:\n");
715 sb.append(" description: |\n");
716 sb.append(" Namespace for business related constructs\n");
717 sb.append(" properties:\n");
718 sb.append(" customers:\n");
719 sb.append(" type: array\n");
720 sb.append(" items:\n");
721 sb.append(" $ref: \"#/definitions/customer\"\n");
722 sb.append(" customer:\n");
723 sb.append(" description: |\n");
724 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
725 sb.append(" ###### Related Nodes\n");
727 " - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
729 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
730 sb.append(" required:\n");
731 sb.append(" - global-customer-id\n");
732 sb.append(" - subscriber-name\n");
733 sb.append(" - subscriber-type\n");
734 sb.append(" properties:\n");
735 sb.append(" global-customer-id:\n");
736 sb.append(" type: string\n");
738 " description: Global customer id used across to uniquely identify customer.\n");
739 sb.append(" subscriber-name:\n");
740 sb.append(" type: string\n");
742 " description: Subscriber name, an alternate way to retrieve a customer.\n");
743 sb.append(" subscriber-type:\n");
744 sb.append(" type: string\n");
746 " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
747 sb.append(" resource-version:\n");
748 sb.append(" type: string\n");
750 " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
751 sb.append(" service-subscriptions:\n");
752 sb.append(" type: array\n");
753 sb.append(" items:\n");
754 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
755 sb.append(" customers:\n");
756 sb.append(" description: |\n");
758 " Collection of customer identifiers to provide linkage back to BSS information.\n");
759 sb.append(" properties:\n");
760 sb.append(" customer:\n");
761 sb.append(" type: array\n");
762 sb.append(" items: \n");
763 sb.append(" $ref: \"#/definitions/customer\"\n");
764 sb.append(" inventory:\n");
765 sb.append(" properties:\n");
766 sb.append(" business:\n");
767 sb.append(" type: object\n");
768 sb.append(" $ref: \"#/definitions/business\"\n");
769 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
770 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
771 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
772 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
773 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
774 sb.append(" $ref: \"#/definitions/inventory-item-data\""
775 + OxmFileProcessor.LINE_SEPARATOR);
776 sb.append(" service-subscription:\n");
777 sb.append(" description: |\n");
778 sb.append(" Object that group service instances.\n");
779 sb.append(" ###### Related Nodes\n");
781 " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
782 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
784 " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
787 " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
789 " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
790 sb.append(" required:\n");
791 sb.append(" - service-type\n");
792 sb.append(" properties:\n");
793 sb.append(" service-type:\n");
794 sb.append(" type: string\n");
796 " description: Value defined by orchestration to identify this service.\n");
797 sb.append(" temp-ub-sub-account-id:\n");
798 sb.append(" type: string\n");
800 " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
801 sb.append(" resource-version:\n");
802 sb.append(" type: string\n");
804 " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
805 sb.append(" service-subscriptions:\n");
806 sb.append(" description: |\n");
807 sb.append(" Collection of objects that group service instances.\n");
808 sb.append(" properties:\n");
809 sb.append(" service-subscription:\n");
810 sb.append(" type: array\n");
811 sb.append(" items: \n");
812 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
813 return sb.toString();
816 public String YAMLdefsAddPatch() {
817 StringBuilder sb = new StringBuilder(8092);
818 sb.append(" zzzz-patch-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");
823 " - 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(" properties:\n");
827 sb.append(" global-customer-id:\n");
828 sb.append(" type: string\n");
830 " description: Global customer id used across to uniquely identify customer.\n");
831 sb.append(" subscriber-name:\n");
832 sb.append(" type: string\n");
834 " description: Subscriber name, an alternate way to retrieve a customer.\n");
835 sb.append(" subscriber-type:\n");
836 sb.append(" type: string\n");
838 " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
839 sb.append(" zzzz-patch-service-subscription:\n");
840 sb.append(" description: |\n");
841 sb.append(" Object that group service instances.\n");
842 sb.append(" ###### Related Nodes\n");
844 " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
845 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
847 " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
850 " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
852 " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
853 sb.append(" properties:\n");
854 sb.append(" service-type:\n");
855 sb.append(" type: string\n");
857 " description: Value defined by orchestration to identify this service.\n");
858 sb.append(" temp-ub-sub-account-id:\n");
859 sb.append(" type: string\n");
861 " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
862 return sb.toString();
865 public String YAMLRelationshipList() {
866 StringBuilder sb = new StringBuilder(8092);
867 sb.append(" relationship-list:\n");
868 sb.append(" properties:\n");
869 sb.append(" relationship:\n");
870 sb.append(" type: object\n");
871 sb.append(" $ref: \"#/definitions/relationship\"\n");
872 return sb.toString();
875 public static String EdgeDefs() {
876 StringBuilder sb = new StringBuilder(8092);
877 sb.append("{\n" + " \"rules\": [\n");
879 sb.append(" \"from\": \"service-subscription\",\n");
880 sb.append(" \"to\": \"customer\",\n"
881 + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
882 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
883 + " \"contains-other-v\": \"!${direction}\",\n"
884 + " \"delete-other-v\": \"!${direction}\",\n"
885 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
886 + " \"description\":\"\"\n");
888 sb.append(" {\n" + " \"from\": \"service-instance\",\n"
889 + " \"to\": \"service-subscription\",\n"
890 + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
891 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
892 + " \"contains-other-v\": \"!${direction}\",\n"
893 + " \"delete-other-v\": \"!${direction}\",\n"
894 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
895 + " \"description\":\"\"\n" + " },\n");
896 sb.append(" {\n" + " \"from\": \"service-subscription\",\n"
897 + " \"to\": \"tenant\",\n"
898 + " \"label\": \"org.onap.relationships.inventory.Uses\",\n"
899 + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2MANY\",\n"
900 + " \"contains-other-v\": \"NONE\",\n" + " \"delete-other-v\": \"NONE\",\n"
901 + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
902 + " \"description\":\"\"\n" + " }");
903 sb.append(" ]\n" + "}\n");
904 return sb.toString();