diff options
-rw-r--r-- | aai-annotations/pom.xml | 4 | ||||
-rw-r--r-- | aai-queries/pom.xml | 4 | ||||
-rw-r--r-- | aai-schema-gen/pom.xml | 4 | ||||
-rw-r--r-- | aai-schema-service/pom.xml | 4 | ||||
-rw-r--r-- | aai-schema/pom.xml | 4 | ||||
-rw-r--r-- | aai-schema/src/main/resources/onap/oxm/v16/aai_oxm_v16.xml | 14 | ||||
-rw-r--r-- | aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java | 119 | ||||
-rw-r--r-- | pom.xml | 4 | ||||
-rw-r--r-- | version.properties | 2 |
9 files changed, 130 insertions, 29 deletions
diff --git a/aai-annotations/pom.xml b/aai-annotations/pom.xml index 13443be..edd99cf 100644 --- a/aai-annotations/pom.xml +++ b/aai-annotations/pom.xml @@ -27,12 +27,12 @@ <parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> </parent> <artifactId>aai-annotations</artifactId> <name>aai-annotations</name> <packaging>jar</packaging> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> </properties> diff --git a/aai-queries/pom.xml b/aai-queries/pom.xml index a807229..a70da3f 100644 --- a/aai-queries/pom.xml +++ b/aai-queries/pom.xml @@ -27,11 +27,11 @@ <parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> </parent> <artifactId>aai-queries</artifactId> <name>aai-queries</name> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> <!-- Start of Default ONAP Schema Properties --> diff --git a/aai-schema-gen/pom.xml b/aai-schema-gen/pom.xml index 2b5175e..2fcce4c 100644 --- a/aai-schema-gen/pom.xml +++ b/aai-schema-gen/pom.xml @@ -27,11 +27,11 @@ <parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> </parent> <artifactId>aai-schema-gen</artifactId> <name>aai-schema-gen</name> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> <!-- Start of Default ONAP Schema Properties --> diff --git a/aai-schema-service/pom.xml b/aai-schema-service/pom.xml index b35f751..1c6a1d3 100644 --- a/aai-schema-service/pom.xml +++ b/aai-schema-service/pom.xml @@ -25,11 +25,11 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> </parent> <properties> <java.version>1.8</java.version> diff --git a/aai-schema/pom.xml b/aai-schema/pom.xml index 34f4a26..127aa25 100644 --- a/aai-schema/pom.xml +++ b/aai-schema/pom.xml @@ -27,11 +27,11 @@ <parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> </parent> <artifactId>aai-schema</artifactId> <name>aai-schema</name> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> <!-- Start of Default ONAP Schema Properties --> diff --git a/aai-schema/src/main/resources/onap/oxm/v16/aai_oxm_v16.xml b/aai-schema/src/main/resources/onap/oxm/v16/aai_oxm_v16.xml index aaf9e5c..78f71f5 100644 --- a/aai-schema/src/main/resources/onap/oxm/v16/aai_oxm_v16.xml +++ b/aai-schema/src/main/resources/onap/oxm/v16/aai_oxm_v16.xml @@ -3845,7 +3845,7 @@ <xml-properties> <xml-property name="description" value="VPN binding"/> <xml-property name="nameProps" value="vpn-name,vpn-type"/> - <xml-property name="indexedProps" value="vpn-name,vpn-id,vpn-type,access-provider-id,access-client-id,access-topology-id,src-access-node-id,src-access-ltp-id,dst-access-node-id,dst-access-ltp-id,operational-status"/> + <xml-property name="indexedProps" value="vpn-name,vpn-id,vpn-type,access-provider-id,access-client-id,access-topology-id,src-access-node-id,src-access-ltp-id,dst-access-node-id,dst-access-ltp-id,operational-status,model-invariant-id,model-version-id"/> <xml-property name="searchable" value="vpn-id,vpn-name"/> <xml-property name="uniqueProps" value="vpn-id"/> <xml-property name="container" value="vpn-bindings"/> @@ -7718,7 +7718,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of an sp-partner"/> - <xml-property name="indexedProps" value="sp-partner-id,url,callsource"/> + <xml-property name="indexedProps" value="sp-partner-id,url,callsource,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="sp-partner-id"/> <xml-property name="searchable" value="sp-partner-id"/> <xml-property name="uniqueProps" value="sp-partner-id"/> @@ -7863,7 +7863,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of a connectivity"/> - <xml-property name="indexedProps" value="connectivity-id,etht-svc-name,bandwidth-profile-name,vpn-type,color-aware,coupling-flag,access-provider-id,access-client-id,access-topology-id,access-node-id,access-ltp-id,operational-status"/> + <xml-property name="indexedProps" value="connectivity-id,etht-svc-name,bandwidth-profile-name,vpn-type,color-aware,coupling-flag,access-provider-id,access-client-id,access-topology-id,access-node-id,access-ltp-id,operational-status,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="etht-svc-name"/> <xml-property name="searchable" value="connectivity-id"/> <xml-property name="uniqueProps" value="connectivity-id"/> @@ -8188,7 +8188,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of a site-resource"/> - <xml-property name="indexedProps" value="site-resource-id,site-resource-name,type,role,generated-site-id,operational-status"/> + <xml-property name="indexedProps" value="site-resource-id,site-resource-name,type,role,generated-site-id,operational-status,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="site-resource-name"/> <xml-property name="searchable" value="site-resource-id"/> <xml-property name="uniqueProps" value="site-resource-id"/> @@ -8291,7 +8291,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of an sdwan-vpn"/> - <xml-property name="indexedProps" value="sdwan-vpn-id,sdwan-vpn-name,vxlan-id,topology,operational-status"/> + <xml-property name="indexedProps" value="sdwan-vpn-id,sdwan-vpn-name,vxlan-id,topology,operational-status,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="sdwan-vpn-name"/> <xml-property name="searchable" value="sdwan-vpn-id"/> <xml-property name="uniqueProps" value="sdwan-vpn-id"/> @@ -8410,7 +8410,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of a device"/> - <xml-property name="indexedProps" value="device-id,device-name,esn,vendor,class,type,version,system-ip,system-ipv4,system-ipv6,operational-status"/> + <xml-property name="indexedProps" value="device-id,device-name,esn,vendor,class,type,version,system-ip,system-ipv4,system-ipv6,operational-status,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="device-name"/> <xml-property name="searchable" value="device-id"/> <xml-property name="uniqueProps" value="device-id"/> @@ -8555,7 +8555,7 @@ </java-attributes> <xml-properties> <xml-property name="description" value="Instance of a wan-port-config"/> - <xml-property name="indexedProps" value="wan-port-config-id,wan-port-config-name,device-id,ip-address,ipv4-address,ipv6-address,port-type,port-number,device-port-id,wan-port-id,operational-status"/> + <xml-property name="indexedProps" value="wan-port-config-id,wan-port-config-name,device-id,ip-address,ipv4-address,ipv6-address,port-type,port-number,device-port-id,wan-port-id,operational-status,model-invariant-id,model-version-id"/> <xml-property name="nameProps" value="wan-port-config-name"/> <xml-property name="searchable" value="wan-port-config-id"/> <xml-property name="uniqueProps" value="wan-port-config-id"/> diff --git a/aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java b/aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java index cd8c76f..0dcf1b3 100644 --- a/aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java +++ b/aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java @@ -20,10 +20,10 @@ package org.onap.aai.schema; -//import org.junit.Test; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.DirectoryFileFilter; +import org.apache.commons.io.filefilter.FileFileFilter; +import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.RegexFileFilter; import org.junit.Test; import org.w3c.dom.Document; @@ -39,14 +39,12 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import java.io.*; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class ValidateOXMTest { @@ -54,7 +52,7 @@ public class ValidateOXMTest { @Test public void testFindXmlPropContainingSpace() throws XPathExpressionException, IOException, SAXException, ParserConfigurationException { boolean foundIssue = false; - List<File> fileList = getFiles(); + List<File> fileList = getLatestFiles(); StringBuilder msg = new StringBuilder(); for (File file : fileList) { @@ -101,7 +99,13 @@ public class ValidateOXMTest { msg.append("\n"); Document xmlDocument = getDocument(file); XPath xPath = XPathFactory.newInstance().newXPath(); - String expression = "/xml-bindings/java-types/java-type[count(xml-properties/xml-property[@name='container']) > 0 and count(xml-properties/xml-property[@name='uriTemplate']) = 0 ]"; + String expression = "/xml-bindings/java-types/java-type[" + + "(" + + "count(xml-properties/xml-property[@name='container']) > 0 " + + "or count(xml-properties/xml-property[@name='dependentOn']) > 0" + + ") " + + "and count(xml-properties/xml-property[@name='uriTemplate']) = 0 " + + "]"; NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { @@ -122,16 +126,113 @@ public class ValidateOXMTest { } + + /** + * Verifies that all specified properties are indexed + * Currently set to check that "model-invariant-id","model-version-id" which are aliased are indexed + * @throws XPathExpressionException + * @throws IOException + * @throws SAXException + * @throws ParserConfigurationException + */ + @Test + public void aliasedIndexedPropsAreInIndexedListWithPropName() throws XPathExpressionException, IOException, SAXException, ParserConfigurationException { + + final List<String> props = Arrays.asList("model-invariant-id","model-version-id"); + + boolean foundIssue = false; + List<File> fileList = getLatestFiles(); + StringBuilder msg = new StringBuilder(); + + for (File file : fileList) { + msg.append(file.getAbsolutePath().replaceAll(".*aai-schema", "")); + msg.append("\n"); + for (String prop : props) { + Document xmlDocument = getDocument(file); + XPath xPath = XPathFactory.newInstance().newXPath(); + String expression = "/xml-bindings/java-types/java-type[" + + "(" + + "count(xml-properties/xml-property[@name='container']) > 0 " + + "or count(xml-properties/xml-property[@name='dependentOn']) > 0" + + ") " + + "and count(xml-properties/xml-property[@name='indexedProps' and not(contains(@value,'" + prop + "'))]) > 0 " + //prop is not in indexed props list + "and count(java-attributes/xml-element[@name='" + prop + "']) > 0 " + // prop is a property on obj + "]"; + + NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); + + if (nodeList.getLength() > 0) { + msg.append("\t") + .append(prop) + .append("\n"); + } + for (int i = 0; i < nodeList.getLength(); i++) { + String name = nodeList.item(i).getAttributes().getNamedItem("name").getNodeValue(); + if (name.equals("InstanceFilter") || name.equals("InventoryResponseItems") || name.equals("InventoryResponseItem")) { + continue; + } + foundIssue = true; + msg.append("\t\t") + .append(name) + .append("\n"); + } + } + } + + if (foundIssue) { + System.out.println(msg.toString()); + fail("Missing index entry in oxm."); + } + + } + private List<File> getFiles() { Path currentRelativePath = Paths.get("../aai-schema/src/main/resources/").toAbsolutePath(); return FileUtils.listFiles( currentRelativePath.toFile(), new RegexFileFilter(".*\\.xml"), DirectoryFileFilter.DIRECTORY) - .stream().filter(file -> file.getAbsolutePath().contains("oxm")) + .stream() + .filter(file -> file.getAbsolutePath().contains("oxm")) + .filter(file -> !file.getAbsolutePath().contains("onap")) // skips onap for checks .collect(Collectors.toList()); } + /** + * Finds all of the oxm files for the latest version. + * @return list of the latest version of the oxm files. + */ + private List<File> getLatestFiles() { + List<String> latest = new ArrayList<>(); + Path currentRelativePath = Paths.get("../aai-schema/src/main/resources/").toAbsolutePath(); + List<File> subDirs = Arrays.asList(currentRelativePath.toFile().listFiles(File::isDirectory)); + for (File subDir : subDirs) { + String oxm = subDir.getAbsolutePath() + "/oxm"; + File[] oxms = new File(oxm).listFiles(File::isDirectory); + Arrays.stream(oxms).map(File::getAbsolutePath).max(new Comparator<String>() { + public int compare(String o1, String o2) { + return extractInt(o1) - extractInt(o2); + } + int extractInt(String s) { + String num = s.replaceAll("\\D", ""); + return num.isEmpty() ? 0 : Integer.parseInt(num); + } + }).ifPresent(latest::add); + } + + List<File> latestFiles = new ArrayList<>(); + latest.forEach(s -> + FileUtils.listFiles( + new File(s), + new RegexFileFilter(".*\\.xml"), + DirectoryFileFilter.DIRECTORY) + .stream() + .filter(file -> file.getAbsolutePath().contains("oxm")) + .forEach(latestFiles::add)); + + return latestFiles; + } + //TODO test that all oxm xml are valid xml @@ -30,7 +30,7 @@ </parent> <groupId>org.onap.aai.schema-service</groupId> <artifactId>schema-service</artifactId> - <version>1.0.2-SNAPSHOT</version> + <version>1.0.3-SNAPSHOT</version> <name>aai-schema-service</name> <packaging>pom</packaging> <modules> @@ -126,7 +126,7 @@ <include>src/test/java/**</include> <include>pom.xml</include> </includes> - <skipExistingHeaders>false</skipExistingHeaders> + <skipExistingHeaders>true</skipExistingHeaders> <skip>false</skip> <validHeaders> <header>LICENSE_ALT1.txt</header> diff --git a/version.properties b/version.properties index 7c09f12..88f8ce6 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ # because they are used in Jenkins, whose plug-in doesn't support major_version=1 minor_version=0 -patch_version=2 +patch_version=3 base_version=${major_version}.${minor_version}.${patch_version} # Release must be completed with GIT information # in Jenkins release_version=${base_version} |