aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java
diff options
context:
space:
mode:
authorThreefoot, Jane (jt6620) <jt6620@att.com>2017-09-08 09:34:19 -0400
committerThreefoot, Jane (jt6620) <jt6620@att.com>2017-09-08 15:43:41 -0400
commitf94c995d4d2b5ffd7f7fa7cf6ec10cdcbf4932a7 (patch)
treeb55fd1ba04576abec768823c4dad9f4a800909e2 /aai-core/src/test/java
parent6042ff29f5f1f00b537f4b92e7aeeded13810545 (diff)
EdgeRules throws descriptive error on invalid rule
Also added test coverage, including refactoring of test resources to simplify test suites. Issue-ID: AAI-277 Change-Id: Ibfdc81342a139d121740f10bccc66a7420b61945 Signed-off-by: Threefoot, Jane (jt6620) <jt6620@att.com>
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/AAISetup.java34
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java17
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java16
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java13
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java11
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java25
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java14
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java18
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java5
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java37
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java19
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java49
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java36
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java15
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java13
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java56
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java33
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java41
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java42
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java41
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java29
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java44
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java35
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java85
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java94
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java45
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java45
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java19
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java36
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java21
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java65
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java19
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java43
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java163
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java15
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java32
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java10
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java35
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java28
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/util/CNNameTest.java7
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java9
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java6
42 files changed, 733 insertions, 687 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/AAISetup.java b/aai-core/src/test/java/org/openecomp/aai/AAISetup.java
new file mode 100644
index 00000000..b0fce58d
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/AAISetup.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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;
+
+import org.junit.BeforeClass;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
+import org.openecomp.aai.util.AAIConstants;
+
+public abstract class AAISetup {
+
+ @BeforeClass
+ public static void setupBundleconfig() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
+ }
+}
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
index 3a1d9cc1..7cf5ac71 100644
--- a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
@@ -20,22 +20,15 @@
package org.openecomp.aai.dbmodel;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Map.Entry;
-
+import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.Multimap;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
-import com.google.common.collect.ImmutableSetMultimap;
-import com.google.common.collect.Multimap;
+import java.io.*;
+import java.util.Map.Entry;
-import freemarker.template.TemplateException;
+import static org.junit.Assert.*;
public class DbEdgeRulesConverterTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
index 862f6911..554b6418 100644
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
@@ -20,26 +20,18 @@
package org.openecomp.aai.exceptions;
+import org.junit.Test;
+import org.openecomp.aai.AAISetup;
+
import static org.junit.Assert.assertEquals;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
+public class AAIExceptionTest extends AAISetup {
-public class AAIExceptionTest {
private static final String code = "4004";
private static final String details = "This is a detailed description of the exception.";
private static final Throwable cause = new RuntimeException("This is a runtime exception.");
private static final Throwable noMessage = new RuntimeException();
- @BeforeClass
- public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
- }
-
/**
* Test constructor with 0 params.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
index b6357e43..41841ac7 100644
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
@@ -20,16 +20,14 @@
package org.openecomp.aai.exceptions;
-import org.junit.BeforeClass;
import org.junit.Test;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
+import org.openecomp.aai.AAISetup;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
-public class AAIExceptionWithInfoTest {
+public class AAIExceptionWithInfoTest extends AAISetup {
private static final HashMap<String, Object> map = new HashMap<String, Object>();
@@ -45,13 +43,6 @@ public class AAIExceptionWithInfoTest {
private static final String details = "This is a detailed description of the exception.";
private static final Throwable cause = new RuntimeException("This is a runtime exception.");
- @BeforeClass
- public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
- }
-
/**
* Test constructor with 2 params.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
index 47fef7ee..1ecc6923 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
@@ -20,15 +20,12 @@
package org.openecomp.aai.introspection;
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.Set;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import com.google.common.collect.Sets;
-public class IntrospectorTestSpec {
+import static org.junit.Assert.assertEquals;
+
+public class IntrospectorTestSpec extends AAISetup {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
index 9504c46b..0f67ddfc 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
@@ -20,37 +20,12 @@
package org.openecomp.aai.introspection;
-import java.io.StringReader;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
-import org.eclipse.persistence.dynamic.DynamicEntity;
-import org.eclipse.persistence.jaxb.UnmarshallerProperties;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.BeforeClass;
import org.junit.Test;
-
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
public class MoxyEngineTest extends IntrospectorTestSpec {
/**
- * Configure.
- * @throws Exception
- * @throws SecurityException
- * @throws NoSuchFieldException
- */
- @BeforeClass
- public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
- }
-
- /**
* Container object.
* @throws AAIUnknownObjectException
*/
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
index 34a6279b..b820cfef 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
@@ -20,25 +20,17 @@
package org.openecomp.aai.introspection;
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.openecomp.aai.db.props.AAIProperties;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.openecomp.aai.db.props.AAIProperties;
+import static org.junit.Assert.*;
public class PojoInjestorTest {
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- }
-
@Test
public void getVersionTest() {
String latestVersion = "org.openecomp.aai.yang.VnfImage";
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
index 0eeb966b..e4e58b60 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
@@ -20,24 +20,18 @@
package org.openecomp.aai.introspection;
-import static org.junit.Assert.*;
-
-import org.junit.BeforeClass;
import org.junit.Test;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.domain.yang.v9.VnfImage;
import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException;
import org.openecomp.aai.restcore.MediaType;
-public class PojoLoaderTest {
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class PojoLoaderTest extends AAISetup {
+
-
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- }
-
@Test
public void test() {
Loader pojoLoader = LoaderFactory.createLoaderForVersion(ModelType.POJO, Version.v9);
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
index 4843b10d..0bd61178 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
@@ -20,14 +20,13 @@
package org.openecomp.aai.introspection;
-import static org.junit.Assert.*;
-
import org.junit.Test;
-
import org.openecomp.aai.domain.yang.CloudRegion;
import org.openecomp.aai.domain.yang.VolumeGroup;
import org.openecomp.aai.schema.enums.ObjectMetadata;
+import static org.junit.Assert.assertEquals;
+
public class PojoStrategyTest {
@Test
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
index ac430e1b..50aea8fe 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
@@ -20,34 +20,29 @@
package org.openecomp.aai.introspection;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import java.util.Set;
-
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.Ignore;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-@Ignore
-public class PropertyPredicatesTest {
+import java.util.Set;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+public class PropertyPredicatesTest extends AAISetup {
+
+ private final Version version = Version.getLatest();
+
+ private Loader loader;
+ private ModelType introspectorFactoryType = ModelType.MOXY;
+ private Introspector obj;
- private final static Version version = Version.v10;
- private static Loader loader;
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private static Introspector obj;
-
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
+ @Before
+ public void setup() throws Exception {
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
obj = loader.introspectorFromName("test-object");
-
}
@Test
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
index 8781d59c..d7cd7b18 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
@@ -20,31 +20,12 @@
package org.openecomp.aai.introspection;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-
-import javax.xml.bind.JAXBException;
-
-import org.junit.BeforeClass;
import org.junit.Test;
-
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider;
public class ReflectionEngineTest extends IntrospectorTestSpec {
/**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- }
-
- /**
* Container object.
*
* @throws InstantiationException the instantiation exception
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
index 0d40f89f..8e37fe05 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
@@ -20,17 +20,8 @@
package org.openecomp.aai.introspection.sideeffect;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
import org.apache.commons.io.IOUtils;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -43,11 +34,7 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.dbmap.DBConnectionType;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.introspection.sideeffect.exceptions.AAIMissingRequiredPropertyException;
import org.openecomp.aai.parsers.query.QueryParser;
import org.openecomp.aai.serialization.db.DBSerializer;
@@ -55,17 +42,22 @@ import org.openecomp.aai.serialization.db.EdgeProperty;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
-@Ignore
public class DataCopyTest {
private static TitanGraph graph;
- private final static Version version = Version.v10;
+ private final static Version version = Version.getLatest();
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private final static DBConnectionType type = DBConnectionType.REALTIME;
@@ -83,7 +75,6 @@ public class DataCopyTest {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
queryStyle,
@@ -112,7 +103,7 @@ public class DataCopyTest {
@Test
public void runPopulatePersonaModelVer() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
final Introspector obj = loader.introspectorFromName("test-object");
obj.setValue("vnf-id", "myId");
obj.setValue("model-invariant-id", "key1");
@@ -168,7 +159,7 @@ public class DataCopyTest {
@Test
public void verifyNestedSideEffect() throws URISyntaxException, AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, IOException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
final Introspector obj = loader.unmarshal("customer", this.getJsonString("nested-case.json"));
System.out.println(obj.marshal(true));
TransactionalGraphEngine spy = spy(dbEngine);
@@ -194,7 +185,7 @@ public class DataCopyTest {
@Test
public void expectedMissingPropertyExceptionInURI() throws AAIException, UnsupportedEncodingException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
final Introspector obj = loader.introspectorFromName("test-object");
obj.setValue("vnf-id", "myId");
obj.setValue("model-invariant-id", "key1");
@@ -217,7 +208,7 @@ public class DataCopyTest {
@Test
public void expectedMissingPropertyExceptionForResultingObject() throws AAIException, UnsupportedEncodingException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
final Introspector obj = loader.introspectorFromName("test-object");
obj.setValue("vnf-id", "myId");
obj.setValue("model-invariant-id", "key3");
@@ -241,7 +232,7 @@ public class DataCopyTest {
@Test
public void expectNoProcessingWithNoProperties() throws AAIException, UnsupportedEncodingException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
final Introspector obj = loader.introspectorFromName("test-object");
obj.setValue("vnf-id", "myId");
@@ -267,7 +258,7 @@ public class DataCopyTest {
private String getJsonString(String filename) throws IOException {
- FileInputStream is = new FileInputStream("src/test/resources/org/openecomp/aai/introspection/sideeffect/" + filename);
+ FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/oxm/sideeffect/" + filename);
String s = IOUtils.toString(is, "UTF-8");
IOUtils.closeQuietly(is);
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
index 4aafe460..8220b86c 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
@@ -20,16 +20,8 @@
package org.openecomp.aai.introspection.sideeffect;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.util.List;
-
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -41,28 +33,28 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.dbmap.DBConnectionType;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.parsers.query.QueryParser;
import org.openecomp.aai.serialization.db.DBSerializer;
import org.openecomp.aai.serialization.db.EdgeProperty;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
-@Ignore
public class DataLinkTest {
private static TitanGraph graph;
- private final static Version version = Version.v10;
+ private final static Version version = Version.getLatest();
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private final static DBConnectionType type = DBConnectionType.REALTIME;
@@ -80,7 +72,6 @@ public class DataLinkTest {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
queryStyle,
@@ -184,6 +175,7 @@ public class DataLinkTest {
GraphTraversalSource traversal = g.traversal();
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(traversal);
when(spy.tx()).thenReturn(g);
when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
when(prop.orElse(null)).thenReturn(obj.getURI());
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
index d3a9492f..8b76967a 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
@@ -20,27 +20,22 @@
package org.openecomp.aai.introspection.validation;
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.introspection.tools.IntrospectorValidator;
import org.openecomp.aai.introspection.tools.Issue;
import org.openecomp.aai.introspection.tools.IssueType;
import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
import org.openecomp.aai.util.AAIConstants;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
public class IntrospectorValidationTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
index 3fe2098c..9cc522eb 100644
--- a/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
@@ -20,18 +20,11 @@
package org.openecomp.aai.logging;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
-import org.junit.Test;
+import static org.junit.Assert.*;
public class LoggingContextTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
index b22a98e6..a4070b02 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
@@ -20,30 +20,15 @@
package org.openecomp.aai.parsers.query;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.LoaderFactory;
@@ -53,15 +38,24 @@ import org.openecomp.aai.rest.RestTokens;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-@Ignore
-public class GraphTraversalTest {
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
- private static TransactionalGraphEngine dbEngine;
-
- private static TransactionalGraphEngine dbEnginev9;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+
+public class GraphTraversalTest extends AAISetup {
+
+ private TransactionalGraphEngine dbEngine;
+ private TransactionalGraphEngine dbEnginev9;
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -72,12 +66,9 @@ public class GraphTraversalTest {
* @throws SecurityException
* @throws NoSuchFieldException
*/
- @BeforeClass
- public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
- dbEngine =
+ @Before
+ public void configure() throws Exception {
+ dbEngine =
new TitanDBEngine(QueryStyle.TRAVERSAL,
LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST),
false);
@@ -693,7 +684,6 @@ public class GraphTraversalTest {
assertEquals("dependent",true, query.isDependent());
}
- @Ignore
@Test
public void pluralCousin() throws UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers").build();
@@ -728,7 +718,6 @@ public class GraphTraversalTest {
assertEquals("dependent",true, query.isDependent());
}
- @Ignore
@Test
public void specificCousin() throws UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2").build();
@@ -764,7 +753,6 @@ public class GraphTraversalTest {
assertEquals("dependent",true, query.isDependent());
}
- @Ignore
@Test
public void doubleSpecificCousin() throws UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2/related-to/vservers/vserver/key3").build();
@@ -804,7 +792,6 @@ public class GraphTraversalTest {
assertEquals("dependent",true, query.isDependent());
}
- @Ignore
@Test
public void traversalEndsInRelatedTo() throws UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to").build();
@@ -815,7 +802,6 @@ public class GraphTraversalTest {
}
- @Ignore
@Test
public void pluralCousinToPluralCousin() throws UnsupportedEncodingException, AAIException {
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/related-to/pservers").build();
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 2a1f94b4..5c68fc67 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
@@ -20,19 +20,10 @@
package org.openecomp.aai.parsers.query;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelInjestor;
@@ -42,10 +33,19 @@ import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class LegacyQueryTest {
+public class LegacyQueryTest extends AAISetup {
+
private ModelInjestor injestor = ModelInjestor.getInstance();
+
private TransactionalGraphEngine dbEngine =
new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
@@ -53,16 +53,7 @@ public class LegacyQueryTest {
private final Version version = Version.v8;
private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
- /**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
+
/**
* Parent query.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
index 3ab45379..0aad09c4 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
@@ -20,38 +20,31 @@
package org.openecomp.aai.parsers.query;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.IntrospectorFactory;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelInjestor;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class RelationshipGremlinQueryTest {
+public class RelationshipGremlinQueryTest extends AAISetup {
private ModelInjestor injestor = ModelInjestor.getInstance();
private TransactionalGraphEngine dbEngine =
@@ -65,16 +58,6 @@ public class RelationshipGremlinQueryTest {
public ExpectedException thrown = ExpectedException.none();
/**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
-
- /**
* Parent query.
*
* @throws JAXBException the JAXB exception
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
index 25369338..94fe0c59 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
@@ -20,35 +20,29 @@
package org.openecomp.aai.parsers.query;
-import static org.junit.Assert.assertEquals;
-
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.IntrospectorFactory;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelInjestor;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class RelationshipQueryTest {
+public class RelationshipQueryTest extends AAISetup {
+
private ModelInjestor injestor = ModelInjestor.getInstance();
private TransactionalGraphEngine dbEngine =
@@ -57,17 +51,7 @@ public class RelationshipQueryTest {
false);
private final Version version = Version.v8;
private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
- /**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
-
+
/**
* Parent query.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
index 50bbbd0e..870bbd36 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
@@ -20,15 +20,6 @@
package org.openecomp.aai.parsers.query;
-import static org.junit.Assert.assertEquals;
-
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -36,22 +27,26 @@ import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.IntrospectorFactory;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelInjestor;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class UniqueRelationshipQueryTest {
+public class UniqueRelationshipQueryTest extends AAISetup {
+
private ModelInjestor injestor = ModelInjestor.getInstance();
private TransactionalGraphEngine dbEngine =
new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
@@ -62,16 +57,6 @@ public class UniqueRelationshipQueryTest {
private Unmarshaller unmarshaller = null;
/**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- }
-
-
- /**
* Setup.
*
* @throws JAXBException the JAXB exception
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java
index 9bf4919b..e1be7f25 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java
@@ -20,21 +20,13 @@
package org.openecomp.aai.parsers.query;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import javax.ws.rs.core.UriBuilder;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelInjestor;
@@ -44,8 +36,15 @@ import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+import javax.ws.rs.core.UriBuilder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class UniqueURIQueryTest {
+public class UniqueURIQueryTest extends AAISetup {
+
private ModelInjestor injestor = ModelInjestor.getInstance();
private TransactionalGraphEngine dbEngine =
new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
@@ -55,16 +54,6 @@ public class UniqueURIQueryTest {
private DynamicJAXBContext context = injestor.getContextForVersion(version);
/**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- }
-
-
- /**
* Parent query.
*
* @throws UnsupportedEncodingException the unsupported encoding exception
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 6fac3427..bc20af11 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
@@ -20,38 +20,28 @@
package org.openecomp.aai.parsers.relationship;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
import org.apache.commons.io.IOUtils;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException;
import org.openecomp.aai.parsers.exceptions.AmbiguousMapAAIException;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-@Ignore
-public class RelationshipToURITest {
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+
+public class RelationshipToURITest extends AAISetup {
-
-
private final ModelType modelType = ModelType.MOXY;
private final Version version10 = Version.v10;
private final Version version9 = Version.v9;
@@ -59,14 +49,6 @@ public class RelationshipToURITest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
-
- }
-
@Test
public void onlyLink() throws AAIException, URISyntaxException, IOException {
Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
@@ -223,7 +205,7 @@ public class RelationshipToURITest {
private String getJsonString(String filename) throws IOException {
- FileInputStream is = new FileInputStream("src/test/resources/org/openecomp/aai/parsers/relationship/" + filename);
+ FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/relationship/" + filename);
String s = IOUtils.toString(is, "UTF-8");
IOUtils.closeQuietly(is);
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
index 1fa3aea2..da863c1e 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
@@ -20,29 +20,25 @@
package org.openecomp.aai.parsers.uri;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelType;
import org.openecomp.aai.introspection.Version;
-@Ignore
-public class URIParserTest {
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+
+public class URIParserTest extends AAISetup {
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8);
@@ -50,15 +46,6 @@ public class URIParserTest {
public ExpectedException thrown = ExpectedException.none();
/**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
- /**
* Invalid path.
*
* @throws JAXBException the JAXB exception
@@ -71,7 +58,7 @@ public class URIParserTest {
URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/network/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3001")));
+ thrown.expect(hasProperty("code", is("AAI_3000")));
new URIToDBKey(loader, uri);
}
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 5ba47119..9aabdf1a 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
@@ -20,34 +20,28 @@
package org.openecomp.aai.parsers.uri;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.*;
import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelInjestor;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
@Ignore
@PrepareForTest(ModelInjestor.class)
-public class URIToDBKeyTest {
+public class URIToDBKeyTest extends AAISetup {
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8);
@@ -55,13 +49,45 @@ public class URIToDBKeyTest {
public ExpectedException thrown = ExpectedException.none();
/**
- * Configure.
+ * Uri.
+ *
+ * @throws JAXBException the JAXB exception
+ * @throws AAIException the AAI exception
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
+ @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();
+ URIToDBKey parse = new URIToDBKey(loader, uri);
+ Object result = parse.getResult();
+
+ String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+
+ assertEquals("blah", expected, result);
+
+ }
+
+ /**
+ * Uri no version.
+ *
+ * @throws JAXBException the JAXB exception
+ * @throws AAIException the AAI exception
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws UnsupportedEncodingException the unsupported encoding exception
*/
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ @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();
+ URIToDBKey parse = new URIToDBKey(loader, uri);
+ Object result = parse.getResult();
+
+ String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+
+ assertEquals("blah", expected, result);
+
}
+
/**
* Bad URI.
@@ -76,7 +102,7 @@ public class URIToDBKeyTest {
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_3001")));
+ thrown.expect(hasProperty("code", is("AAI_3000")));
new URIToDBKey(loader, uri);
}
@@ -107,6 +133,17 @@ public class URIToDBKeyTest {
* @throws IllegalArgumentException the illegal argument exception
* @throws UnsupportedEncodingException the unsupported encoding exception
*/
+ @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();
+
+ URIToDBKey parse = new URIToDBKey(loader, uri);
+ Object result = parse.getResult();
+
+ String expected = "cloud-region/att-aic/AAIAIC25/tenant/key1/vserver/key2/l-interface/key3";
+
+ assertEquals("blah", expected, result);
+ }
/**
* Naming exceptions.
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
new file mode 100644
index 00000000..ee665d31
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.parsers.uri;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openecomp.aai.AAISetup;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.restcore.HttpMethod;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+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);
+
+ /**
+ * Vservers V 7.
+ *
+ * @throws JAXBException the JAXB exception
+ * @throws AAIException the AAI exception
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
+ @Test
+ public void vserversV8() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+ URI uri = UriBuilder.fromPath("/aai/" + v8Loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/key1/vservers/vserver/key2").build();
+ URIToExtensionInformation parse = new URIToExtensionInformation(v8Loader, uri);
+
+ String namespace = "cloudInfrastructure";
+ String preMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPreProc";
+ String postMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPostProc";
+ String topLevel = "CloudRegion";
+ testSpec(parse, HttpMethod.PUT, namespace, preMethodName, postMethodName, topLevel);
+
+ }
+
+ /**
+ * Test spec.
+ *
+ * @param info the info
+ * @param httpMethod the http method
+ * @param namespace the namespace
+ * @param preMethodName the pre method name
+ * @param postMethodName the post method name
+ * @param topLevel the top level
+ */
+ private void testSpec(URIToExtensionInformation info, HttpMethod httpMethod, String namespace, String preMethodName, String postMethodName, String topLevel) {
+
+
+ String namespaceResult = info.getNamespace();
+ String methodNameResult = info.getMethodName(httpMethod, true);
+
+ assertEquals("namespace", namespace, namespaceResult);
+ assertEquals("preprocess method name", preMethodName, methodNameResult);
+ methodNameResult = info.getMethodName(httpMethod, false);
+
+ assertEquals("postprocess method name", postMethodName, methodNameResult);
+
+ String topLevelResult = info.getTopObject();
+
+ assertEquals("topLevel", topLevel, topLevelResult);
+ }
+
+
+}
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 3bbc00fd..7261a2dc 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
@@ -20,52 +20,37 @@
package org.openecomp.aai.parsers.uri;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.HashMap;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.HashMap;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+
@Ignore
-public class URIToObjectTest {
+public class URIToObjectTest extends AAISetup {
private Version version = Version.v8;
private Version currentVersion = AAIProperties.LATEST;
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version);
+
@Rule
public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
-
+
/**
* Uri.
*
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 ed278243..42c602ba 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
@@ -20,50 +20,35 @@
package org.openecomp.aai.parsers.uri;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertTrue;
-
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertTrue;
@Ignore
-public class URIToRelationshipObjectTest {
+public class URIToRelationshipObjectTest extends AAISetup {
private Version latest = AAIProperties.LATEST;
private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, latest);
@Rule
public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Configure.
- */
- @BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
+
/**
* Uri.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java
index 072ba694..e57fb0e5 100644
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java
@@ -17,20 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.aai.query.builder;
-
-import static org.junit.Assert.*;
-import java.util.List;
+package org.openecomp.aai.query.builder;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.LoaderFactory;
@@ -38,15 +35,17 @@ import org.openecomp.aai.introspection.ModelType;
import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.serialization.db.EdgeRules;
import org.openecomp.aai.serialization.db.EdgeType;
-import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-public class SimplePathTest {
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+public class SimplePathTest extends AAISetup {
+
public Loader loader;
@Before
- public void setup() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ public void setup() throws Exception {
loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
index 0ea9a11c..f8418bd1 100644
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
@@ -20,40 +20,36 @@
package org.openecomp.aai.query.builder;
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
-
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-public class TraversalQueryTest {
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertEquals;
+
+public class TraversalQueryTest extends AAISetup {
- public static Loader loader;
- @Mock public GraphTraversalSource g;
- @BeforeClass
- public static void configure() throws NoSuchFieldException, SecurityException, Exception {
-
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
+ private Loader loader;
+
+ @Mock
+ private GraphTraversalSource g;
+
+ @Before
+ public void configure() throws Exception {
loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java
index fa434b44..b6c6025a 100644
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java
@@ -17,12 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.aai.query.builder;
-import static org.junit.Assert.assertTrue;
+package org.openecomp.aai.query.builder;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
@@ -30,6 +27,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Loader;
@@ -38,15 +36,18 @@ import org.openecomp.aai.introspection.ModelType;
import org.openecomp.aai.serialization.db.EdgeRules;
import org.openecomp.aai.serialization.db.EdgeType;
-public class UntilTest {
- public Loader loader;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+public class UntilTest extends AAISetup {
+
+ private Loader loader;
@Before
- public void setup(){
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ public void setup() throws Exception {
loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
}
private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
index cc419c67..d4793939 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
@@ -20,71 +20,63 @@
package org.openecomp.aai.serialization.db;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.Map;
-
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.dbmap.DBConnectionType;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Introspector;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.*;
import org.openecomp.aai.parsers.query.QueryParser;
import org.openecomp.aai.schema.enums.PropertyMetadata;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
-@Ignore
-public class DbAliasTest {
+public class DbAliasTest extends AAISetup {
-
-
private TitanGraph graph;
+
private final Version version = Version.v9;
private final ModelType introspectorFactoryType = ModelType.MOXY;
private final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private final DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
+
@Before
- public void setup() throws NoSuchFieldException, SecurityException, Exception {
+ public void setup() throws Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
queryStyle,
type,
loader);
}
-
+
@After
public void tearDown() {
graph.tx().rollback();
graph.close();
}
-
+
@Test
public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, NoSuchMethodException, InterruptedException {
final String property = "persona-model-customization-id";
@@ -109,17 +101,17 @@ public class DbAliasTest {
if (map.containsKey(PropertyMetadata.DB_ALIAS)) {
dbPropertyName = map.get(PropertyMetadata.DB_ALIAS);
}
-
+
assertEquals("dbAlias is ", "model-customization-id", dbPropertyName);
assertEquals("dbAlias property exists", "hello", v.property(dbPropertyName).orElse(""));
assertEquals("model property does not", "missing", v.property(property).orElse("missing"));
-
+
}
-
+
@Test
public void checkOnRead() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, NoSuchMethodException, InterruptedException, MalformedURLException {
final String property = "persona-model-customization-id";
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
Vertex v = graph.traversal().addV("vnf-id", "key1", "model-customization-id", "hello").next();
@@ -131,9 +123,10 @@ public class DbAliasTest {
DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
Introspector obj = loader.introspectorFromName("generic-vnf");
serializer.dbToObject(Collections.singletonList(v), obj, 0, true, "false");
-
+
assertEquals("dbAlias property exists", "hello", obj.getValue(property));
-
+
}
-
+
+
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java
index b100b014..3c3ec789 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java
@@ -20,17 +20,14 @@
package org.openecomp.aai.serialization.db;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
+import com.thinkaurelius.titan.core.TitanFactory;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.dbmap.DBConnectionType;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Loader;
@@ -41,10 +38,12 @@ import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.TitanFactory;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class DbSerializerTest extends AAISetup {
-@Ignore
-public class DbSerializerTest {
protected Graph graph;
protected final EdgeRules rules = EdgeRules.getInstance();
@@ -58,10 +57,8 @@ public class DbSerializerTest {
TransactionalGraphEngine.Admin adminSpy;
@Before
- public void setup() throws NoSuchFieldException, SecurityException, Exception {
+ public void setup() throws Exception {
graph = TitanFactory.build().set("storage.backend", "inmemory").open();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(queryStyle, type, loader);
spy = spy(dbEngine);
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java
new file mode 100644
index 00000000..fb3c0469
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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.serialization.db;
+
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class EdgePropertyMapTest {
+
+ @Test
+ public void run() {
+ Map<String, String> map = new EdgePropertyMap<>();
+ map.put("direction", "OUT");
+ map.put("test", "hello");
+ map.put("isParent", "${direction}");
+ map.put("SVC-INFRA", "!${direction}");
+
+ assertEquals("normal retrieval", "hello", map.get("test"));
+ assertEquals("variable retrieval", "OUT", map.get("isParent"));
+ assertEquals("negate variable retrieval", "IN", map.get("SVC-INFRA"));
+ }
+}
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 faa4d28e..87bb6ca7 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
@@ -20,26 +20,37 @@
package org.openecomp.aai.serialization.db;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.junit.Test;
+import org.openecomp.aai.AAISetup;
import static org.junit.Assert.assertEquals;
import java.util.Map;
+import java.util.Set;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.BeforeClass;
-import org.junit.Test;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.serialization.db.exceptions.EdgeMultiplicityException;
import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-public class EdgeRulesTest {
+import com.google.common.collect.Multimap;
+
+public class EdgeRulesTest extends AAISetup {
+
+ //set thrown.expect to whatever a specific test needs
+ //this establishes a default of expecting no exceptions to be thrown
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
- @BeforeClass
- public static void setup() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
-
@Test
public void verifyOutDirection() throws AAIException, NoEdgeRuleFoundException {
EdgeRules rules = EdgeRules.getInstance();
@@ -93,4 +104,134 @@ public class EdgeRulesTest {
assertEquals(false, EdgeRules.getInstance(Version.v8).hasEdgeRule("model-element", "model-ver"));
}
+ @Test
+ public void hasEdgeRuleVertexTest() {
+ Graph graph = TinkerGraph.open();
+ Vertex v1 = graph.addVertex("aai-node-type", "cloud-region");
+ 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();
+ Vertex v1 = graph.addVertex("aai-node-type", "cloud-region");
+ Vertex v2 = graph.addVertex("aai-node-type", "tenant");
+ EdgeRules rules = EdgeRules.getInstance();
+ EdgeRule rule = rules.getEdgeRule(EdgeType.TREE, v1, v2);
+ assertEquals(true, "OUT".equalsIgnoreCase(rule.getContains()));
+ assertEquals(true, "NONE".equalsIgnoreCase(rule.getDeleteOtherV()));
+ assertEquals(true, MultiplicityRule.ONE2MANY.equals(rule.getMultiplicityRule()));
+ assertEquals(true, "IN".equalsIgnoreCase(rule.getServiceInfrastructure()));
+ assertEquals(true, "OUT".equalsIgnoreCase(rule.getPreventDelete()));
+ }
+
+ @Test
+ public void addTreeEdgeTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "cloud-region");
+ Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "tenant");
+ EdgeRules rules = EdgeRules.getInstance();
+ 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();
+ Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "flavor");
+ Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "vserver");
+ EdgeRules rules = EdgeRules.getInstance(Version.getLatest());
+ 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");
+ Set<EdgeRule> children = rules.getChildren("foo");
+ assertEquals(2, children.size());
+ boolean sawBazRule = false;
+ boolean sawQuuxRule = false;
+ for (EdgeRule r : children) {
+ 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");
+ Multimap<String, EdgeRule> allRules = rules.getAllRules();
+ assertEquals(3, allRules.size());
+ assertEquals(true, allRules.containsKey("foo|bar"));
+ 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
+ // so if any required properties are missing, the verification builds
+ // will catch it and incorrect rules can't get merged in.
+ for (Version v : Version.values()) {
+ EdgeRules rules = EdgeRules.getInstance(v);
+ rules.getAllRules();
+ }
+ }
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
index 8b6d4913..f9a511a2 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
@@ -20,24 +20,23 @@
package org.openecomp.aai.serialization.queryformats;
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.when;
+
public class QueryFormatTestHelper {
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java
index 51ccd363..766274cd 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java
@@ -20,19 +20,7 @@
package org.openecomp.aai.serialization.queryformats;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-
+import com.google.gson.JsonObject;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -57,9 +45,15 @@ import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
-import org.openecomp.aai.util.AAIConstants;
-import com.google.gson.JsonObject;
+import java.io.UnsupportedEncodingException;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
public class SimpleFormatTest {
@@ -72,9 +66,6 @@ public class SimpleFormatTest {
private DBSerializer serializer;
private RawFormat simpleFormat;
private Vertex vfModule;
-
-
-
private final ModelType factoryType = ModelType.MOXY;
@Before
@@ -82,11 +73,6 @@ public class SimpleFormatTest {
MockitoAnnotations.initMocks(this);
- System.setProperty("AJSC_HOME", "src/test/resources");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"),
- "src/test/resources/org/openecomp/aai/introspection/");
-
graph = TinkerGraph.open();
vfModule = graph.addVertex(
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java
index d5a09ece..3eade856 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java
@@ -20,11 +20,6 @@
package org.openecomp.aai.serialization.queryformats.utils;
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -34,6 +29,11 @@ import org.openecomp.aai.serialization.db.DBSerializer;
import org.openecomp.aai.serialization.queryformats.Resource;
import org.openecomp.aai.serialization.queryformats.Resource.Builder;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
+import static org.junit.Assert.assertEquals;
+
public class QueryParamInjectorTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java
index dd22c0b5..605bbcd9 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java
@@ -19,40 +19,37 @@
*/
package org.openecomp.aai.serialization.queryformats.utils;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.openecomp.aai.AAISetup;
import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.serialization.db.DBSerializer;
import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.openecomp.aai.util.AAIConstants;
-public class UrlBuilderTest {
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+public class UrlBuilderTest extends AAISetup {
+
+ @Mock
+ private DBSerializer serializer;
+ @Mock
+ private Vertex v;
- @Mock private DBSerializer serializer;
- @Mock private Vertex v;
private static final String uri = "/test/uri";
private static final Object vId = new Long(123);
private static final String protocolAndHost = "http://localhost/aai/";
- @BeforeClass
- public static void setUp() {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- }
-
@Before
public void before() throws UnsupportedEncodingException, URISyntaxException {
MockitoAnnotations.initMocks(this);
@@ -60,7 +57,6 @@ public class UrlBuilderTest {
when(v.id()).thenReturn(vId);
}
- @Ignore
@Test
public void v11Pathed() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
Version version = Version.v11;
@@ -71,7 +67,6 @@ public class UrlBuilderTest {
}
- @Ignore
@Test
public void v11Id() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
Version version = Version.v11;
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java
index 7a0a1693..c4440527 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java
@@ -20,33 +20,29 @@
package org.openecomp.aai.serialization.tinkerpop;
-import static org.junit.Assert.assertEquals;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.aai.serialization.db.EdgeProperty;
import org.openecomp.aai.serialization.engines.query.GraphTraversalQueryEngine;
+import static org.junit.Assert.assertEquals;
+
@Ignore
public class TreeBackedVertexTest {
-
- private static Graph graph = TinkerGraph.open();
- private static Object startKey = null;
- private static Tree<Element> tree = null;
- private static Tree<Element> treeDepth1 = null;
- private static Tree<Element> treeDepth0NodeOnly = null;
- @BeforeClass
- public static void configure() {
+ private Graph graph = TinkerGraph.open();
+ private Object startKey = null;
+ private Tree<Element> tree = null;
+ private Tree<Element> treeDepth1 = null;
+ private Tree<Element> treeDepth0NodeOnly = null;
+
+ @Before
+ public void configure() {
GraphTraversalSource g = graph.traversal();
startKey = g.addV(T.label, "vserver").as("v1").property("test", "hello")
diff --git a/aai-core/src/test/java/org/openecomp/aai/util/CNNameTest.java b/aai-core/src/test/java/org/openecomp/aai/util/CNNameTest.java
index 6b2536c9..f5b67233 100644
--- a/aai-core/src/test/java/org/openecomp/aai/util/CNNameTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/util/CNNameTest.java
@@ -21,11 +21,11 @@
package org.openecomp.aai.util;
import ch.qos.logback.access.spi.IAccessEvent;
-import org.openecomp.aai.logging.CNName;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
+import org.openecomp.aai.logging.CNName;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.agent.PowerMockAgent;
@@ -55,9 +55,10 @@ public class CNNameTest {
* Initialize.
*/
@Before
- public void initialize(){
+ public void initialize() throws Exception {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
mockAccEvent = Mockito.mock(IAccessEvent.class);
mockHttpServletRequest = Mockito.mock(HttpServletRequest.class);
cert = Mockito.mock(X509Certificate.class);
diff --git a/aai-core/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java b/aai-core/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java
index 090f9101..31a7b5e4 100644
--- a/aai-core/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java
@@ -20,16 +20,13 @@
package org.openecomp.aai.util;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Ignore;
import org.junit.Test;
-
import org.openecomp.aai.logging.CNName;
import org.openecomp.aai.logging.CustomLogPatternLayout;
-@Ignore
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public class CustomLogPatternLayoutTest {
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
index 61ba275d..51636271 100644
--- a/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
@@ -20,13 +20,13 @@
package org.openecomp.aai.workarounds;
-import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
public class RemoveDME2QueryParamsTest {