summaryrefslogtreecommitdiffstats
path: root/aai-schema/src
diff options
context:
space:
mode:
authorEric Santos <eric.santos@yoppworks.com>2021-01-27 14:34:17 -0500
committerEric Santos <eric.santos@yoppworks.com>2021-01-27 14:34:17 -0500
commitbd6468173eec459beea471778d20a7ff0278aad0 (patch)
tree3664718b16d2e7e924e01e9f1fcbf72c7e7d4deb /aai-schema/src
parent282ae8d55e130a6442c1c5512fd07e63a5720bc4 (diff)
Unit test for ownerCheck
Issue-ID: AAI-3256 Signed-off-by: Santos, Eric <eric.santos@yoppworks.com> Change-Id: I02a8e2be8a3bac4f5986c03b9a4aa7e803f70d43
Diffstat (limited to 'aai-schema/src')
-rw-r--r--aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java49
1 files changed, 49 insertions, 0 deletions
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 79323aa..a65ddd9 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
@@ -628,6 +628,55 @@ public class ValidateOXMTest {
}
/**
+ * Check dataOwner elements to ensure that they have ownerCheck side effect added to it.
+ *
+ */
+ @Test
+ public void testDataOwnerWithOwnerCheck() throws XPathExpressionException, IOException, SAXException, ParserConfigurationException, ParseException {
+ List<File> fileList = getLatestFiles();
+
+ for (File file : fileList) {
+ Document xmlDocument = getDocument(file);
+ XPath xPath = XPathFactory.newInstance().newXPath();
+ String expression = "/xml-bindings/java-types/java-type/java-attributes/xml-element[@name='data-owner']";
+ NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
+
+ List<String> typeMissingOwnerCheck = new ArrayList<>();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ String type = nodeList.item(i).getParentNode().getParentNode().getAttributes().getNamedItem("name").getNodeValue();
+ NodeList xmlPropertiesList = ((Element) nodeList.item(i)).getElementsByTagName("xml-properties");
+
+ boolean missingOwnerCheck = true;
+ for (int j = 0; j < xmlPropertiesList.getLength(); j++) {
+ NodeList xmlProperties = ((Element) xmlPropertiesList.item(j)).getElementsByTagName("xml-property");
+
+ for (int k = 0; k < xmlProperties.getLength(); k++) {
+ String xmlProp = xmlProperties.item(k).getAttributes().getNamedItem("name").getNodeValue();
+
+ if ("ownerCheck".equals(xmlProp)) {
+ missingOwnerCheck = false;
+ break;
+ }
+ }
+
+ if (!missingOwnerCheck) {
+ break;
+ }
+ }
+
+ if (missingOwnerCheck) {
+ typeMissingOwnerCheck.add(type);
+ }
+ }
+
+ if (!typeMissingOwnerCheck.isEmpty()) {
+ fail(file.getAbsolutePath().replaceAll(".*aai-schema", "") + ": " + String.join(", ", typeMissingOwnerCheck));
+ }
+ }
+ }
+
+ /**
* Null check for strings
* @param s
* @return