[AAI] Remove Robby Maharajh & Harish Kajur as committers
[aai/schema-service.git] / aai-schema-gen / src / test / java / org / onap / aai / schemagen / genxsd / YAMLfromOXMTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.onap.aai.schemagen.genxsd;
21
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;
45
46 import java.io.BufferedWriter;
47 import java.io.File;
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;
56
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;
61
62
63 @RunWith(SpringJUnit4ClassRunner.class)
64 @ContextConfiguration(classes = {
65                 SchemaVersions.class,
66         SchemaLocationsBean.class,
67         TestUtilConfigTranslatorforBusiness.class,
68         SchemaVersions.class,
69         EdgeIngestor.class,
70         NodeIngestor.class,
71                 SwaggerGenerationConfiguration.class
72
73 })
74 @TestPropertySource(properties = {
75                 "schema.uri.base.path = /aai",
76                 "schema.xsd.maxoccurs = 5000"
77 })
78 public class YAMLfromOXMTest {
79         @Autowired
80     EdgeIngestor edgeIngestor;
81
82         @Autowired
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";
90     boolean first = true;
91
92     @Autowired
93         YAMLfromOXM yamlFromOxm;
94
95     @Autowired
96     SchemaVersions schemaVersions;
97
98         @BeforeClass
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);
103         }
104         
105         
106
107         @Before
108         public void setUp() throws Exception {
109         XSDElementTest x = new XSDElementTest();
110                 x.setUp();
111                 testXML = x.testXML;
112                 logger.debug(testXML);
113                 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
114                 bw.write(testXML);
115                 bw.close();
116                 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
117                 bw1.write(EdgeDefs());
118                 bw1.close();
119     }
120         
121         public void setupRelationship() throws Exception{
122         XSDElementTest x = new XSDElementTest();
123
124                 x.setUpRelationship();
125
126                 testXML = x.testXML;
127                 logger.debug(testXML);
128                 BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
129
130                 bw.write(testXML);
131
132                 bw.close();
133                 BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
134                 bw1.write(EdgeDefs());
135                 bw1.close();
136         }
137
138         @Test
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()); } );
144                 }
145                 Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
146                 assertNotNull(doc);
147         }
148
149         @Test
150         public void testGetDocumentHeader() {
151                 SchemaVersion v = schemaVersions.getAppRootVersion();
152                 String apiVersion = v.toString();
153                 String header = null;
154                 try {
155                         yamlFromOxm.setXmlVersion(testXML, v);
156                         yamlFromOxm.process();
157                         header = yamlFromOxm.getDocumentHeader();
158                 } catch(Exception e) {
159                         e.printStackTrace();
160                 }
161                 assertThat("Header:\n"+header,header, is(YAMLheader()));
162         }
163
164         @Test
165         public void testProcess() {
166                 SchemaVersion v = schemaVersions.getAppRootVersion();
167                 String apiVersion = v.toString();
168                 String fileContent = null;
169                 try {
170                         yamlFromOxm.setXmlVersion(testXML, v);
171                         fileContent = yamlFromOxm.process();
172                 } catch(Exception e) {
173                         e.printStackTrace();
174                 }
175                 assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
176         }
177
178         @Test
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);
187                 bw.write(testXML);
188                 bw.close();
189                 SchemaVersion v = schemaVersions.getAppRootVersion();
190                 String apiVersion = v.toString();
191                 String fileContent = null;
192                 try {
193                         yamlFromOxm.setXmlVersion(testXML, v);
194                         fileContent = yamlFromOxm.process();
195                 } catch(Exception e) {
196                         e.printStackTrace();
197                 }
198                 XMLfile.delete();
199                 assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
200          }
201
202         @Test
203         public void testYAMLfromOXMStringVersionFile() {
204                 SchemaVersion v = schemaVersions.getAppRootVersion();
205                 String apiVersion = v.toString();
206                 String fileContent = null;
207                 try {
208                         yamlFromOxm.setXmlVersion(testXML, v);
209                         fileContent = yamlFromOxm.process();
210                 } catch(Exception e) {
211                         e.printStackTrace();
212                 }
213                 assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
214         }
215         
216         @Test
217         public void testRelationshipListYAMLfromOXMStringVersionFile() {
218                 try {
219                         setupRelationship();
220                 } catch (Exception e1) {
221                         // TODO Auto-generated catch block
222                         e1.printStackTrace();
223                 }
224                 SchemaVersion v = schemaVersions.getAppRootVersion();
225                 String apiVersion = v.toString();
226                 String fileContent = null;
227                 try {
228                         yamlFromOxm.setXmlVersion(testXML, v);
229                         fileContent = yamlFromOxm.process();
230                 } catch(Exception e) {
231                         e.printStackTrace();
232                 }
233                 boolean matchFound = fileContent.contains(( YAMLRelationshipList()));
234                 assertTrue("RelationshipListFormat:\n", matchFound);
235         }
236
237         @Test
238         public void testAppendDefinitions() {
239                 SchemaVersion v = schemaVersions.getAppRootVersion();
240                 String apiVersion = v.toString();
241                 String definitions = null;
242                 try {
243                         yamlFromOxm.setXmlVersion(testXML, v);
244                         yamlFromOxm.process();
245                         definitions = yamlFromOxm.appendDefinitions();
246                 } catch(Exception e) {
247                         e.printStackTrace();
248                 }
249                 assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLdefsAddPatch()));
250         }
251
252         @Test
253         public void testGetXMLRootElementName() {
254                 String target = "RootElement=customer";
255                 SchemaVersion v = schemaVersions.getAppRootVersion();
256                 String apiVersion = v.toString();
257                 Element customer = null;
258                 String root = null;
259                 try {
260                         yamlFromOxm.setXmlVersion(testXML, v);
261                         yamlFromOxm.process();
262                         customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
263                         root = yamlFromOxm.getXMLRootElementName(customer);
264                 } catch(Exception e) {
265                         e.printStackTrace();
266                 }
267                 assertThat("RootElement="+root, is(target));
268         }
269
270         @Test
271         public void testGetXmlRootElementName() {
272                 String target = "RootElement=customer";
273                 SchemaVersion v = schemaVersions.getAppRootVersion();
274                 String apiVersion = v.toString();
275                 String root = null;
276                 try {
277                         yamlFromOxm.setXmlVersion(testXML, v);
278                         yamlFromOxm.process();
279                         root = yamlFromOxm.getXmlRootElementName("Customer");
280                 } catch(Exception e) {
281                         e.printStackTrace();
282                 }
283                 assertThat("RootElement="+root, is(target));
284         }
285
286         @Test
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;
292                 try {
293                         yamlFromOxm.setXmlVersion(testXML, v);
294                         yamlFromOxm.process();
295                         customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
296                 } catch(Exception e) {
297                         e.printStackTrace();
298                 }
299                 assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
300         }
301
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();
309         }
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");
315                 sb.append("\n");
316                 sb.append("    [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
317                 sb.append("    Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
318                 sb.append("    Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
319                 sb.append("    You may obtain a copy of the License at\n");
320                 sb.append("\n");
321                 sb.append("    (https://creativecommons.org/licenses/by/4.0/)"+ OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
322                 sb.append("    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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);
323                 sb.append("    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." + OxmFileProcessor.LINE_SEPARATOR);
324                 sb.append("  version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
325                 sb.append("  title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
326                 sb.append("  license:" + OxmFileProcessor.LINE_SEPARATOR);
327                 sb.append("    name: Apache 2.0\n");
328                 sb.append("    url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
329                 sb.append("  contact:" + OxmFileProcessor.LINE_SEPARATOR);
330                 sb.append("    name: n/a" + OxmFileProcessor.LINE_SEPARATOR);
331                 sb.append("    url: n/a" + OxmFileProcessor.LINE_SEPARATOR);
332                 sb.append("    email: n/a" + OxmFileProcessor.LINE_SEPARATOR);
333                 sb.append("host: n/a" + OxmFileProcessor.LINE_SEPARATOR);
334                 sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
335                 sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
336                 sb.append("  - https\n");
337                 sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
338                 return sb.toString();
339         }
340
341         public String YAMLops() {
342                 StringBuilder sb = new StringBuilder(16384);
343                 sb.append("  /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
344                 sb.append("    get:\n");
345                 sb.append("      tags:\n");
346                 sb.append("        - Business\n");
347                 sb.append("      summary: returns service-subscription\n");
348                 sb.append("      description: returns service-subscription\n");
349                 sb.append("      operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
350                 sb.append("      produces:\n");
351                 sb.append("        - application/json\n");
352                 sb.append("        - application/xml\n");
353                 sb.append("      responses:\n");
354                 sb.append("        \"200\":\n");
355                 sb.append("          description: successful operation\n");
356                 sb.append("          schema:\n");
357                 sb.append("              $ref: \"#/definitions/service-subscription\"\n");
358                 sb.append("        \"default\":\n");
359                 sb.append("          null      parameters:\n");
360                 sb.append("        - name: global-customer-id\n");
361                 sb.append("          in: path\n");
362                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
363                 sb.append("          required: true\n");
364                 sb.append("          type: string\n");
365                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
366                 sb.append("        - name: service-type\n");
367                 sb.append("          in: path\n");
368                 sb.append("          description: Value defined by orchestration to identify this service.\n");
369                 sb.append("          required: true\n");
370                 sb.append("          type: string\n");
371                 sb.append("          example: __SERVICE-TYPE__\n");
372                 sb.append("    put:\n");
373                 sb.append("      tags:\n");
374                 sb.append("        - Business\n");
375                 sb.append("      summary: create or update an existing service-subscription\n");
376                 sb.append("      description: |\n");
377                 sb.append("        Create or update an existing service-subscription.\n");
378                 sb.append("        #\n");
379                 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");
380                 sb.append("      operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
381                 sb.append("      consumes:\n");
382                 sb.append("        - application/json\n");
383                 sb.append("        - application/xml\n");
384                 sb.append("      produces:\n");
385                 sb.append("        - application/json\n");
386                 sb.append("        - application/xml\n");
387                 sb.append("      responses:\n");
388                 sb.append("        \"default\":\n");
389                 sb.append("          null      parameters:\n");
390                 sb.append("        - name: global-customer-id\n");
391                 sb.append("          in: path\n");
392                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
393                 sb.append("          required: true\n");
394                 sb.append("          type: string\n");
395                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
396                 sb.append("        - name: service-type\n");
397                 sb.append("          in: path\n");
398                 sb.append("          description: Value defined by orchestration to identify this service.\n");
399                 sb.append("          required: true\n");
400                 sb.append("          type: string\n");
401                 sb.append("          example: __SERVICE-TYPE__\n");
402                 sb.append("        - name: body\n");
403                 sb.append("          in: body\n");
404                 sb.append("          description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
405                 sb.append("          required: true\n");
406                 sb.append("          schema:\n");
407                 sb.append("            $ref: \"#/definitions/service-subscription\"\n");
408                 sb.append("    patch:\n");
409                 sb.append("      tags:\n");
410                 sb.append("        - Business\n");
411                 sb.append("      summary: update an existing service-subscription\n");
412                 sb.append("      description: |\n");
413                 sb.append("        Update an existing service-subscription\n");
414                 sb.append("        #\n");
415                 sb.append("        Note:  Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
416                 sb.append("        The PUT operation will entirely replace an existing object.\n");
417                 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");
418                 sb.append("        #\n");
419                 sb.append("        Other differences between PUT and PATCH are:\n");
420                 sb.append("        #\n");
421                 sb.append("        - For PATCH, you can send any of the values shown in sample REQUEST body.  There are no required values.\n");
422                 sb.append("        - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
423                 sb.append("        - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
424                 sb.append("      operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
425                 sb.append("      consumes:\n");
426                 sb.append("        - application/json\n");
427                 sb.append("      produces:\n");
428                 sb.append("        - application/json\n");
429                 sb.append("      responses:\n");
430                 sb.append("        \"default\":\n");
431                 sb.append("          null      parameters:\n");
432                 sb.append("        - name: global-customer-id\n");
433                 sb.append("          in: path\n");
434                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
435                 sb.append("          required: true\n");
436                 sb.append("          type: string\n");
437                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
438                 sb.append("        - name: service-type\n");
439                 sb.append("          in: path\n");
440                 sb.append("          description: Value defined by orchestration to identify this service.\n");
441                 sb.append("          required: true\n");
442                 sb.append("          type: string\n");
443                 sb.append("          example: __SERVICE-TYPE__\n");
444                 sb.append("        - name: body\n");
445                 sb.append("          in: body\n");
446                 sb.append("          description: service-subscription object that needs to be updated.");
447                 sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
448                 sb.append("          required: true\n");
449                 sb.append("          schema:\n");
450                 sb.append("            $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
451                 sb.append("    delete:\n");
452                 sb.append("      tags:\n");
453                 sb.append("        - Business\n");
454                 sb.append("      summary: delete an existing service-subscription\n");
455                 sb.append("      description: delete an existing service-subscription\n");
456                 sb.append("      operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
457                 sb.append("      consumes:\n");
458                 sb.append("        - application/json\n");
459                 sb.append("        - application/xml\n");
460                 sb.append("      produces:\n");
461                 sb.append("        - application/json\n");
462                 sb.append("        - application/xml\n");
463                 sb.append("      responses:\n");
464                 sb.append("        \"default\":\n");
465                 sb.append("          null      parameters:\n");
466                 sb.append("        - name: global-customer-id\n");
467                 sb.append("          in: path\n");
468                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
469                 sb.append("          required: true\n");
470                 sb.append("          type: string\n");
471                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
472                 sb.append("        - name: service-type\n");
473                 sb.append("          in: path\n");
474                 sb.append("          description: Value defined by orchestration to identify this service.\n");
475                 sb.append("          required: true\n");
476                 sb.append("          type: string\n");
477                 sb.append("          example: __SERVICE-TYPE__\n");
478                 sb.append("        - name: resource-version\n");
479                 sb.append("          in: query\n");
480                 sb.append("          description: resource-version for concurrency\n");
481                 sb.append("          required: true\n");
482                 sb.append("          type: string\n");
483                 sb.append("  /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
484                 sb.append("    get:\n");
485                 sb.append("      tags:\n");
486                 sb.append("        - Business\n");
487                 sb.append("      summary: returns service-subscriptions\n");
488                 sb.append("      description: returns service-subscriptions\n");
489                 sb.append("      operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
490                 sb.append("      produces:\n");
491                 sb.append("        - application/json\n");
492                 sb.append("        - application/xml\n");
493                 sb.append("      responses:\n");
494                 sb.append("        \"200\":\n");
495                 sb.append("          description: successful operation\n");
496                 sb.append("          schema:\n");
497                 sb.append("              $ref: \"#/definitions/service-subscriptions\"\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");
502                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
503                 sb.append("          required: true\n");
504                 sb.append("          type: string\n");
505                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
506                 sb.append("        - name: service-type\n");
507                 sb.append("          in: query\n");
508                 sb.append("          description: n/a\n");
509                 sb.append("          required: false\n");
510                 sb.append("          type: string\n");
511                 sb.append("  /business/customers/customer/{global-customer-id}:\n");
512                 sb.append("    get:\n");
513                 sb.append("      tags:\n");
514                 sb.append("        - Business\n");
515                 sb.append("      summary: returns customer\n");
516                 sb.append("      description: returns customer\n");
517                 sb.append("      operationId: getBusinessCustomersCustomer\n");
518                 sb.append("      produces:\n");
519                 sb.append("        - application/json\n");
520                 sb.append("        - application/xml\n");
521                 sb.append("      responses:\n");
522                 sb.append("        \"200\":\n");
523                 sb.append("          description: successful operation\n");
524                 sb.append("          schema:\n");
525                 sb.append("              $ref: \"#/definitions/customer\"\n");
526                 sb.append("        \"default\":\n");
527                 sb.append("          null      parameters:\n");
528                 sb.append("        - name: global-customer-id\n");
529                 sb.append("          in: path\n");
530                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
531                 sb.append("          required: true\n");
532                 sb.append("          type: string\n");
533                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
534                 sb.append("    put:\n");
535                 sb.append("      tags:\n");
536                 sb.append("        - Business\n");
537                 sb.append("      summary: create or update an existing customer\n");
538                 sb.append("      description: |\n");
539                 sb.append("        Create or update an existing customer.\n");
540                 sb.append("        #\n");
541                 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");
542                 sb.append("      operationId: createOrUpdateBusinessCustomersCustomer\n");
543                 sb.append("      consumes:\n");
544                 sb.append("        - application/json\n");
545                 sb.append("        - application/xml\n");
546                 sb.append("      produces:\n");
547                 sb.append("        - application/json\n");
548                 sb.append("        - application/xml\n");
549                 sb.append("      responses:\n");
550                 sb.append("        \"default\":\n");
551                 sb.append("          null      parameters:\n");
552                 sb.append("        - name: global-customer-id\n");
553                 sb.append("          in: path\n");
554                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
555                 sb.append("          required: true\n");
556                 sb.append("          type: string\n");
557                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
558                 sb.append("        - name: body\n");
559                 sb.append("          in: body\n");
560                 sb.append("          description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
561                 sb.append("          required: true\n");
562                 sb.append("          schema:\n");
563                 sb.append("            $ref: \"#/definitions/customer\"\n");
564                 sb.append("    patch:\n");
565                 sb.append("      tags:\n");
566                 sb.append("        - Business\n");
567                 sb.append("      summary: update an existing customer\n");
568                 sb.append("      description: |\n");
569                 sb.append("        Update an existing customer\n");
570                 sb.append("        #\n");
571                 sb.append("        Note:  Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
572                 sb.append("        The PUT operation will entirely replace an existing object.\n");
573                 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");
574                 sb.append("        #\n");
575                 sb.append("        Other differences between PUT and PATCH are:\n");
576                 sb.append("        #\n");
577                 sb.append("        - For PATCH, you can send any of the values shown in sample REQUEST body.  There are no required values.\n");
578                 sb.append("        - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
579                 sb.append("        - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
580                 sb.append("      operationId: UpdateBusinessCustomersCustomer\n");
581                 sb.append("      consumes:\n");
582                 sb.append("        - application/json\n");
583                 sb.append("      produces:\n");
584                 sb.append("        - application/json\n");
585                 sb.append("      responses:\n");
586                 sb.append("        \"default\":\n");
587                 sb.append("          null      parameters:\n");
588                 sb.append("        - name: global-customer-id\n");
589                 sb.append("          in: path\n");
590                 sb.append("          description: Global customer id used across to uniquely identify customer.\n");
591                 sb.append("          required: true\n");
592                 sb.append("          type: string\n");
593                 sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
594                 sb.append("        - name: body\n");
595                 sb.append("          in: body\n");
596                 sb.append("          description: customer object that needs to be updated.");
597                 sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\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/a\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/a\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/a\n");
657                 sb.append("          required: false\n");
658                 sb.append("          type: string\n");
659                 return sb.toString();
660         }
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");
677                 sb.append("\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");
726                 sb.append("\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();
750         }
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");
758                 sb.append("\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");
777                 sb.append("\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();
788         }
789         
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();
798         }
799         
800         public static String EdgeDefs() {
801                 StringBuilder sb = new StringBuilder(8092);
802                 sb.append("{\n" +
803                                 "       \"rules\": [\n");
804                 sb.append("             {\n");
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");
815                 sb.append("             },\n");
816                 sb.append("             {\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" +
827                                 "               },\n");
828                 sb.append("             {\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" +
839                                 "               }");
840                 sb.append("     ]\n" +
841                                 "}\n");
842                 return sb.toString();
843         }
844 }