2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.schemagen.genxsd;
22 import com.google.common.collect.Multimap;
23 import org.junit.Before;
24 import org.junit.BeforeClass;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.aai.edges.EdgeIngestor;
28 import org.onap.aai.edges.EdgeRule;
29 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
30 import org.onap.aai.nodes.NodeIngestor;
31 import org.onap.aai.schemagen.SwaggerGenerationConfiguration;
32 import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
33 import org.onap.aai.setup.SchemaLocationsBean;
34 import org.onap.aai.setup.SchemaVersion;
35 import org.onap.aai.setup.SchemaVersions;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
40 import org.springframework.test.context.ContextConfiguration;
41 import org.springframework.test.context.TestPropertySource;
42 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
43 import org.w3c.dom.Document;
44 import org.w3c.dom.Element;
46 import java.io.BufferedWriter;
48 import java.io.FileWriter;
49 import java.io.IOException;
50 import java.nio.charset.Charset;
51 import java.nio.file.Files;
52 import java.nio.file.Path;
53 import java.nio.file.Paths;
54 import java.util.SortedSet;
55 import java.util.TreeSet;
57 import static org.hamcrest.CoreMatchers.is;
58 import static org.junit.Assert.assertNotNull;
59 import static org.junit.Assert.assertThat;
60 import static org.junit.Assert.assertTrue;
63 @RunWith(SpringJUnit4ClassRunner.class)
64 @ContextConfiguration(classes = {
66 SchemaLocationsBean.class,
67 TestUtilConfigTranslatorforBusiness.class,
71 SwaggerGenerationConfiguration.class
74 @TestPropertySource(properties = {
75 "schema.uri.base.path = /aai",
76 "schema.xsd.maxoccurs = 5000"
78 public class YAMLfromOXMTest {
80 EdgeIngestor edgeIngestor;
83 NodeIngestor nodeIngestor;
84 private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
85 private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
86 private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
87 public static AnnotationConfigApplicationContext ctx = null;
88 private static String testXML;
89 protected static final String SERVICE_NAME = "JUNIT";
93 YAMLfromOXM yamlFromOxm;
96 SchemaVersions schemaVersions;
99 public static void setUpBeforeClass() throws Exception {
100 System.setProperty("AJSC_HOME", ".");
101 System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
102 System.setProperty("aai.service.name", SERVICE_NAME);
108 public void setUp() throws Exception {
109 XSDElementTest x = new XSDElementTest();
112 logger.debug(testXML);
113 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
116 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
117 bw1.write(EdgeDefs());
121 public void setupRelationship() throws Exception{
122 XSDElementTest x = new XSDElementTest();
124 x.setUpRelationship();
127 logger.debug(testXML);
128 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
133 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
134 bw1.write(EdgeDefs());
139 public void AtestIngestors() throws EdgeRuleNotFoundException {
140 Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
141 SortedSet<String> ss=new TreeSet<String>(results.keySet());
142 for(String key : ss) {
143 results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
145 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
150 public void testGetDocumentHeader() {
151 SchemaVersion v = schemaVersions.getAppRootVersion();
152 String apiVersion = v.toString();
153 String header = null;
155 yamlFromOxm.setXmlVersion(testXML, v);
156 yamlFromOxm.process();
157 header = yamlFromOxm.getDocumentHeader();
158 } catch(Exception e) {
161 assertThat("Header:\n"+header,header, is(YAMLheader()));
165 public void testProcess() {
166 SchemaVersion v = schemaVersions.getAppRootVersion();
167 String apiVersion = v.toString();
168 String fileContent = null;
170 yamlFromOxm.setXmlVersion(testXML, v);
171 fileContent = yamlFromOxm.process();
172 } catch(Exception e) {
175 assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
179 public void testYAMLfromOXMFileVersionFile() throws IOException {
180 String outfileName = "testXML.xml";
181 File XMLfile = new File(outfileName);
182 XMLfile.createNewFile();
183 BufferedWriter bw = null;
184 Charset charset = Charset.forName("UTF-8");
185 Path path = Paths.get(outfileName);
186 bw = Files.newBufferedWriter(path, charset);
189 SchemaVersion v = schemaVersions.getAppRootVersion();
190 String apiVersion = v.toString();
191 String fileContent = null;
193 yamlFromOxm.setXmlVersion(testXML, v);
194 fileContent = yamlFromOxm.process();
195 } catch(Exception e) {
199 assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
203 public void testYAMLfromOXMStringVersionFile() {
204 SchemaVersion v = schemaVersions.getAppRootVersion();
205 String apiVersion = v.toString();
206 String fileContent = null;
208 yamlFromOxm.setXmlVersion(testXML, v);
209 fileContent = yamlFromOxm.process();
210 } catch(Exception e) {
213 assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
217 public void testRelationshipListYAMLfromOXMStringVersionFile() {
220 } catch (Exception e1) {
221 // TODO Auto-generated catch block
222 e1.printStackTrace();
224 SchemaVersion v = schemaVersions.getAppRootVersion();
225 String apiVersion = v.toString();
226 String fileContent = null;
228 yamlFromOxm.setXmlVersion(testXML, v);
229 fileContent = yamlFromOxm.process();
230 } catch(Exception e) {
233 boolean matchFound = fileContent.contains(( YAMLRelationshipList()));
234 assertTrue("RelationshipListFormat:\n", matchFound);
238 public void testAppendDefinitions() {
239 SchemaVersion v = schemaVersions.getAppRootVersion();
240 String apiVersion = v.toString();
241 String definitions = null;
243 yamlFromOxm.setXmlVersion(testXML, v);
244 yamlFromOxm.process();
245 definitions = yamlFromOxm.appendDefinitions();
246 } catch(Exception e) {
249 assertThat("Definitions:\n"+definitions,definitions, 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"), is(target));
302 public String YAMLresult() {
303 StringBuilder sb = new StringBuilder(32368);
304 sb.append(YAMLheader());
305 sb.append(YAMLops());
306 sb.append(YAMLdefs());
307 sb.append(YAMLdefsAddPatch());
308 return sb.toString();
310 public String YAMLheader() {
311 StringBuilder sb = new StringBuilder(1500);
312 sb.append("swagger: \"2.0\"\n");
313 sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
314 sb.append(" description: |\n");
316 sb.append(" [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
317 sb.append(" Copyright © 2017-18 AT&T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
318 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");
320 sb.append(" You may obtain a copy of the License at\n");
322 sb.append(" (https://creativecommons.org/licenses/by/4.0/)\n");
324 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." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
325 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." + OxmFileProcessor.LINE_SEPARATOR);
326 sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
327 sb.append(" title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
328 sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
329 sb.append(" name: Apache 2.0\n");
330 sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
331 sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
332 sb.append(" name:" + OxmFileProcessor.LINE_SEPARATOR);
333 sb.append(" url:" + OxmFileProcessor.LINE_SEPARATOR);
334 sb.append(" email:" + OxmFileProcessor.LINE_SEPARATOR);
335 sb.append("host:" + OxmFileProcessor.LINE_SEPARATOR);
336 sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
337 sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
338 sb.append(" - https\n");
339 sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
340 return sb.toString();
343 public String YAMLops() {
344 StringBuilder sb = new StringBuilder(16384);
345 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
346 sb.append(" get:\n");
347 sb.append(" tags:\n");
348 sb.append(" - Business\n");
349 sb.append(" summary: returns service-subscription\n");
350 sb.append(" description: returns service-subscription\n");
351 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
352 sb.append(" produces:\n");
353 sb.append(" - application/json\n");
354 sb.append(" - application/xml\n");
355 sb.append(" responses:\n");
356 sb.append(" \"200\":\n");
357 sb.append(" description: successful operation\n");
358 sb.append(" schema:\n");
359 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
360 sb.append(" \"default\":\n");
361 sb.append(" null parameters:\n");
362 sb.append(" - name: global-customer-id\n");
363 sb.append(" in: path\n");
364 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
365 sb.append(" required: true\n");
366 sb.append(" type: string\n");
367 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
368 sb.append(" - name: service-type\n");
369 sb.append(" in: path\n");
370 sb.append(" description: Value defined by orchestration to identify this service.\n");
371 sb.append(" required: true\n");
372 sb.append(" type: string\n");
373 sb.append(" example: __SERVICE-TYPE__\n");
374 sb.append(" put:\n");
375 sb.append(" tags:\n");
376 sb.append(" - Business\n");
377 sb.append(" summary: create or update an existing service-subscription\n");
378 sb.append(" description: |\n");
379 sb.append(" Create or update an existing service-subscription.\n");
381 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");
382 sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
383 sb.append(" consumes:\n");
384 sb.append(" - application/json\n");
385 sb.append(" - application/xml\n");
386 sb.append(" produces:\n");
387 sb.append(" - application/json\n");
388 sb.append(" - application/xml\n");
389 sb.append(" responses:\n");
390 sb.append(" \"default\":\n");
391 sb.append(" null parameters:\n");
392 sb.append(" - name: global-customer-id\n");
393 sb.append(" in: path\n");
394 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
395 sb.append(" required: true\n");
396 sb.append(" type: string\n");
397 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
398 sb.append(" - name: service-type\n");
399 sb.append(" in: path\n");
400 sb.append(" description: Value defined by orchestration to identify this service.\n");
401 sb.append(" required: true\n");
402 sb.append(" type: string\n");
403 sb.append(" example: __SERVICE-TYPE__\n");
404 sb.append(" - name: body\n");
405 sb.append(" in: body\n");
406 sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
407 sb.append(" required: true\n");
408 sb.append(" schema:\n");
409 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
410 sb.append(" patch:\n");
411 sb.append(" tags:\n");
412 sb.append(" - Business\n");
413 sb.append(" summary: update an existing service-subscription\n");
414 sb.append(" description: |\n");
415 sb.append(" Update an existing service-subscription\n");
417 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
418 sb.append(" The PUT operation will entirely replace an existing object.\n");
419 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");
421 sb.append(" Other differences between PUT and PATCH are:\n");
423 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
424 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
425 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
426 sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
427 sb.append(" consumes:\n");
428 sb.append(" - application/json\n");
429 sb.append(" produces:\n");
430 sb.append(" - application/json\n");
431 sb.append(" responses:\n");
432 sb.append(" \"default\":\n");
433 sb.append(" null parameters:\n");
434 sb.append(" - name: global-customer-id\n");
435 sb.append(" in: path\n");
436 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
437 sb.append(" required: true\n");
438 sb.append(" type: string\n");
439 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
440 sb.append(" - name: service-type\n");
441 sb.append(" in: path\n");
442 sb.append(" description: Value defined by orchestration to identify this service.\n");
443 sb.append(" required: true\n");
444 sb.append(" type: string\n");
445 sb.append(" example: __SERVICE-TYPE__\n");
446 sb.append(" - name: body\n");
447 sb.append(" in: body\n");
448 sb.append(" description: service-subscription object that needs to be updated.\n");
449 sb.append(" required: true\n");
450 sb.append(" schema:\n");
451 sb.append(" $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
452 sb.append(" delete:\n");
453 sb.append(" tags:\n");
454 sb.append(" - Business\n");
455 sb.append(" summary: delete an existing service-subscription\n");
456 sb.append(" description: delete an existing service-subscription\n");
457 sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
458 sb.append(" consumes:\n");
459 sb.append(" - application/json\n");
460 sb.append(" - application/xml\n");
461 sb.append(" produces:\n");
462 sb.append(" - application/json\n");
463 sb.append(" - application/xml\n");
464 sb.append(" responses:\n");
465 sb.append(" \"default\":\n");
466 sb.append(" null parameters:\n");
467 sb.append(" - name: global-customer-id\n");
468 sb.append(" in: path\n");
469 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
470 sb.append(" required: true\n");
471 sb.append(" type: string\n");
472 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
473 sb.append(" - name: service-type\n");
474 sb.append(" in: path\n");
475 sb.append(" description: Value defined by orchestration to identify this service.\n");
476 sb.append(" required: true\n");
477 sb.append(" type: string\n");
478 sb.append(" example: __SERVICE-TYPE__\n");
479 sb.append(" - name: resource-version\n");
480 sb.append(" in: query\n");
481 sb.append(" description: resource-version for concurrency\n");
482 sb.append(" required: true\n");
483 sb.append(" type: string\n");
484 sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
485 sb.append(" get:\n");
486 sb.append(" tags:\n");
487 sb.append(" - Business\n");
488 sb.append(" summary: returns service-subscriptions\n");
489 sb.append(" description: returns service-subscriptions\n");
490 sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
491 sb.append(" produces:\n");
492 sb.append(" - application/json\n");
493 sb.append(" - application/xml\n");
494 sb.append(" responses:\n");
495 sb.append(" \"200\":\n");
496 sb.append(" description: successful operation\n");
497 sb.append(" schema:\n");
498 sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
499 sb.append(" \"default\":\n");
500 sb.append(" null parameters:\n");
501 sb.append(" - name: global-customer-id\n");
502 sb.append(" in: path\n");
503 sb.append(" 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: query\n");
509 sb.append(" description:\n");
510 sb.append(" required: false\n");
511 sb.append(" type: string\n");
512 sb.append(" /business/customers/customer/{global-customer-id}:\n");
513 sb.append(" get:\n");
514 sb.append(" tags:\n");
515 sb.append(" - Business\n");
516 sb.append(" summary: returns customer\n");
517 sb.append(" description: returns customer\n");
518 sb.append(" operationId: getBusinessCustomersCustomer\n");
519 sb.append(" produces:\n");
520 sb.append(" - application/json\n");
521 sb.append(" - application/xml\n");
522 sb.append(" responses:\n");
523 sb.append(" \"200\":\n");
524 sb.append(" description: successful operation\n");
525 sb.append(" schema:\n");
526 sb.append(" $ref: \"#/definitions/customer\"\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(" put:\n");
536 sb.append(" tags:\n");
537 sb.append(" - Business\n");
538 sb.append(" summary: create or update an existing customer\n");
539 sb.append(" description: |\n");
540 sb.append(" Create or update an existing customer.\n");
542 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");
543 sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
544 sb.append(" consumes:\n");
545 sb.append(" - application/json\n");
546 sb.append(" - application/xml\n");
547 sb.append(" produces:\n");
548 sb.append(" - application/json\n");
549 sb.append(" - application/xml\n");
550 sb.append(" responses:\n");
551 sb.append(" \"default\":\n");
552 sb.append(" null parameters:\n");
553 sb.append(" - name: global-customer-id\n");
554 sb.append(" in: path\n");
555 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
556 sb.append(" required: true\n");
557 sb.append(" type: string\n");
558 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
559 sb.append(" - name: body\n");
560 sb.append(" in: body\n");
561 sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
562 sb.append(" required: true\n");
563 sb.append(" schema:\n");
564 sb.append(" $ref: \"#/definitions/customer\"\n");
565 sb.append(" patch:\n");
566 sb.append(" tags:\n");
567 sb.append(" - Business\n");
568 sb.append(" summary: update an existing customer\n");
569 sb.append(" description: |\n");
570 sb.append(" Update an existing customer\n");
572 sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
573 sb.append(" The PUT operation will entirely replace an existing object.\n");
574 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");
576 sb.append(" Other differences between PUT and PATCH are:\n");
578 sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
579 sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
580 sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
581 sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
582 sb.append(" consumes:\n");
583 sb.append(" - application/json\n");
584 sb.append(" produces:\n");
585 sb.append(" - application/json\n");
586 sb.append(" responses:\n");
587 sb.append(" \"default\":\n");
588 sb.append(" null parameters:\n");
589 sb.append(" - name: global-customer-id\n");
590 sb.append(" in: path\n");
591 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
592 sb.append(" required: true\n");
593 sb.append(" type: string\n");
594 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
595 sb.append(" - name: body\n");
596 sb.append(" in: body\n");
597 sb.append(" description: customer object that needs to be updated.\n");
598 sb.append(" required: true\n");
599 sb.append(" schema:\n");
600 sb.append(" $ref: \"#/definitions/zzzz-patch-customer\"\n");
601 sb.append(" delete:\n");
602 sb.append(" tags:\n");
603 sb.append(" - Business\n");
604 sb.append(" summary: delete an existing customer\n");
605 sb.append(" description: delete an existing customer\n");
606 sb.append(" operationId: deleteBusinessCustomersCustomer\n");
607 sb.append(" consumes:\n");
608 sb.append(" - application/json\n");
609 sb.append(" - application/xml\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(" \"default\":\n");
615 sb.append(" null parameters:\n");
616 sb.append(" - name: global-customer-id\n");
617 sb.append(" in: path\n");
618 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
619 sb.append(" required: true\n");
620 sb.append(" type: string\n");
621 sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
622 sb.append(" - name: resource-version\n");
623 sb.append(" in: query\n");
624 sb.append(" description: resource-version for concurrency\n");
625 sb.append(" required: true\n");
626 sb.append(" type: string\n");
627 sb.append(" /business/customers:\n");
628 sb.append(" get:\n");
629 sb.append(" tags:\n");
630 sb.append(" - Business\n");
631 sb.append(" summary: returns customers\n");
632 sb.append(" description: returns customers\n");
633 sb.append(" operationId: getBusinessCustomers\n");
634 sb.append(" produces:\n");
635 sb.append(" - application/json\n");
636 sb.append(" - application/xml\n");
637 sb.append(" responses:\n");
638 sb.append(" \"200\":\n");
639 sb.append(" description: successful operation\n");
640 sb.append(" schema:\n");
641 sb.append(" $ref: \"#/definitions/customers\"\n");
642 sb.append(" \"default\":\n");
643 sb.append(" null parameters:\n");
644 sb.append(" - name: global-customer-id\n");
645 sb.append(" in: query\n");
646 sb.append(" description:\n");
647 sb.append(" required: false\n");
648 sb.append(" type: string\n");
649 sb.append(" - name: subscriber-name\n");
650 sb.append(" in: query\n");
651 sb.append(" description:\n");
652 sb.append(" required: false\n");
653 sb.append(" type: string\n");
654 sb.append(" - name: subscriber-type\n");
655 sb.append(" in: query\n");
656 sb.append(" description:\n");
657 sb.append(" required: false\n");
658 sb.append(" type: string\n");
659 return sb.toString();
661 public String YAMLdefs() {
662 StringBuilder sb = new StringBuilder(8092);
663 sb.append("definitions:\n");
664 sb.append(" business:\n");
665 sb.append(" description: |\n");
666 sb.append(" Namespace for business related constructs\n");
667 sb.append(" properties:\n");
668 sb.append(" customers:\n");
669 sb.append(" type: array\n");
670 sb.append(" items:\n");
671 sb.append(" $ref: \"#/definitions/customer\"\n");
672 sb.append(" customer:\n");
673 sb.append(" description: |\n");
674 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
675 sb.append(" ###### Related Nodes\n");
676 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
678 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
679 sb.append(" required:\n");
680 sb.append(" - global-customer-id\n");
681 sb.append(" - subscriber-name\n");
682 sb.append(" - subscriber-type\n");
683 sb.append(" properties:\n");
684 sb.append(" global-customer-id:\n");
685 sb.append(" type: string\n");
686 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
687 sb.append(" subscriber-name:\n");
688 sb.append(" type: string\n");
689 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
690 sb.append(" subscriber-type:\n");
691 sb.append(" type: string\n");
692 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
693 sb.append(" resource-version:\n");
694 sb.append(" type: string\n");
695 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
696 sb.append(" service-subscriptions:\n");
697 sb.append(" type: array\n");
698 sb.append(" items:\n");
699 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
700 sb.append(" customers:\n");
701 sb.append(" description: |\n");
702 sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
703 sb.append(" properties:\n");
704 sb.append(" customer:\n");
705 sb.append(" type: array\n");
706 sb.append(" items: \n");
707 sb.append(" $ref: \"#/definitions/customer\"\n");
708 sb.append(" inventory:\n");
709 sb.append(" properties:\n");
710 sb.append(" business:\n");
711 sb.append(" type: object\n");
712 sb.append(" $ref: \"#/definitions/business\"\n");
713 sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
714 sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
715 sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
716 sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
717 sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
718 sb.append(" $ref: \"#/definitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
719 sb.append(" service-subscription:\n");
720 sb.append(" description: |\n");
721 sb.append(" Object that group service instances.\n");
722 sb.append(" ###### Related Nodes\n");
723 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
724 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
725 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
727 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
728 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
729 sb.append(" required:\n");
730 sb.append(" - service-type\n");
731 sb.append(" properties:\n");
732 sb.append(" service-type:\n");
733 sb.append(" type: string\n");
734 sb.append(" description: Value defined by orchestration to identify this service.\n");
735 sb.append(" temp-ub-sub-account-id:\n");
736 sb.append(" type: string\n");
737 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
738 sb.append(" resource-version:\n");
739 sb.append(" type: string\n");
740 sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
741 sb.append(" service-subscriptions:\n");
742 sb.append(" description: |\n");
743 sb.append(" Collection of objects that group service instances.\n");
744 sb.append(" properties:\n");
745 sb.append(" service-subscription:\n");
746 sb.append(" type: array\n");
747 sb.append(" items: \n");
748 sb.append(" $ref: \"#/definitions/service-subscription\"\n");
749 return sb.toString();
751 public String YAMLdefsAddPatch() {
752 StringBuilder sb = new StringBuilder(8092);
753 sb.append(" zzzz-patch-customer:\n");
754 sb.append(" description: |\n");
755 sb.append(" customer identifiers to provide linkage back to BSS information.\n");
756 sb.append(" ###### Related Nodes\n");
757 sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
759 sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
760 sb.append(" properties:\n");
761 sb.append(" global-customer-id:\n");
762 sb.append(" type: string\n");
763 sb.append(" description: Global customer id used across to uniquely identify customer.\n");
764 sb.append(" subscriber-name:\n");
765 sb.append(" type: string\n");
766 sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
767 sb.append(" subscriber-type:\n");
768 sb.append(" type: string\n");
769 sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
770 sb.append(" zzzz-patch-service-subscription:\n");
771 sb.append(" description: |\n");
772 sb.append(" Object that group service instances.\n");
773 sb.append(" ###### Related Nodes\n");
774 sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
775 sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
776 sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
778 sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
779 sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
780 sb.append(" properties:\n");
781 sb.append(" service-type:\n");
782 sb.append(" type: string\n");
783 sb.append(" description: Value defined by orchestration to identify this service.\n");
784 sb.append(" temp-ub-sub-account-id:\n");
785 sb.append(" type: string\n");
786 sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
787 return sb.toString();
790 public String YAMLRelationshipList() {
791 StringBuilder sb = new StringBuilder(8092);
792 sb.append(" relationship-list:\n");
793 sb.append(" properties:\n");
794 sb.append(" relationship:\n");
795 sb.append(" type: object\n");
796 sb.append(" $ref: \"#/definitions/relationship\"\n");
797 return sb.toString();
800 public static String EdgeDefs() {
801 StringBuilder sb = new StringBuilder(8092);
805 sb.append(" \"from\": \"service-subscription\",\n");
806 sb.append(" \"to\": \"customer\",\n" +
807 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
808 " \"direction\": \"OUT\",\n" +
809 " \"multiplicity\": \"MANY2ONE\",\n" +
810 " \"contains-other-v\": \"!${direction}\",\n" +
811 " \"delete-other-v\": \"!${direction}\",\n" +
812 " \"prevent-delete\": \"NONE\",\n" +
813 " \"default\": \"true\",\n" +
814 " \"description\":\"\"\n");
817 " \"from\": \"service-instance\",\n" +
818 " \"to\": \"service-subscription\",\n" +
819 " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
820 " \"direction\": \"OUT\",\n" +
821 " \"multiplicity\": \"MANY2ONE\",\n" +
822 " \"contains-other-v\": \"!${direction}\",\n" +
823 " \"delete-other-v\": \"!${direction}\",\n" +
824 " \"prevent-delete\": \"NONE\",\n" +
825 " \"default\": \"true\",\n" +
826 " \"description\":\"\"\n" +
829 " \"from\": \"service-subscription\",\n" +
830 " \"to\": \"tenant\",\n" +
831 " \"label\": \"org.onap.relationships.inventory.Uses\",\n" +
832 " \"direction\": \"OUT\",\n" +
833 " \"multiplicity\": \"MANY2MANY\",\n" +
834 " \"contains-other-v\": \"NONE\",\n" +
835 " \"delete-other-v\": \"NONE\",\n" +
836 " \"prevent-delete\": \"NONE\",\n" +
837 " \"default\": \"true\",\n" +
838 " \"description\":\"\"\n" +
842 return sb.toString();