diff options
Diffstat (limited to 'aai-core/src/test/java')
4 files changed, 151 insertions, 37 deletions
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(" <xs:element name=\"service-subscription\">\n"); sb.append(" <xs:complexType>\n"); @@ -218,7 +247,7 @@ public class HTMLfromOXMTest { sb.append(" </xs:appinfo>\r\n"); sb.append(" </xs:annotation>\r\n"); sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element name=\"service-type\" type=\"xs:string\">\n"); + sb.append(" <xs:element name=\"service-type\" type=\"xs:string\" minOccurs=\"0\">\n"); sb.append(" <xs:annotation>\r\n"); sb.append(" <xs:appinfo>\r\n"); sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")</annox:annotate>\r\n"); @@ -258,38 +287,60 @@ public class HTMLfromOXMTest { sb.append(" <xs:complexType>\n"); sb.append(" <xs:annotation>\r\n"); sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"class\">@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\")</annox:annotate>\r\n"); + if ( sbopt == 0 ) { + sb.append(" <annox:annotate target=\"class\">@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\")</annox:annotate>\r\n"); + } else { + sb.append(" <annox:annotate target=\"class\">@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\")</annox:annotate>\r\n"); + } sb.append(" </xs:appinfo>\r\n"); sb.append(" </xs:annotation>\r\n"); sb.append(" <xs:sequence>\n"); - sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\">\n"); + sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\" minOccurs=\"0\">\n"); sb.append(" <xs:annotation>\r\n"); sb.append(" <xs:appinfo>\r\n"); sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")</annox:annotate>\r\n"); sb.append(" </xs:appinfo>\r\n"); sb.append(" </xs:annotation>\r\n"); sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\">\n"); + sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\" minOccurs=\"0\">\n"); sb.append(" <xs:annotation>\r\n"); sb.append(" <xs:appinfo>\r\n"); sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>\r\n"); sb.append(" </xs:appinfo>\r\n"); sb.append(" </xs:annotation>\r\n"); sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); - sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); - sb.append(" <xs:annotation>\r\n"); - sb.append(" <xs:appinfo>\r\n"); - sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); - sb.append(" </xs:appinfo>\r\n"); - sb.append(" </xs:annotation>\r\n"); - sb.append(" </xs:element>\n"); + if ( sbopt == 0 ) { + sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">\n"); + sb.append(" <xs:annotation>\r\n"); + sb.append(" <xs:appinfo>\r\n"); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n"); + sb.append(" </xs:appinfo>\r\n"); + sb.append(" </xs:annotation>\r\n"); + sb.append(" </xs:element>\n"); + sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); + sb.append(" <xs:annotation>\r\n"); + sb.append(" <xs:appinfo>\r\n"); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); + sb.append(" </xs:appinfo>\r\n"); + sb.append(" </xs:annotation>\r\n"); + sb.append(" </xs:element>\n"); + } else { + sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n"); + sb.append(" <xs:annotation>\r\n"); + sb.append(" <xs:appinfo>\r\n"); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n"); + sb.append(" </xs:appinfo>\r\n"); + sb.append(" </xs:annotation>\r\n"); + sb.append(" </xs:element>\n"); + sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">\n"); + sb.append(" <xs:annotation>\r\n"); + sb.append(" <xs:appinfo>\r\n"); + sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n"); + sb.append(" </xs:appinfo>\r\n"); + sb.append(" </xs:annotation>\r\n"); + sb.append(" </xs:element>\n"); + + } sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>\n"); sb.append(" </xs:sequence>\n"); sb.append(" </xs:complexType>\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("</java-type>\n"); } + private void addCustomerNoSubscriberType(StringBuilder sb){ + sb.append("<java-type name=\"Customer\">\n"); + sb.append("<xml-root-element name=\"customer\" />\n"); + sb.append("<java-attributes>\n"); + sb.append("<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"description\" value=\"Global customer id used across to uniquely identify customer.\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</xml-element>\n"); + sb.append("<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</xml-element>\n"); + sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</xml-element>\n"); + sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n"); +// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n"); + sb.append("</java-attributes>\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n"); + sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n"); + sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id\" />\n"); + sb.append("<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n"); + sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n"); + sb.append("<xml-property name=\"container\" value=\"customers\" />\n"); + sb.append("<xml-property name=\"namespace\" value=\"business\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</java-type>\n"); + } + + private void addCustomerSubscriberType(StringBuilder sb){ + sb.append("<java-type name=\"Customer\">\n"); + sb.append("<xml-root-element name=\"customer\" />\n"); + sb.append("<java-attributes>\n"); + sb.append("<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n"); + sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</xml-element>\n"); + sb.append("</java-attributes>\n"); + sb.append("<xml-properties>\n"); + sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-type\" />\n"); + sb.append("<xml-property name=\"container\" value=\"customers\" />\n"); + sb.append("</xml-properties>\n"); + sb.append("</java-type>\n"); + } + private void addServiceSubscriptions(StringBuilder sb){ sb.append("<java-type name=\"ServiceSubscriptions\">\n"); sb.append("<xml-properties>\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 |