From 0fdb2155e5c1d0e721709dd00c9dd55c175f0356 Mon Sep 17 00:00:00 2001 From: "LaMont, William (wl2432)" Date: Tue, 25 Sep 2018 15:31:25 -0400 Subject: fix xsd generation when obj crosses oxm files Issue-ID: AAI-1654 Change-Id: I118b0d94099c7f986303fc9dd9e5dae5144b4bbb Signed-off-by: LaMont, William (wl2432) --- .../org/onap/aai/util/genxsd/HTMLfromOXMTest.java | 101 ++++++++++++++++----- .../onap/aai/util/genxsd/NodesYAMLfromOXMTest.java | 3 +- .../org/onap/aai/util/genxsd/XSDElementTest.java | 81 +++++++++++++++-- .../org/onap/aai/util/genxsd/YAMLfromOXMTest.java | 3 +- 4 files changed, 151 insertions(+), 37 deletions(-) (limited to 'aai-core/src/test') diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java index d35cc4f0..5e019196 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java @@ -65,7 +65,8 @@ import org.w3c.dom.Element; }) @TestPropertySource(properties = { - "schema.uri.base.path = /aai" + "schema.uri.base.path = /aai", + "schema.xsd.maxoccurs = 5000" }) public class HTMLfromOXMTest { private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXMTest.class"); @@ -95,14 +96,18 @@ public class HTMLfromOXMTest { @Before public void setUp() throws Exception { + setUp(0); + } + + public void setUp(int sbopt) throws Exception + { XSDElementTest x = new XSDElementTest(); - x.setUp(); + x.setUp(sbopt); testXML = x.testXML; logger.debug(testXML); BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME)); bw.write(testXML); bw.close(); - } @Test @@ -133,7 +138,23 @@ public class HTMLfromOXMTest { } logger.debug("FileContent-I:"); logger.debug(fileContent); - assertThat(fileContent, is(HTMLresult())); + assertThat(fileContent, is(HTMLresult(0))); + } + + @Test + public void testProcessWithCombiningJavaTypes() { + SchemaVersion v = schemaVersions.getAppRootVersion(); + String fileContent = null; + try { + setUp(1); + htmlFromOxm.setXmlVersion(testXML, v); + fileContent = htmlFromOxm.process(); + } catch(Exception e) { + e.printStackTrace(); + } + logger.debug("FileContent-I:"); + logger.debug(fileContent); + assertThat(fileContent, is(HTMLresult(1))); } @Test @@ -158,7 +179,7 @@ public class HTMLfromOXMTest { XMLfile.delete(); logger.debug("FileContent-I:"); logger.debug(fileContent); - assertThat(fileContent, is(HTMLresult())); + assertThat(fileContent, is(HTMLresult(0))); } @Test @@ -173,7 +194,7 @@ public class HTMLfromOXMTest { } logger.debug("FileContent-II:"); logger.debug(fileContent); - assertThat(fileContent, is(HTMLresult())); + assertThat(fileContent, is(HTMLresult(0))); } @Test @@ -193,9 +214,13 @@ public class HTMLfromOXMTest { assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target)); } public String HTMLresult() { + return HTMLresult(0); + } + + public String HTMLresult(int sbopt) { StringBuilder sb = new StringBuilder(32368); sb.append(HTMLheader()); - sb.append(HTMLdefs()); + sb.append(HTMLdefs(sbopt)); return sb.toString(); } @@ -208,7 +233,11 @@ public class HTMLfromOXMTest { sb.append(" jaxb:extensionBindingPrefixes=\"annox\">\n\n"); return sb.toString(); } + public String HTMLdefs() { + return HTMLdefs(0); + } + public String HTMLdefs(int sbopt) { StringBuilder sb = new StringBuilder(1500); sb.append(" \n"); sb.append(" \n"); @@ -218,7 +247,7 @@ public class HTMLfromOXMTest { sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" \n"); - sb.append(" \n"); + sb.append(" \n"); sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" @org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")\r\n"); @@ -258,38 +287,60 @@ public class HTMLfromOXMTest { sb.append(" \n"); sb.append(" \r\n"); sb.append(" \r\n"); - sb.append(" @org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")\r\n"); + if ( sbopt == 0 ) { + sb.append(" @org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")\r\n"); + } else { + sb.append(" @org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-type,subscriber-name,global-customer-id\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")\r\n"); + } sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" \n"); - sb.append(" \n"); + sb.append(" \n"); sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" @org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")\r\n"); sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" \n"); - sb.append(" \n"); + sb.append(" \n"); sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" @org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")\r\n"); sb.append(" \r\n"); sb.append(" \r\n"); sb.append(" \n"); - sb.append(" \n"); - sb.append(" \r\n"); - sb.append(" \r\n"); - sb.append(" @org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")\r\n"); - sb.append(" \r\n"); - sb.append(" \r\n"); - sb.append(" \n"); - sb.append(" \n"); - sb.append(" \r\n"); - sb.append(" \r\n"); - sb.append(" @org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")\r\n"); - sb.append(" \r\n"); - sb.append(" \r\n"); - sb.append(" \n"); + if ( sbopt == 0 ) { + sb.append(" \n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" @org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")\r\n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" \n"); + sb.append(" \n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" @org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")\r\n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" \n"); + } else { + sb.append(" \n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" @org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")\r\n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" \n"); + sb.append(" \n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" @org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")\r\n"); + sb.append(" \r\n"); + sb.append(" \r\n"); + sb.append(" \n"); + + } sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java index 2dfcd4ed..b19a524b 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/NodesYAMLfromOXMTest.java @@ -64,7 +64,8 @@ import org.w3c.dom.Element; }) @TestPropertySource(properties = { - "schema.uri.base.path = /aai" + "schema.uri.base.path = /aai", + "schema.xsd.maxoccurs = 5000" }) public class NodesYAMLfromOXMTest { //public class NodesYAMLfromOXMTest extends AAISetup { diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java index 94047c37..7f0d1ed7 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java @@ -70,16 +70,25 @@ public class XSDElementTest { @Before public void setUp() throws Exception { - StringBuilder sb = new StringBuilder(maxSizeForXml); - addNamespace(sb); - addBusiness(sb); - addCustomers(sb); - addCustomer(sb); - addServiceSubscriptions(sb); - addServiceSubscription(sb); - addEndOfXML(sb); - testXML = sb.toString(); - init(); + setUp(0); + } + + public void setUp(int sbopt) throws Exception { + StringBuilder sb = new StringBuilder(maxSizeForXml); + addNamespace(sb); + addBusiness(sb); + addCustomers(sb); + if ( sbopt == 0 ) { + addCustomer(sb); + } else { + addCustomerNoSubscriberType(sb); + addCustomerSubscriberType(sb); + } + addServiceSubscriptions(sb); + addServiceSubscription(sb); + addEndOfXML(sb); + testXML = sb.toString(); + init(); } private void addNamespace(StringBuilder sb){ @@ -163,6 +172,58 @@ public class XSDElementTest { sb.append("\n"); } + private void addCustomerNoSubscriberType(StringBuilder sb){ + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); +// sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + } + + private void addCustomerSubscriberType(StringBuilder sb){ + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + } + private void addServiceSubscriptions(StringBuilder sb){ sb.append("\n"); sb.append("\n"); diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java index e1288978..813ad837 100644 --- a/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java @@ -76,7 +76,8 @@ import com.google.common.collect.Multimap; }) @TestPropertySource(properties = { - "schema.uri.base.path = /aai" + "schema.uri.base.path = /aai", + "schema.xsd.maxoccurs = 5000" }) public class YAMLfromOXMTest { @Autowired -- cgit 1.2.3-korg