Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
9dc96c46
Commit
9dc96c46
authored
Nov 19, 2016
by
Apoorv Naik
Committed by
Madhan Neethiraj
Nov 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1292: Integration test fixes caused by recent bootstrap changes
parent
774975c9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
120 deletions
+135
-120
EntityNotificationIT.java
...a/org/apache/atlas/notification/EntityNotificationIT.java
+9
-2
NotificationHookConsumerIT.java
...apache/atlas/notification/NotificationHookConsumerIT.java
+35
-15
BaseResourceIT.java
...t/java/org/apache/atlas/web/resources/BaseResourceIT.java
+13
-10
DataSetLineageJerseyResourceIT.java
...e/atlas/web/resources/DataSetLineageJerseyResourceIT.java
+11
-14
EntityJerseyResourceIT.java
...rg/apache/atlas/web/resources/EntityJerseyResourceIT.java
+66
-19
EntityLineageJerseyResourceIT.java
...he/atlas/web/resources/EntityLineageJerseyResourceIT.java
+1
-60
No files found.
webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
View file @
9dc96c46
...
...
@@ -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
();
...
...
webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
View file @
9dc96c46
...
...
@@ -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
(
"n
ame"
)));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where
qualifiedName='%s'"
,
DATABASE_TYPE
,
entity
.
get
(
"qualifiedN
ame"
)));
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
(
"n
ame"
));
Referenceable
instance
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
qualifiedName"
,
(
String
)
entity
.
get
(
"qualifiedN
ame"
));
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
,
"
n
ame"
,
dbName
,
newEntity
));
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
"
qualifiedN
ame"
,
dbName
,
newEntity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
public
boolean
evaluate
()
throws
Exception
{
Referenceable
localEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
n
ame"
,
dbName
);
Referenceable
localEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
qualifiedN
ame"
,
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
,
"
n
ame"
,
dbName
);
Referenceable
actualEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
qualifiedN
ame"
,
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
(
"
n
ame"
,
newName
);
newEntity
.
set
(
"
qualifiedN
ame"
,
newName
);
sendHookMessage
(
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
"
n
ame"
,
dbName
,
newEntity
));
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
"
qualifiedN
ame"
,
dbName
,
newEntity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
public
boolean
evaluate
()
throws
Exception
{
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where
n
ame='%s'"
,
DATABASE_TYPE
,
newName
));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where
qualifiedN
ame='%s'"
,
DATABASE_TYPE
,
newName
));
return
results
.
length
()
==
1
;
}
});
//no entity with the old qualified name
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where
n
ame='%s'"
,
DATABASE_TYPE
,
dbName
));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where
qualifiedN
ame='%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
,
"
n
ame"
,
dbName
));
new
HookNotification
.
EntityDeleteRequest
(
TEST_USER
,
DATABASE_TYPE
,
"
qualifiedN
ame"
,
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
,
"
n
ame"
,
dbName
);
Referenceable
actualEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
qualifiedN
ame"
,
dbName
);
assertEquals
(
actualEntity
.
get
(
"description"
),
newEntity
.
get
(
"description"
));
assertEquals
(
actualEntity
.
get
(
"owner"
),
newEntity
.
get
(
"owner"
));
}
...
...
webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
View file @
9dc96c46
...
...
@@ -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
{
/**
...
...
webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
View file @
9dc96c46
...
...
@@ -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
(
"
dataT
ype"
));
Assert
.
assertNotNull
(
row
.
getString
(
"
t
ype"
));
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
(
"
dataT
ype"
));
Assert
.
assertNotNull
(
row
.
getString
(
"
t
ype"
));
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
dataT
ype
,
String
comment
,
String
...
traitNames
)
throws
Exception
{
Referenceable
column
(
String
name
,
String
t
ype
,
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
(
"user
Name
"
,
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
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
View file @
9dc96c46
...
...
@@ -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
,
"
n
ame"
,
dbName
);
Referenceable
referenceable
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"
qualifiedN
ame"
,
dbName
);
Assert
.
assertEquals
(
referenceable
.
getTypeName
(),
DATABASE_TYPE
);
Assert
.
assertEquals
(
referenceable
.
get
(
"
n
ame"
),
dbName
);
Assert
.
assertEquals
(
referenceable
.
get
(
"
qualifiedN
ame"
),
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
(
"
dataT
ype"
,
"int"
);
values
.
put
(
"
t
ype"
,
"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
,
"
n
ame"
,
dbName
).
getDeletedEntities
();
List
<
String
>
deletedGuidsList
=
serviceClient
.
deleteEntity
(
DATABASE_TYPE
,
"
qualifiedN
ame"
,
dbName
).
getDeletedEntities
();
// Verify that deleteEntities() response has database entity guids
Assert
.
assertEquals
(
deletedGuidsList
.
size
(),
1
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
View file @
9dc96c46
...
...
@@ -41,7 +41,7 @@ import java.util.Set;
/**
* Entity Lineage v2 Integration Tests.
*/
public
class
EntityLineageJerseyResourceIT
extends
Base
ResourceIT
{
public
class
EntityLineageJerseyResourceIT
extends
DataSetLineageJersey
ResourceIT
{
private
static
final
String
BASE_URI
=
"api/atlas/v2/lineage/"
;
private
static
final
String
INPUT_DIRECTION
=
"INPUT"
;
private
static
final
String
OUTPUT_DIRECTION
=
"OUTPUT"
;
...
...
@@ -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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment