summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-09-15 07:43:00 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-09-15 07:50:51 -0400
commit4bf722bff30e0b08586946eb973facf0022d3989 (patch)
tree4753784d55e3000c474c50c13336216f1944aa07 /aai-core/src/test/java
parentd4a0f78244d85b406a11735f84c7dd0e50eda296 (diff)
Increase code coverage for aai-common repo to 30%
Issue-ID: AAI-215 Change-Id: Ied7d885274d83fa183880ca683a2c440818e66dc Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java86
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java70
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java2
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java18
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java40
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java13
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java38
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java54
10 files changed, 197 insertions, 132 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java b/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
deleted file mode 100644
index 7cf5ac71..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 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.openecomp.aai.dbmodel;
-
-import com.google.common.collect.ImmutableSetMultimap;
-import com.google.common.collect.Multimap;
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-import java.io.*;
-import java.util.Map.Entry;
-
-import static org.junit.Assert.*;
-
-public class DbEdgeRulesConverterTest {
-
- @Test
- public void testExtractData() {
- Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
- .putAll("availability-zone|complex",
- "groupsResourcesIn,OUT,Many2Many,false,true,false,true").build();
-
- DbEdgeRulesConverter dberConverter = new DbEdgeRulesConverter();
-
- for (Entry<String, String> r : EdgeRules.entries()) {
- EdgeRuleBean bean = dberConverter.extractData(r);
- assertEquals("from availability-zone", "availability-zone", bean.getFrom());
- assertEquals("to complex", "complex", bean.getTo());
- assertEquals("label", "groupsResourcesIn", bean.getLabel());
- assertEquals("direction", "OUT", bean.getDirection());
- assertEquals("multiplicity", "Many2Many", bean.getMultiplicity());
- assertEquals("isParent", "false", bean.getIsParent());
- assertEquals("usesResource", "true", bean.getUsesResource());
- assertEquals("hasDelTarget", "false", bean.getHasDelTarget());
- assertEquals("SVC-INFRA", "true", bean.getSvcInfra());
- }
- }
-
- @Test
- public void testConvert(){
- DbEdgeRulesConverter dberCon = new DbEdgeRulesConverter();
- String dest = "src/test/resources/dbEdgeRulesConversion";
- String outFile = dest + "/testOutput.json";
-
- Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
- .putAll("foo|bar",
- "has,OUT,Many2Many,false,false,false,false")
- .putAll("baz|quux",
- "treatsVeryKindly,IN,One2One,true,true,true,true")
- .build();
-
- try {
- dberCon.setup(dest);
- File result = new File(outFile);
- //Add delete hook to delete the temporary result file on exit/
- result.deleteOnExit();
- FileOutputStream writeStream = new FileOutputStream(result);
- Writer writer = new OutputStreamWriter(writeStream);
- dberCon.convert(EdgeRules, writer);
- File compare = new File("src/test/resources/dbEdgeRulesConversion/conversionTestCompare.json");
- assertTrue(FileUtils.contentEquals(result, compare));
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- fail("IOException on setup");
- }
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java
new file mode 100644
index 00000000..8752e6f1
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.aai.logging;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import org.junit.*;
+
+public class EelfClassOfCallerTest {
+
+ EelfClassOfCaller _eelfClassOfCaller;
+ ILoggingEvent mockEvent;
+ StackTraceElement[] cdafive = new StackTraceElement[5];
+ StackTraceElement[] cdaone = new StackTraceElement[1];
+ StackTraceElement[] cdazero = new StackTraceElement[0];
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ mockEvent = mock(ILoggingEvent.class);
+ _eelfClassOfCaller= spy(EelfClassOfCaller.class);
+
+ }
+
+
+ @Test
+ public void getFullyQualifiedNameCDALENFiveTest(){
+ StackTraceElement temp = new StackTraceElement("classname_five","methodname","filename", 4);
+ cdafive[2]=temp;
+ when(mockEvent.getCallerData()).thenReturn(cdafive);
+ assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_five");
+
+ }
+ @Test
+ public void getFullyQualifiedNameCDALenOneTest(){
+ StackTraceElement temp = new StackTraceElement("classname_one","methodname","filename", 4);
+ cdaone[0]=temp;
+ when(mockEvent.getCallerData()).thenReturn(cdaone);
+ assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_one");
+
+ }
+
+ @Test
+ public void getFullyQualifiedNameCDALenZeroTest(){
+ when(mockEvent.getCallerData()).thenReturn(cdazero);
+ assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"?");
+
+ }
+
+}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
index 5c68fc67..baaad6c9 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
@@ -92,7 +92,6 @@ public class LegacyQueryTest extends AAISetup {
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws AAIException the AAI exception
*/
- @Ignore
@Test
public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key1/lag-interfaces/lag-interface/key2").build();
@@ -125,7 +124,6 @@ public class LegacyQueryTest extends AAISetup {
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws AAIException the AAI exception
*/
- @Ignore
@Test
public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
index bc20af11..092d5c66 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
@@ -84,8 +84,6 @@ public class RelationshipToURITest extends AAISetup {
thrown.expect(AAIIdentityMapParseException.class);
thrown.expect(hasProperty("code", is("AAI_3000")));
RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
-
URI uri = parse.getUri();
}
@@ -97,8 +95,6 @@ public class RelationshipToURITest extends AAISetup {
URI expected = new URI("/network/test-objects/test-object/key2");
RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
-
URI uri = parse.getUri();
assertEquals("related-link is equal", expected, uri);
@@ -122,6 +118,20 @@ public class RelationshipToURITest extends AAISetup {
}
@Test
+ public void failNothingToParse() throws AAIException, URISyntaxException, IOException {
+ Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
+ Introspector obj = loader.unmarshal("relationship", this.getJsonString("nothing-to-parse.json"));
+ URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
+
+ thrown.expect(AAIIdentityMapParseException.class);
+ thrown.expect(hasProperty("code", is("AAI_3000")));
+ RelationshipToURI parse = new RelationshipToURI(loader, obj);
+
+ URI uri = parse.getUri();
+
+ }
+
+ @Test
public void successV10() throws AAIException, URISyntaxException, IOException {
Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-successv10-failv9.json"));
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java
index 9aabdf1a..626e97ab 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java
@@ -26,6 +26,8 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException;
+import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.introspection.*;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -39,11 +41,11 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
-@Ignore
+
@PrepareForTest(ModelInjestor.class)
public class URIToDBKeyTest extends AAISetup {
- private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8);
+ private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -58,11 +60,11 @@ public class URIToDBKeyTest extends AAISetup {
*/
@Test
public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
+ URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
URIToDBKey parse = new URIToDBKey(loader, uri);
Object result = parse.getResult();
- String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+ String expected = "cloud-region/tenant/vserver/l-interface";
assertEquals("blah", expected, result);
@@ -78,11 +80,11 @@ public class URIToDBKeyTest extends AAISetup {
*/
@Test
public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
+ URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
URIToDBKey parse = new URIToDBKey(loader, uri);
Object result = parse.getResult();
- String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+ String expected = "cloud-region/tenant/vserver/l-interface";
assertEquals("blah", expected, result);
@@ -102,12 +104,28 @@ public class URIToDBKeyTest extends AAISetup {
URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build();
thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
+ thrown.expect(hasProperty("code", is("AAI_3001")));
new URIToDBKey(loader, uri);
}
/**
+ * NotValid namespace.
+ *
+ * @throws JAXBException the JAXB exception
+ * @throws DoesNotStartWithValidNamespaceException the AAI exception
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
+ @Test
+ public void notValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+ URI uri = UriBuilder.fromPath("/cloud-region/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
+ thrown.expect(DoesNotStartWithValidNamespaceException.class);
+ URIToDBKey parse = new URIToDBKey(loader, uri);
+ }
+
+
+ /**
* No valid tokens.
*
* @throws JAXBException the JAXB exception
@@ -120,7 +138,7 @@ public class URIToDBKeyTest extends AAISetup {
URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud/blah/blah").build();
thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3001")));
+ thrown.expect(hasProperty("code", is("AAI_3000")));
new URIToDBKey(loader, uri);
}
@@ -135,12 +153,12 @@ public class URIToDBKeyTest extends AAISetup {
*/
@Test
public void startsWithValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
+ URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
URIToDBKey parse = new URIToDBKey(loader, uri);
Object result = parse.getResult();
- String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+ String expected = "cloud-region/tenant/vserver/l-interface";
assertEquals("blah", expected, result);
}
@@ -158,7 +176,7 @@ public class URIToDBKeyTest extends AAISetup {
URIToDBKey parse = new URIToDBKey(loader, uri);
Object result = parse.getResult();
- String expected = "vce/key1/port-group/key2/cvlan-tag/655";
+ String expected = "vce/port-group/cvlan-tag";
assertEquals("blah", expected, result);
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
index ee665d31..38377f73 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
@@ -37,10 +37,10 @@ import java.net.URI;
import static org.junit.Assert.assertEquals;
-@Ignore
+
public class URIToExtensionInformationTest extends AAISetup {
- private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8);
+ private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
/**
* Vservers V 7.
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
index 7261a2dc..9eb013f6 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
@@ -41,10 +41,10 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
-@Ignore
+
public class URIToObjectTest extends AAISetup {
- private Version version = Version.v8;
+ private Version version = Version.v10;
private Version currentVersion = AAIProperties.LATEST;
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version);
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
index 42c602ba..ee7b8651 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
@@ -40,10 +40,10 @@ import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertTrue;
-@Ignore
+
public class URIToRelationshipObjectTest extends AAISetup {
- private Version latest = AAIProperties.LATEST;
+ private Version latest = Version.v10;
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, latest);
@Rule
@@ -61,10 +61,11 @@ public class URIToRelationshipObjectTest extends AAISetup {
*/
@Test
public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException {
+
URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
+ String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
assertTrue("blah", result.marshal(false).matches(expected));
}
@@ -84,7 +85,7 @@ public class URIToRelationshipObjectTest extends AAISetup {
URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
+ String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
assertTrue("blah", result.marshal(false).matches(expected));
@@ -105,7 +106,7 @@ public class URIToRelationshipObjectTest extends AAISetup {
URI uri = UriBuilder.fromPath("/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3/").build();
URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"ctag-pool\",\"related-link\":\".*?:8443/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"ctag-pool.target-pe\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"ctag-pool.availability-zone-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
+ String expected = "\\{\"related-to\":\"ctag-pool\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"ctag-pool.target-pe\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"ctag-pool.availability-zone-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
assertTrue("blah", result.marshal(false).matches(expected));
}
@@ -125,7 +126,7 @@ public class URIToRelationshipObjectTest extends AAISetup {
URI uri = UriBuilder.fromPath("/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144").build();
URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"cvlan-tag\",\"related-link\":\".*?:8443/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144\",\"relationship-data\":\\[\\{\"relationship-key\":\"vce.vnf-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"port-group.interface-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"cvlan-tag.cvlan-tag\",\"relationship-value\":\"144\"\\}\\]\\}";
+ String expected = "\\{\"related-to\":\"cvlan-tag\",\"related-link\":\"/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144\",\"relationship-data\":\\[\\{\"relationship-key\":\"vce.vnf-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"port-group.interface-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"cvlan-tag.cvlan-tag\",\"relationship-value\":\"144\"\\}\\]\\}";
assertTrue("blah", result.marshal(false).matches(expected));
}
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
index 87bb6ca7..0257e6b1 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
@@ -111,7 +111,7 @@ public class EdgeRulesTest extends AAISetup {
Vertex v2 = graph.addVertex("aai-node-type", "tenant");
assertEquals(true, EdgeRules.getInstance().hasEdgeRule(v1, v2));
}
-
+
@Test
public void getEdgeRuleByTypeAndVertices() throws AAIException {
Graph graph = TinkerGraph.open();
@@ -125,7 +125,7 @@ public class EdgeRulesTest extends AAISetup {
assertEquals(true, "IN".equalsIgnoreCase(rule.getServiceInfrastructure()));
assertEquals(true, "OUT".equalsIgnoreCase(rule.getPreventDelete()));
}
-
+
@Test
public void addTreeEdgeTest() throws AAIException {
Graph graph = TinkerGraph.open();
@@ -135,11 +135,11 @@ public class EdgeRulesTest extends AAISetup {
GraphTraversalSource g = graph.traversal();
rules.addTreeEdge(g, v1, v2);
assertEquals(true, g.V(v1).out("has").has("aai-node-type", "tenant").hasNext());
-
+
Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "cloud-region");
assertEquals(null, rules.addTreeEdgeIfPossible(g, v3, v2));
}
-
+
@Test
public void addCousinEdgeTest() throws AAIException {
Graph graph = TinkerGraph.open();
@@ -149,27 +149,27 @@ public class EdgeRulesTest extends AAISetup {
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, v1, v2);
assertEquals(true, g.V(v2).out("hasFlavor").has("aai-node-type", "flavor").hasNext());
-
+
Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "flavor");
assertEquals(null, rules.addEdgeIfPossible(g, v3, v2));
}
-
+
@Test
public void multiplicityViolationTest() throws AAIException {
thrown.expect(EdgeMultiplicityException.class);
thrown.expectMessage("multiplicity rule violated: only one edge can exist with label: uses between vf-module and volume-group");
-
+
Graph graph = TinkerGraph.open();
Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "vf-module");
Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "volume-group");
EdgeRules rules = EdgeRules.getInstance(Version.getLatest());
GraphTraversalSource g = graph.traversal();
-
+
rules.addEdge(g, v2, v1);
Vertex v3 = graph.addVertex(T.id, "3", "aai-node-type", "vf-module");
rules.addEdge(g, v2, v3);
}
-
+
@Test
public void getChildrenTest() {
EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json");
@@ -178,15 +178,15 @@ public class EdgeRulesTest extends AAISetup {
boolean sawBazRule = false;
boolean sawQuuxRule = false;
for (EdgeRule r : children) {
- if ("isVeryHappyAbout".equals(r.getLabel())) {
- sawBazRule = true;
+ if ("isVeryHappyAbout".equals(r.getLabel())) {
+ sawBazRule = true;
} else if ("dancesWith".equals(r.getLabel())) {
sawQuuxRule = true;
}
}
assertEquals(true, sawBazRule && sawQuuxRule);
}
-
+
@Test
public void getAllRulesTest() {
EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json");
@@ -196,34 +196,34 @@ public class EdgeRulesTest extends AAISetup {
assertEquals(true, allRules.containsKey("foo|bar"));
assertEquals(true, allRules.containsKey("quux|foo"));
}
-
+
@Test
public void getAllRulesMissingPropertyTest() {
EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
+
thrown.expect(RuntimeException.class);
thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between foo and bar is missing property delete-other-v.");
rules.getAllRules();
}
-
+
@Test
public void getChildrenMissingPropertyTest() {
EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
+
thrown.expect(RuntimeException.class);
thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA.");
rules.getChildren("foo");
}
-
+
@Test
public void getEdgeRuleMissingPropertyTest() throws AAIException {
EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
+
thrown.expect(RuntimeException.class);
thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA.");
rules.getEdgeRules("foo", "quux");
}
-
+
@Test
public void verifyAllRules() {
// This will cause every rule in the real json files to be verified
diff --git a/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java b/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java
new file mode 100644
index 00000000..c990e309
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.aai.util;
+
+import org.junit.Test;
+import org.openecomp.aai.introspection.Version;
+
+public class GenerateXsdTest {
+
+ @Test
+ public void testGenerationOfXsdAndYaml() throws Exception {
+
+ GenerateXsd generateXsd = new GenerateXsd();
+ System.setProperty("gen_version", Version.getLatest().toString());
+ System.setProperty("gen_type", "XSD");
+ System.setProperty("yamlresponses_url", "");
+ System.setProperty("yamlresponses_label", "");
+
+ generateXsd.main(new String[]{});
+
+ System.setProperty("gen_version", Version.getLatest().toString());
+ System.setProperty("gen_type", "YAML");
+
+ String wikiLink = System.getProperty("aai.wiki.link");
+
+ if(wikiLink == null){
+ wikiLink = "https://wiki.onap.org/";
+ }
+
+ System.setProperty("yamlresponses_url", wikiLink);
+ System.setProperty("yamlresponses_label", "Response codes found in [response codes]");
+
+ generateXsd.main(new String[]{});
+ }
+
+}