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
03684a05
Commit
03684a05
authored
Feb 08, 2017
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1540: fix for unit test failures in TestEntityREST
parent
7ed6b02c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
27 deletions
+35
-27
RequestContext.java
...er-api/src/main/java/org/apache/atlas/RequestContext.java
+8
-1
TestEntityREST.java
...st/java/org/apache/atlas/web/adapters/TestEntityREST.java
+27
-26
No files found.
server-api/src/main/java/org/apache/atlas/RequestContext.java
View file @
03684a05
...
@@ -94,7 +94,14 @@ public class RequestContext {
...
@@ -94,7 +94,14 @@ public class RequestContext {
}
}
public
static
void
clear
()
{
public
static
void
clear
()
{
CURRENT_CONTEXT
.
get
().
entityCache
.
clear
();
RequestContext
instance
=
CURRENT_CONTEXT
.
get
();
if
(
instance
!=
null
)
{
if
(
instance
.
entityCache
!=
null
)
{
instance
.
entityCache
.
clear
();
}
}
CURRENT_CONTEXT
.
remove
();
CURRENT_CONTEXT
.
remove
();
}
}
...
...
webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
View file @
03684a05
...
@@ -58,16 +58,12 @@ public class TestEntityREST {
...
@@ -58,16 +58,12 @@ public class TestEntityREST {
private
AtlasEntity
dbEntity
;
private
AtlasEntity
dbEntity
;
private
String
dbGuid
;
private
AtlasClassification
testClassification
;
private
AtlasClassification
testClassification
;
@BeforeClass
@BeforeClass
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
AtlasTypesDef
typesDef
=
TestUtilsV2
.
defineHiveTypes
();
AtlasTypesDef
typesDef
=
TestUtilsV2
.
defineHiveTypes
();
typeStore
.
createTypesDef
(
typesDef
);
typeStore
.
createTypesDef
(
typesDef
);
Map
<
String
,
AtlasEntity
>
dbEntityMap
=
TestUtilsV2
.
createDBEntity
();
dbEntity
=
dbEntityMap
.
values
().
iterator
().
next
();
}
}
@AfterClass
@AfterClass
...
@@ -80,9 +76,12 @@ public class TestEntityREST {
...
@@ -80,9 +76,12 @@ public class TestEntityREST {
RequestContext
.
clear
();
RequestContext
.
clear
();
}
}
public
void
createOrUpdateEntity
()
throws
Exception
{
private
void
createTestEntity
()
throws
Exception
{
Map
<
String
,
AtlasEntity
>
dbEntityMap
=
new
HashMap
<>();
Map
<
String
,
AtlasEntity
>
dbEntityMap
=
TestUtilsV2
.
createDBEntity
();
AtlasEntity
dbEntity
=
dbEntityMap
.
values
().
iterator
().
next
();
dbEntityMap
.
put
(
dbEntity
.
getGuid
(),
dbEntity
);
dbEntityMap
.
put
(
dbEntity
.
getGuid
(),
dbEntity
);
final
EntityMutationResponse
response
=
entitiesREST
.
createOrUpdate
(
dbEntityMap
);
final
EntityMutationResponse
response
=
entitiesREST
.
createOrUpdate
(
dbEntityMap
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
...
@@ -91,37 +90,37 @@ public class TestEntityREST {
...
@@ -91,37 +90,37 @@ public class TestEntityREST {
Assert
.
assertNotNull
(
entitiesMutated
);
Assert
.
assertNotNull
(
entitiesMutated
);
Assert
.
assertEquals
(
entitiesMutated
.
size
(),
1
);
Assert
.
assertEquals
(
entitiesMutated
.
size
(),
1
);
Assert
.
assertNotNull
(
entitiesMutated
.
get
(
0
));
Assert
.
assertNotNull
(
entitiesMutated
.
get
(
0
));
dbGuid
=
entitiesMutated
.
get
(
0
).
getGuid
();
dbEntity
.
setGuid
(
entitiesMutated
.
get
(
0
).
getGuid
());
Assert
.
assertEquals
(
entitiesMutated
.
size
(),
1
);
this
.
dbEntity
=
dbEntity
;
}
}
@Test
@Test
public
void
testGetEntityById
()
throws
Exception
{
public
void
testGetEntityById
()
throws
Exception
{
create
OrUpdate
Entity
();
create
Test
Entity
();
AtlasEntityWithExtInfo
response
=
entityREST
.
getById
(
db
Guid
);
AtlasEntityWithExtInfo
response
=
entityREST
.
getById
(
db
Entity
.
getGuid
()
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
getEntity
());
Assert
.
assertNotNull
(
response
.
getEntity
());
TestEntitiesREST
.
verifyAttributes
(
response
.
getEntity
().
getAttributes
(),
dbEntity
.
getAttributes
());
TestEntitiesREST
.
verifyAttributes
(
response
.
getEntity
().
getAttributes
(),
dbEntity
.
getAttributes
());
}
}
@Test
@Test
(
dependsOnMethods
=
"testGetEntityById"
)
public
void
testAddAndGetClassification
()
throws
Exception
{
public
void
testAddAndGetClassification
()
throws
Exception
{
createOrUpdateEntity
();
List
<
AtlasClassification
>
classifications
=
new
ArrayList
<>();
List
<
AtlasClassification
>
classifications
=
new
ArrayList
<>();
testClassification
=
new
AtlasClassification
(
TestUtilsV2
.
CLASSIFICATION
,
new
HashMap
<
String
,
Object
>()
{{
put
(
"tag"
,
"tagName"
);
}});
testClassification
=
new
AtlasClassification
(
TestUtilsV2
.
CLASSIFICATION
,
new
HashMap
<
String
,
Object
>()
{{
put
(
"tag"
,
"tagName"
);
}});
classifications
.
add
(
testClassification
);
classifications
.
add
(
testClassification
);
entityREST
.
addClassifications
(
db
Guid
,
classifications
);
entityREST
.
addClassifications
(
db
Entity
.
getGuid
()
,
classifications
);
final
AtlasClassification
.
AtlasClassifications
retrievedClassifications
=
entityREST
.
getClassifications
(
db
Guid
);
final
AtlasClassification
.
AtlasClassifications
retrievedClassifications
=
entityREST
.
getClassifications
(
db
Entity
.
getGuid
()
);
Assert
.
assertNotNull
(
retrievedClassifications
);
Assert
.
assertNotNull
(
retrievedClassifications
);
final
List
<
AtlasClassification
>
retrievedClassificationsList
=
retrievedClassifications
.
getList
();
final
List
<
AtlasClassification
>
retrievedClassificationsList
=
retrievedClassifications
.
getList
();
Assert
.
assertNotNull
(
retrievedClassificationsList
);
Assert
.
assertNotNull
(
retrievedClassificationsList
);
Assert
.
assertEquals
(
classifications
,
retrievedClassificationsList
);
Assert
.
assertEquals
(
classifications
,
retrievedClassificationsList
);
final
AtlasClassification
retrievedClassification
=
entityREST
.
getClassification
(
db
Guid
,
TestUtilsV2
.
CLASSIFICATION
);
final
AtlasClassification
retrievedClassification
=
entityREST
.
getClassification
(
db
Entity
.
getGuid
()
,
TestUtilsV2
.
CLASSIFICATION
);
Assert
.
assertNotNull
(
retrievedClassification
);
Assert
.
assertNotNull
(
retrievedClassification
);
Assert
.
assertEquals
(
retrievedClassification
,
testClassification
);
Assert
.
assertEquals
(
retrievedClassification
,
testClassification
);
...
@@ -131,7 +130,7 @@ public class TestEntityREST {
...
@@ -131,7 +130,7 @@ public class TestEntityREST {
@Test
(
dependsOnMethods
=
"testAddAndGetClassification"
)
@Test
(
dependsOnMethods
=
"testAddAndGetClassification"
)
public
void
testGetEntityWithAssociations
()
throws
Exception
{
public
void
testGetEntityWithAssociations
()
throws
Exception
{
AtlasEntityWithExtInfo
entity
=
entityREST
.
getById
(
db
Guid
);
AtlasEntityWithExtInfo
entity
=
entityREST
.
getById
(
db
Entity
.
getGuid
()
);
final
List
<
AtlasClassification
>
retrievedClassifications
=
entity
.
getEntity
().
getClassifications
();
final
List
<
AtlasClassification
>
retrievedClassifications
=
entity
.
getEntity
().
getClassifications
();
Assert
.
assertNotNull
(
retrievedClassifications
);
Assert
.
assertNotNull
(
retrievedClassifications
);
...
@@ -141,8 +140,8 @@ public class TestEntityREST {
...
@@ -141,8 +140,8 @@ public class TestEntityREST {
@Test
(
dependsOnMethods
=
"testGetEntityWithAssociations"
)
@Test
(
dependsOnMethods
=
"testGetEntityWithAssociations"
)
public
void
testDeleteClassification
()
throws
Exception
{
public
void
testDeleteClassification
()
throws
Exception
{
entityREST
.
deleteClassification
(
db
Guid
,
TestUtilsV2
.
CLASSIFICATION
);
entityREST
.
deleteClassification
(
db
Entity
.
getGuid
()
,
TestUtilsV2
.
CLASSIFICATION
);
final
AtlasClassification
.
AtlasClassifications
retrievedClassifications
=
entityREST
.
getClassifications
(
db
Guid
);
final
AtlasClassification
.
AtlasClassifications
retrievedClassifications
=
entityREST
.
getClassifications
(
db
Entity
.
getGuid
()
);
Assert
.
assertNotNull
(
retrievedClassifications
);
Assert
.
assertNotNull
(
retrievedClassifications
);
Assert
.
assertEquals
(
retrievedClassifications
.
getList
().
size
(),
0
);
Assert
.
assertEquals
(
retrievedClassifications
.
getList
().
size
(),
0
);
...
@@ -151,26 +150,28 @@ public class TestEntityREST {
...
@@ -151,26 +150,28 @@ public class TestEntityREST {
@Test
(
dependsOnMethods
=
"testDeleteClassification"
)
@Test
(
dependsOnMethods
=
"testDeleteClassification"
)
public
void
testDeleteEntityById
()
throws
Exception
{
public
void
testDeleteEntityById
()
throws
Exception
{
EntityMutationResponse
response
=
entityREST
.
deleteByGuid
(
db
Guid
);
EntityMutationResponse
response
=
entityREST
.
deleteByGuid
(
db
Entity
.
getGuid
()
);
List
<
AtlasEntityHeader
>
entitiesMutated
=
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
);
List
<
AtlasEntityHeader
>
entitiesMutated
=
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
);
Assert
.
assertNotNull
(
entitiesMutated
);
Assert
.
assertNotNull
(
entitiesMutated
);
Assert
.
assertEquals
(
entitiesMutated
.
get
(
0
).
getGuid
(),
db
Guid
);
Assert
.
assertEquals
(
entitiesMutated
.
get
(
0
).
getGuid
(),
db
Entity
.
getGuid
()
);
}
}
@Test
@Test
public
void
testUpdateGetDeleteEntityByUniqueAttribute
()
throws
Exception
{
public
void
testUpdateGetDeleteEntityByUniqueAttribute
()
throws
Exception
{
Map
<
String
,
AtlasEntity
>
dbEntityMap
=
TestUtilsV2
.
createDBEntity
();
Map
<
String
,
AtlasEntity
>
dbEntityMap
=
TestUtilsV2
.
createDBEntity
();
entitiesREST
.
createOrUpdate
(
dbEntityMap
);
AtlasEntity
dbEntity
=
dbEntityMap
.
values
().
iterator
().
next
();
EntityMutationResponse
response
=
entitiesREST
.
createOrUpdate
(
dbEntityMap
);
String
dbGuid
=
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE
).
get
(
0
).
getGuid
();
Assert
.
assertTrue
(
AtlasEntity
.
isAssigned
(
dbGuid
));
final
String
prevDBName
=
(
String
)
dbEntity
.
getAttribute
(
TestUtilsV2
.
NAME
);
final
String
prevDBName
=
(
String
)
dbEntity
.
getAttribute
(
TestUtilsV2
.
NAME
);
final
String
updatedDBName
=
"updatedDBName
"
;
final
String
updatedDBName
=
prevDBName
+
":updated
"
;
dbEntity
.
setAttribute
(
TestUtilsV2
.
NAME
,
updatedDBName
);
dbEntity
.
setAttribute
(
TestUtilsV2
.
NAME
,
updatedDBName
);
final
EntityMutationResponse
response
=
entityREST
.
partialUpdateByUniqueAttribute
(
TestUtilsV2
.
DATABASE_TYPE
,
TestUtilsV2
.
NAME
,
prevDBName
,
dbEntity
);
response
=
entityREST
.
partialUpdateByUniqueAttribute
(
TestUtilsV2
.
DATABASE_TYPE
,
TestUtilsV2
.
NAME
,
prevDBName
,
dbEntity
);
String
dbGuid
=
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
UPDATE
).
get
(
0
).
getGuid
();
Assert
.
assertEquals
(
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
UPDATE
).
get
(
0
).
getGuid
(),
dbGuid
);
Assert
.
assertTrue
(
AtlasEntity
.
isAssigned
(
dbGuid
));
//Get By unique attribute
//Get By unique attribute
List
<
AtlasEntity
>
entities
=
entityREST
.
getByUniqueAttribute
(
TestUtilsV2
.
DATABASE_TYPE
,
TestUtilsV2
.
NAME
,
updatedDBName
);
List
<
AtlasEntity
>
entities
=
entityREST
.
getByUniqueAttribute
(
TestUtilsV2
.
DATABASE_TYPE
,
TestUtilsV2
.
NAME
,
updatedDBName
);
...
...
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