Commit 461a2a4e by Shwetha GS

ATLAS-209 Use testng and delete junit and scalatest (ltfxyz via shwethags)

parent 538fa496
......@@ -991,13 +991,6 @@
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.binary.version}</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalamacros</groupId>
<artifactId>quasiquotes_${scala.binary.version}</artifactId>
<version>${scala.macros.version}</version>
......@@ -1108,14 +1101,6 @@
<scope>test</scope>
</dependency>
<!-- todo - use testng and delete junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
......@@ -1409,11 +1394,6 @@
<artifactId>surefire-testng</artifactId>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin>
......
......@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
ALL CHANGES:
ATLAS-209 Use testng and delete junit and scalatest (ltfxyz via shwethags)
ATLAS-163 New Trait UI (Tag) ( darshankumar89 via sumasai)
ATLAS-199 webapp build fails (grunt + tests) ( darshankumar89 via sumasai)
ATLAS-204 Lineage I/O Lineage Enhancement ( Anilsg via sumasai )
......
......@@ -155,12 +155,6 @@
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.binary.version}</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalamacros</groupId>
<artifactId>quasiquotes_${scala.binary.version}</artifactId>
</dependency>
......@@ -176,11 +170,6 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
......
......@@ -19,10 +19,10 @@
package org.apache.atlas.repository;
import org.apache.atlas.typesystem.types.TypeSystem;
import org.junit.Before;
import org.testng.annotations.BeforeMethod;
public abstract class BaseTest {
@Before
@BeforeMethod
public void setup() throws Exception {
TypeSystem ts = TypeSystem.getInstance();
ts.reset();
......
......@@ -23,7 +23,6 @@ import com.thinkaurelius.titan.core.util.TitanCleanup;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import junit.framework.Assert;
import org.apache.atlas.AtlasException;
import org.apache.atlas.GraphTransaction;
import org.apache.atlas.RepositoryMetadataModule;
......@@ -44,6 +43,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import org.testng.Assert;
import javax.inject.Inject;
import java.util.List;
......@@ -121,7 +121,7 @@ public class GraphBackedTypeStoreTest {
clsTypeFound = true;
}
}
Assert.assertTrue("Manager type not restored", clsTypeFound);
Assert.assertTrue(clsTypeFound, "Manager type not restored");
//validate trait
List<HierarchicalTypeDefinition<TraitType>> traitTypes = types.traitTypesAsJavaList();
......
......@@ -20,11 +20,11 @@ package org.apache.atlas.query
import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.BaseTest
import org.junit.{Before, Test}
import org.testng.annotations.{BeforeMethod,Test}
class ExpressionTest extends BaseTest {
@Before
@BeforeMethod
override def setup {
super.setup
......
......@@ -24,20 +24,16 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.graph.{TitanGraphProvider, GraphBackedMetadataRepository}
import org.apache.atlas.typesystem.types.TypeSystem
import org.junit.Test
import org.junit.runner.RunWith
import org.scalatest.Matchers._
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.testng.annotations.{Test,BeforeClass,AfterClass}
@RunWith(classOf[JUnitRunner])
class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
class GremlinTest extends BaseGremlinTest {
var g: TitanGraph = null
var gp: GraphPersistenceStrategies = null;
var gProvider: TitanGraphProvider = null;
override def beforeAll() {
@BeforeClass
def beforeAll() {
TypeSystem.getInstance().reset()
QueryTestsUtils.setupTypes
gProvider = new TitanGraphProvider();
......@@ -46,7 +42,8 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
}
override def afterAll() {
@AfterClass
def afterAll() {
g.shutdown()
try {
TitanCleanup.clear(g);
......@@ -56,7 +53,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
}
}
test("testClass") {
@Test def testClass {
val r = QueryProcessor.evaluate(_class("DB"), g, gp)
validateJson(r, """{
| "query": "DB",
......@@ -149,12 +146,12 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
| }""".stripMargin)
}
test("testName") {
@Test def testName {
val r = QueryProcessor.evaluate(_class("DB").field("name"), g, gp)
validateJson(r, "{\n \"query\":\"DB.name\",\n \"dataType\":\"string\",\n \"rows\":[\n \"Sales\",\n \"Reporting\"\n ]\n}")
}
test("testFilter") {
@Test def testFilter {
var r = QueryProcessor.evaluate(_class("DB").where(id("name").`=`(string("Reporting"))), g, gp)
validateJson(r, """{
| "query": "DB where (name = \"Reporting\")",
......@@ -233,7 +230,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin);
}
test("testFilter2") {
@Test def testFilter2 {
var r = QueryProcessor.evaluate(_class("DB").where(id("DB").field("name").`=`(string("Reporting"))), g, gp)
validateJson(r, """{
| "query": "DB where (name = \"Reporting\")",
......@@ -312,7 +309,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin);
}
test("testSelect") {
@Test def testSelect {
val r = QueryProcessor.evaluate(_class("DB").where(id("name").`=`(string("Reporting"))).
select(id("name"), id("owner")), g, gp)
validateJson(r, """{
......@@ -358,7 +355,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin);
}
test("testIsTrait") {
@Test def testIsTrait {
val r = QueryProcessor.evaluate(_class("Table").where(isTrait("Dimension")), g, gp)
validateJson(r, """{
| "query":"Table where Table is Dimension",
......@@ -494,7 +491,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin)
}
test("testhasField") {
@Test def testhasField {
val r = QueryProcessor.evaluate(_class("DB").where(hasField("name")), g, gp)
validateJson(r, """{
| "query":"DB where DB has name",
......@@ -586,7 +583,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin)
}
test("testFieldReference") {
@Test def testFieldReference {
val r = QueryProcessor.evaluate(_class("DB").field("Table"), g, gp)
validateJson(r, """{
| "query":"DB Table",
......@@ -771,19 +768,19 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin);
}
test("testBackReference") {
@Test def testBackReference {
val r = QueryProcessor.evaluate(
_class("DB").as("db").field("Table").where(id("db").field("name").`=`(string("Reporting"))), g, gp)
validateJson(r, null)
}
test("testArith") {
@Test def testArith {
val r = QueryProcessor.evaluate(_class("DB").where(id("name").`=`(string("Reporting"))).
select(id("name"), id("createTime") + int(1)), g, gp)
validateJson(r, "{\n \"query\":\"DB where (name = \\\"Reporting\\\") as _src1 select _src1.name as _col_0, (_src1.createTime + 1) as _col_1\",\n \"dataType\":{\n \"typeName\":\"__tempQueryResultStruct3\",\n \"attributeDefinitions\":[\n {\n \"name\":\"_col_0\",\n \"dataTypeName\":\"string\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":true,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"_col_1\",\n \"dataTypeName\":\"int\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":true,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"__tempQueryResultStruct3\",\n \"_col_1\":1501,\n \"_col_0\":\"Reporting\"\n }\n ]\n}")
}
test("testComparisonLogical") {
@Test def testComparisonLogical {
val r = QueryProcessor.evaluate(_class("DB").where(id("name").`=`(string("Reporting")).
and(id("createTime") > int(0))), g, gp)
validateJson(r, """{
......@@ -865,7 +862,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin);
}
test("testJoinAndSelect1") {
@Test def testJoinAndSelect1 {
val r = QueryProcessor.evaluate(
_class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab").
where((isTrait("Dimension"))).
......@@ -874,7 +871,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
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\":true,\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\":true,\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}")
}
test("testJoinAndSelect2") {
@Test def testJoinAndSelect2 {
val r = QueryProcessor.evaluate(
_class("DB").as("db1").where((id("db1").field("createTime") > int(0))
.or(id("name").`=`(string("Reporting")))).field("Table").as("tab")
......@@ -883,7 +880,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
validateJson(r, "{\n \"query\":\"DB as db1 where (db1.createTime > 0) or (name = \\\"Reporting\\\") Table as tab select db1.name as dbName, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"__tempQueryResultStruct6\",\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\":true,\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\":true,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Sales\",\n \"tabName\":\"sales_fact\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Sales\",\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Sales\",\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Sales\",\n \"tabName\":\"customer_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Reporting\",\n \"tabName\":\"sales_fact_daily_mv\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct6\",\n \"dbName\":\"Reporting\",\n \"tabName\":\"sales_fact_monthly_mv\"\n }\n ]\n}")
}
test("testJoinAndSelect3") {
@Test def testJoinAndSelect3 {
val r = QueryProcessor.evaluate(
_class("DB").as("db1").where((id("db1").field("createTime") > int(0))
.and(id("db1").field("name").`=`(string("Reporting")))
......@@ -893,7 +890,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
validateJson(r, "{\n \"query\":\"DB as db1 where (db1.createTime > 0) and (db1.name = \\\"Reporting\\\") or db1 has owner Table as tab select db1.name as dbName, tab.name as tabName\",\n \"dataType\":{\n \"typeName\":\"__tempQueryResultStruct7\",\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\":true,\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\":true,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Sales\",\n \"tabName\":\"sales_fact\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Sales\",\n \"tabName\":\"product_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Sales\",\n \"tabName\":\"time_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Sales\",\n \"tabName\":\"customer_dim\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Reporting\",\n \"tabName\":\"sales_fact_daily_mv\"\n },\n {\n \"$typeName$\":\"__tempQueryResultStruct7\",\n \"dbName\":\"Reporting\",\n \"tabName\":\"sales_fact_monthly_mv\"\n }\n ]\n}")
}
test("testJoinAndSelect4") {
@Test def testJoinAndSelect4 {
val r = QueryProcessor.evaluate(
_class("DB").as("db1").where(id("name").`=`(string("Sales"))).field("Table").as("tab").
where((isTrait("Dimension"))).
......@@ -902,7 +899,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
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\":true,\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\":true,\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}")
}
test("testArrayComparision") {
@Test def testArrayComparision {
val p = new QueryParser
val e = p("Partition as p where values = ['2015-01-01']," +
" table where name = 'sales_fact_daily_mv'," +
......@@ -940,7 +937,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin)
}
test("testArrayComparisionWithSelectOnArray") {
@Test def testArrayComparisionWithSelectOnArray {
val p = new QueryParser
val e = p("Partition as p where values = ['2015-01-01']," +
" table where name = 'sales_fact_daily_mv'," +
......@@ -979,7 +976,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
""".stripMargin)
}
test("testArrayInWhereClause") {
@Test def testArrayInWhereClause {
val p = new QueryParser
val e = p("Partition as p where values = ['2015-01-01']").right.get
val r = QueryProcessor.evaluate(e, g, gp)
......@@ -1039,7 +1036,7 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
|}""".stripMargin)
}
test("testArrayWithStruct") {
@Test def testArrayWithStruct {
// val p = new QueryParser
// val e = p("from LoadProcess select inputTables").right.get
// val r = QueryProcessor.evaluate(e, g)
......@@ -1047,14 +1044,14 @@ class GremlinTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
validateJson(r)
}
test("testNegativeInvalidType") {
@Test(expectedExceptions = Array(classOf[ExpressionException]))
def testNegativeInvalidType {
val p = new QueryParser
val e = p("from blah").right.get
an[ExpressionException] should be thrownBy QueryProcessor.evaluate(e, g, gp)
QueryProcessor.evaluate(e, g, gp)
}
test("testJoinAndSelect5") {
@Test def testJoinAndSelect5 {
val p = new QueryParser
val e = p("Table as t where name = 'sales_fact' db where name = 'Sales' and owner = 'John ETL' select t").right.get
val r = QueryProcessor.evaluate(e, g, gp)
......
......@@ -24,18 +24,16 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.graph.{TitanGraphProvider, GraphBackedMetadataRepository}
import org.apache.atlas.typesystem.types.TypeSystem
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.testng.annotations.{Test,BeforeClass,AfterClass}
@RunWith(classOf[JUnitRunner])
class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
class GremlinTest2 extends BaseGremlinTest {
var g: TitanGraph = null
var gProvider:TitanGraphProvider = null;
var gp:GraphPersistenceStrategies = null;
override def beforeAll() {
@BeforeClass
def beforeAll() {
TypeSystem.getInstance().reset()
QueryTestsUtils.setupTypes
gProvider = new TitanGraphProvider();
......@@ -43,7 +41,8 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
g = QueryTestsUtils.setupTestGraph(gProvider)
}
override def afterAll() {
@AfterClass
def afterAll() {
g.shutdown()
try {
TitanCleanup.clear(g);
......@@ -53,43 +52,43 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
}
}
test("testTraitSelect") {
@Test def testTraitSelect {
val r = QueryProcessor.evaluate(_class("Table").as("t").join("Dimension").as("dim").select(id("t"), id("dim")), g)
validateJson(r, "{\n \"query\":\"Table as t.Dimension as dim select t as _col_0, dim as _col_1\",\n \"dataType\":{\n \"typeName\":\"\",\n \"attributeDefinitions\":[\n {\n \"name\":\"_col_0\",\n \"dataTypeName\":\"Table\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":true,\n \"reverseAttributeName\":null\n },\n {\n \"name\":\"_col_1\",\n \"dataTypeName\":\"Dimension\",\n \"multiplicity\":{\n \"lower\":0,\n \"upper\":1,\n \"isUnique\":false\n },\n \"isComposite\":false,\n \"isUnique\":false,\n \"isIndexable\":true,\n \"reverseAttributeName\":null\n }\n ]\n },\n \"rows\":[\n {\n \"$typeName$\":\"\",\n \"_col_1\":{\n \"$typeName$\":\"Dimension\"\n },\n \"_col_0\":{\n \"id\":\"3328\",\n \"$typeName$\":\"Table\",\n \"version\":0\n }\n },\n {\n \"$typeName$\":\"\",\n \"_col_1\":{\n \"$typeName$\":\"Dimension\"\n },\n \"_col_0\":{\n \"id\":\"4864\",\n \"$typeName$\":\"Table\",\n \"version\":0\n }\n },\n {\n \"$typeName$\":\"\",\n \"_col_1\":{\n \"$typeName$\":\"Dimension\"\n },\n \"_col_0\":{\n \"id\":\"6656\",\n \"$typeName$\":\"Table\",\n \"version\":0\n }\n }\n ]\n}")
}
test("testTrait") {
@Test def testTrait {
val r = QueryProcessor.evaluate(_trait("Dimension"), g)
validateJson(r)
}
test("testTraitInstance") {
@Test def testTraitInstance {
val r = QueryProcessor.evaluate(_trait("Dimension").traitInstance(), g)
validateJson(r)
}
test("testInstanceAddedToFilter") {
@Test def testInstanceAddedToFilter {
val r = QueryProcessor.evaluate(_trait("Dimension").hasField("typeName"), g)
validateJson(r)
}
test("testInstanceFilter") {
@Test def testInstanceFilter {
val r = QueryProcessor.evaluate(_trait("Dimension").traitInstance().hasField("name"), g)
validateJson(r)
}
test("testLineageWithPath") {
@Test def testLineageWithPath {
val r = QueryProcessor.evaluate(_class("Table").loop(id("LoadProcess").field("outputTable")).path(), g)
validateJson(r)
}
test("testLineageAllSelectWithPath") {
@Test def testLineageAllSelectWithPath {
val r = QueryProcessor.evaluate(_class("Table").as("src").loop(id("LoadProcess").field("outputTable")).as("dest").
select(id("src").field("name").as("srcTable"), id("dest").field("name").as("destTable")).path(), g)
validateJson(r)
}
test("testLineageAllSelectWithPathFromParser") {
@Test def testLineageAllSelectWithPathFromParser {
val p = new QueryParser
val e = p("Table as src loop (LoadProcess outputTable) as dest " +
"select src.name as srcTable, dest.name as destTable withPath").right.get
......@@ -98,7 +97,7 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson(r)
}
test("testLineageAllSelectWithPathFromParser2") {
@Test def testLineageAllSelectWithPathFromParser2 {
val p = new QueryParser
val e = p("Table as src loop (`LoadProcess->outputTable` inputTables) as dest " +
......@@ -107,7 +106,7 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson(r)
}
test("testHighLevelLineage") {
@Test def testHighLevelLineage {
val r = HiveLineageQuery("Table", "sales_fact_monthly_mv",
"LoadProcess",
"inputTables",
......@@ -116,7 +115,7 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson(r)
}
test("testHighLevelLineageReturnGraph") {
@Test def testHighLevelLineageReturnGraph {
val r = HiveLineageQuery("Table", "sales_fact_monthly_mv",
"LoadProcess",
"inputTables",
......@@ -127,7 +126,7 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
//validateJson(r)
}
test("testHighLevelWhereUsed") {
@Test def testHighLevelWhereUsed {
val r = HiveWhereUsedQuery("Table", "sales_fact",
"LoadProcess",
"inputTables",
......@@ -136,7 +135,7 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson(r)
}
test("testHighLevelWhereUsedReturnGraph") {
@Test def testHighLevelWhereUsedReturnGraph {
val r = HiveWhereUsedQuery("Table", "sales_fact",
"LoadProcess",
"inputTables",
......
......@@ -18,7 +18,8 @@
package org.apache.atlas.query
import org.junit.{Assert, Test}
import org.testng.Assert
import org.testng.annotations.Test
import scala.util.parsing.input.CharArrayReader
......
......@@ -24,18 +24,16 @@ import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
import org.apache.atlas.query.Expressions._
import org.apache.atlas.repository.graph.{GraphBackedMetadataRepository, TitanGraphProvider}
import org.apache.atlas.typesystem.types.TypeSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{Assertions, BeforeAndAfterAll, FunSuite}
import org.testng.annotations.{Test,BeforeClass,AfterClass}
@RunWith(classOf[JUnitRunner])
class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinTest {
class LineageQueryTest extends BaseGremlinTest {
var g: TitanGraph = null
var gProvider:TitanGraphProvider = null;
var gp:GraphPersistenceStrategies = null;
override def beforeAll() {
@BeforeClass
def beforeAll() {
TypeSystem.getInstance().reset()
QueryTestsUtils.setupTypes
gProvider = new TitanGraphProvider();
......@@ -43,7 +41,8 @@ class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinT
g = QueryTestsUtils.setupTestGraph(gProvider)
}
override def afterAll() {
@AfterClass
def afterAll() {
g.shutdown()
try {
TitanCleanup.clear(g);
......@@ -55,7 +54,7 @@ class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinT
val PREFIX_SPACES_REGEX = ("\\n\\s*").r
test("testInputTables") {
@Test def testInputTables {
val r = QueryProcessor.evaluate(_class("LoadProcess").field("inputTables"), g, gp)
val x = r.toJson
validateJson(r,"""{
......@@ -183,12 +182,12 @@ class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinT
""".stripMargin)
}
test("testLoadProcessOut") {
@Test def testLoadProcessOut {
val r = QueryProcessor.evaluate(_class("Table").field("LoadProcess").field("outputTable"), g, gp)
validateJson(r, null)
}
test("testLineageAll") {
@Test def testLineageAll {
val r = QueryProcessor.evaluate(_class("Table").loop(id("LoadProcess").field("outputTable")), g, gp)
validateJson(r, """{
| "query":"Table as _loop0 loop (LoadProcess outputTable)",
......@@ -343,7 +342,7 @@ class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinT
|}""".stripMargin)
}
test("testLineageAllSelect") {
@Test def testLineageAllSelect {
val r = QueryProcessor.evaluate(_class("Table").as("src").loop(id("LoadProcess").field("outputTable")).as("dest").
select(id("src").field("name").as("srcTable"), id("dest").field("name").as("destTable")), g, gp)
validateJson(r, """{
......@@ -409,7 +408,7 @@ class LineageQueryTest extends FunSuite with BeforeAndAfterAll with BaseGremlinT
}""".stripMargin)
}
test("testLineageFixedDepth") {
@Test def testLineageFixedDepth {
val r = QueryProcessor.evaluate(_class("Table").loop(id("LoadProcess").field("outputTable"), int(1)), g, gp)
validateJson(r, """{
| "query":"Table as _loop0 loop (LoadProcess outputTable) times 1",
......
......@@ -19,12 +19,12 @@
package org.apache.atlas.query
import org.apache.atlas.repository.BaseTest
import org.junit.{Before, Test}
import org.testng.annotations.{BeforeMethod,Test}
class ParserTest extends BaseTest {
@Before
@BeforeMethod
override def setup {
super.setup
QueryTestsUtils.setupTypes
......
......@@ -30,7 +30,6 @@ import org.apache.atlas.typesystem.types._
import org.apache.commons.configuration.{Configuration, ConfigurationException, MapConfiguration}
import org.apache.commons.io.FileUtils
import org.json.JSONObject
import org.scalatest.{Assertions, BeforeAndAfterAll, FunSuite}
import org.skyscreamer.jsonassert.JSONAssert
......@@ -170,8 +169,6 @@ object QueryTestsUtils extends GraphUtils {
}
trait BaseGremlinTest {
self : FunSuite with BeforeAndAfterAll =>
val STRUCT_NAME_REGEX = (TypeUtils.TEMP_STRUCT_NAME_PREFIX + "\\d+").r
def validateJson(r: GremlinQueryResult, expected: String = null): Unit = {
val rJ = r.toJson
......
......@@ -70,12 +70,6 @@
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.binary.version}</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalamacros</groupId>
<artifactId>quasiquotes_${scala.binary.version}</artifactId>
</dependency>
......@@ -106,11 +100,6 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
......
......@@ -34,9 +34,9 @@ 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.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.Assert;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
......@@ -45,7 +45,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createTraitTypeD
public class SerializationJavaTest extends BaseTest {
@Before
@BeforeMethod
public void setup() throws Exception {
super.setup();
}
......
......@@ -25,7 +25,7 @@ import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.junit.Before;
import org.testng.annotations.BeforeMethod;
import java.math.BigDecimal;
import java.math.BigInteger;
......@@ -67,7 +67,7 @@ public abstract class BaseTest {
return TypeSystem.getInstance();
}
@Before
@BeforeMethod
public void setup() throws Exception {
TypeSystem ts = TypeSystem.getInstance();
ts.reset();
......@@ -86,9 +86,8 @@ public abstract class BaseTest {
TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE),
TypesUtil.createOptionalAttrDef("l", DataTypes.DATE_TYPE),
TypesUtil.createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)),
TypesUtil.createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), TypesUtil
.createOptionalAttrDef("o",
ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)));
TypesUtil.createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)),
TypesUtil.createOptionalAttrDef("o", ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)));
System.out.println("defined structType = " + structType);
StructType recursiveStructType =
......
......@@ -21,13 +21,13 @@ package org.apache.atlas.typesystem.types;
import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.Referenceable;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
public class ClassTest extends BaseTest {
@Before
@BeforeMethod
public void setup() throws Exception {
super.setup();
}
......
......@@ -27,9 +27,9 @@ import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.ITypedStruct;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.math.BigDecimal;
import java.math.BigInteger;
......@@ -42,7 +42,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAt
public class EnumTest extends BaseTest {
@Before
@BeforeMethod
public void setup() throws Exception {
super.setup();
}
......
......@@ -21,16 +21,16 @@ package org.apache.atlas.typesystem.types;
import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.ITypedStruct;
import org.apache.atlas.typesystem.Struct;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
public class StructTest extends BaseTest {
StructType structType;
StructType recursiveStructType;
@Before
@BeforeMethod
public void setup() throws Exception {
super.setup();
structType = getTypeSystem().getDataType(StructType.class, STRUCT_TYPE_1);
......
......@@ -23,10 +23,9 @@ import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.ITypedStruct;
import org.apache.atlas.typesystem.Struct;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
......@@ -37,7 +36,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createTraitTypeD
public class TraitTest extends BaseTest {
@Before
@BeforeMethod
public void setup() throws Exception {
super.setup();
}
......@@ -54,7 +53,7 @@ public class TraitTest extends BaseTest {
* complete Path.
* For e.g. the 'b' attribute in A (that is a superType for B) is hidden the 'b' attribute
* in B.
* So it is availabel by the name 'A.B.D.b'
* So it is available by the name 'A.B.D.b'
*
* - Another way to set attributes is to cast. Casting a 'D' instance of 'B' makes the 'A.B.D
* .b' attribute
......@@ -176,8 +175,8 @@ public class TraitTest extends BaseTest {
createOptionalAttrDef("d", DataTypes.SHORT_TYPE));
HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.<String>of("A"),
createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE));
HierarchicalTypeDefinition C =
createTraitTypeDef("C", ImmutableList.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE));
HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.<String>of("A"),
createOptionalAttrDef("c", DataTypes.BYTE_TYPE));
HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.<String>of("B", "C"),
createOptionalAttrDef("d", DataTypes.SHORT_TYPE));
......
......@@ -20,13 +20,14 @@ package org.apache.atlas.typesystem.builders
import org.apache.atlas.typesystem.TypesDef
import org.apache.atlas.typesystem.types.TypeSystem
import org.scalatest.{BeforeAndAfter, FunSuite}
import org.testng.annotations.BeforeMethod
abstract class BuilderTest extends FunSuite with BeforeAndAfter {
abstract class BuilderTest {
var tDef : TypesDef = null
before {
@BeforeMethod
def before {
TypeSystem.getInstance().reset()
val b = new TypesBuilder
......
......@@ -19,11 +19,11 @@
package org.apache.atlas.typesystem.builders
import org.apache.atlas.typesystem.types.{ClassType, Multiplicity, TypeSystem}
import org.testng.annotations.Test
class InstanceBuilderTest extends BuilderTest {
test("test1") {
@Test def test1 {
TypeSystem.getInstance().defineTypes(tDef)
val b = new InstanceBuilder
......
......@@ -20,12 +20,12 @@ package org.apache.atlas.typesystem.builders
import org.apache.atlas.AtlasException
import org.apache.atlas.typesystem.types.{ClassType, Multiplicity, TypeSystem}
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.testng.annotations.{BeforeMethod,Test}
class MultiplicityTest {
class MultiplicityTest extends FunSuite with BeforeAndAfterAll {
override def beforeAll() = {
@BeforeMethod
def beforeAll {
TypeSystem.getInstance().reset()
val b = new TypesBuilder
......@@ -83,7 +83,8 @@ class MultiplicityTest extends FunSuite with BeforeAndAfterAll {
TypeSystem.getInstance().defineTypes(tDef)
}
test("test1") {
@Test
def test1 {
val b = new InstanceBuilder
import b._
......@@ -108,7 +109,8 @@ class MultiplicityTest extends FunSuite with BeforeAndAfterAll {
}
}
test("WrongMultiplicity") {
@Test(expectedExceptions = Array(classOf[AtlasException]) , expectedExceptionsMessageRegExp = "A multiplicty of more than one requires a collection type for attribute 'stringSet'")
def WrongMultiplicity {
val b = new TypesBuilder
import b._
val tDef = types {
......@@ -117,9 +119,6 @@ class MultiplicityTest extends FunSuite with BeforeAndAfterAll {
"stringSet" ~ (string, multiplicty(0, Int.MaxValue, true))
}
}
val me = intercept[AtlasException] {
TypeSystem.getInstance().defineTypes(tDef)
}
assert("A multiplicty of more than one requires a collection type for attribute 'stringSet'" == me.getMessage)
}
}
......@@ -20,14 +20,12 @@ package org.apache.atlas.typesystem.builders
import org.apache.atlas.typesystem.json.TypesSerialization
import org.apache.atlas.typesystem.types.TypeSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.testng.annotations.Test
@RunWith(classOf[JUnitRunner])
class TypesBuilderTest extends BuilderTest {
test("test1") {
@Test def test1 {
TypeSystem.getInstance().defineTypes(tDef)
println(TypesSerialization.toJson(TypeSystem.getInstance(), x => true))
......
......@@ -26,14 +26,15 @@ import org.apache.atlas.typesystem.{ITypedReferenceableInstance, ITypedStruct, R
import org.json4s.native.JsonMethods._
import org.json4s.native.Serialization.{write => swrite, _}
import org.json4s.{NoTypeHints, _}
import org.junit.{Assert, Before, Test}
import org.testng.Assert
import org.testng.annotations.{BeforeMethod,Test}
class SerializationTest extends BaseTest {
private[atlas] var structType: StructType = null
private[atlas] var recursiveStructType: StructType = null
@Before
@BeforeMethod
override def setup {
super.setup
structType = getTypeSystem.getDataType(classOf[StructType], BaseTest.STRUCT_TYPE_1).asInstanceOf[StructType]
......
......@@ -20,7 +20,8 @@ package org.apache.atlas.typesystem.json
import com.google.common.collect.ImmutableList
import org.apache.atlas.typesystem.types._
import org.junit.{Assert, Test}
import org.testng.Assert
import org.testng.annotations.Test
class TypesSerializationTest extends BaseTest with TypeHelpers {
......
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