aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java
blob: aa03cd2ce0acdb47077315c0cee3a4a3116580b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
/**
 * ============LICENSE_START=======================================================
 * org.onap.aai
 * ================================================================================
 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 * ============LICENSE_END=========================================================
 */
package org.onap.aai.schemagen.genxsd;

import com.google.common.collect.Multimap;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.schemagen.SwaggerGenerationConfiguration;
import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.SortedSet;
import java.util.TreeSet;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
		SchemaVersions.class,
        SchemaLocationsBean.class,
        TestUtilConfigTranslatorforBusiness.class,
        SchemaVersions.class,
        EdgeIngestor.class,
        NodeIngestor.class,
		SwaggerGenerationConfiguration.class

})
@TestPropertySource(properties = {
		"schema.uri.base.path = /aai",
		"schema.xsd.maxoccurs = 5000"
})
public class YAMLfromOXMTest {
	@Autowired
    EdgeIngestor edgeIngestor;

	@Autowired
    NodeIngestor nodeIngestor;
	private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
	private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
	private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
	public static AnnotationConfigApplicationContext ctx = null;
	private static String testXML;
	protected static final String SERVICE_NAME = "JUNIT";
    boolean first = true;

    @Autowired
	YAMLfromOXM yamlFromOxm;

    @Autowired
    SchemaVersions schemaVersions;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		 System.setProperty("AJSC_HOME", ".");
	        System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
	        System.setProperty("aai.service.name", SERVICE_NAME);
	}
	
	

	@Before
	public void setUp() throws Exception {
        XSDElementTest x = new XSDElementTest();
		x.setUp();
		testXML = x.testXML;
		logger.debug(testXML);
		BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
		bw.write(testXML);
		bw.close();
		BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
		bw1.write(EdgeDefs());
		bw1.close();
    }
	
	public void setupRelationship() throws Exception{
        XSDElementTest x = new XSDElementTest();

		x.setUpRelationship();

		testXML = x.testXML;
		logger.debug(testXML);
		BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));

		bw.write(testXML);

		bw.close();
		BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
		bw1.write(EdgeDefs());
		bw1.close();
	}

	@Test
	public void AtestIngestors() throws EdgeRuleNotFoundException {
		Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
		SortedSet<String> ss=new TreeSet<String>(results.keySet());
		for(String key : ss) {
			results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
		}
		Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
		assertNotNull(doc);
	}

	@Test
	public void testGetDocumentHeader() {
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String header = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			yamlFromOxm.process();
			header = yamlFromOxm.getDocumentHeader();
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("Header:\n"+header,header, is(YAMLheader()));
	}

	@Test
	public void testProcess() {
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String fileContent = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			fileContent = yamlFromOxm.process();
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
	}

	@Test
	public void testYAMLfromOXMFileVersionFile() throws IOException {
		String outfileName = "testXML.xml";
		File XMLfile = new File(outfileName);
		XMLfile.createNewFile();
		BufferedWriter bw = null;
		Charset charset = Charset.forName("UTF-8");
		Path path = Paths.get(outfileName);
		bw = Files.newBufferedWriter(path, charset);
		bw.write(testXML);
		bw.close();
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String fileContent = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			fileContent = yamlFromOxm.process();
		} catch(Exception e) {
			e.printStackTrace();
		}
		XMLfile.delete();
		assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
	 }

	@Test
	public void testYAMLfromOXMStringVersionFile() {
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String fileContent = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			fileContent = yamlFromOxm.process();
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
	}
	
	@Test
	public void testRelationshipListYAMLfromOXMStringVersionFile() {
		try {
			setupRelationship();
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String fileContent = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			fileContent = yamlFromOxm.process();
		} catch(Exception e) {
			e.printStackTrace();
		}
		boolean matchFound = fileContent.contains(( YAMLRelationshipList()));
		assertTrue("RelationshipListFormat:\n", matchFound);
	}

	@Test
	public void testAppendDefinitions() {
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String definitions = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			yamlFromOxm.process();
			definitions = yamlFromOxm.appendDefinitions();
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLdefsAddPatch()));
	}

	@Test
	public void testGetXMLRootElementName() {
		String target = "RootElement=customer";
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		Element customer = null;
		String root = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			yamlFromOxm.process();
			customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
			root = yamlFromOxm.getXMLRootElementName(customer);
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("RootElement="+root, is(target));
	}

	@Test
	public void testGetXmlRootElementName() {
		String target = "RootElement=customer";
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		String root = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			yamlFromOxm.process();
			root = yamlFromOxm.getXmlRootElementName("Customer");
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("RootElement="+root, is(target));
	}

	@Test
	public void testGetJavaTypeElementSwagger() {
		String target = "Element=java-type/Customer";
		SchemaVersion v = schemaVersions.getAppRootVersion();
		String apiVersion = v.toString();
		Element customer = null;
		try {
			yamlFromOxm.setXmlVersion(testXML, v);
			yamlFromOxm.process();
			customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
		} catch(Exception e) {
			e.printStackTrace();
		}
		assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
	}

	public String YAMLresult() {
		StringBuilder sb = new StringBuilder(32368);
		sb.append(YAMLheader());
		sb.append(YAMLops());
		sb.append(YAMLdefs());
		sb.append(YAMLdefsAddPatch());
		return sb.toString();
	}
	public String YAMLheader() {
		StringBuilder sb = new StringBuilder(1500);
		sb.append("swagger: \"2.0\"\n");
		sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  description: |\n");
		sb.append("\n");
		sb.append("    [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
		sb.append("    Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
		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.\n");
		sb.append("\n");
		sb.append("    You may obtain a copy of the License at\n");
		sb.append("\n");
		sb.append("    (https://creativecommons.org/licenses/by/4.0/)\n");
		sb.append("\n");
		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);
		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);
		sb.append("  version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  license:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("    name: Apache 2.0\n");
		sb.append("    url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  contact:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("    name:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("    url:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("    email:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("host:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  - https\n");
		sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
		return sb.toString();
	}

	public String YAMLops() {
		StringBuilder sb = new StringBuilder(16384);
		sb.append("  /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
		sb.append("    get:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: returns service-subscription\n");
		sb.append("      description: returns service-subscription\n");
		sb.append("      operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"200\":\n");
		sb.append("          description: successful operation\n");
		sb.append("          schema:\n");
		sb.append("              $ref: \"#/definitions/service-subscription\"\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: service-type\n");
		sb.append("          in: path\n");
		sb.append("          description: Value defined by orchestration to identify this service.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __SERVICE-TYPE__\n");
		sb.append("    put:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: create or update an existing service-subscription\n");
		sb.append("      description: |\n");
		sb.append("        Create or update an existing service-subscription.\n");
		sb.append("        #\n");
		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");
		sb.append("      operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: service-type\n");
		sb.append("          in: path\n");
		sb.append("          description: Value defined by orchestration to identify this service.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __SERVICE-TYPE__\n");
		sb.append("        - name: body\n");
		sb.append("          in: body\n");
		sb.append("          description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
		sb.append("          required: true\n");
		sb.append("          schema:\n");
		sb.append("            $ref: \"#/definitions/service-subscription\"\n");
		sb.append("    patch:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: update an existing service-subscription\n");
		sb.append("      description: |\n");
		sb.append("        Update an existing service-subscription\n");
		sb.append("        #\n");
		sb.append("        Note:  Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
		sb.append("        The PUT operation will entirely replace an existing object.\n");
		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");
		sb.append("        #\n");
		sb.append("        Other differences between PUT and PATCH are:\n");
		sb.append("        #\n");
		sb.append("        - For PATCH, you can send any of the values shown in sample REQUEST body.  There are no required values.\n");
		sb.append("        - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
		sb.append("        - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
		sb.append("      operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: service-type\n");
		sb.append("          in: path\n");
		sb.append("          description: Value defined by orchestration to identify this service.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __SERVICE-TYPE__\n");
		sb.append("        - name: body\n");
		sb.append("          in: body\n");
		sb.append("          description: service-subscription object that needs to be updated.\n");
		sb.append("          required: true\n");
		sb.append("          schema:\n");
		sb.append("            $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
		sb.append("    delete:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: delete an existing service-subscription\n");
		sb.append("      description: delete an existing service-subscription\n");
		sb.append("      operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: service-type\n");
		sb.append("          in: path\n");
		sb.append("          description: Value defined by orchestration to identify this service.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __SERVICE-TYPE__\n");
		sb.append("        - name: resource-version\n");
		sb.append("          in: query\n");
		sb.append("          description: resource-version for concurrency\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("  /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
		sb.append("    get:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: returns service-subscriptions\n");
		sb.append("      description: returns service-subscriptions\n");
		sb.append("      operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"200\":\n");
		sb.append("          description: successful operation\n");
		sb.append("          schema:\n");
		sb.append("              $ref: \"#/definitions/service-subscriptions\"\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: service-type\n");
		sb.append("          in: query\n");
		sb.append("          description:\n");
		sb.append("          required: false\n");
		sb.append("          type: string\n");
		sb.append("  /business/customers/customer/{global-customer-id}:\n");
		sb.append("    get:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: returns customer\n");
		sb.append("      description: returns customer\n");
		sb.append("      operationId: getBusinessCustomersCustomer\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"200\":\n");
		sb.append("          description: successful operation\n");
		sb.append("          schema:\n");
		sb.append("              $ref: \"#/definitions/customer\"\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("    put:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: create or update an existing customer\n");
		sb.append("      description: |\n");
		sb.append("        Create or update an existing customer.\n");
		sb.append("        #\n");
		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");
		sb.append("      operationId: createOrUpdateBusinessCustomersCustomer\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: body\n");
		sb.append("          in: body\n");
		sb.append("          description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
		sb.append("          required: true\n");
		sb.append("          schema:\n");
		sb.append("            $ref: \"#/definitions/customer\"\n");
		sb.append("    patch:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: update an existing customer\n");
		sb.append("      description: |\n");
		sb.append("        Update an existing customer\n");
		sb.append("        #\n");
		sb.append("        Note:  Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
		sb.append("        The PUT operation will entirely replace an existing object.\n");
		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");
		sb.append("        #\n");
		sb.append("        Other differences between PUT and PATCH are:\n");
		sb.append("        #\n");
		sb.append("        - For PATCH, you can send any of the values shown in sample REQUEST body.  There are no required values.\n");
		sb.append("        - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
		sb.append("        - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
		sb.append("      operationId: UpdateBusinessCustomersCustomer\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: body\n");
		sb.append("          in: body\n");
		sb.append("          description: customer object that needs to be updated.\n");
		sb.append("          required: true\n");
		sb.append("          schema:\n");
		sb.append("            $ref: \"#/definitions/zzzz-patch-customer\"\n");
		sb.append("    delete:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: delete an existing customer\n");
		sb.append("      description: delete an existing customer\n");
		sb.append("      operationId: deleteBusinessCustomersCustomer\n");
		sb.append("      consumes:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: path\n");
		sb.append("          description: Global customer id used across to uniquely identify customer.\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("          example: __GLOBAL-CUSTOMER-ID__\n");
		sb.append("        - name: resource-version\n");
		sb.append("          in: query\n");
		sb.append("          description: resource-version for concurrency\n");
		sb.append("          required: true\n");
		sb.append("          type: string\n");
		sb.append("  /business/customers:\n");
		sb.append("    get:\n");
		sb.append("      tags:\n");
		sb.append("        - Business\n");
		sb.append("      summary: returns customers\n");
		sb.append("      description: returns customers\n");
		sb.append("      operationId: getBusinessCustomers\n");
		sb.append("      produces:\n");
		sb.append("        - application/json\n");
		sb.append("        - application/xml\n");
		sb.append("      responses:\n");
		sb.append("        \"200\":\n");
		sb.append("          description: successful operation\n");
		sb.append("          schema:\n");
		sb.append("              $ref: \"#/definitions/customers\"\n");
		sb.append("        \"default\":\n");
		sb.append("          null      parameters:\n");
		sb.append("        - name: global-customer-id\n");
		sb.append("          in: query\n");
		sb.append("          description:\n");
		sb.append("          required: false\n");
		sb.append("          type: string\n");
		sb.append("        - name: subscriber-name\n");
		sb.append("          in: query\n");
		sb.append("          description:\n");
		sb.append("          required: false\n");
		sb.append("          type: string\n");
		sb.append("        - name: subscriber-type\n");
		sb.append("          in: query\n");
		sb.append("          description:\n");
		sb.append("          required: false\n");
		sb.append("          type: string\n");
		return sb.toString();
	}
	public String YAMLdefs() {
		StringBuilder sb = new StringBuilder(8092);
		sb.append("definitions:\n");
		sb.append("  business:\n");
		sb.append("    description: |\n");
		sb.append("      Namespace for business related constructs\n");
		sb.append("    properties:\n");
		sb.append("      customers:\n");
		sb.append("        type: array\n");
		sb.append("        items:\n");
		sb.append("          $ref: \"#/definitions/customer\"\n");
		sb.append("  customer:\n");
		sb.append("    description: |\n");
		sb.append("      customer identifiers to provide linkage back to BSS information.\n");
		sb.append("      ###### Related Nodes\n");
		sb.append("      - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
		sb.append("\n");
		sb.append("      -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
		sb.append("    required:\n");
		sb.append("    - global-customer-id\n");
		sb.append("    - subscriber-name\n");
		sb.append("    - subscriber-type\n");
		sb.append("    properties:\n");
		sb.append("      global-customer-id:\n");
		sb.append("        type: string\n");
		sb.append("        description: Global customer id used across to uniquely identify customer.\n");
		sb.append("      subscriber-name:\n");
		sb.append("        type: string\n");
		sb.append("        description: Subscriber name, an alternate way to retrieve a customer.\n");
		sb.append("      subscriber-type:\n");
		sb.append("        type: string\n");
		sb.append("        description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
		sb.append("      resource-version:\n");
		sb.append("        type: string\n");
		sb.append("        description: Used for optimistic concurrency.  Must be empty on create, valid on update and delete.\n");
		sb.append("      service-subscriptions:\n");
		sb.append("        type: array\n");
		sb.append("        items:\n");
		sb.append("          $ref: \"#/definitions/service-subscription\"\n");
		sb.append("  customers:\n");
		sb.append("    description: |\n");
		sb.append("      Collection of customer identifiers to provide linkage back to BSS information.\n");
		sb.append("    properties:\n");
		sb.append("      customer:\n");
		sb.append("        type: array\n");
		sb.append("        items:          \n");
		sb.append("          $ref: \"#/definitions/customer\"\n");
		sb.append("  inventory:\n");
		sb.append("    properties:\n");
		sb.append("      business:\n");
		sb.append("        type: object\n");
		sb.append("        $ref: \"#/definitions/business\"\n");
		sb.append("  nodes:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("    properties:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("      inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("        type: array" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("        items:" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("          $ref: \"#/definitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
		sb.append("  service-subscription:\n");
		sb.append("    description: |\n");
		sb.append("      Object that group service instances.\n");
		sb.append("      ###### Related Nodes\n");
		sb.append("      - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
		sb.append("      - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
		sb.append("      - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
		sb.append("\n");
		sb.append("      -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
		sb.append("      -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
		sb.append("    required:\n");
		sb.append("    - service-type\n");
		sb.append("    properties:\n");
		sb.append("      service-type:\n");
		sb.append("        type: string\n");
		sb.append("        description: Value defined by orchestration to identify this service.\n");
		sb.append("      temp-ub-sub-account-id:\n");
		sb.append("        type: string\n");
		sb.append("        description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
		sb.append("      resource-version:\n");
		sb.append("        type: string\n");
		sb.append("        description: Used for optimistic concurrency.  Must be empty on create, valid on update and delete.\n");
		sb.append("  service-subscriptions:\n");
		sb.append("    description: |\n");
		sb.append("      Collection of objects that group service instances.\n");
		sb.append("    properties:\n");
		sb.append("      service-subscription:\n");
		sb.append("        type: array\n");
		sb.append("        items:          \n");
		sb.append("          $ref: \"#/definitions/service-subscription\"\n");
		return sb.toString();
	}
	public String YAMLdefsAddPatch() {
		StringBuilder sb = new StringBuilder(8092);
		sb.append("  zzzz-patch-customer:\n");
		sb.append("    description: |\n");
		sb.append("      customer identifiers to provide linkage back to BSS information.\n");
		sb.append("      ###### Related Nodes\n");
		sb.append("      - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
		sb.append("\n");
		sb.append("      -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
		sb.append("    properties:\n");
		sb.append("      global-customer-id:\n");
		sb.append("        type: string\n");
		sb.append("        description: Global customer id used across to uniquely identify customer.\n");
		sb.append("      subscriber-name:\n");
		sb.append("        type: string\n");
		sb.append("        description: Subscriber name, an alternate way to retrieve a customer.\n");
		sb.append("      subscriber-type:\n");
		sb.append("        type: string\n");
		sb.append("        description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
		sb.append("  zzzz-patch-service-subscription:\n");
		sb.append("    description: |\n");
		sb.append("      Object that group service instances.\n");
		sb.append("      ###### Related Nodes\n");
		sb.append("      - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
		sb.append("      - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
		sb.append("      - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
		sb.append("\n");
		sb.append("      -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
		sb.append("      -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
		sb.append("    properties:\n");
		sb.append("      service-type:\n");
		sb.append("        type: string\n");
		sb.append("        description: Value defined by orchestration to identify this service.\n");
		sb.append("      temp-ub-sub-account-id:\n");
		sb.append("        type: string\n");
		sb.append("        description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
		return sb.toString();
	}
	
	public String YAMLRelationshipList() {
		StringBuilder sb = new StringBuilder(8092);
		sb.append("  relationship-list:\n");
		sb.append("    properties:\n");
		sb.append("      relationship:\n");
		sb.append("        type: object\n");
		sb.append("        $ref: \"#/definitions/relationship\"\n");
		return sb.toString();
	}
	
	public static String EdgeDefs() {
		StringBuilder sb = new StringBuilder(8092);
		sb.append("{\n" +
				"	\"rules\": [\n");
		sb.append("		{\n");
		sb.append("			\"from\": \"service-subscription\",\n");
		sb.append("			\"to\": \"customer\",\n" +
				"			\"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
				"			\"direction\": \"OUT\",\n" +
				"			\"multiplicity\": \"MANY2ONE\",\n" +
				"			\"contains-other-v\": \"!${direction}\",\n" +
				"			\"delete-other-v\": \"!${direction}\",\n" +
				"			\"prevent-delete\": \"NONE\",\n" +
				"			\"default\": \"true\",\n" +
				"			\"description\":\"\"\n");
		sb.append("		},\n");
		sb.append("		{\n" +
				"			\"from\": \"service-instance\",\n" +
				"			\"to\": \"service-subscription\",\n" +
				"			\"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
				"			\"direction\": \"OUT\",\n" +
				"			\"multiplicity\": \"MANY2ONE\",\n" +
				"			\"contains-other-v\": \"!${direction}\",\n" +
				"			\"delete-other-v\": \"!${direction}\",\n" +
				"			\"prevent-delete\": \"NONE\",\n" +
				"			\"default\": \"true\",\n" +
				"			\"description\":\"\"\n" +
				"		},\n");
		sb.append("		{\n" +
				"			\"from\": \"service-subscription\",\n" +
				"			\"to\": \"tenant\",\n" +
				"			\"label\": \"org.onap.relationships.inventory.Uses\",\n" +
				"			\"direction\": \"OUT\",\n" +
				"			\"multiplicity\": \"MANY2MANY\",\n" +
				"			\"contains-other-v\": \"NONE\",\n" +
				"			\"delete-other-v\": \"NONE\",\n" +
				"			\"prevent-delete\": \"NONE\",\n" +
				"			\"default\": \"true\",\n" +
				"			\"description\":\"\"\n" +
				"		}");
		sb.append("	]\n" +
				"}\n");
		return sb.toString();
	}
}