atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1292: Integration test fixes caused by recent bootstrap changes
Date Sat, 19 Nov 2016 22:31:00 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 774975c97 -> 9dc96c467


ATLAS-1292: Integration test fixes caused by recent bootstrap changes


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/9dc96c46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/9dc96c46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/9dc96c46

Branch: refs/heads/master
Commit: 9dc96c467a6315c6713ec76d8afe32dbe46271a1
Parents: 774975c
Author: Apoorv Naik <naik.apoorv@gmail.com>
Authored: Sat Nov 19 14:30:26 2016 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Sat Nov 19 14:30:26 2016 -0800

----------------------------------------------------------------------
 .../notification/EntityNotificationIT.java      | 11 ++-
 .../NotificationHookConsumerIT.java             | 50 ++++++++----
 .../atlas/web/resources/BaseResourceIT.java     | 23 +++---
 .../DataSetLineageJerseyResourceIT.java         | 25 +++---
 .../web/resources/EntityJerseyResourceIT.java   | 85 +++++++++++++++-----
 .../EntityLineageJerseyResourceIT.java          | 69 ++--------------
 6 files changed, 139 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
index bb7595d..1d50884 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
@@ -80,8 +80,11 @@ public class EntityNotificationIT extends BaseResourceIT {
 
     @Test
     public void testCreateEntity() throws Exception {
-        Referenceable tableInstance = createHiveTableInstance(DATABASE_NAME, TABLE_NAME);
+        Referenceable hiveDBInstance = createHiveDBInstance(DATABASE_NAME);
+        Id dbID = createInstance(hiveDBInstance);
+        hiveDBInstance.replaceWithNewId(dbID);
 
+        Referenceable tableInstance = createHiveTableInstance(hiveDBInstance, TABLE_NAME);
         tableId = createInstance(tableInstance);
 
         final String guid = tableId._getId();
@@ -107,7 +110,11 @@ public class EntityNotificationIT extends BaseResourceIT {
     public void testDeleteEntity() throws Exception {
         final String tableName = "table-" + randomString();
         final String dbName = "db-" + randomString();
-        Referenceable tableInstance = createHiveTableInstance(dbName, tableName);
+        Referenceable hiveDBInstance = createHiveDBInstance(dbName);
+        Id dbID = createInstance(hiveDBInstance);
+        hiveDBInstance.replaceWithNewId(dbID);
+
+        Referenceable tableInstance = createHiveTableInstance(hiveDBInstance, tableName);
         final Id tableId = createInstance(tableInstance);
         final String guid = tableId._getId();
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
index 1b47e6e..de0a459 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
@@ -65,8 +65,11 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
 
         //send valid message
         final Referenceable entity = new Referenceable(DATABASE_TYPE);
-        entity.set("name", "db" + randomString());
+        String dbName = "db" + randomString();
+        entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
         sendHookMessage(new HookNotification.EntityCreateRequest(TEST_USER, entity));
 
         waitFor(MAX_WAIT_TIME, new Predicate() {
@@ -81,21 +84,24 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
     @Test
     public void testCreateEntity() throws Exception {
         final Referenceable entity = new Referenceable(DATABASE_TYPE);
-        entity.set("name", "db" + randomString());
+        String dbName = "db" + randomString();
+        entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
 
         sendHookMessage(new HookNotification.EntityCreateRequest(TEST_USER, entity));
 
         waitFor(MAX_WAIT_TIME, new Predicate() {
             @Override
             public boolean evaluate() throws Exception {
-                JSONArray results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE,
entity.get("name")));
+                JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'",
DATABASE_TYPE, entity.get("qualifiedName")));
                 return results.length() == 1;
             }
         });
 
         //Assert that user passed in hook message is used in audit
-        Referenceable instance = serviceClient.getEntity(DATABASE_TYPE, "name", (String)
entity.get("name"));
+        Referenceable instance = serviceClient.getEntity(DATABASE_TYPE, "qualifiedName",
(String) entity.get("qualifiedName"));
         List<EntityAuditEvent> events =
                 serviceClient.getEntityAuditEvents(instance.getId()._getId(), (short) 1);
         assertEquals(events.size(), 1);
@@ -108,22 +114,25 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
         final String dbName = "db" + randomString();
         entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
+
         serviceClient.createEntity(entity);
 
         final Referenceable newEntity = new Referenceable(DATABASE_TYPE);
         newEntity.set("owner", randomString());
         sendHookMessage(
-                new HookNotification.EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE,
"name", dbName, newEntity));
+                new HookNotification.EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE,
"qualifiedName", dbName, newEntity));
         waitFor(MAX_WAIT_TIME, new Predicate() {
             @Override
             public boolean evaluate() throws Exception {
-                Referenceable localEntity = serviceClient.getEntity(DATABASE_TYPE, "name",
dbName);
+                Referenceable localEntity = serviceClient.getEntity(DATABASE_TYPE, "qualifiedName",
dbName);
                 return (localEntity.get("owner") != null && localEntity.get("owner").equals(newEntity.get("owner")));
             }
         });
 
         //Its partial update and un-set fields are not updated
-        Referenceable actualEntity = serviceClient.getEntity(DATABASE_TYPE, "name", dbName);
+        Referenceable actualEntity = serviceClient.getEntity(DATABASE_TYPE, "qualifiedName",
dbName);
         assertEquals(actualEntity.get("description"), entity.get("description"));
     }
 
@@ -133,24 +142,27 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
         final String dbName = "db" + randomString();
         entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
+
         serviceClient.createEntity(entity);
 
         final Referenceable newEntity = new Referenceable(DATABASE_TYPE);
         final String newName = "db" + randomString();
-        newEntity.set("name", newName);
+        newEntity.set("qualifiedName", newName);
 
         sendHookMessage(
-                new HookNotification.EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE,
"name", dbName, newEntity));
+                new HookNotification.EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE,
"qualifiedName", dbName, newEntity));
         waitFor(MAX_WAIT_TIME, new Predicate() {
             @Override
             public boolean evaluate() throws Exception {
-                JSONArray results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE,
newName));
+                JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'",
DATABASE_TYPE, newName));
                 return results.length() == 1;
             }
         });
 
         //no entity with the old qualified name
-        JSONArray results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE,
dbName));
+        JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE,
dbName));
         assertEquals(results.length(), 0);
 
     }
@@ -161,10 +173,13 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
         final String dbName = "db" + randomString();
         entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
+
         final String dbId = serviceClient.createEntity(entity).get(0);
 
         sendHookMessage(
-            new HookNotification.EntityDeleteRequest(TEST_USER, DATABASE_TYPE, "name", dbName));
+            new HookNotification.EntityDeleteRequest(TEST_USER, DATABASE_TYPE, "qualifiedName",
dbName));
         waitFor(MAX_WAIT_TIME, new Predicate() {
             @Override
             public boolean evaluate() throws Exception {
@@ -180,24 +195,29 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
         final String dbName = "db" + randomString();
         entity.set("name", dbName);
         entity.set("description", randomString());
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
+
         serviceClient.createEntity(entity);
 
         final Referenceable newEntity = new Referenceable(DATABASE_TYPE);
-        newEntity.set("name", dbName);
+        newEntity.set("name", randomString());
         newEntity.set("description", randomString());
         newEntity.set("owner", randomString());
+        newEntity.set("qualifiedName", dbName);
+        newEntity.set("clusterName", randomString());
 
         //updating unique attribute
         sendHookMessage(new HookNotification.EntityUpdateRequest(TEST_USER, newEntity));
         waitFor(MAX_WAIT_TIME, new Predicate() {
             @Override
             public boolean evaluate() throws Exception {
-                JSONArray results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE,
dbName));
+                JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'",
DATABASE_TYPE, newEntity.get("qualifiedName")));
                 return results.length() == 1;
             }
         });
 
-        Referenceable actualEntity = serviceClient.getEntity(DATABASE_TYPE, "name", dbName);
+        Referenceable actualEntity = serviceClient.getEntity(DATABASE_TYPE, "qualifiedName",
dbName);
         assertEquals(actualEntity.get("description"), newEntity.get("description"));
         assertEquals(actualEntity.get("owner"), newEntity.get("owner"));
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
index 0238b95..50ca842 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
@@ -90,14 +90,11 @@ public abstract class BaseResourceIT {
     }
 
     protected void createType(TypesDef typesDef) throws Exception {
-        HierarchicalTypeDefinition<ClassType> sampleType = typesDef.classTypesAsJavaList().get(0);
         try {
-            serviceClient.getType(sampleType.typeName);
-            LOG.info("Types already exist. Skipping type creation");
-        } catch(AtlasServiceException ase) {
-            //Expected if type doesnt exist
             String typesAsJSON = TypesSerialization.toJson(typesDef);
             createType(typesAsJSON);
+        } catch(AtlasServiceException ase) {
+            LOG.info("Types failed. Tests might malfunction");
         }
     }
 
@@ -186,6 +183,7 @@ public abstract class BaseResourceIT {
         TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.of(enumTypeDefinition),
                 ImmutableList.of(structTypeDefinition),
                 ImmutableList.of(classificationTrait, piiTrait, phiTrait, pciTrait, soxTrait,
secTrait, financeTrait),
+//                ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
                 ImmutableList.of(dbClsDef, columnClsDef, tblClsDef, loadProcessClsDef));
 
         createType(typesDef);
@@ -210,11 +208,7 @@ public abstract class BaseResourceIT {
         return RandomStringUtils.randomAlphanumeric(10);
     }
 
-    protected Referenceable createHiveTableInstance(String dbName, String tableName) throws
Exception {
-        Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
-        databaseInstance.set("name", dbName);
-        databaseInstance.set("description", "foo database");
-
+    protected Referenceable createHiveTableInstance(Referenceable databaseInstance, String
tableName) throws Exception {
         Referenceable tableInstance =
                 new Referenceable(HIVE_TABLE_TYPE, "classification", "pii", "phi", "pci",
"sox", "sec", "finance");
         tableInstance.set("name", tableName);
@@ -246,6 +240,15 @@ public abstract class BaseResourceIT {
         return tableInstance;
     }
 
+    protected Referenceable createHiveDBInstance(String dbName) {
+        Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
+        databaseInstance.set("name", dbName);
+        databaseInstance.set("qualifiedName", dbName);
+        databaseInstance.set("clusterName", randomString());
+        databaseInstance.set("description", "foo database");
+        return databaseInstance;
+    }
+
     public interface Predicate {
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
index d8568ae..f9e4c40 100644
--- a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
@@ -167,9 +167,10 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
 
         for (int index = 0; index < rows.length(); index++) {
             final JSONObject row = rows.getJSONObject(index);
+            LOG.info("JsonRow - {}", row);
             Assert.assertNotNull(row.getString("name"));
             Assert.assertNotNull(row.getString("comment"));
-            Assert.assertNotNull(row.getString("dataType"));
+            Assert.assertNotNull(row.getString("type"));
             Assert.assertEquals(row.getString("$typeName$"), "hive_column");
         }
     }
@@ -185,23 +186,15 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
 
         for (int index = 0; index < rows.length(); index++) {
             final JSONObject row = rows.getJSONObject(index);
+            LOG.info("JsonRow - {}", row);
             Assert.assertNotNull(row.getString("name"));
             Assert.assertNotNull(row.getString("comment"));
-            Assert.assertNotNull(row.getString("dataType"));
+            Assert.assertNotNull(row.getString("type"));
             Assert.assertEquals(row.getString("$typeName$"), "hive_column");
         }
     }
 
     @Test
-    public void testSchemaForEmptyTable() throws Exception {
-        WebResource resource = service.path(BASE_URI).path("").path("schema");
-
-        ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
-    }
-
-    @Test
     public void testSchemaForInvalidTable() throws Exception {
         WebResource resource = service.path(BASE_URI).path("blah").path("schema");
 
@@ -264,6 +257,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
     throws Exception {
         Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames);
         referenceable.set("name", name);
+        referenceable.set("qualifiedName", name);
+        referenceable.set("clusterName", locationUri + name);
         referenceable.set("description", description);
         referenceable.set("owner", owner);
         referenceable.set("locationUri", locationUri);
@@ -272,10 +267,11 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
         return createInstance(referenceable);
     }
 
-    Referenceable column(String name, String dataType, String comment, String... traitNames)
throws Exception {
+    Referenceable column(String name, String type, String comment, String... traitNames)
throws Exception {
         Referenceable referenceable = new Referenceable(COLUMN_TYPE, traitNames);
         referenceable.set("name", name);
-        referenceable.set("dataType", dataType);
+        referenceable.set("qualifiedName", name);
+        referenceable.set("type", type);
         referenceable.set("comment", comment);
 
         return referenceable;
@@ -304,13 +300,14 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
         Referenceable referenceable = new Referenceable(HIVE_PROCESS_TYPE, traitNames);
         referenceable.set("name", name);
         referenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
-        referenceable.set("user", user);
+        referenceable.set("userName", user);
         referenceable.set("startTime", System.currentTimeMillis());
         referenceable.set("endTime", System.currentTimeMillis() + 10000);
 
         referenceable.set("inputs", inputTables);
         referenceable.set("outputs", outputTables);
 
+        referenceable.set("operationType", "testOperation");
         referenceable.set("queryText", queryText);
         referenceable.set("queryPlan", queryPlan);
         referenceable.set("queryId", queryId);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
index ea86cc6..18d4642 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
@@ -48,11 +48,13 @@ import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
 import org.apache.atlas.typesystem.types.StructTypeDefinition;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
+import org.apache.atlas.utils.AuthenticationUtil;
 import org.apache.atlas.web.util.Servlets;
 import org.apache.commons.lang.RandomStringUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -72,7 +74,6 @@ import java.util.UUID;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.fail;
-import org.apache.atlas.utils.AuthenticationUtil;
 
 
 /**
@@ -111,7 +112,17 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
 
     @Test
     public void testSubmitEntity() throws Exception {
-        tableInstance = createHiveTableInstance(DATABASE_NAME, TABLE_NAME);
+        Referenceable dbInstance = createHiveDBInstance(DATABASE_NAME);
+
+        Id dbID = createInstance(dbInstance);
+        try {
+            Assert.assertNotNull(UUID.fromString(dbID._getId()));
+            dbInstance.replaceWithNewId(dbID);
+        } catch (IllegalArgumentException e) {
+            Assert.fail("Response is not a guid, " + dbID._getId());
+        }
+
+        tableInstance = createHiveTableInstance(dbInstance, TABLE_NAME);
         tableId = createInstance(tableInstance);
 
         final String guid = tableId._getId();
@@ -125,7 +136,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     @Test
     public void testRequestUser() throws Exception {
         Referenceable entity = new Referenceable(DATABASE_TYPE);
-        entity.set("name", randomString());
+        String dbName = randomString();
+        entity.set("name", dbName);
+        entity.set("qualifiedName", dbName);
+        entity.set("clusterName", randomString());
         entity.set("description", randomString());
 
         String user = "admin";
@@ -146,7 +160,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     //API should accept single entity (or jsonarray of entities)
     public void testSubmitSingleEntity() throws Exception {
         Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
-        databaseInstance.set("name", randomString());
+        String dbName = randomString();
+        databaseInstance.set("name", dbName);
+        databaseInstance.set("qualifiedName", dbName);
+        databaseInstance.set("clusterName", randomString());
         databaseInstance.set("description", randomString());
 
         ClientResponse clientResponse =
@@ -171,6 +188,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         final Referenceable db = new Referenceable(DATABASE_TYPE);
         final String dbName = "db" + randomString();
         db.set("name", dbName);
+        db.set("qualifiedName", dbName);
+        db.set("clusterName", randomString());
         db.set("description", randomString());
 
         final String dbid = serviceClient.createEntity(db).get(0);
@@ -263,7 +282,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     @Test(dataProvider = "invalidAttrValues")
     public void testEntityInvalidValue(String value) throws Exception {
         Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
-        databaseInstance.set("name", randomString());
+        String dbName = randomString();
+        databaseInstance.set("name", dbName);
         databaseInstance.set("description", value);
 
         try {
@@ -279,19 +299,25 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
         String dbName = randomString();
         databaseInstance.set("name", dbName);
+        databaseInstance.set("qualifiedName", dbName);
+        databaseInstance.set("clusterName", randomString());
         databaseInstance.set("description", "foo database");
         createInstance(databaseInstance);
 
         //get entity by attribute
-        Referenceable referenceable = serviceClient.getEntity(DATABASE_TYPE, "name", dbName);
+        Referenceable referenceable = serviceClient.getEntity(DATABASE_TYPE, "qualifiedName",
dbName);
         Assert.assertEquals(referenceable.getTypeName(), DATABASE_TYPE);
-        Assert.assertEquals(referenceable.get("name"), dbName);
+        Assert.assertEquals(referenceable.get("qualifiedName"), dbName);
     }
 
     @Test
     public void testSubmitEntityWithBadDateFormat() throws Exception {
         try {
-            Referenceable tableInstance = createHiveTableInstance("db" + randomString(),
"table" + randomString());
+            Referenceable hiveDBInstance = createHiveDBInstance("db" + randomString());
+            Id dbID = createInstance(hiveDBInstance);
+            hiveDBInstance.replaceWithNewId(dbID);
+
+            Referenceable tableInstance = createHiveTableInstance(hiveDBInstance, "table"
+ randomString());
             tableInstance.set("lastAccessTime", "2014-07-11");
             tableId = createInstance(tableInstance);
             Assert.fail("Was expecting an  exception here ");
@@ -322,7 +348,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         }
 
         //non-string property, update
-        String currentTime = String.valueOf(System.currentTimeMillis());
+        String currentTime = String.valueOf(new DateTime());
         addProperty(guid, "createTime", currentTime);
 
         entityRef = getEntityDefinition(getEntityDefinition(guid));
@@ -355,7 +381,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     public void testAddReferenceProperty() throws Exception {
         //Create new db instance
         Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
-        databaseInstance.set("name", randomString());
+        String dbName = randomString();
+        databaseInstance.set("name", dbName);
+        databaseInstance.set("qualifiedName", dbName);
+        databaseInstance.set("clusterName", randomString());
         databaseInstance.set("description", "new database");
 
         Id dbInstance = createInstance(databaseInstance);
@@ -733,7 +762,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         final List<Referenceable> columns = new ArrayList<>();
         Map<String, Object> values = new HashMap<>();
         values.put("name", "col1");
-        values.put("dataType", "string");
+        values.put("qualifiedName", "qualifiedName.col1");
+        values.put("type", "string");
         values.put("comment", "col1 comment");
 
         Referenceable ref = new Referenceable(BaseResourceIT.COLUMN_TYPE, values);
@@ -755,7 +785,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         Assert.assertTrue(refs.get(0).equalsContents(columns.get(0)));
 
         //Update by unique attribute
-        values.put("dataType", "int");
+        values.put("type", "int");
         ref = new Referenceable(BaseResourceIT.COLUMN_TYPE, values);
         columns.set(0, ref);
         tableUpdated = new Referenceable(BaseResourceIT.HIVE_TABLE_TYPE, new HashMap<String,
Object>() {{
@@ -782,12 +812,14 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         final List<Referenceable> columns = new ArrayList<>();
         Map<String, Object> values1 = new HashMap<>();
         values1.put("name", "col3");
-        values1.put("dataType", "string");
+        values1.put("qualifiedName", "qualifiedName.col3");
+        values1.put("type", "string");
         values1.put("comment", "col3 comment");
 
         Map<String, Object> values2 = new HashMap<>();
         values2.put("name", "col4");
-        values2.put("dataType", "string");
+        values2.put("qualifiedName", "qualifiedName.col4");
+        values2.put("type", "string");
         values2.put("comment", "col4 comment");
 
         Referenceable ref1 = new Referenceable(BaseResourceIT.COLUMN_TYPE, values1);
@@ -839,11 +871,18 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     public void testDeleteEntitiesViaRestApi() throws Exception {
         // Create 2 database entities
         Referenceable db1 = new Referenceable(DATABASE_TYPE);
-        db1.set("name", randomString());
+        String dbName1 = randomString();
+        db1.set("name", dbName1);
+        db1.set("qualifiedName", dbName1);
+        db1.set("clusterName", randomString());
         db1.set("description", randomString());
         Id db1Id = createInstance(db1);
+
         Referenceable db2 = new Referenceable(DATABASE_TYPE);
-        db2.set("name", randomString());
+        String dbName2 = randomString();
+        db2.set("name", dbName2);
+        db2.set("qualifiedName", dbName2);
+        db2.set("clusterName", randomString());
         db2.set("description", randomString());
         Id db2Id = createInstance(db2);
         
@@ -869,11 +908,17 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
     public void testDeleteEntitiesViaClientApi() throws Exception {
         // Create 2 database entities
         Referenceable db1 = new Referenceable(DATABASE_TYPE);
-        db1.set("name", randomString());
+        String dbName1 = randomString();
+        db1.set("name", dbName1);
+        db1.set("qualifiedName", dbName1);
+        db1.set("clusterName", randomString());
         db1.set("description", randomString());
         Id db1Id = createInstance(db1);
         Referenceable db2 = new Referenceable(DATABASE_TYPE);
-        db2.set("name", randomString());
+        String dbName2 = randomString();
+        db2.set("name", dbName2);
+        db2.set("qualifiedName", dbName2);
+        db2.set("clusterName", randomString());
         db2.set("description", randomString());
         Id db2Id = createInstance(db2);
         
@@ -899,11 +944,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         Referenceable db1 = new Referenceable(DATABASE_TYPE);
         String dbName = randomString();
         db1.set("name", dbName);
+        db1.set("qualifiedName", dbName);
+        db1.set("clusterName", randomString());
         db1.set("description", randomString());
         Id db1Id = createInstance(db1);
 
         // Delete the database entity
-        List<String> deletedGuidsList = serviceClient.deleteEntity(DATABASE_TYPE, "name",
dbName).getDeletedEntities();
+        List<String> deletedGuidsList = serviceClient.deleteEntity(DATABASE_TYPE, "qualifiedName",
dbName).getDeletedEntities();
 
         // Verify that deleteEntities() response has database entity guids
         Assert.assertEquals(deletedGuidsList.size(), 1);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9dc96c46/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
index f0455c0..cf25814 100644
--- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
@@ -41,13 +41,13 @@ import java.util.Set;
 /**
  * Entity Lineage v2 Integration Tests.
  */
-public class EntityLineageJerseyResourceIT extends BaseResourceIT {
+public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceIT {
     private static final String BASE_URI = "api/atlas/v2/lineage/";
-    private static final String INPUT_DIRECTION  = "INPUT";
+    private static final String INPUT_DIRECTION = "INPUT";
     private static final String OUTPUT_DIRECTION = "OUTPUT";
-    private static final String BOTH_DIRECTION   = "BOTH";
-    private static final String DIRECTION_PARAM  = "direction";
-    private static final String DEPTH_PARAM      = "depth";
+    private static final String BOTH_DIRECTION = "BOTH";
+    private static final String DIRECTION_PARAM = "direction";
+    private static final String DEPTH_PARAM = "depth";
 
     private String salesFactTable;
     private String salesMonthlyTable;
@@ -191,63 +191,4 @@ public class EntityLineageJerseyResourceIT extends BaseResourceIT {
         loadProcess("loadSalesMonthly" + randomString(), "John ETL", ImmutableList.of(salesFactDaily),
                 ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id",
"graph");
     }
-
-    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);
-        referenceable.set("owner", owner);
-        referenceable.set("locationUri", locationUri);
-        referenceable.set("createTime", System.currentTimeMillis());
-
-        return createInstance(referenceable);
-    }
-
-    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);
-        referenceable.set("comment", comment);
-
-        return referenceable;
-    }
-
-    Id table(String name, String description, Id dbId, 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(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
-        referenceable.set("description", description);
-        referenceable.set("owner", owner);
-        referenceable.set("tableType", tableType);
-        referenceable.set("createTime", System.currentTimeMillis());
-        referenceable.set("lastAccessTime", System.currentTimeMillis());
-        referenceable.set("retention", System.currentTimeMillis());
-
-        referenceable.set("db", dbId);
-        referenceable.set("columns", columns);
-
-        return createInstance(referenceable);
-    }
-
-    Id loadProcess(String name, 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(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
-        referenceable.set("user", user);
-        referenceable.set("startTime", System.currentTimeMillis());
-        referenceable.set("endTime", System.currentTimeMillis() + 10000);
-
-        referenceable.set("inputs", inputTables);
-        referenceable.set("outputs", outputTables);
-
-        referenceable.set("queryText", queryText);
-        referenceable.set("queryPlan", queryPlan);
-        referenceable.set("queryId", queryId);
-        referenceable.set("queryGraph", queryGraph);
-
-        return createInstance(referenceable);
-    }
 }


Mime
View raw message