You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ve...@apache.org on 2015/06/12 22:38:32 UTC
[12/50] [abbrv] incubator-atlas git commit: IDE java code reformat
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/discovery/HiveLineageServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/discovery/HiveLineageServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/HiveLineageServiceTest.java
index 9141d85..ce00f8c 100644
--- a/repository/src/test/java/org/apache/atlas/discovery/HiveLineageServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/discovery/HiveLineageServiceTest.java
@@ -66,66 +66,60 @@ public class HiveLineageServiceTest {
@Inject
private HiveLineageService hiveLineageService;
-// @Inject
-// private GraphProvider<TitanGraph> graphProvider;
+ // @Inject
+ // private GraphProvider<TitanGraph> graphProvider;
@BeforeClass
public void setUp() throws Exception {
setUpTypes();
setupInstances();
- // TestUtils.dumpGraph(graphProvider.get());
+ // TestUtils.dumpGraph(graphProvider.get());
}
@DataProvider(name = "dslQueriesProvider")
private Object[][] createDSLQueries() {
- return new String[][] {
- // joins
- {"hive_table where name=\"sales_fact\", columns"},
- {"hive_table where name=\"sales_fact\", columns select name, dataType, comment"},
- {"hive_table where name=\"sales_fact\", columns as c select c.name, c.dataType, c.comment"},
-// {"hive_db as db where (db.name=\"Reporting\"), hive_table as table select db.name, table.name"},
- {"from hive_db"},
- {"hive_db"},
- {"hive_db where hive_db.name=\"Reporting\""},
- {"hive_db hive_db.name = \"Reporting\""},
- {"hive_db where hive_db.name=\"Reporting\" select name, owner"},
- {"hive_db has name"},
-// {"hive_db, hive_table"},
-// {"hive_db, hive_process has name"},
-// {"hive_db as db1, hive_table where db1.name = \"Reporting\""},
-// {"hive_db where hive_db.name=\"Reporting\" and hive_db.createTime < " + System.currentTimeMillis()},
- {"from hive_table"},
- {"hive_table"},
- {"hive_table is Dimension"},
- {"hive_column where hive_column isa PII"},
-// {"hive_column where hive_column isa PII select hive_column.name"},
- {"hive_column select hive_column.name"},
- {"hive_column select name"},
- {"hive_column where hive_column.name=\"customer_id\""},
- {"from hive_table select hive_table.name"},
- {"hive_db where (name = \"Reporting\")"},
- {"hive_db where (name = \"Reporting\") select name as _col_0, owner as _col_1"},
- {"hive_db where hive_db has name"},
-// {"hive_db hive_table"},
- {"hive_db where hive_db has name"},
-// {"hive_db as db1 hive_table where (db1.name = \"Reporting\")"},
- {"hive_db where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1 "},
-// {"hive_db where (name = \"Reporting\") and ((createTime + 1) > 0)"},
-// {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name = \"Reporting\") select db1.name as dbName, tab.name as tabName"},
-// {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) or (db1.name = \"Reporting\") select db1.name as dbName, tab.name as tabName"},
-// {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name = \"Reporting\") or db1 has owner select db1.name as dbName, tab.name as tabName"},
-// {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name = \"Reporting\") or db1 has owner select db1.name as dbName, tab.name as tabName"},
- // trait searches
- {"Dimension"},
- {"Fact"},
- {"ETL"},
- {"Metric"},
- {"PII"},
- };
+ return new String[][]{
+ // joins
+ {"hive_table where name=\"sales_fact\", columns"},
+ {"hive_table where name=\"sales_fact\", columns select name, dataType, comment"},
+ {"hive_table where name=\"sales_fact\", columns as c select c.name, c.dataType, c.comment"},
+ // {"hive_db as db where (db.name=\"Reporting\"), hive_table as table select db.name,
+ // table.name"},
+ {"from hive_db"}, {"hive_db"}, {"hive_db where hive_db.name=\"Reporting\""},
+ {"hive_db hive_db.name = \"Reporting\""},
+ {"hive_db where hive_db.name=\"Reporting\" select name, owner"}, {"hive_db has name"},
+ // {"hive_db, hive_table"},
+ // {"hive_db, hive_process has name"},
+ // {"hive_db as db1, hive_table where db1.name = \"Reporting\""},
+ // {"hive_db where hive_db.name=\"Reporting\" and hive_db.createTime < " + System
+ // .currentTimeMillis()},
+ {"from hive_table"}, {"hive_table"}, {"hive_table is Dimension"},
+ {"hive_column where hive_column isa PII"},
+ // {"hive_column where hive_column isa PII select hive_column.name"},
+ {"hive_column select hive_column.name"}, {"hive_column select name"},
+ {"hive_column where hive_column.name=\"customer_id\""}, {"from hive_table select hive_table.name"},
+ {"hive_db where (name = \"Reporting\")"},
+ {"hive_db where (name = \"Reporting\") select name as _col_0, owner as _col_1"},
+ {"hive_db where hive_db has name"},
+ // {"hive_db hive_table"},
+ {"hive_db where hive_db has name"},
+ // {"hive_db as db1 hive_table where (db1.name = \"Reporting\")"},
+ {"hive_db where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1 "},
+ // {"hive_db where (name = \"Reporting\") and ((createTime + 1) > 0)"},
+ // {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name =
+ // \"Reporting\") select db1.name as dbName, tab.name as tabName"},
+ // {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) or (db1.name =
+ // \"Reporting\") select db1.name as dbName, tab.name as tabName"},
+ // {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name =
+ // \"Reporting\") or db1 has owner select db1.name as dbName, tab.name as tabName"},
+ // {"hive_db as db1 hive_table as tab where ((db1.createTime + 1) > 0) and (db1.name =
+ // \"Reporting\") or db1 has owner select db1.name as dbName, tab.name as tabName"},
+ // trait searches
+ {"Dimension"}, {"Fact"}, {"ETL"}, {"Metric"}, {"PII"},};
}
- @Test (dataProvider = "dslQueriesProvider")
+ @Test(dataProvider = "dslQueriesProvider")
public void testSearchByDSLQueries(String dslQuery) throws Exception {
System.out.println("Executing dslQuery = " + dslQuery);
String jsonResults = discoveryService.searchByDSL(dslQuery);
@@ -163,19 +157,19 @@ public class HiveLineageServiceTest {
Assert.assertTrue(paths.length() > 0);
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetInputsTableNameNull() throws Exception {
hiveLineageService.getInputs(null);
Assert.fail();
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetInputsTableNameEmpty() throws Exception {
hiveLineageService.getInputs("");
Assert.fail();
}
- @Test (expectedExceptions = EntityNotFoundException.class)
+ @Test(expectedExceptions = EntityNotFoundException.class)
public void testGetInputsBadTableName() throws Exception {
hiveLineageService.getInputs("blah");
Assert.fail();
@@ -183,8 +177,7 @@ public class HiveLineageServiceTest {
@Test
public void testGetInputsGraph() throws Exception {
- JSONObject results = new JSONObject(
- hiveLineageService.getInputsGraph("sales_fact_monthly_mv"));
+ JSONObject results = new JSONObject(hiveLineageService.getInputsGraph("sales_fact_monthly_mv"));
Assert.assertNotNull(results);
System.out.println("inputs graph = " + results);
@@ -212,19 +205,19 @@ public class HiveLineageServiceTest {
Assert.assertTrue(paths.length() > 0);
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetOututsTableNameNull() throws Exception {
hiveLineageService.getOutputs(null);
Assert.fail();
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetOutputsTableNameEmpty() throws Exception {
hiveLineageService.getOutputs("");
Assert.fail();
}
- @Test (expectedExceptions = EntityNotFoundException.class)
+ @Test(expectedExceptions = EntityNotFoundException.class)
public void testGetOutputsBadTableName() throws Exception {
hiveLineageService.getOutputs("blah");
Assert.fail();
@@ -248,15 +241,11 @@ public class HiveLineageServiceTest {
@DataProvider(name = "tableNamesProvider")
private Object[][] tableNames() {
- return new String[][] {
- {"sales_fact", "4"},
- {"time_dim", "3"},
- {"sales_fact_daily_mv", "4"},
- {"sales_fact_monthly_mv", "4"}
- };
+ return new String[][]{{"sales_fact", "4"}, {"time_dim", "3"}, {"sales_fact_daily_mv", "4"},
+ {"sales_fact_monthly_mv", "4"}};
}
- @Test (dataProvider = "tableNamesProvider")
+ @Test(dataProvider = "tableNamesProvider")
public void testGetSchema(String tableName, String expected) throws Exception {
JSONObject results = new JSONObject(hiveLineageService.getSchema(tableName));
Assert.assertNotNull(results);
@@ -274,19 +263,19 @@ public class HiveLineageServiceTest {
}
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetSchemaTableNameNull() throws Exception {
hiveLineageService.getSchema(null);
Assert.fail();
}
- @Test (expectedExceptions = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGetSchemaTableNameEmpty() throws Exception {
hiveLineageService.getSchema("");
Assert.fail();
}
- @Test (expectedExceptions = EntityNotFoundException.class)
+ @Test(expectedExceptions = EntityNotFoundException.class)
public void testGetSchemaBadTableName() throws Exception {
hiveLineageService.getSchema("blah");
Assert.fail();
@@ -306,95 +295,62 @@ public class HiveLineageServiceTest {
private static final String VIEW_TYPE = "View";
private TypesDef createTypeDefinitions() {
- HierarchicalTypeDefinition<ClassType> dbClsDef
- = TypesUtil.createClassTypeDef(DATABASE_TYPE, null,
- attrDef("name", DataTypes.STRING_TYPE),
- attrDef("description", DataTypes.STRING_TYPE),
- attrDef("locationUri", DataTypes.STRING_TYPE),
- attrDef("owner", DataTypes.STRING_TYPE),
- attrDef("createTime", DataTypes.LONG_TYPE)
- );
-
- HierarchicalTypeDefinition<ClassType> storageDescClsDef =
- TypesUtil.createClassTypeDef(STORAGE_DESC_TYPE, null,
- attrDef("location", DataTypes.STRING_TYPE),
- attrDef("inputFormat", DataTypes.STRING_TYPE),
- attrDef("outputFormat", DataTypes.STRING_TYPE),
- attrDef("compressed", DataTypes.STRING_TYPE,
- Multiplicity.REQUIRED, false, null)
- );
-
- HierarchicalTypeDefinition<ClassType> columnClsDef =
- TypesUtil.createClassTypeDef(COLUMN_TYPE, null,
- attrDef("name", DataTypes.STRING_TYPE),
- attrDef("dataType", DataTypes.STRING_TYPE),
- attrDef("comment", DataTypes.STRING_TYPE)
- );
-
- HierarchicalTypeDefinition<ClassType> tblClsDef =
- TypesUtil.createClassTypeDef(HIVE_TABLE_TYPE, ImmutableList.of("DataSet"),
- attrDef("owner", DataTypes.STRING_TYPE),
- attrDef("createTime", DataTypes.LONG_TYPE),
- attrDef("lastAccessTime", DataTypes.LONG_TYPE),
- attrDef("tableType", DataTypes.STRING_TYPE),
+ HierarchicalTypeDefinition<ClassType> dbClsDef = TypesUtil
+ .createClassTypeDef(DATABASE_TYPE, null, attrDef("name", DataTypes.STRING_TYPE),
+ attrDef("description", DataTypes.STRING_TYPE), attrDef("locationUri", DataTypes.STRING_TYPE),
+ attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE));
+
+ HierarchicalTypeDefinition<ClassType> storageDescClsDef = TypesUtil
+ .createClassTypeDef(STORAGE_DESC_TYPE, null, attrDef("location", DataTypes.STRING_TYPE),
+ attrDef("inputFormat", DataTypes.STRING_TYPE), attrDef("outputFormat", DataTypes.STRING_TYPE),
+ attrDef("compressed", DataTypes.STRING_TYPE, Multiplicity.REQUIRED, false, null));
+
+ HierarchicalTypeDefinition<ClassType> columnClsDef = TypesUtil
+ .createClassTypeDef(COLUMN_TYPE, null, attrDef("name", DataTypes.STRING_TYPE),
+ attrDef("dataType", DataTypes.STRING_TYPE), attrDef("comment", DataTypes.STRING_TYPE));
+
+ HierarchicalTypeDefinition<ClassType> tblClsDef = TypesUtil
+ .createClassTypeDef(HIVE_TABLE_TYPE, ImmutableList.of("DataSet"),
+ attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE),
+ attrDef("lastAccessTime", DataTypes.LONG_TYPE), attrDef("tableType", DataTypes.STRING_TYPE),
attrDef("temporary", DataTypes.BOOLEAN_TYPE),
- new AttributeDefinition("db", DATABASE_TYPE,
- Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("db", DATABASE_TYPE, Multiplicity.REQUIRED, false, null),
// todo - uncomment this, something is broken
-// new AttributeDefinition("sd", STORAGE_DESC_TYPE,
-// Multiplicity.REQUIRED, true, null),
- new AttributeDefinition("columns",
- DataTypes.arrayTypeName(COLUMN_TYPE),
- Multiplicity.COLLECTION, true, null)
- );
-
- HierarchicalTypeDefinition<ClassType> loadProcessClsDef =
- TypesUtil.createClassTypeDef(HIVE_PROCESS_TYPE, ImmutableList.of("Process"),
- attrDef("userName", DataTypes.STRING_TYPE),
- attrDef("startTime", DataTypes.LONG_TYPE),
+ // new AttributeDefinition("sd", STORAGE_DESC_TYPE,
+ // Multiplicity.REQUIRED, true, null),
+ new AttributeDefinition("columns", DataTypes.arrayTypeName(COLUMN_TYPE),
+ Multiplicity.COLLECTION, true, null));
+
+ HierarchicalTypeDefinition<ClassType> loadProcessClsDef = TypesUtil
+ .createClassTypeDef(HIVE_PROCESS_TYPE, ImmutableList.of("Process"),
+ attrDef("userName", DataTypes.STRING_TYPE), attrDef("startTime", DataTypes.LONG_TYPE),
attrDef("endTime", DataTypes.LONG_TYPE),
attrDef("queryText", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
attrDef("queryPlan", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
attrDef("queryId", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
- attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED)
- );
-
- HierarchicalTypeDefinition<ClassType> viewClsDef =
- TypesUtil.createClassTypeDef(VIEW_TYPE, null,
- attrDef("name", DataTypes.STRING_TYPE),
- new AttributeDefinition("db", DATABASE_TYPE,
- Multiplicity.REQUIRED, false, null),
- new AttributeDefinition("inputTables",
- DataTypes.arrayTypeName(HIVE_TABLE_TYPE),
- Multiplicity.COLLECTION, false, null)
- );
-
- HierarchicalTypeDefinition<TraitType> dimTraitDef =
- TypesUtil.createTraitTypeDef("Dimension", null);
-
- HierarchicalTypeDefinition<TraitType> factTraitDef =
- TypesUtil.createTraitTypeDef("Fact", null);
-
- HierarchicalTypeDefinition<TraitType> metricTraitDef =
- TypesUtil.createTraitTypeDef("Metric", null);
-
- HierarchicalTypeDefinition<TraitType> etlTraitDef =
- TypesUtil.createTraitTypeDef("ETL", null);
-
- HierarchicalTypeDefinition<TraitType> piiTraitDef =
- TypesUtil.createTraitTypeDef("PII", null);
-
- HierarchicalTypeDefinition<TraitType> jdbcTraitDef =
- TypesUtil.createTraitTypeDef("JdbcAccess", null);
-
- return TypeUtils.getTypesDef(
- ImmutableList.<EnumTypeDefinition>of(),
- ImmutableList.<StructTypeDefinition>of(),
- ImmutableList.of(dimTraitDef, factTraitDef,
- piiTraitDef, metricTraitDef, etlTraitDef, jdbcTraitDef),
- ImmutableList.of(dbClsDef, storageDescClsDef, columnClsDef,
- tblClsDef, loadProcessClsDef, viewClsDef)
- );
+ attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED));
+
+ HierarchicalTypeDefinition<ClassType> viewClsDef = TypesUtil
+ .createClassTypeDef(VIEW_TYPE, null, attrDef("name", DataTypes.STRING_TYPE),
+ new AttributeDefinition("db", DATABASE_TYPE, Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("inputTables", DataTypes.arrayTypeName(HIVE_TABLE_TYPE),
+ Multiplicity.COLLECTION, false, null));
+
+ HierarchicalTypeDefinition<TraitType> dimTraitDef = TypesUtil.createTraitTypeDef("Dimension", null);
+
+ HierarchicalTypeDefinition<TraitType> factTraitDef = TypesUtil.createTraitTypeDef("Fact", null);
+
+ HierarchicalTypeDefinition<TraitType> metricTraitDef = TypesUtil.createTraitTypeDef("Metric", null);
+
+ HierarchicalTypeDefinition<TraitType> etlTraitDef = TypesUtil.createTraitTypeDef("ETL", null);
+
+ HierarchicalTypeDefinition<TraitType> piiTraitDef = TypesUtil.createTraitTypeDef("PII", null);
+
+ HierarchicalTypeDefinition<TraitType> jdbcTraitDef = TypesUtil.createTraitTypeDef("JdbcAccess", null);
+
+ return TypeUtils.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
+ ImmutableList.of(dimTraitDef, factTraitDef, piiTraitDef, metricTraitDef, etlTraitDef, jdbcTraitDef),
+ ImmutableList.of(dbClsDef, storageDescClsDef, columnClsDef, tblClsDef, loadProcessClsDef, viewClsDef));
}
AttributeDefinition attrDef(String name, IDataType dT) {
@@ -405,88 +361,73 @@ public class HiveLineageServiceTest {
return attrDef(name, dT, m, false, null);
}
- AttributeDefinition attrDef(String name, IDataType dT,
- Multiplicity m, boolean isComposite, String reverseAttributeName) {
+ AttributeDefinition attrDef(String name, IDataType dT, Multiplicity m, boolean isComposite,
+ String reverseAttributeName) {
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(dT);
return new AttributeDefinition(name, dT.getName(), m, isComposite, reverseAttributeName);
}
private void setupInstances() throws Exception {
- Id salesDB = database(
- "Sales", "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales");
-
- Referenceable sd = storageDescriptor("hdfs://host:8000/apps/warehouse/sales",
- "TextInputFormat", "TextOutputFormat", true);
-
- List<Referenceable> salesFactColumns = ImmutableList.of(
- column("time_id", "int", "time id"),
- column("product_id", "int", "product id"),
- column("customer_id", "int", "customer id", "PII"),
- column("sales", "double", "product id", "Metric")
- );
-
- Id salesFact = table("sales_fact", "sales fact table",
- salesDB, sd, "Joe", "Managed", salesFactColumns, "Fact");
-
- List<Referenceable> timeDimColumns = ImmutableList.of(
- column("time_id", "int", "time id"),
- column("dayOfYear", "int", "day Of Year"),
- column("weekDay", "int", "week Day")
- );
-
- Id timeDim = table("time_dim", "time dimension table",
- salesDB, sd, "John Doe", "External", timeDimColumns, "Dimension");
-
- Id reportingDB = database("Reporting", "reporting database", "Jane BI",
- "hdfs://host:8000/apps/warehouse/reporting");
-
- Id salesFactDaily = table("sales_fact_daily_mv",
- "sales fact daily materialized view",
- reportingDB, sd, "Joe BI", "Managed", salesFactColumns, "Metric");
-
- loadProcess("loadSalesDaily", "hive query for daily summary", "John ETL",
- ImmutableList.of(salesFact, timeDim), ImmutableList.of(salesFactDaily),
- "create table as select ", "plan", "id", "graph",
- "ETL");
-
- List<Referenceable> productDimColumns = ImmutableList.of(
- column("product_id", "int", "product id"),
- column("product_name", "string", "product name"),
- column("brand_name", "int", "brand name")
- );
-
- Id productDim = table("product_dim", "product dimension table",
- salesDB, sd, "John Doe", "Managed", productDimColumns, "Dimension");
-
- view("product_dim_view", reportingDB,
- ImmutableList.of(productDim), "Dimension", "JdbcAccess");
-
- List<Referenceable> customerDimColumns = ImmutableList.of(
- column("customer_id", "int", "customer id", "PII"),
- column("name", "string", "customer name", "PII"),
- column("address", "string", "customer address", "PII")
- );
-
- Id customerDim = table("customer_dim", "customer dimension table",
- salesDB, sd, "fetl", "External", customerDimColumns, "Dimension");
-
- view("customer_dim_view", reportingDB,
- ImmutableList.of(customerDim), "Dimension", "JdbcAccess");
-
- Id salesFactMonthly = table("sales_fact_monthly_mv",
- "sales fact monthly materialized view",
- reportingDB, sd, "Jane BI", "Managed", salesFactColumns, "Metric");
-
- loadProcess("loadSalesMonthly", "hive query for monthly summary", "John ETL",
- ImmutableList.of(salesFactDaily), ImmutableList.of(salesFactMonthly),
- "create table as select ", "plan", "id", "graph",
- "ETL");
+ Id salesDB = database("Sales", "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales");
+
+ Referenceable sd =
+ storageDescriptor("hdfs://host:8000/apps/warehouse/sales", "TextInputFormat", "TextOutputFormat", true);
+
+ List<Referenceable> salesFactColumns = ImmutableList
+ .of(column("time_id", "int", "time id"), column("product_id", "int", "product id"),
+ column("customer_id", "int", "customer id", "PII"),
+ column("sales", "double", "product id", "Metric"));
+
+ Id salesFact = table("sales_fact", "sales fact table", salesDB, sd, "Joe", "Managed", salesFactColumns, "Fact");
+
+ List<Referenceable> timeDimColumns = ImmutableList
+ .of(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"),
+ column("weekDay", "int", "week Day"));
+
+ Id timeDim = table("time_dim", "time dimension table", salesDB, sd, "John Doe", "External", timeDimColumns,
+ "Dimension");
+
+ Id reportingDB =
+ database("Reporting", "reporting database", "Jane BI", "hdfs://host:8000/apps/warehouse/reporting");
+
+ Id salesFactDaily =
+ table("sales_fact_daily_mv", "sales fact daily materialized view", reportingDB, sd, "Joe BI", "Managed",
+ salesFactColumns, "Metric");
+
+ loadProcess("loadSalesDaily", "hive query for daily summary", "John ETL", ImmutableList.of(salesFact, timeDim),
+ ImmutableList.of(salesFactDaily), "create table as select ", "plan", "id", "graph", "ETL");
+
+ List<Referenceable> productDimColumns = ImmutableList
+ .of(column("product_id", "int", "product id"), column("product_name", "string", "product name"),
+ column("brand_name", "int", "brand name"));
+
+ Id productDim =
+ table("product_dim", "product dimension table", salesDB, sd, "John Doe", "Managed", productDimColumns,
+ "Dimension");
+
+ view("product_dim_view", reportingDB, ImmutableList.of(productDim), "Dimension", "JdbcAccess");
+
+ List<Referenceable> customerDimColumns = ImmutableList.of(column("customer_id", "int", "customer id", "PII"),
+ column("name", "string", "customer name", "PII"),
+ column("address", "string", "customer address", "PII"));
+
+ Id customerDim =
+ table("customer_dim", "customer dimension table", salesDB, sd, "fetl", "External", customerDimColumns,
+ "Dimension");
+
+ view("customer_dim_view", reportingDB, ImmutableList.of(customerDim), "Dimension", "JdbcAccess");
+
+ Id salesFactMonthly =
+ table("sales_fact_monthly_mv", "sales fact monthly materialized view", reportingDB, sd, "Jane BI",
+ "Managed", salesFactColumns, "Metric");
+
+ loadProcess("loadSalesMonthly", "hive query for monthly summary", "John ETL", ImmutableList.of(salesFactDaily),
+ ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph", "ETL");
}
- Id database(String name, String description,
- String owner, String locationUri,
- String... traitNames) throws Exception {
+ Id database(String name, String description, String owner, String locationUri, String... traitNames)
+ throws Exception {
Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("description", description);
@@ -497,9 +438,8 @@ public class HiveLineageServiceTest {
return createInstance(referenceable);
}
- Referenceable storageDescriptor(String location, String inputFormat,
- String outputFormat,
- boolean compressed) throws Exception {
+ Referenceable storageDescriptor(String location, String inputFormat, String outputFormat, boolean compressed)
+ throws Exception {
Referenceable referenceable = new Referenceable(STORAGE_DESC_TYPE);
referenceable.set("location", location);
referenceable.set("inputFormat", inputFormat);
@@ -509,8 +449,7 @@ public class HiveLineageServiceTest {
return referenceable;
}
- Referenceable column(String name, String dataType, String comment,
- String... traitNames) throws Exception {
+ Referenceable column(String name, String dataType, String comment, String... traitNames) throws Exception {
Referenceable referenceable = new Referenceable(COLUMN_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("dataType", dataType);
@@ -519,11 +458,8 @@ public class HiveLineageServiceTest {
return referenceable;
}
- Id table(String name, String description,
- Id dbId, Referenceable sd,
- String owner, String tableType,
- List<Referenceable> columns,
- String... traitNames) throws Exception {
+ Id table(String name, String description, Id dbId, Referenceable sd, String owner, String tableType,
+ List<Referenceable> columns, String... traitNames) throws Exception {
Referenceable referenceable = new Referenceable(HIVE_TABLE_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("description", description);
@@ -542,12 +478,9 @@ public class HiveLineageServiceTest {
return createInstance(referenceable);
}
- Id loadProcess(String name, String description, String user,
- List<Id> inputTables,
- List<Id> outputTables,
- String queryText, String queryPlan,
- String queryId, String queryGraph,
- String... traitNames) throws Exception {
+ Id loadProcess(String name, String description, String user, List<Id> inputTables, List<Id> outputTables,
+ String queryText, String queryPlan, String queryId, String queryGraph, String... traitNames)
+ throws Exception {
Referenceable referenceable = new Referenceable(HIVE_PROCESS_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("description", description);
@@ -566,9 +499,7 @@ public class HiveLineageServiceTest {
return createInstance(referenceable);
}
- Id view(String name, Id dbId,
- List<Id> inputTables,
- String... traitNames) throws Exception {
+ Id view(String name, Id dbId, List<Id> inputTables, String... traitNames) throws Exception {
Referenceable referenceable = new Referenceable(VIEW_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("db", dbId);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/BaseTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/BaseTest.java b/repository/src/test/java/org/apache/atlas/repository/BaseTest.java
index f53429c..8924c37 100755
--- a/repository/src/test/java/org/apache/atlas/repository/BaseTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/BaseTest.java
@@ -50,12 +50,11 @@ public abstract class BaseTest {
public static final String STRUCT_TYPE_1 = "t1";
public static final String STRUCT_TYPE_2 = "t2";
public static final String TEST_DATE = "2014-12-11T02:35:58.440Z";
- public static final long TEST_DATE_IN_LONG=1418265358440L;
+ public static final long TEST_DATE_IN_LONG = 1418265358440L;
protected IRepository repo;
public static Struct createStruct() throws AtlasException {
- StructType structType = (StructType) TypeSystem.getInstance()
- .getDataType(StructType.class, STRUCT_TYPE_1);
+ StructType structType = (StructType) TypeSystem.getInstance().getDataType(StructType.class, STRUCT_TYPE_1);
Struct s = new Struct(structType.getName());
s.set("a", 1);
s.set("b", true);
@@ -70,8 +69,7 @@ public abstract class BaseTest {
s.set("k", new BigDecimal(1));
s.set("l", new Date(1418265358440L));
s.set("m", Lists.<Integer>asList(Integer.valueOf(1), new Integer[]{Integer.valueOf(1)}));
- s.set("n", Lists.<BigDecimal>asList(BigDecimal.valueOf(1.1),
- new BigDecimal[]{BigDecimal.valueOf(1.1)}));
+ s.set("n", Lists.<BigDecimal>asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)}));
Map<String, Double> hm = Maps.<String, Double>newHashMap();
hm.put("a", 1.0);
hm.put("b", 2.0);
@@ -94,33 +92,30 @@ public abstract class BaseTest {
ts.reset();
repo = new MemRepository(ts);
- StructType structType = ts.defineStructType(STRUCT_TYPE_1,
- true,
- TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE),
- TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE),
- TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE),
- TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE),
- TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE),
- TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE),
- TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE),
- 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)));
-
- StructType recursiveStructType = ts.defineStructType(STRUCT_TYPE_2,
- true,
- TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("s", STRUCT_TYPE_2));
+ StructType structType =
+ ts.defineStructType(STRUCT_TYPE_1, true, TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE),
+ TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE),
+ TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE),
+ TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE),
+ TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE),
+ TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE),
+ TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE),
+ 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)));
+
+ StructType recursiveStructType =
+ ts.defineStructType(STRUCT_TYPE_2, true, TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("s", STRUCT_TYPE_2));
}
- protected Map<String, IDataType> defineTraits(HierarchicalTypeDefinition... tDefs)
- throws AtlasException {
+ protected Map<String, IDataType> defineTraits(HierarchicalTypeDefinition... tDefs) throws AtlasException {
return getTypeSystem().defineTraitTypes(tDefs);
}
@@ -135,45 +130,33 @@ public abstract class BaseTest {
*/
protected void defineDeptEmployeeTypes(TypeSystem ts) throws AtlasException {
- HierarchicalTypeDefinition<ClassType> deptTypeDef =
- TypesUtil.createClassTypeDef("Department", ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> deptTypeDef = TypesUtil
+ .createClassTypeDef("Department", ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
new AttributeDefinition("employees", String.format("array<%s>", "Person"),
- Multiplicity.COLLECTION, true, "department")
- );
- HierarchicalTypeDefinition<ClassType> personTypeDef =
- TypesUtil.createClassTypeDef("Person", ImmutableList.<String>of(),
+ Multiplicity.COLLECTION, true, "department"));
+ HierarchicalTypeDefinition<ClassType> personTypeDef = TypesUtil
+ .createClassTypeDef("Person", ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- new AttributeDefinition("department",
- "Department", Multiplicity.REQUIRED, false, "employees"),
- new AttributeDefinition("manager",
- "Manager", Multiplicity.OPTIONAL, false, "subordinates")
- );
- HierarchicalTypeDefinition<ClassType> managerTypeDef =
- TypesUtil.createClassTypeDef("Manager",
- ImmutableList.<String>of("Person"),
- new AttributeDefinition("subordinates",
- String.format("array<%s>", "Person"),
- Multiplicity.COLLECTION, false, "manager")
- );
-
- HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef =
- TypesUtil.createTraitTypeDef("SecurityClearance",
- ImmutableList.<String>of(),
- TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE)
- );
+ new AttributeDefinition("department", "Department", Multiplicity.REQUIRED, false, "employees"),
+ new AttributeDefinition("manager", "Manager", Multiplicity.OPTIONAL, false, "subordinates"));
+ HierarchicalTypeDefinition<ClassType> managerTypeDef = TypesUtil
+ .createClassTypeDef("Manager", ImmutableList.<String>of("Person"),
+ new AttributeDefinition("subordinates", String.format("array<%s>", "Person"),
+ Multiplicity.COLLECTION, false, "manager"));
+
+ HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = TypesUtil
+ .createTraitTypeDef("SecurityClearance", ImmutableList.<String>of(),
+ TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE));
ts.defineTypes(ImmutableList.<StructTypeDefinition>of(),
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(securityClearanceTypeDef),
- ImmutableList.<HierarchicalTypeDefinition<ClassType>>of(deptTypeDef, personTypeDef,
- managerTypeDef));
-
- ImmutableList<HierarchicalType> types = ImmutableList.of(
- ts.getDataType(HierarchicalType.class, "SecurityClearance"),
- ts.getDataType(ClassType.class, "Department"),
- ts.getDataType(ClassType.class, "Person"),
- ts.getDataType(ClassType.class, "Manager")
- );
+ ImmutableList.<HierarchicalTypeDefinition<ClassType>>of(deptTypeDef, personTypeDef, managerTypeDef));
+
+ ImmutableList<HierarchicalType> types = ImmutableList
+ .of(ts.getDataType(HierarchicalType.class, "SecurityClearance"),
+ ts.getDataType(ClassType.class, "Department"), ts.getDataType(ClassType.class, "Person"),
+ ts.getDataType(ClassType.class, "Manager"));
repo.defineTypes(types);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
index 642a8eb..fb697d0 100755
--- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
@@ -128,7 +128,7 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertNotNull(entity);
}
- @Test (expectedExceptions = RepositoryException.class)
+ @Test(expectedExceptions = RepositoryException.class)
public void testGetEntityDefinitionNonExistent() throws Exception {
repositoryService.getEntityDefinition("blah");
Assert.fail();
@@ -144,15 +144,14 @@ public class GraphBackedMetadataRepositoryTest {
@Test
public void testGetTypeAttributeName() throws Exception {
- Assert.assertEquals(
- repositoryService.getTypeAttributeName(), Constants.ENTITY_TYPE_PROPERTY_KEY);
+ Assert.assertEquals(repositoryService.getTypeAttributeName(), Constants.ENTITY_TYPE_PROPERTY_KEY);
}
- @Test (dependsOnMethods = "testSubmitEntity")
+ @Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitLabel() throws Exception {
- Assert.assertEquals(repositoryService.getTraitLabel(
- typeSystem.getDataType(ClassType.class, TABLE_TYPE),
- CLASSIFICATION), TABLE_TYPE + "." + CLASSIFICATION);
+ Assert.assertEquals(
+ repositoryService.getTraitLabel(typeSystem.getDataType(ClassType.class, TABLE_TYPE), CLASSIFICATION),
+ TABLE_TYPE + "." + CLASSIFICATION);
}
@Test
@@ -174,8 +173,7 @@ public class GraphBackedMetadataRepositoryTest {
String dbGUID = repositoryService.createEntity(db);
System.out.println("added db = " + dbGUID);
- Referenceable dbInstance = new Referenceable(
- dbGUID, DATABASE_TYPE, databaseInstance.getValuesMap());
+ Referenceable dbInstance = new Referenceable(dbGUID, DATABASE_TYPE, databaseInstance.getValuesMap());
ITypedReferenceableInstance table = createHiveTableInstance(dbInstance);
String tableGUID = repositoryService.createEntity(table);
@@ -203,8 +201,7 @@ public class GraphBackedMetadataRepositoryTest {
private Vertex getTableEntityVertex() {
TitanGraph graph = graphProvider.get();
- GraphQuery query = graph.query()
- .has(Constants.ENTITY_TYPE_PROPERTY_KEY, Compare.EQUAL, TABLE_TYPE);
+ GraphQuery query = graph.query().has(Constants.ENTITY_TYPE_PROPERTY_KEY, Compare.EQUAL, TABLE_TYPE);
Iterator<Vertex> results = query.vertices().iterator();
// returning one since guid should be unique
Vertex tableVertex = results.hasNext() ? results.next() : null;
@@ -215,7 +212,7 @@ public class GraphBackedMetadataRepositoryTest {
return tableVertex;
}
- @Test (dependsOnMethods = "testCreateEntity")
+ @Test(dependsOnMethods = "testCreateEntity")
public void testGetTraitNames() throws Exception {
final List<String> traitNames = repositoryService.getTraitNames(getGUID());
Assert.assertEquals(traitNames.size(), 1);
@@ -228,13 +225,13 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertEquals(traitNames.size(), 0);
}
- @Test (expectedExceptions = EntityNotFoundException.class)
+ @Test(expectedExceptions = EntityNotFoundException.class)
public void testGetTraitNamesForBadEntity() throws Exception {
repositoryService.getTraitNames(UUID.randomUUID().toString());
Assert.fail();
}
- @Test (dependsOnMethods = "testGetTraitNames")
+ @Test(dependsOnMethods = "testGetTraitNames")
public void testAddTrait() throws Exception {
final String aGUID = getGUID();
@@ -244,8 +241,7 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertTrue(traitNames.contains(CLASSIFICATION));
Assert.assertFalse(traitNames.contains(PII));
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(PII, ImmutableList.<String>of());
+ HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil.createTraitTypeDef(PII, ImmutableList.<String>of());
TraitType traitType = typeSystem.defineTraitType(piiTrait);
ITypedStruct traitInstance = traitType.createInstance();
@@ -258,14 +254,14 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertTrue(traitNames.contains(CLASSIFICATION));
}
- @Test (dependsOnMethods = "testAddTrait")
+ @Test(dependsOnMethods = "testAddTrait")
public void testAddTraitWithAttribute() throws Exception {
final String aGUID = getGUID();
final String traitName = "P_I_I";
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableList.<String>of(),
- TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
+ HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil
+ .createTraitTypeDef(traitName, ImmutableList.<String>of(),
+ TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
TraitType traitType = typeSystem.defineTraitType(piiTrait);
ITypedStruct traitInstance = traitType.createInstance();
traitInstance.set("type", "SSN");
@@ -285,13 +281,13 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertEquals(type, "SSN");
}
- @Test (expectedExceptions = NullPointerException.class)
+ @Test(expectedExceptions = NullPointerException.class)
public void testAddTraitWithNullInstance() throws Exception {
repositoryService.addTrait(getGUID(), null);
Assert.fail();
}
- @Test (dependsOnMethods = "testAddTrait", expectedExceptions = RepositoryException.class)
+ @Test(dependsOnMethods = "testAddTrait", expectedExceptions = RepositoryException.class)
public void testAddTraitForBadEntity() throws Exception {
TraitType traitType = typeSystem.getDataType(TraitType.class, PII);
ITypedStruct traitInstance = traitType.createInstance();
@@ -300,7 +296,7 @@ public class GraphBackedMetadataRepositoryTest {
Assert.fail();
}
- @Test (dependsOnMethods = "testAddTrait")
+ @Test(dependsOnMethods = "testAddTrait")
public void testDeleteTrait() throws Exception {
final String aGUID = getGUID();
@@ -319,20 +315,20 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertFalse(traitNames.contains(PII));
}
- @Test (expectedExceptions = RepositoryException.class)
+ @Test(expectedExceptions = RepositoryException.class)
public void testDeleteTraitForNonExistentEntity() throws Exception {
repositoryService.deleteTrait(UUID.randomUUID().toString(), PII);
Assert.fail();
}
- @Test (expectedExceptions = RepositoryException.class)
+ @Test(expectedExceptions = RepositoryException.class)
public void testDeleteTraitForNonExistentTrait() throws Exception {
final String aGUID = getGUID();
repositoryService.deleteTrait(aGUID, "PCI");
Assert.fail();
}
- @Test (dependsOnMethods = "testCreateEntity")
+ @Test(dependsOnMethods = "testCreateEntity")
public void testGetIdFromVertex() throws Exception {
Vertex tableVertex = getTableEntityVertex();
@@ -341,12 +337,11 @@ public class GraphBackedMetadataRepositoryTest {
Assert.fail();
}
- Id expected = new Id(guid,
- tableVertex.<Integer>getProperty(Constants.VERSION_PROPERTY_KEY), TABLE_TYPE);
+ Id expected = new Id(guid, tableVertex.<Integer>getProperty(Constants.VERSION_PROPERTY_KEY), TABLE_TYPE);
Assert.assertEquals(repositoryService.getIdFromVertex(TABLE_TYPE, tableVertex), expected);
}
- @Test (dependsOnMethods = "testCreateEntity")
+ @Test(dependsOnMethods = "testCreateEntity")
public void testGetTypeName() throws Exception {
Vertex tableVertex = getTableEntityVertex();
Assert.assertEquals(repositoryService.getTypeName(tableVertex), TABLE_TYPE);
@@ -414,9 +409,8 @@ public class GraphBackedMetadataRepositoryTest {
@Test(dependsOnMethods = "testCreateEntity")
public void testBug37860() throws Exception {
- String dslQuery =
- "hive_table as t where name = 'bar' " +
- "database where name = 'foo' and description = 'foo database' select t";
+ String dslQuery = "hive_table as t where name = 'bar' "
+ + "database where name = 'foo' and description = 'foo database' select t";
System.out.println("Executing dslQuery = " + dslQuery);
String jsonResults = discoveryService.searchByDSL(dslQuery);
Assert.assertNotNull(jsonResults);
@@ -437,10 +431,10 @@ public class GraphBackedMetadataRepositoryTest {
}
/**
- * Full text search requires GraphBackedSearchIndexer, and GraphBackedSearchIndexer can't be enabled in
- * GraphBackedDiscoveryServiceTest because of its test data. So, test for full text search is in
- * GraphBackedMetadataRepositoryTest:(
- */
+ * Full text search requires GraphBackedSearchIndexer, and GraphBackedSearchIndexer can't be enabled in
+ * GraphBackedDiscoveryServiceTest because of its test data. So, test for full text search is in
+ * GraphBackedMetadataRepositoryTest:(
+ */
@Test(dependsOnMethods = "testSubmitEntity")
public void testFullTextSearch() throws Exception {
//todo fix this
@@ -475,114 +469,88 @@ public class GraphBackedMetadataRepositoryTest {
}
private void createHiveTypes() throws Exception {
- HierarchicalTypeDefinition<ClassType> superTypeDefinition =
- TypesUtil.createClassTypeDef(SUPER_TYPE_NAME,
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> superTypeDefinition = TypesUtil
+ .createClassTypeDef(SUPER_TYPE_NAME, ImmutableList.<String>of(),
TypesUtil.createOptionalAttrDef("namespace", DataTypes.STRING_TYPE),
TypesUtil.createOptionalAttrDef("cluster", DataTypes.STRING_TYPE),
TypesUtil.createOptionalAttrDef("colo", DataTypes.STRING_TYPE));
- HierarchicalTypeDefinition<ClassType> databaseTypeDefinition =
- TypesUtil.createClassTypeDef(DATABASE_TYPE,
- ImmutableList.of(SUPER_TYPE_NAME),
+ HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil
+ .createClassTypeDef(DATABASE_TYPE, ImmutableList.of(SUPER_TYPE_NAME),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createOptionalAttrDef("created", DataTypes.DATE_TYPE),
TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
- StructTypeDefinition structTypeDefinition =
- new StructTypeDefinition("serdeType",
- new AttributeDefinition[]{
- TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)
- });
+ StructTypeDefinition structTypeDefinition = new StructTypeDefinition("serdeType",
+ new AttributeDefinition[]{TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
+ TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)});
- EnumValue values[] = {
- new EnumValue("MANAGED", 1),
- new EnumValue("EXTERNAL", 2),
- };
+ EnumValue values[] = {new EnumValue("MANAGED", 1), new EnumValue("EXTERNAL", 2),};
EnumTypeDefinition enumTypeDefinition = new EnumTypeDefinition("tableType", values);
typeSystem.defineEnumType(enumTypeDefinition);
- HierarchicalTypeDefinition<ClassType> columnsDefinition =
- TypesUtil.createClassTypeDef("column_type",
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> columnsDefinition = TypesUtil
+ .createClassTypeDef("column_type", ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
- StructTypeDefinition partitionDefinition =
- new StructTypeDefinition("partition_type",
- new AttributeDefinition[]{
- TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- });
+ StructTypeDefinition partitionDefinition = new StructTypeDefinition("partition_type",
+ new AttributeDefinition[]{TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),});
- HierarchicalTypeDefinition<ClassType> tableTypeDefinition =
- TypesUtil.createClassTypeDef(TABLE_TYPE,
- ImmutableList.of(SUPER_TYPE_NAME),
+ HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil
+ .createClassTypeDef(TABLE_TYPE, ImmutableList.of(SUPER_TYPE_NAME),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE),
TypesUtil.createOptionalAttrDef("created", DataTypes.DATE_TYPE),
// enum
- new AttributeDefinition("tableType", "tableType",
- Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("tableType", "tableType", Multiplicity.REQUIRED, false, null),
// array of strings
new AttributeDefinition("columnNames",
- String.format("array<%s>", DataTypes.STRING_TYPE.getName()),
- Multiplicity.COLLECTION, false, null),
+ String.format("array<%s>", DataTypes.STRING_TYPE.getName()), Multiplicity.COLLECTION,
+ false, null),
// array of classes
- new AttributeDefinition("columns",
- String.format("array<%s>", "column_type"),
+ new AttributeDefinition("columns", String.format("array<%s>", "column_type"),
Multiplicity.COLLECTION, true, null),
// array of structs
- new AttributeDefinition("partitions",
- String.format("array<%s>", "partition_type"),
+ new AttributeDefinition("partitions", String.format("array<%s>", "partition_type"),
Multiplicity.COLLECTION, true, null),
// map of primitives
new AttributeDefinition("parametersMap",
- DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(),
- DataTypes.STRING_TYPE.getName()),
+ DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(), DataTypes.STRING_TYPE.getName()),
Multiplicity.COLLECTION, true, null),
// map of classes - todo - enable this
-// new AttributeDefinition("columnsMap",
-// DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(),
-// "column_type"),
-// Multiplicity.COLLECTION, true, null),
+ // new AttributeDefinition("columnsMap",
+ // DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(),
+ // "column_type"),
+ // Multiplicity.COLLECTION, true, null),
// map of structs todo - enable this
-// new AttributeDefinition("partitionsMap",
-// DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(),
-// "partition_type"),
-// Multiplicity.COLLECTION, true, null),
+ // new AttributeDefinition("partitionsMap",
+ // DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(),
+ // "partition_type"),
+ // Multiplicity.COLLECTION, true, null),
// struct reference
- new AttributeDefinition("serde1",
- "serdeType", Multiplicity.REQUIRED, false, null),
- new AttributeDefinition("serde2",
- "serdeType", Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("serde1", "serdeType", Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("serde2", "serdeType", Multiplicity.REQUIRED, false, null),
// class reference
- new AttributeDefinition("database",
- DATABASE_TYPE, Multiplicity.REQUIRED, true, null)
- );
+ new AttributeDefinition("database", DATABASE_TYPE, Multiplicity.REQUIRED, true, null));
- HierarchicalTypeDefinition<TraitType> classificationTypeDefinition =
- TypesUtil.createTraitTypeDef(CLASSIFICATION,
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<TraitType> classificationTypeDefinition = TypesUtil
+ .createTraitTypeDef(CLASSIFICATION, ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
- HierarchicalTypeDefinition<TraitType> fetlClassificationTypeDefinition =
- TypesUtil.createTraitTypeDef("fetl" + CLASSIFICATION,
- ImmutableList.of(CLASSIFICATION),
+ HierarchicalTypeDefinition<TraitType> fetlClassificationTypeDefinition = TypesUtil
+ .createTraitTypeDef("fetl" + CLASSIFICATION, ImmutableList.of(CLASSIFICATION),
TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
- typeSystem.defineTypes(
- ImmutableList.of(structTypeDefinition, partitionDefinition),
+ typeSystem.defineTypes(ImmutableList.of(structTypeDefinition, partitionDefinition),
ImmutableList.of(classificationTypeDefinition, fetlClassificationTypeDefinition),
- ImmutableList.of(superTypeDefinition, databaseTypeDefinition,
- columnsDefinition, tableTypeDefinition));
+ ImmutableList.of(superTypeDefinition, databaseTypeDefinition, columnsDefinition, tableTypeDefinition));
}
- private ITypedReferenceableInstance createHiveTableInstance(
- Referenceable databaseInstance) throws Exception {
+ private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance) throws Exception {
Referenceable tableInstance = new Referenceable(TABLE_TYPE, CLASSIFICATION);
tableInstance.set("name", TABLE_NAME);
tableInstance.set("description", "bar table");
@@ -630,7 +598,7 @@ public class GraphBackedMetadataRepositoryTest {
tableInstance.set("columns", columns);
// tableInstance.set("columnsMap", columnsMap);
-// HashMap<String, Struct> partitionsMap = new HashMap<>();
+ // HashMap<String, Struct> partitionsMap = new HashMap<>();
ArrayList<Struct> partitions = new ArrayList<>();
for (int index = 0; index < 5; index++) {
Struct partitionInstance = new Struct("partition_type");
@@ -638,10 +606,10 @@ public class GraphBackedMetadataRepositoryTest {
partitionInstance.set("name", name);
partitions.add(partitionInstance);
-// partitionsMap.put(name, partitionInstance);
+ // partitionsMap.put(name, partitionInstance);
}
tableInstance.set("partitions", partitions);
-// tableInstance.set("partitionsMap", partitionsMap);
+ // tableInstance.set("partitionsMap", partitionsMap);
HashMap<String, String> parametersMap = new HashMap<>();
parametersMap.put("foo", "bar");
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java
index 21e6a64..01b7480 100755
--- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java
@@ -22,10 +22,7 @@ import com.google.common.collect.ImmutableList;
import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanIndexQuery;
-import com.thinkaurelius.titan.core.schema.TitanGraphIndex;
import com.thinkaurelius.titan.diskstorage.BackendException;
-import com.thinkaurelius.titan.diskstorage.configuration.Configuration;
-import com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration;
import com.thinkaurelius.titan.diskstorage.configuration.ReadConfiguration;
import com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration;
import com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration;
@@ -33,7 +30,6 @@ import com.tinkerpop.blueprints.Compare;
import com.tinkerpop.blueprints.GraphQuery;
import com.tinkerpop.blueprints.Vertex;
import org.apache.atlas.GraphTransaction;
-import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.Referenceable;
@@ -54,14 +50,11 @@ import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.commons.io.FileUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Guice;
import org.testng.annotations.Test;
-import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.Map;
import java.util.Random;
@@ -73,7 +66,8 @@ public class GraphRepoMapperScaleTest {
private static final String TABLE_TYPE = "hive_table_type";
private static final String TABLE_NAME = "bar";
- private static final String INDEX_DIR = System.getProperty("java.io.tmpdir", "/tmp") + "/atlas-test" + new Random().nextLong();
+ private static final String INDEX_DIR =
+ System.getProperty("java.io.tmpdir", "/tmp") + "/atlas-test" + new Random().nextLong();
private GraphProvider<TitanGraph> graphProvider = new GraphProvider<TitanGraph>() {
@@ -130,7 +124,7 @@ public class GraphRepoMapperScaleTest {
graphProvider.get().shutdown();
try {
FileUtils.deleteDirectory(new File(INDEX_DIR));
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
System.err.println("Failed to cleanup index directory");
}
}
@@ -147,8 +141,7 @@ public class GraphRepoMapperScaleTest {
dbGUID = repositoryService.createEntity(db);
- Referenceable dbInstance = new Referenceable(
- dbGUID, DATABASE_TYPE, databaseInstance.getValuesMap());
+ Referenceable dbInstance = new Referenceable(dbGUID, DATABASE_TYPE, databaseInstance.getValuesMap());
for (int index = 0; index < 1000; index++) {
ITypedReferenceableInstance table = createHiveTableInstance(dbInstance, index);
@@ -175,14 +168,13 @@ public class GraphRepoMapperScaleTest {
long start = System.currentTimeMillis();
int count = 0;
try {
- GraphQuery query = graph.query()
- .has(key, Compare.EQUAL, value);
+ GraphQuery query = graph.query().has(key, Compare.EQUAL, value);
for (Vertex ignored : query.vertices()) {
count++;
}
} finally {
- System.out.println("Search on [" + key + "=" + value + "] returned results: " + count
- + ", took " + (System.currentTimeMillis() - start) + " ms");
+ System.out.println("Search on [" + key + "=" + value + "] returned results: " + count + ", took " + (
+ System.currentTimeMillis() - start) + " ms");
}
}
@@ -197,82 +189,64 @@ public class GraphRepoMapperScaleTest {
count++;
}
} finally {
- System.out.println("Search on [" + key + "=" + value + "] returned results: " + count
- + ", took " + (System.currentTimeMillis() - start) + " ms");
+ System.out.println("Search on [" + key + "=" + value + "] returned results: " + count + ", took " + (
+ System.currentTimeMillis() - start) + " ms");
}
}
private void createHiveTypes() throws Exception {
- HierarchicalTypeDefinition<ClassType> databaseTypeDefinition =
- TypesUtil.createClassTypeDef(DATABASE_TYPE,
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil
+ .createClassTypeDef(DATABASE_TYPE, ImmutableList.<String>of(),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
- StructTypeDefinition structTypeDefinition =
- new StructTypeDefinition("hive_serde_type",
- new AttributeDefinition[]{
- TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)
- });
+ StructTypeDefinition structTypeDefinition = new StructTypeDefinition("hive_serde_type",
+ new AttributeDefinition[]{TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
+ TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)});
- EnumValue values[] = {
- new EnumValue("MANAGED", 1),
- new EnumValue("EXTERNAL", 2),
- };
+ EnumValue values[] = {new EnumValue("MANAGED", 1), new EnumValue("EXTERNAL", 2),};
EnumTypeDefinition enumTypeDefinition = new EnumTypeDefinition("table_type", values);
final EnumType enumType = typeSystem.defineEnumType(enumTypeDefinition);
- HierarchicalTypeDefinition<ClassType> columnsDefinition =
- TypesUtil.createClassTypeDef("hive_column_type",
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> columnsDefinition = TypesUtil
+ .createClassTypeDef("hive_column_type", ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
- StructTypeDefinition partitionDefinition =
- new StructTypeDefinition("hive_partition_type",
- new AttributeDefinition[]{
- TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- });
+ StructTypeDefinition partitionDefinition = new StructTypeDefinition("hive_partition_type",
+ new AttributeDefinition[]{TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),});
- HierarchicalTypeDefinition<ClassType> tableTypeDefinition =
- TypesUtil.createClassTypeDef(TABLE_TYPE,
- ImmutableList.<String>of(),
+ HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil
+ .createClassTypeDef(TABLE_TYPE, ImmutableList.<String>of(),
TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE),
TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE),
// enum
- new AttributeDefinition("tableType", "table_type",
- Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("tableType", "table_type", Multiplicity.REQUIRED, false, null),
// array of strings
new AttributeDefinition("columnNames",
- String.format("array<%s>", DataTypes.STRING_TYPE.getName()),
- Multiplicity.COLLECTION, false, null),
+ String.format("array<%s>", DataTypes.STRING_TYPE.getName()), Multiplicity.COLLECTION,
+ false, null),
// array of classes
- new AttributeDefinition("columns",
- String.format("array<%s>", "hive_column_type"),
+ new AttributeDefinition("columns", String.format("array<%s>", "hive_column_type"),
Multiplicity.COLLECTION, true, null),
// array of structs
- new AttributeDefinition("partitions",
- String.format("array<%s>", "hive_partition_type"),
+ new AttributeDefinition("partitions", String.format("array<%s>", "hive_partition_type"),
Multiplicity.COLLECTION, true, null),
// struct reference
- new AttributeDefinition("serde1",
- "hive_serde_type", Multiplicity.REQUIRED, false, null),
- new AttributeDefinition("serde2",
- "hive_serde_type", Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("serde1", "hive_serde_type", Multiplicity.REQUIRED, false, null),
+ new AttributeDefinition("serde2", "hive_serde_type", Multiplicity.REQUIRED, false, null),
// class reference
- new AttributeDefinition("database",
- DATABASE_TYPE, Multiplicity.REQUIRED, true, null));
+ new AttributeDefinition("database", DATABASE_TYPE, Multiplicity.REQUIRED, true, null));
HierarchicalTypeDefinition<TraitType> classificationTypeDefinition =
TypesUtil.createTraitTypeDef("pii_type", ImmutableList.<String>of());
- Map<String, IDataType> types = typeSystem.defineTypes(
- ImmutableList.of(structTypeDefinition, partitionDefinition),
- ImmutableList.of(classificationTypeDefinition),
- ImmutableList.of(databaseTypeDefinition, columnsDefinition, tableTypeDefinition));
+ Map<String, IDataType> types = typeSystem
+ .defineTypes(ImmutableList.of(structTypeDefinition, partitionDefinition),
+ ImmutableList.of(classificationTypeDefinition),
+ ImmutableList.of(databaseTypeDefinition, columnsDefinition, tableTypeDefinition));
ArrayList<IDataType> typesAdded = new ArrayList<IDataType>();
@@ -281,8 +255,8 @@ public class GraphRepoMapperScaleTest {
searchIndexer.onAdd(typesAdded);
}
- private ITypedReferenceableInstance createHiveTableInstance(
- Referenceable databaseInstance, int uberIndex) throws Exception {
+ private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance, int uberIndex)
+ throws Exception {
Referenceable tableInstance = new Referenceable(TABLE_TYPE, "pii_type");
tableInstance.set("name", TABLE_NAME + "-" + uberIndex);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/memory/EnumTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/memory/EnumTest.java b/repository/src/test/java/org/apache/atlas/repository/memory/EnumTest.java
index 07a298f..6a0402a 100755
--- a/repository/src/test/java/org/apache/atlas/repository/memory/EnumTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/memory/EnumTest.java
@@ -55,26 +55,16 @@ public class EnumTest extends BaseTest {
}
void defineEnums(TypeSystem ts) throws AtlasException {
- ts.defineEnumType("HiveObjectType",
- new EnumValue("GLOBAL", 1),
- new EnumValue("DATABASE", 2),
- new EnumValue("TABLE", 3),
- new EnumValue("PARTITION", 4),
- new EnumValue("COLUMN", 5));
+ ts.defineEnumType("HiveObjectType", new EnumValue("GLOBAL", 1), new EnumValue("DATABASE", 2),
+ new EnumValue("TABLE", 3), new EnumValue("PARTITION", 4), new EnumValue("COLUMN", 5));
- ts.defineEnumType("PrincipalType",
- new EnumValue("USER", 1),
- new EnumValue("ROLE", 2),
+ ts.defineEnumType("PrincipalType", new EnumValue("USER", 1), new EnumValue("ROLE", 2),
new EnumValue("GROUP", 3));
- ts.defineEnumType("TxnState",
- new EnumValue("COMMITTED", 1),
- new EnumValue("ABORTED", 2),
+ ts.defineEnumType("TxnState", new EnumValue("COMMITTED", 1), new EnumValue("ABORTED", 2),
new EnumValue("OPEN", 3));
- ts.defineEnumType("LockLevel",
- new EnumValue("DB", 1),
- new EnumValue("TABLE", 2),
+ ts.defineEnumType("LockLevel", new EnumValue("DB", 1), new EnumValue("TABLE", 2),
new EnumValue("PARTITION", 3));
}
@@ -93,8 +83,7 @@ public class EnumTest extends BaseTest {
s.set("k", new BigDecimal(1));
s.set("l", new Date(1418265358440L));
s.set("m", Lists.asList(1, new Integer[]{1}));
- s.set("n",
- Lists.asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)}));
+ s.set("n", Lists.asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)}));
Map<String, Double> hm = Maps.newHashMap();
hm.put("a", 1.0);
hm.put("b", 2.0);
@@ -118,65 +107,54 @@ public class EnumTest extends BaseTest {
}
protected ClassType defineClassTypeWithEnum(TypeSystem ts) throws AtlasException {
- return ts.defineClassType(TypesUtil.createClassTypeDef("t4",
- ImmutableList.<String>of(),
+ return ts.defineClassType(TypesUtil.createClassTypeDef("t4", ImmutableList.<String>of(),
TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE),
TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE),
TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE),
- TypesUtil.createOptionalAttrDef("enum1",
- ts.getDataType(EnumType.class, "HiveObjectType")),
+ TypesUtil.createOptionalAttrDef("enum1", ts.getDataType(EnumType.class, "HiveObjectType")),
TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE),
TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE),
TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE),
- TypesUtil.createOptionalAttrDef("enum2",
- ts.getDataType(EnumType.class, "PrincipalType")),
+ TypesUtil.createOptionalAttrDef("enum2", ts.getDataType(EnumType.class, "PrincipalType")),
TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE),
TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE),
TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE),
TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE),
- TypesUtil
- .createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")),
+ TypesUtil.createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")),
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("enum4",
- ts.getDataType(EnumType.class, "LockLevel"))));
+ TypesUtil.createOptionalAttrDef("o", ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)),
+ TypesUtil.createOptionalAttrDef("enum4", ts.getDataType(EnumType.class, "LockLevel"))));
}
@Test
public void testStruct() throws AtlasException {
TypeSystem ts = getTypeSystem();
defineEnums(ts);
- StructType structType = ts.defineStructType("t3",
- true,
- TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE),
- TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE),
- TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE),
- TypesUtil.createOptionalAttrDef("enum1",
- ts.getDataType(EnumType.class, "HiveObjectType")),
- TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE),
- TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE),
- TypesUtil.createOptionalAttrDef("enum2",
- ts.getDataType(EnumType.class, "PrincipalType")),
- TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE),
- TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE),
- TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE),
- TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE),
- TypesUtil
- .createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")),
+ StructType structType =
+ ts.defineStructType("t3", true, TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE),
+ TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE),
+ TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE),
+ TypesUtil.createOptionalAttrDef("enum1", ts.getDataType(EnumType.class, "HiveObjectType")),
+ TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE),
+ TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE),
+ TypesUtil.createOptionalAttrDef("enum2", ts.getDataType(EnumType.class, "PrincipalType")),
+ TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE),
+ TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE),
+ TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE),
+ TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE),
+ TypesUtil.createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")),
- 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("enum4",
- ts.getDataType(EnumType.class, "LockLevel")));
+ 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("enum4", ts.getDataType(EnumType.class, "LockLevel")));
Struct s = createStructWithEnum("t3");
ITypedStruct typedS = structType.convert(s, Multiplicity.REQUIRED);