Commit 235f4e9e by apoorvnaik

ATLAS-1753: Sandbox test data to avoid interference

parent b6eef8c2
...@@ -34,13 +34,6 @@ under the License. --> ...@@ -34,13 +34,6 @@ under the License. -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<version>6.9.4</version> <version>6.9.4</version>
...@@ -55,4 +48,21 @@ under the License. --> ...@@ -55,4 +48,21 @@ under the License. -->
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/
package org.apache.atlas.graph;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException;
import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class GraphSandboxUtil {
private static final Logger LOG = LoggerFactory.getLogger(GraphSandboxUtil.class);
public static void create() {
Configuration configuration;
try {
configuration = ApplicationProperties.get();
// Append a suffix to isolate the database for each instance
long currentMillisecs = System.currentTimeMillis();
String newStorageDir = System.getProperty("atlas.data") +
File.pathSeparator + "storage" +
File.pathSeparator + currentMillisecs;
configuration.setProperty("atlas.graph.storage.directory", newStorageDir);
String newIndexerDir = System.getProperty("atlas.data") +
File.pathSeparator + "index" +
File.pathSeparator + currentMillisecs;
configuration.setProperty("atlas.graph.index.search.directory", newIndexerDir);
LOG.debug("New Storage dir : {}", newStorageDir);
LOG.debug("New Indexer dir : {}", newIndexerDir);
} catch (AtlasException ignored) {}
}
}
...@@ -166,6 +166,14 @@ ...@@ -166,6 +166,14 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-graphdb-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
package org.apache.atlas.repository.graphdb.titan0; package org.apache.atlas.repository.graphdb.titan0;
import java.util.ArrayList; import org.apache.atlas.graph.GraphSandboxUtil;
import java.util.Collections;
import java.util.List;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasCardinality; import org.apache.atlas.repository.graphdb.AtlasCardinality;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
...@@ -32,6 +29,10 @@ import org.testng.annotations.AfterClass; ...@@ -32,6 +29,10 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* *
*/ */
...@@ -46,13 +47,10 @@ public abstract class AbstractGraphDatabaseTest { ...@@ -46,13 +47,10 @@ public abstract class AbstractGraphDatabaseTest {
private AtlasGraph<?, ?> graph = null; private AtlasGraph<?, ?> graph = null;
public AbstractGraphDatabaseTest() {
super();
}
@BeforeClass @BeforeClass
public static void createIndices() { public static void createIndices() {
GraphSandboxUtil.create();
Titan0GraphDatabase db = new Titan0GraphDatabase(); Titan0GraphDatabase db = new Titan0GraphDatabase();
AtlasGraphManagement mgmt = db.getGraph().getManagementSystem(); AtlasGraphManagement mgmt = db.getGraph().getManagementSystem();
......
...@@ -18,22 +18,8 @@ ...@@ -18,22 +18,8 @@
package org.apache.atlas.repository.graphdb.titan0; package org.apache.atlas.repository.graphdb.titan0;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.graph.GraphSandboxUtil;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasCardinality; import org.apache.atlas.repository.graphdb.AtlasCardinality;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
...@@ -48,6 +34,16 @@ import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; ...@@ -48,6 +34,16 @@ import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.testng.Assert.*;
/** /**
* Sanity test of basic graph operations using the Titan 0.5.4 graphdb * Sanity test of basic graph operations using the Titan 0.5.4 graphdb
* abstraction layer implementation. * abstraction layer implementation.
...@@ -57,6 +53,8 @@ public class Titan0DatabaseTest { ...@@ -57,6 +53,8 @@ public class Titan0DatabaseTest {
private AtlasGraph<?, ?> atlasGraph; private AtlasGraph<?, ?> atlasGraph;
private <V, E> AtlasGraph<V, E> getGraph() { private <V, E> AtlasGraph<V, E> getGraph() {
GraphSandboxUtil.create();
if (atlasGraph == null) { if (atlasGraph == null) {
Titan0GraphDatabase db = new Titan0GraphDatabase(); Titan0GraphDatabase db = new Titan0GraphDatabase();
atlasGraph = db.getGraph(); atlasGraph = db.getGraph();
......
...@@ -19,6 +19,7 @@ package org.apache.atlas.repository.graphdb.titan0; ...@@ -19,6 +19,7 @@ package org.apache.atlas.repository.graphdb.titan0;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.graph.GraphSandboxUtil;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.testng.Assert; import org.testng.Assert;
...@@ -34,6 +35,8 @@ public class Titan0DatabaseValidationTest { ...@@ -34,6 +35,8 @@ public class Titan0DatabaseValidationTest {
@BeforeTest @BeforeTest
public void setUp() throws AtlasException { public void setUp() throws AtlasException {
GraphSandboxUtil.create();
// First get Instance // First get Instance
graph = new Titan0Graph(); graph = new Titan0Graph();
configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(),
......
...@@ -210,6 +210,14 @@ ...@@ -210,6 +210,14 @@
<artifactId>tinkergraph-gremlin</artifactId> <artifactId>tinkergraph-gremlin</artifactId>
<version>3.0.1-incubating</version> <version>3.0.1-incubating</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-graphdb-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
package org.apache.atlas.repository.graphdb.titan1; package org.apache.atlas.repository.graphdb.titan1;
import java.util.ArrayList; import org.apache.atlas.graph.GraphSandboxUtil;
import java.util.Collections;
import java.util.List;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasCardinality; import org.apache.atlas.repository.graphdb.AtlasCardinality;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
...@@ -32,6 +29,10 @@ import org.testng.annotations.AfterClass; ...@@ -32,6 +29,10 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* *
*/ */
...@@ -46,13 +47,10 @@ public abstract class AbstractGraphDatabaseTest { ...@@ -46,13 +47,10 @@ public abstract class AbstractGraphDatabaseTest {
private AtlasGraph<?, ?> graph = null; private AtlasGraph<?, ?> graph = null;
public AbstractGraphDatabaseTest() {
super();
}
@BeforeClass @BeforeClass
public static void createIndices() { public static void createIndices() {
GraphSandboxUtil.create();
Titan1GraphDatabase db = new Titan1GraphDatabase(); Titan1GraphDatabase db = new Titan1GraphDatabase();
AtlasGraphManagement mgmt = db.getGraph().getManagementSystem(); AtlasGraphManagement mgmt = db.getGraph().getManagementSystem();
......
...@@ -18,21 +18,8 @@ ...@@ -18,21 +18,8 @@
package org.apache.atlas.repository.graphdb.titan1; package org.apache.atlas.repository.graphdb.titan1;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.graph.GraphSandboxUtil;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasCardinality; import org.apache.atlas.repository.graphdb.AtlasCardinality;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
...@@ -47,6 +34,15 @@ import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; ...@@ -47,6 +34,15 @@ import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.testng.Assert.*;
/** /**
* Sanity test of basic graph operations using the Titan 0.5.4 graphdb * Sanity test of basic graph operations using the Titan 0.5.4 graphdb
* abstraction layer implementation. * abstraction layer implementation.
...@@ -56,6 +52,8 @@ public class Titan1DatabaseTest { ...@@ -56,6 +52,8 @@ public class Titan1DatabaseTest {
private AtlasGraph<?, ?> atlasGraph; private AtlasGraph<?, ?> atlasGraph;
private <V, E> AtlasGraph<V, E> getGraph() { private <V, E> AtlasGraph<V, E> getGraph() {
GraphSandboxUtil.create();
if (atlasGraph == null) { if (atlasGraph == null) {
Titan1GraphDatabase db = new Titan1GraphDatabase(); Titan1GraphDatabase db = new Titan1GraphDatabase();
atlasGraph = db.getGraph(); atlasGraph = db.getGraph();
......
...@@ -19,6 +19,7 @@ package org.apache.atlas.repository.graphdb.titan1; ...@@ -19,6 +19,7 @@ package org.apache.atlas.repository.graphdb.titan1;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.graph.GraphSandboxUtil;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.testng.Assert; import org.testng.Assert;
...@@ -34,6 +35,8 @@ public class TitanGraphProviderTest { ...@@ -34,6 +35,8 @@ public class TitanGraphProviderTest {
@BeforeTest @BeforeTest
public void setUp() throws AtlasException { public void setUp() throws AtlasException {
GraphSandboxUtil.create();
//First get Instance //First get Instance
graph = new Titan1Graph(); graph = new Titan1Graph();
configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(),
......
...@@ -1240,6 +1240,14 @@ ...@@ -1240,6 +1240,14 @@
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-graphdb-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-server-api</artifactId> <artifactId>atlas-server-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
...@@ -1805,7 +1813,8 @@ ...@@ -1805,7 +1813,8 @@
<log4j.configuration>atlas-log4j.xml</log4j.configuration> <log4j.configuration>atlas-log4j.xml</log4j.configuration>
</systemProperties> </systemProperties>
<skipTests>${skipTests}</skipTests> <skipTests>${skipTests}</skipTests>
<forkMode>always</forkMode> <forkCount>2C</forkCount>
<reuseForks>false</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile> <redirectTestOutputToFile>true</redirectTestOutputToFile>
<argLine>-Djava.awt.headless=true -Dproject.version=${project.version} <argLine>-Djava.awt.headless=true -Dproject.version=${project.version}
-Dhadoop.tmp.dir="${project.build.directory}/tmp-hadoop-${user.name}" -Dhadoop.tmp.dir="${project.build.directory}/tmp-hadoop-${user.name}"
...@@ -1838,10 +1847,8 @@ ...@@ -1838,10 +1847,8 @@
-Xmx1024m -XX:MaxPermSize=512m ${atlas.surefire.options} -Xmx1024m -XX:MaxPermSize=512m ${atlas.surefire.options}
</argLine> </argLine>
<skip>${skipITs}</skip> <skip>${skipITs}</skip>
<parallel>none</parallel>
<reuseForks>false</reuseForks> <reuseForks>false</reuseForks>
<forkCount>1</forkCount> <forkCount>2C</forkCount>
<threadCount>5</threadCount>
<redirectTestOutputToFile>true</redirectTestOutputToFile> <redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration> </configuration>
<executions> <executions>
......
...@@ -144,7 +144,8 @@ ...@@ -144,7 +144,8 @@
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId> <artifactId>atlas-graphdb-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier> <classifier>tests</classifier>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
...@@ -222,8 +223,17 @@ ...@@ -222,8 +223,17 @@
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>net.alchim31.maven</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>scala-maven-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration combine.children="override">
<properties>
<property>
<name>listener</name>
<value>org.apache.atlas.DBSandboxer</value>
</property>
</properties>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
......
...@@ -20,7 +20,6 @@ package org.apache.atlas; ...@@ -20,7 +20,6 @@ package org.apache.atlas;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.repository.MetadataRepository; import org.apache.atlas.repository.MetadataRepository;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
...@@ -31,32 +30,22 @@ import org.apache.atlas.typesystem.Referenceable; ...@@ -31,32 +30,22 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.TypesSerialization; import org.apache.atlas.typesystem.json.TypesSerialization;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.types.AttributeDefinition; import org.apache.atlas.typesystem.types.*;
import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.typesystem.types.EnumTypeDefinition;
import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import org.apache.atlas.typesystem.types.IDataType;
import org.apache.atlas.typesystem.types.Multiplicity;
import org.apache.atlas.typesystem.types.StructTypeDefinition;
import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.TypeSystem;
import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_INPUTS; import javax.inject.Inject;
import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.inject.Inject; import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_INPUTS;
import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS;
/** /**
* Base Class to set up hive types and instances for tests * Base Class to set up hive types and instances for tests
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class BaseRepositoryTest { public class BaseRepositoryTest {
@Inject @Inject
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/
package org.apache.atlas;
import org.apache.atlas.graph.GraphSandboxUtil;
import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.testng.ITestContext;
import org.testng.TestListenerAdapter;
public class DBSandboxer extends TestListenerAdapter {
@Override
public void onStart(ITestContext context) {
GraphSandboxUtil.create();
}
@Override
public void onFinish(ITestContext context) {
AtlasGraphProvider.cleanup();
}
}
...@@ -29,7 +29,7 @@ import org.testng.annotations.Test; ...@@ -29,7 +29,7 @@ import org.testng.annotations.Test;
* Uses TestNG's Guice annotation to load the necessary modules and inject the * Uses TestNG's Guice annotation to load the necessary modules and inject the
* objects from Guice * objects from Guice
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class RepositoryServiceLoadingTest { public class RepositoryServiceLoadingTest {
@Test @Test
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/
package org.apache.atlas;
import org.apache.atlas.graph.GraphSandboxUtil;
public class TestOnlyModule extends RepositoryMetadataModule {
@Override
protected void configure() {
GraphSandboxUtil.create();
// Configure extra stuff for test DI here
super.configure();
}
}
...@@ -18,33 +18,9 @@ ...@@ -18,33 +18,9 @@
package org.apache.atlas; package org.apache.atlas;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; import com.google.common.collect.ImmutableList;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; import com.google.common.collect.ImmutableSet;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; import com.google.inject.Provider;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createTraitTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createUniqueRequiredAttrDef;
import static org.testng.Assert.assertEquals;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.listener.EntityChangeListener;
import org.apache.atlas.listener.TypesChangeListener; import org.apache.atlas.listener.TypesChangeListener;
import org.apache.atlas.repository.MetadataRepository; import org.apache.atlas.repository.MetadataRepository;
...@@ -65,19 +41,8 @@ import org.apache.atlas.typesystem.Referenceable; ...@@ -65,19 +41,8 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.typesystem.json.InstanceSerialization;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.types.AttributeDefinition; import org.apache.atlas.typesystem.types.*;
import org.apache.atlas.typesystem.types.AttributeInfo;
import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
import org.apache.atlas.typesystem.types.EnumTypeDefinition;
import org.apache.atlas.typesystem.types.EnumValue;
import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import org.apache.atlas.typesystem.types.IDataType;
import org.apache.atlas.typesystem.types.Multiplicity;
import org.apache.atlas.typesystem.types.StructTypeDefinition;
import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.TypeSystem;
import org.apache.atlas.typesystem.types.cache.DefaultTypeCache; import org.apache.atlas.typesystem.types.cache.DefaultTypeCache;
import org.apache.atlas.typesystem.types.cache.TypeCache; import org.apache.atlas.typesystem.types.cache.TypeCache;
import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.atlas.typesystem.types.utils.TypesUtil;
...@@ -88,9 +53,27 @@ import org.codehaus.jettison.json.JSONArray; ...@@ -88,9 +53,27 @@ import org.codehaus.jettison.json.JSONArray;
import org.testng.Assert; import org.testng.Assert;
import org.testng.SkipException; import org.testng.SkipException;
import com.google.common.collect.ImmutableList; import java.io.File;
import com.google.common.collect.ImmutableSet; import java.io.FileOutputStream;
import com.google.inject.Provider; import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.*;
import static org.testng.Assert.assertEquals;
/** /**
* Test utility class. * Test utility class.
......
...@@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableList; ...@@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableList;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.BaseRepositoryTest; import org.apache.atlas.BaseRepositoryTest;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.query.QueryParams; import org.apache.atlas.query.QueryParams;
import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Referenceable;
...@@ -55,7 +55,7 @@ import static org.testng.Assert.fail; ...@@ -55,7 +55,7 @@ import static org.testng.Assert.fail;
/** /**
* Unit tests for Hive LineageService. * Unit tests for Hive LineageService.
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class DataSetLineageServiceTest extends BaseRepositoryTest { public class DataSetLineageServiceTest extends BaseRepositoryTest {
@Inject @Inject
......
...@@ -18,30 +18,11 @@ ...@@ -18,30 +18,11 @@
package org.apache.atlas.discovery; package org.apache.atlas.discovery;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; import com.google.common.collect.ImmutableSet;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.BaseRepositoryTest; import org.apache.atlas.BaseRepositoryTest;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService;
import org.apache.atlas.query.QueryParams; import org.apache.atlas.query.QueryParams;
...@@ -64,7 +45,6 @@ import org.codehaus.jettison.json.JSONArray; ...@@ -64,7 +45,6 @@ import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
...@@ -72,9 +52,17 @@ import org.testng.annotations.DataProvider; ...@@ -72,9 +52,17 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import javax.inject.Inject;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
@Inject @Inject
......
...@@ -18,22 +18,11 @@ ...@@ -18,22 +18,11 @@
package org.apache.atlas.lineage; package org.apache.atlas.lineage;
import static org.testng.Assert.assertEquals; import com.google.common.collect.ImmutableList;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.BaseRepositoryTest; import org.apache.atlas.BaseRepositoryTest;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.discovery.EntityLineageService; import org.apache.atlas.discovery.EntityLineageService;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -49,17 +38,25 @@ import org.apache.commons.lang.RandomStringUtils; ...@@ -49,17 +38,25 @@ import org.apache.commons.lang.RandomStringUtils;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import javax.inject.Inject;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
/** /**
* Unit tests for the new v2 Instance LineageService. * Unit tests for the new v2 Instance LineageService.
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class EntityLineageServiceTest extends BaseRepositoryTest { public class EntityLineageServiceTest extends BaseRepositoryTest {
@Inject @Inject
......
...@@ -17,12 +17,7 @@ ...@@ -17,12 +17,7 @@
*/ */
package org.apache.atlas.query; package org.apache.atlas.query;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; import com.google.common.collect.ImmutableSet;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
import java.util.HashSet;
import java.util.Set;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.types.ClassType; import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes; import org.apache.atlas.typesystem.types.DataTypes;
...@@ -32,14 +27,17 @@ import org.apache.atlas.typesystem.types.IDataType; ...@@ -32,14 +27,17 @@ import org.apache.atlas.typesystem.types.IDataType;
import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.typesystem.types.TypeSystem;
import org.apache.atlas.typesystem.types.cache.DefaultTypeCache; import org.apache.atlas.typesystem.types.cache.DefaultTypeCache;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
import com.google.common.collect.ImmutableSet;
import scala.util.Either; import scala.util.Either;
import scala.util.parsing.combinator.Parsers; import scala.util.parsing.combinator.Parsers;
import java.util.HashSet;
import java.util.Set;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/** /**
* Tests the logic for skipping type cache lookup for things that * Tests the logic for skipping type cache lookup for things that
* cannot be types. * cannot be types.
......
...@@ -17,16 +17,6 @@ ...@@ -17,16 +17,6 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.gremlin.GremlinExpressionFactory; import org.apache.atlas.gremlin.GremlinExpressionFactory;
import org.apache.atlas.gremlin.optimizer.GremlinQueryOptimizer; import org.apache.atlas.gremlin.optimizer.GremlinQueryOptimizer;
...@@ -54,19 +44,31 @@ import org.apache.atlas.typesystem.types.TypeSystem; ...@@ -54,19 +44,31 @@ import org.apache.atlas.typesystem.types.TypeSystem;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
public abstract class AbstractGremlinQueryOptimizerTest implements IAtlasGraphProvider { public abstract class AbstractGremlinQueryOptimizerTest implements IAtlasGraphProvider {
protected abstract GremlinExpressionFactory getFactory(); protected abstract GremlinExpressionFactory getFactory();
private MetadataRepository repo = new GraphBackedMetadataRepository(this, new HardDeleteHandler(TypeSystem.getInstance())); private MetadataRepository repo;
private final GraphPersistenceStrategies STRATEGY = mock(GraphPersistenceStrategies.class); private final GraphPersistenceStrategies STRATEGY = mock(GraphPersistenceStrategies.class);
@BeforeClass @BeforeClass
public void setUp() { public void setUp() {
GremlinQueryOptimizer.reset(); GremlinQueryOptimizer.reset();
GremlinQueryOptimizer.setExpressionFactory(getFactory()); GremlinQueryOptimizer.setExpressionFactory(getFactory());
when(STRATEGY.typeAttributeName()).thenReturn(Constants.ENTITY_TYPE_PROPERTY_KEY); when(STRATEGY.typeAttributeName()).thenReturn(Constants.ENTITY_TYPE_PROPERTY_KEY);
when(STRATEGY.superTypeAttributeName()).thenReturn(Constants.SUPER_TYPES_PROPERTY_KEY); when(STRATEGY.superTypeAttributeName()).thenReturn(Constants.SUPER_TYPES_PROPERTY_KEY);
repo = new GraphBackedMetadataRepository(this, new HardDeleteHandler(TypeSystem.getInstance()));
} }
private FieldInfo getTestFieldInfo() throws AtlasException { private FieldInfo getTestFieldInfo() throws AtlasException {
...@@ -695,6 +697,7 @@ public abstract class AbstractGremlinQueryOptimizerTest implements IAtlasGraphPr ...@@ -695,6 +697,7 @@ public abstract class AbstractGremlinQueryOptimizerTest implements IAtlasGraphPr
protected abstract String getExpectedGremlinForTestRangeWithOrderBy(); protected abstract String getExpectedGremlinForTestRangeWithOrderBy();
@Override @Override
public AtlasGraph get() throws RepositoryException { public AtlasGraph get() throws RepositoryException {
AtlasGraph graph = mock(AtlasGraph.class); AtlasGraph graph = mock(AtlasGraph.class);
......
...@@ -20,15 +20,14 @@ package org.apache.atlas.repository.graph; ...@@ -20,15 +20,14 @@ package org.apache.atlas.repository.graph;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasClient.EntityResult; import org.apache.atlas.AtlasClient.EntityResult;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.repository.MetadataRepository; import org.apache.atlas.repository.MetadataRepository;
import org.apache.atlas.repository.RepositoryException; import org.apache.atlas.repository.RepositoryException;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
...@@ -45,16 +44,7 @@ import org.apache.atlas.typesystem.exception.EntityExistsException; ...@@ -45,16 +44,7 @@ import org.apache.atlas.typesystem.exception.EntityExistsException;
import org.apache.atlas.typesystem.exception.EntityNotFoundException; import org.apache.atlas.typesystem.exception.EntityNotFoundException;
import org.apache.atlas.typesystem.exception.NullRequiredAttributeException; import org.apache.atlas.typesystem.exception.NullRequiredAttributeException;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.types.AttributeDefinition; import org.apache.atlas.typesystem.types.*;
import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.typesystem.types.EnumTypeDefinition;
import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import org.apache.atlas.typesystem.types.IDataType;
import org.apache.atlas.typesystem.types.Multiplicity;
import org.apache.atlas.typesystem.types.StructTypeDefinition;
import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.TypeSystem;
import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
...@@ -70,15 +60,7 @@ import java.util.HashMap; ...@@ -70,15 +60,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.apache.atlas.TestUtils.COLUMNS_ATTR_NAME; import static org.apache.atlas.TestUtils.*;
import static org.apache.atlas.TestUtils.COLUMN_TYPE;
import static org.apache.atlas.TestUtils.NAME;
import static org.apache.atlas.TestUtils.PII;
import static org.apache.atlas.TestUtils.PROCESS_TYPE;
import static org.apache.atlas.TestUtils.TABLE_TYPE;
import static org.apache.atlas.TestUtils.createColumnEntity;
import static org.apache.atlas.TestUtils.createDBEntity;
import static org.apache.atlas.TestUtils.createTableEntity;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
...@@ -90,7 +72,7 @@ import static org.testng.Assert.fail; ...@@ -90,7 +72,7 @@ import static org.testng.Assert.fail;
* Guice loads the dependencies and injects the necessary objects * Guice loads the dependencies and injects the necessary objects
* *
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public abstract class GraphBackedMetadataRepositoryDeleteTestBase { public abstract class GraphBackedMetadataRepositoryDeleteTestBase {
protected MetadataRepository repositoryService; protected MetadataRepository repositoryService;
......
...@@ -18,32 +18,13 @@ ...@@ -18,32 +18,13 @@
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; import com.google.common.collect.ImmutableList;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createUniqueRequiredAttrDef; import com.google.common.collect.ImmutableSet;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import javax.inject.Inject;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.GraphTransaction; import org.apache.atlas.GraphTransaction;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService;
import org.apache.atlas.query.QueryParams; import org.apache.atlas.query.QueryParams;
...@@ -84,10 +65,26 @@ import org.testng.annotations.BeforeMethod; ...@@ -84,10 +65,26 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import javax.inject.Inject;
import com.google.common.collect.ImmutableSet; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createUniqueRequiredAttrDef;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/** /**
* GraphBackedMetadataRepository test * GraphBackedMetadataRepository test
...@@ -95,7 +92,7 @@ import java.util.Arrays; ...@@ -95,7 +92,7 @@ import java.util.Arrays;
* Guice loads the dependencies and injects the necessary objects * Guice loads the dependencies and injects the necessary objects
* *
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class GraphBackedMetadataRepositoryTest { public class GraphBackedMetadataRepositoryTest {
@Inject @Inject
......
...@@ -18,12 +18,11 @@ ...@@ -18,12 +18,11 @@
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance;
......
...@@ -18,12 +18,11 @@ ...@@ -18,12 +18,11 @@
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance;
......
...@@ -18,16 +18,9 @@ ...@@ -18,16 +18,9 @@
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import static junit.framework.Assert.assertTrue; import com.google.inject.Inject;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import java.util.Arrays;
import java.util.Set;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraph;
...@@ -45,12 +38,16 @@ import org.apache.commons.lang.RandomStringUtils; ...@@ -45,12 +38,16 @@ import org.apache.commons.lang.RandomStringUtils;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Inject; import java.util.Arrays;
import java.util.Set;
@Guice(modules = RepositoryMetadataModule.class)
public class GraphBackedSearchIndexerTest {
import static junit.framework.Assert.assertTrue;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
@Guice(modules = TestOnlyModule.class)
public class GraphBackedSearchIndexerTest {
@Inject @Inject
private GraphBackedSearchIndexer graphBackedSearchIndexer; private GraphBackedSearchIndexer graphBackedSearchIndexer;
......
...@@ -17,12 +17,6 @@ ...@@ -17,12 +17,6 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import java.util.Iterator;
import org.apache.atlas.repository.RepositoryException; import org.apache.atlas.repository.RepositoryException;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
...@@ -32,6 +26,12 @@ import org.mockito.MockitoAnnotations; ...@@ -32,6 +26,12 @@ import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Iterator;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
public class GraphHelperMockTest { public class GraphHelperMockTest {
private GraphHelper graphHelperInstance; private GraphHelper graphHelperInstance;
......
...@@ -18,25 +18,8 @@ ...@@ -18,25 +18,8 @@
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.graph.GraphHelper.VertexInfo; import org.apache.atlas.repository.graph.GraphHelper.VertexInfo;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
...@@ -61,7 +44,19 @@ import org.testng.annotations.DataProvider; ...@@ -61,7 +44,19 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Guice(modules = RepositoryMetadataModule.class) import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.testng.Assert.*;
@Guice(modules = TestOnlyModule.class)
public class GraphHelperTest { public class GraphHelperTest {
......
...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.graph; ...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.graph;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.GraphTransaction; import org.apache.atlas.GraphTransaction;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.RepositoryException; import org.apache.atlas.repository.RepositoryException;
...@@ -47,15 +47,14 @@ import org.testng.annotations.BeforeMethod; ...@@ -47,15 +47,14 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import javax.inject.Inject;
@Test @Test
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class GraphRepoMapperScaleTest { public class GraphRepoMapperScaleTest {
private static final String DATABASE_NAME = "foo"; private static final String DATABASE_NAME = "foo";
......
...@@ -24,12 +24,13 @@ import org.testng.annotations.Test; ...@@ -24,12 +24,13 @@ import org.testng.annotations.Test;
@Test @Test
public class Gremlin2QueryOptimizerTest extends AbstractGremlinQueryOptimizerTest { public class Gremlin2QueryOptimizerTest extends AbstractGremlinQueryOptimizerTest {
private static GremlinExpressionFactory FACTORY = null;
private static final GremlinExpressionFactory FACTORY = new Gremlin2ExpressionFactory();
@Override @Override
protected GremlinExpressionFactory getFactory() { protected GremlinExpressionFactory getFactory() {
if (null == FACTORY) {
FACTORY = new Gremlin2ExpressionFactory();
}
return FACTORY; return FACTORY;
} }
......
...@@ -25,10 +25,13 @@ import org.testng.annotations.Test; ...@@ -25,10 +25,13 @@ import org.testng.annotations.Test;
@Test @Test
public class Gremlin3QueryOptimizerTest extends AbstractGremlinQueryOptimizerTest { public class Gremlin3QueryOptimizerTest extends AbstractGremlinQueryOptimizerTest {
public static final GremlinExpressionFactory FACTORY = new Gremlin3ExpressionFactory(); public static GremlinExpressionFactory FACTORY = null;
@Override @Override
protected GremlinExpressionFactory getFactory() { protected GremlinExpressionFactory getFactory() {
if (null == FACTORY) {
FACTORY = new Gremlin3ExpressionFactory();
}
return FACTORY; return FACTORY;
} }
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import java.util.List;
import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.typesystem.types.TypeSystem;
import org.testng.Assert; import org.testng.Assert;
import java.util.List;
/** /**
* Run tests in {@link ReverseReferenceUpdateTestBase} with hard delete enabled. * Run tests in {@link ReverseReferenceUpdateTestBase} with hard delete enabled.
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import java.util.Iterator;
import java.util.List;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
...@@ -28,6 +25,9 @@ import org.apache.atlas.typesystem.persistence.Id; ...@@ -28,6 +25,9 @@ import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.typesystem.types.TypeSystem;
import org.testng.Assert; import org.testng.Assert;
import java.util.Iterator;
import java.util.List;
/** /**
* Run tests in {@link ReverseReferenceUpdateTestBase} with soft delete enabled. * Run tests in {@link ReverseReferenceUpdateTestBase} with soft delete enabled.
......
...@@ -17,13 +17,11 @@ ...@@ -17,13 +17,11 @@
*/ */
package org.apache.atlas.repository.graph; package org.apache.atlas.repository.graph;
import java.util.Arrays; import com.google.common.collect.ImmutableList;
import java.util.Collections; import com.google.common.collect.ImmutableSet;
import java.util.List; import com.google.inject.Inject;
import java.util.Map;
import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.CreateUpdateEntitiesResult;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.MetadataRepository; import org.apache.atlas.repository.MetadataRepository;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
...@@ -45,15 +43,16 @@ import org.testng.annotations.BeforeMethod; ...@@ -45,15 +43,16 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import java.util.Arrays;
import com.google.common.collect.ImmutableSet; import java.util.Collections;
import com.google.inject.Inject; import java.util.List;
import java.util.Map;
/** /**
* Verifies automatic update of reverse references * Verifies automatic update of reverse references
* *
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public abstract class ReverseReferenceUpdateTestBase { public abstract class ReverseReferenceUpdateTestBase {
@Inject @Inject
......
...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.impexp; ...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.impexp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasExportRequest; import org.apache.atlas.model.impexp.AtlasExportRequest;
...@@ -35,10 +35,10 @@ import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1; ...@@ -35,10 +35,10 @@ import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.testng.Assert;
import org.powermock.reflect.Whitebox;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.powermock.reflect.Whitebox;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
...@@ -57,7 +57,7 @@ import java.util.Map; ...@@ -57,7 +57,7 @@ import java.util.Map;
import static org.testng.Assert.*; import static org.testng.Assert.*;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class ExportServiceTest { public class ExportServiceTest {
private static final Logger LOG = LoggerFactory.getLogger(ExportServiceTest.class); private static final Logger LOG = LoggerFactory.getLogger(ExportServiceTest.class);
......
...@@ -18,24 +18,15 @@ ...@@ -18,24 +18,15 @@
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.IOException; @Guice(modules = TestOnlyModule.class)
import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZipSource;
import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.loadModelFromJson;
import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runAndVerifyQuickStart_v1_Import;
@Guice(modules = RepositoryMetadataModule.class)
public class ImportServiceReportingTest { public class ImportServiceReportingTest {
private static final Logger LOG = LoggerFactory.getLogger(ImportServiceReportingTest.class); private static final Logger LOG = LoggerFactory.getLogger(ImportServiceReportingTest.class);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.repository.impexp; package org.apache.atlas.repository.impexp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
...@@ -36,7 +36,7 @@ import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZip ...@@ -36,7 +36,7 @@ import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZip
import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.loadModelFromJson; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.loadModelFromJson;
import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runAndVerifyQuickStart_v1_Import; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runAndVerifyQuickStart_v1_Import;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class ImportServiceTest { public class ImportServiceTest {
private static final Logger LOG = LoggerFactory.getLogger(ImportServiceTest.class); private static final Logger LOG = LoggerFactory.getLogger(ImportServiceTest.class);
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
package org.apache.atlas.repository.store.graph; package org.apache.atlas.repository.store.graph;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter; import org.apache.atlas.model.SearchFilter;
...@@ -38,18 +37,12 @@ import org.testng.annotations.DataProvider; ...@@ -38,18 +37,12 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.*;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class AtlasTypeDefGraphStoreTest { public class AtlasTypeDefGraphStoreTest {
private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreTest.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreTest.class);
......
...@@ -20,9 +20,8 @@ package org.apache.atlas.repository.store.graph.v1; ...@@ -20,9 +20,8 @@ package org.apache.atlas.repository.store.graph.v1;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -38,7 +37,6 @@ import org.apache.atlas.model.typedef.AtlasEnumDef; ...@@ -38,7 +37,6 @@ import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.RepositoryException;
import org.apache.atlas.repository.graph.AtlasEdgeLabel; import org.apache.atlas.repository.graph.AtlasEdgeLabel;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
...@@ -69,7 +67,6 @@ import org.testng.annotations.Guice; ...@@ -69,7 +67,6 @@ import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
...@@ -77,18 +74,14 @@ import java.util.HashMap; ...@@ -77,18 +74,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.apache.atlas.TestUtils.COLUMNS_ATTR_NAME; import static org.apache.atlas.TestUtils.*;
import static org.apache.atlas.TestUtils.COLUMN_TYPE;
import static org.apache.atlas.TestUtils.DEPARTMENT_TYPE;
import static org.apache.atlas.TestUtils.NAME;
import static org.apache.atlas.TestUtils.TABLE_TYPE;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public abstract class AtlasDeleteHandlerV1Test { public abstract class AtlasDeleteHandlerV1Test {
@Inject @Inject
......
...@@ -20,8 +20,8 @@ package org.apache.atlas.repository.store.graph.v1; ...@@ -20,8 +20,8 @@ package org.apache.atlas.repository.store.graph.v1;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -77,7 +77,7 @@ import static org.mockito.Mockito.mock; ...@@ -77,7 +77,7 @@ import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class AtlasEntityStoreV1Test { public class AtlasEntityStoreV1Test {
private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1Test.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1Test.class);
......
...@@ -17,17 +17,16 @@ ...@@ -17,17 +17,16 @@
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v1;
import static org.testng.Assert.assertEquals; import com.google.common.collect.ImmutableList;
import static org.testng.Assert.assertTrue;
import java.util.Map;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import com.google.common.collect.ImmutableList; import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/** /**
* Inverse reference update test with {@link HardDeleteHandlerV1} * Inverse reference update test with {@link HardDeleteHandlerV1}
......
...@@ -17,17 +17,16 @@ ...@@ -17,17 +17,16 @@
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v1;
import static org.testng.Assert.assertEquals; import com.google.common.collect.ImmutableList;
import static org.testng.Assert.assertTrue;
import java.util.Map;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import com.google.common.collect.ImmutableList; import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/** /**
......
...@@ -17,21 +17,10 @@ ...@@ -17,21 +17,10 @@
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v1;
import static org.apache.atlas.TestUtils.NAME; import com.google.common.collect.ImmutableList;
import static org.mockito.Mockito.mock; import com.google.common.collect.ImmutableMap;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -56,14 +45,23 @@ import org.testng.annotations.BeforeMethod; ...@@ -56,14 +45,23 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import javax.inject.Inject;
import com.google.common.collect.ImmutableMap; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.apache.atlas.TestUtils.NAME;
import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
/** /**
* Test automatic inverse reference updating in V1 (V2?) code path. * Test automatic inverse reference updating in V1 (V2?) code path.
* *
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public abstract class InverseReferenceUpdateV1Test { public abstract class InverseReferenceUpdateV1Test {
@Inject @Inject
......
...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.typestore; ...@@ -21,7 +21,7 @@ package org.apache.atlas.repository.typestore;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.RepositoryException; import org.apache.atlas.repository.RepositoryException;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
...@@ -50,7 +50,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAt ...@@ -50,7 +50,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAt
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class GraphBackedTypeStoreTest { public class GraphBackedTypeStoreTest {
private static final String DESCRIPTION = "_description"; private static final String DESCRIPTION = "_description";
......
...@@ -17,19 +17,18 @@ ...@@ -17,19 +17,18 @@
*/ */
package org.apache.atlas.repository.typestore; package org.apache.atlas.repository.typestore;
import com.google.inject.Inject;
import org.apache.atlas.typesystem.types.cache.TypeCache; import org.apache.atlas.typesystem.types.cache.TypeCache;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Inject;
/** /**
* Verify Guice can successfully instantiate and inject StoreBackTypeCache. * Verify Guice can successfully instantiate and inject StoreBackTypeCache.
* StoreBackedTypeCacheTestModule Guice module uses Atlas configuration * StoreBackedTypeCacheTestModule Guice module uses Atlas configuration
* which has type cache implementation class set to {@link StoreBackedTypeCache}. * which has type cache implementation class set to {@link StoreBackedTypeCache}.
*/ */
@Guice(modules = StoreBackedTypeCacheTestModule.class) @Guice(modules = StoreBackedTypeCacheTestOnlyModule.class)
public class StoreBackedTypeCacheConfigurationTest { public class StoreBackedTypeCacheConfigurationTest {
@Inject @Inject
......
...@@ -17,13 +17,10 @@ ...@@ -17,13 +17,10 @@
*/ */
package org.apache.atlas.repository.typestore; package org.apache.atlas.repository.typestore;
import java.util.HashMap; import com.google.common.collect.ImmutableList;
import java.util.Map; import com.google.common.collect.ImmutableSet;
import javax.inject.Inject;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.typesystem.types.AttributeInfo; import org.apache.atlas.typesystem.types.AttributeInfo;
...@@ -41,14 +38,15 @@ import org.testng.annotations.BeforeMethod; ...@@ -41,14 +38,15 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import javax.inject.Inject;
import com.google.common.collect.ImmutableSet; import java.util.HashMap;
import java.util.Map;
/** /**
* Unit test for {@link StoreBackedTypeCache} * Unit test for {@link StoreBackedTypeCache}
*/ */
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class StoreBackedTypeCacheTest { public class StoreBackedTypeCacheTest {
@Inject @Inject
......
...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.typestore; ...@@ -19,7 +19,7 @@ package org.apache.atlas.repository.typestore;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.util.AtlasRepositoryConfiguration; import org.apache.atlas.util.AtlasRepositoryConfiguration;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
...@@ -28,7 +28,8 @@ import org.apache.commons.configuration.Configuration; ...@@ -28,7 +28,8 @@ import org.apache.commons.configuration.Configuration;
* Guice module which sets TypeCache implementation class configuration property to {@link StoreBackedTypeCache}. * Guice module which sets TypeCache implementation class configuration property to {@link StoreBackedTypeCache}.
* *
*/ */
public class StoreBackedTypeCacheTestModule extends RepositoryMetadataModule { public class StoreBackedTypeCacheTestOnlyModule extends TestOnlyModule {
@Override @Override
protected Configuration getConfiguration() { protected Configuration getConfiguration() {
try { try {
......
...@@ -18,36 +18,14 @@ ...@@ -18,36 +18,14 @@
package org.apache.atlas.service; package org.apache.atlas.service;
import static org.apache.atlas.TestUtils.COLUMNS_ATTR_NAME; import com.google.common.collect.ImmutableList;
import static org.apache.atlas.TestUtils.COLUMN_TYPE; import com.google.common.collect.ImmutableSet;
import static org.apache.atlas.TestUtils.PII; import com.google.inject.Inject;
import static org.apache.atlas.TestUtils.TABLE_TYPE;
import static org.apache.atlas.TestUtils.createColumnEntity;
import static org.apache.atlas.TestUtils.createDBEntity;
import static org.apache.atlas.TestUtils.createInstance;
import static org.apache.atlas.TestUtils.createTableEntity;
import static org.apache.atlas.TestUtils.randomString;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.EntityAuditEvent;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
...@@ -94,11 +72,20 @@ import org.testng.annotations.BeforeTest; ...@@ -94,11 +72,20 @@ import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import java.util.ArrayList;
import com.google.common.collect.ImmutableSet; import java.util.Arrays;
import com.google.inject.Inject; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.apache.atlas.TestUtils.*;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
import static org.testng.Assert.*;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = TestOnlyModule.class)
public class DefaultMetadataServiceTest { public class DefaultMetadataServiceTest {
@Inject @Inject
private MetadataService metadataService; private MetadataService metadataService;
......
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
*/ */
package org.apache.atlas.service; package org.apache.atlas.service;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.typestore.ITypeStore; import org.apache.atlas.repository.typestore.ITypeStore;
import org.apache.atlas.repository.typestore.StoreBackedTypeCache; import org.apache.atlas.repository.typestore.StoreBackedTypeCache;
import org.apache.atlas.repository.typestore.StoreBackedTypeCacheTestModule; import org.apache.atlas.repository.typestore.StoreBackedTypeCacheTestOnlyModule;
import org.apache.atlas.services.MetadataService; import org.apache.atlas.services.MetadataService;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.TypesSerialization; import org.apache.atlas.typesystem.json.TypesSerialization;
...@@ -41,19 +44,14 @@ import org.testng.annotations.BeforeMethod; ...@@ -41,19 +44,14 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;
/** /**
* Verify MetadataService type operations trigger StoreBackedTypeCache to load non-cached types from the store. * Verify MetadataService type operations trigger StoreBackedTypeCache to load non-cached types from the store.
* StoreBackedTypeCacheTestModule Guice module sets Atlas configuration * StoreBackedTypeCacheTestModule Guice module sets Atlas configuration
* to use {@link StoreBackedTypeCache} as the TypeCache implementation class. * to use {@link StoreBackedTypeCache} as the TypeCache implementation class.
*/ */
@Guice(modules = StoreBackedTypeCacheTestModule.class) @Guice(modules = StoreBackedTypeCacheTestOnlyModule.class)
public class StoreBackedTypeCacheMetadataServiceTest public class StoreBackedTypeCacheMetadataServiceTest {
{
@Inject @Inject
private MetadataService metadataService; private MetadataService metadataService;
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
package org.apache.atlas.util; package org.apache.atlas.util;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotSame;
import org.apache.atlas.query.QueryParams; import org.apache.atlas.query.QueryParams;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotSame;
/** /**
* Tests hashcode/equals behavior of CompiledQueryCacheKey * Tests hashcode/equals behavior of CompiledQueryCacheKey
* *
......
...@@ -18,13 +18,6 @@ ...@@ -18,13 +18,6 @@
package org.apache.atlas.utils; package org.apache.atlas.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtils;
import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Referenceable;
...@@ -34,6 +27,13 @@ import org.apache.atlas.typesystem.types.ClassType; ...@@ -34,6 +27,13 @@ import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.Multiplicity; import org.apache.atlas.typesystem.types.Multiplicity;
import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.typesystem.types.TypeSystem;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/** /**
* Allows easy creation of entities for classes in the hive test model. * Allows easy creation of entities for classes in the hive test model.
* *
......
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
package org.apache.atlas.query package org.apache.atlas.query
import org.apache.atlas.DBSandboxer
import org.apache.atlas.query.Expressions._ import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.BaseTest import org.apache.atlas.repository.BaseTest
import org.testng.annotations.{BeforeMethod,Test} import org.testng.annotations.{BeforeMethod, Listeners, Test}
class ExpressionTest extends BaseTest { class ExpressionTest extends BaseTest {
......
...@@ -23,10 +23,10 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy ...@@ -23,10 +23,10 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._ import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.graph.{AtlasGraphProvider, GraphBackedMetadataRepository} import org.apache.atlas.repository.graph.{AtlasGraphProvider, GraphBackedMetadataRepository}
import org.apache.atlas.typesystem.types.TypeSystem import org.apache.atlas.typesystem.types.TypeSystem
import org.testng.annotations.{Test,BeforeClass,AfterClass} import org.testng.annotations._
import org.apache.atlas.repository.graph.AtlasGraphProvider import org.apache.atlas.repository.graph.AtlasGraphProvider
import org.testng.annotations.BeforeMethod import org.apache.atlas.{DBSandboxer, TestUtils}
import org.apache.atlas.TestUtils import org.apache.atlas.graph.GraphSandboxUtil
class GremlinTest extends BaseGremlinTest { class GremlinTest extends BaseGremlinTest {
...@@ -41,10 +41,10 @@ class GremlinTest extends BaseGremlinTest { ...@@ -41,10 +41,10 @@ class GremlinTest extends BaseGremlinTest {
@BeforeClass @BeforeClass
def beforeAll() { def beforeAll() {
TypeSystem.getInstance().reset() TypeSystem.getInstance().reset()
var repo = new GraphBackedMetadataRepository(null); var repo = new GraphBackedMetadataRepository(null)
TestUtils.setupGraphProvider(repo); TestUtils.setupGraphProvider(repo)
//force graph to be initialized first //force graph to be initialized first
AtlasGraphProvider.getGraphInstance(); AtlasGraphProvider.getGraphInstance()
//create types and indices up front. Without this, some of the property keys (particularly __traitNames and __superTypes) //create types and indices up front. Without this, some of the property keys (particularly __traitNames and __superTypes)
//get ended up created implicitly with some graph backends with the wrong multiplicity. This also makes the queries //get ended up created implicitly with some graph backends with the wrong multiplicity. This also makes the queries
...@@ -53,12 +53,11 @@ class GremlinTest extends BaseGremlinTest { ...@@ -53,12 +53,11 @@ class GremlinTest extends BaseGremlinTest {
gp = new DefaultGraphPersistenceStrategy(repo) gp = new DefaultGraphPersistenceStrategy(repo)
g = QueryTestsUtils.setupTestGraph(repo) g = QueryTestsUtils.setupTestGraph(repo)
g
} }
@AfterClass @AfterClass
def afterAll() { def afterAll() {
AtlasGraphProvider.cleanup(); AtlasGraphProvider.cleanup()
} }
...@@ -236,7 +235,7 @@ class GremlinTest extends BaseGremlinTest { ...@@ -236,7 +235,7 @@ class GremlinTest extends BaseGremlinTest {
| "clusterName": "test" | "clusterName": "test"
| } | }
| ] | ]
|}""".stripMargin); |}""".stripMargin)
} }
@Test def testFilter2 { @Test def testFilter2 {
...@@ -315,7 +314,7 @@ class GremlinTest extends BaseGremlinTest { ...@@ -315,7 +314,7 @@ class GremlinTest extends BaseGremlinTest {
| "clusterName": "test" | "clusterName": "test"
| } | }
| ] | ]
|}""".stripMargin); |}""".stripMargin)
} }
@Test def testSelect { @Test def testSelect {
...@@ -361,7 +360,7 @@ class GremlinTest extends BaseGremlinTest { ...@@ -361,7 +360,7 @@ class GremlinTest extends BaseGremlinTest {
| "_src1.name": "Reporting" | "_src1.name": "Reporting"
| } | }
| ] | ]
|}""".stripMargin); |}""".stripMargin)
} }
@Test def testIsTrait { @Test def testIsTrait {
...@@ -774,7 +773,7 @@ class GremlinTest extends BaseGremlinTest { ...@@ -774,7 +773,7 @@ class GremlinTest extends BaseGremlinTest {
| "name":"sales_fact_monthly_mv" | "name":"sales_fact_monthly_mv"
| } | }
| ] | ]
|}""".stripMargin); |}""".stripMargin)
} }
@Test def testBackReference { @Test def testBackReference {
...@@ -868,13 +867,13 @@ class GremlinTest extends BaseGremlinTest { ...@@ -868,13 +867,13 @@ class GremlinTest extends BaseGremlinTest {
| "clusterName": "test" | "clusterName": "test"
| } | }
| ] | ]
|}""".stripMargin); |}""".stripMargin)
} }
@Test def testJoinAndSelect1 { @Test def testJoinAndSelect1 {
val r = QueryProcessor.evaluate( val r = QueryProcessor.evaluate(
_class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab"). _class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab").
where((isTrait("Dimension"))). where(isTrait("Dimension")).
select(id("db1").field("name").as("dbName"), id("tab").field("name").as("tabName")), g, gp select(id("db1").field("name").as("dbName"), id("tab").field("name").as("tabName")), g, gp
) )
validateJson(r, "{\n \"query\":\"DB as db1 where (name = \\\"Sales\\\") Table as tab where DB as db1 where (name = \\\"Sales\\\") Table as tab is Dimension as _src1 select db1.name as dbName, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"__tempQueryResultStruct5\",\n \"attributeDefinitions\":[\n {\n \"name\":\"dbName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"tabName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"customer_dim\"\n }\n ]\n}") validateJson(r, "{\n \"query\":\"DB as db1 where (name = \\\"Sales\\\") Table as tab where DB as db1 where (name = \\\"Sales\\\") Table as tab is Dimension as _src1 select db1.name as dbName, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"__tempQueryResultStruct5\",\n \"attributeDefinitions\":[\n {\n \"name\":\"dbName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"tabName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct5\",\n \"dbName\":\"Sales\",\n \"tabName\":\"customer_dim\"\n }\n ]\n}")
...@@ -902,7 +901,7 @@ class GremlinTest extends BaseGremlinTest { ...@@ -902,7 +901,7 @@ class GremlinTest extends BaseGremlinTest {
@Test def testJoinAndSelect4 { @Test def testJoinAndSelect4 {
val r = QueryProcessor.evaluate( val r = QueryProcessor.evaluate(
_class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab"). _class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab").
where((isTrait("Dimension"))). where(isTrait("Dimension")).
select(id("db1").as("dbO"), id("tab").field("name").as("tabName")), g, gp select(id("db1").as("dbO"), id("tab").field("name").as("tabName")), g, gp
) )
validateJson(r, "{\n \"query\":\"DB as db1 where (name = \\\"Sales\\\") Table as tab where DB as db1 where (name = \\\"Sales\\\") Table as tab is Dimension as _src1 select db1 as dbO, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"\",\n \"attributeDefinitions\":[\n {\n \"name\":\"dbO\",\n \"dataTypeName\":\"DB\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"tabName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"customer_dim\"\n }\n ]\n}") validateJson(r, "{\n \"query\":\"DB as db1 where (name = \\\"Sales\\\") Table as tab where DB as db1 where (name = \\\"Sales\\\") Table as tab is Dimension as _src1 select db1 as dbO, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"\",\n \"attributeDefinitions\":[\n {\n \"name\":\"dbO\",\n \"dataTypeName\":\"DB\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"tabName\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":false,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"\",\n \"dbO\":{\n \"$typeName$\":\"DB\",\n \"version\":0\n },\n \"tabName\":\"customer_dim\"\n }\n ]\n}")
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.query package org.apache.atlas.query
import org.apache.atlas.TestUtils import org.apache.atlas.{DBSandboxer, TestUtils}
import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._class import org.apache.atlas.query.Expressions._class
import org.apache.atlas.query.Expressions._trait import org.apache.atlas.query.Expressions._trait
...@@ -26,10 +26,7 @@ import org.apache.atlas.query.Expressions.id ...@@ -26,10 +26,7 @@ import org.apache.atlas.query.Expressions.id
import org.apache.atlas.repository.graph.GraphBackedMetadataRepository import org.apache.atlas.repository.graph.GraphBackedMetadataRepository
import org.apache.atlas.repository.graphdb.AtlasGraph import org.apache.atlas.repository.graphdb.AtlasGraph
import org.apache.atlas.typesystem.types.TypeSystem import org.apache.atlas.typesystem.types.TypeSystem
import org.testng.annotations.AfterClass import org.testng.annotations._
import org.testng.annotations.BeforeClass
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test
import org.apache.atlas.repository.graph.AtlasGraphProvider import org.apache.atlas.repository.graph.AtlasGraphProvider
class GremlinTest2 extends BaseGremlinTest { class GremlinTest2 extends BaseGremlinTest {
...@@ -152,8 +149,6 @@ class GremlinTest2 extends BaseGremlinTest { ...@@ -152,8 +149,6 @@ class GremlinTest2 extends BaseGremlinTest {
println(r.toInstanceJson) println(r.toInstanceJson)
} }
private def getPersistenceStrategy(g: AtlasGraph[_,_]) : GraphPersistenceStrategies = { private def getPersistenceStrategy(g: AtlasGraph[_,_]) : GraphPersistenceStrategies = return GraphPersistenceStrategy1(g)
return GraphPersistenceStrategy1(g);
}
} }
\ No newline at end of file
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
package org.apache.atlas.query package org.apache.atlas.query
import org.apache.atlas.DBSandboxer
import org.testng.Assert import org.testng.Assert
import org.testng.annotations.Test import org.testng.annotations.{Listeners, Test}
import scala.util.parsing.input.CharArrayReader import scala.util.parsing.input.CharArrayReader
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.apache.atlas.query package org.apache.atlas.query
import org.apache.atlas.TestUtils import org.apache.atlas.{DBSandboxer, TestUtils}
import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._class import org.apache.atlas.query.Expressions._class
import org.apache.atlas.query.Expressions.id import org.apache.atlas.query.Expressions.id
...@@ -27,10 +27,7 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider ...@@ -27,10 +27,7 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider
import org.apache.atlas.repository.graph.GraphBackedMetadataRepository import org.apache.atlas.repository.graph.GraphBackedMetadataRepository
import org.apache.atlas.repository.graphdb.AtlasGraph import org.apache.atlas.repository.graphdb.AtlasGraph
import org.apache.atlas.typesystem.types.TypeSystem import org.apache.atlas.typesystem.types.TypeSystem
import org.testng.annotations.AfterClass import org.testng.annotations._
import org.testng.annotations.BeforeClass
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test
class LineageQueryTest extends BaseGremlinTest { class LineageQueryTest extends BaseGremlinTest {
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
package org.apache.atlas.query package org.apache.atlas.query
import org.apache.atlas.DBSandboxer
import org.apache.atlas.repository.BaseTest import org.apache.atlas.repository.BaseTest
import org.testng.annotations.{BeforeMethod,Test} import org.testng.annotations.{BeforeMethod, Listeners, Test}
class ParserTest extends BaseTest { class ParserTest extends BaseTest {
......
...@@ -391,6 +391,18 @@ ...@@ -391,6 +391,18 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-repository</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-graphdb-common</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId> <groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId> <artifactId>nimbus-jose-jwt</artifactId>
<version>3.9</version> <version>3.9</version>
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
package org.apache.atlas.web.adapters; package org.apache.atlas.web.adapters;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -37,15 +37,14 @@ import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; ...@@ -37,15 +37,14 @@ import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import org.apache.atlas.web.rest.EntityREST; import org.apache.atlas.web.rest.EntityREST;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
...@@ -58,7 +57,7 @@ import java.util.List; ...@@ -58,7 +57,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Guice(modules = {RepositoryMetadataModule.class}) @Guice(modules = {TestOnlyModule.class})
public class TestEntitiesREST { public class TestEntitiesREST {
private static final Logger LOG = LoggerFactory.getLogger(TestEntitiesREST.class); private static final Logger LOG = LoggerFactory.getLogger(TestEntitiesREST.class);
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
*/ */
package org.apache.atlas.web.adapters; package org.apache.atlas.web.adapters;
import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContext;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestOnlyModule;
import org.apache.atlas.TestUtilsV2; import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications; import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
...@@ -36,9 +36,9 @@ import org.apache.atlas.type.AtlasTypeUtil; ...@@ -36,9 +36,9 @@ import org.apache.atlas.type.AtlasTypeUtil;
import org.apache.atlas.web.rest.EntityREST; import org.apache.atlas.web.rest.EntityREST;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
...@@ -50,7 +50,7 @@ import java.util.HashMap; ...@@ -50,7 +50,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Guice(modules = {RepositoryMetadataModule.class}) @Guice(modules = {TestOnlyModule.class})
public class TestEntityREST { public class TestEntityREST {
@Inject @Inject
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment