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
52489d60
Commit
52489d60
authored
7 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2014: populate createdBy, updatedBy fields on type create and update
parent
eb82ef9b
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
151 additions
and
15 deletions
+151
-15
TestUtilsV2.java
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
+78
-10
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+6
-0
AtlasTypeDefGraphStoreV1.java
...s/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+22
-0
ExportServiceTest.java
...org/apache/atlas/repository/impexp/ExportServiceTest.java
+8
-0
ImportServiceTest.java
...org/apache/atlas/repository/impexp/ImportServiceTest.java
+8
-0
ZipFileResourceTestUtils.java
...che/atlas/repository/impexp/ZipFileResourceTestUtils.java
+2
-0
AtlasTypeDefGraphStoreTest.java
...as/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+8
-0
AtlasDeleteHandlerV1Test.java
...s/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
+9
-5
AtlasEntityStoreV1Test.java
...las/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+4
-0
AtlasRelationshipStoreV1Test.java
...pository/store/graph/v1/AtlasRelationshipStoreV1Test.java
+2
-0
InverseReferenceUpdateV1Test.java
...pository/store/graph/v1/InverseReferenceUpdateV1Test.java
+4
-0
No files found.
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
View file @
52489d60
...
...
@@ -30,12 +30,14 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef
;
import
org.apache.atlas.model.typedef.AtlasRelationshipDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.RandomStringUtils
;
import
java.math.BigDecimal
;
...
...
@@ -59,6 +61,8 @@ public final class TestUtilsV2 {
public
static
final
long
TEST_DATE_IN_LONG
=
1418265358440L
;
public
static
final
String
TEST_USER
=
"testUser"
;
private
static
AtomicInteger
seq
=
new
AtomicInteger
();
private
TestUtilsV2
()
{
...
...
@@ -147,9 +151,13 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createTraitTypeDef
(
"SecurityClearance"
,
"SecurityClearance"
+
_description
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"level"
,
"int"
));
return
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
ImmutableList
.
of
(
addressDetails
),
AtlasTypesDef
ret
=
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
ImmutableList
.
of
(
addressDetails
),
ImmutableList
.
of
(
securityClearanceTypeDef
),
ImmutableList
.
of
(
deptTypeDef
,
personTypeDef
,
employeeTypeDef
,
managerTypeDef
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
AtlasTypesDef
defineInverseReferenceTestTypes
()
{
...
...
@@ -175,7 +183,11 @@ public final class TestUtilsV2 {
AtlasConstraintDef
.
CONSTRAINT_TYPE_INVERSE_REF
,
Collections
.<
String
,
Object
>
singletonMap
(
AtlasConstraintDef
.
CONSTRAINT_PARAM_ATTRIBUTE
,
"manyB"
)))),
new
AtlasAttributeDef
(
"mappedFromA"
,
"A"
,
true
,
Cardinality
.
SINGLE
,
0
,
1
,
false
,
false
,
Collections
.<
AtlasConstraintDef
>
emptyList
()));
return
new
AtlasTypesDef
(
ImmutableList
.<
AtlasEnumDef
>
of
(),
ImmutableList
.<
AtlasStructDef
>
of
(),
ImmutableList
.<
AtlasClassificationDef
>
of
(),
ImmutableList
.<
AtlasEntityDef
>
of
(
aDef
,
bDef
));
AtlasTypesDef
ret
=
new
AtlasTypesDef
(
ImmutableList
.<
AtlasEnumDef
>
of
(),
ImmutableList
.<
AtlasStructDef
>
of
(),
ImmutableList
.<
AtlasClassificationDef
>
of
(),
ImmutableList
.<
AtlasEntityDef
>
of
(
aDef
,
bDef
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
AtlasTypesDef
defineValidUpdatedDeptEmployeeTypes
()
{
...
...
@@ -255,10 +267,14 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createTraitTypeDef
(
"SecurityClearance"
,
"SecurityClearance"
+
_description
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"level"
,
"int"
));
return
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
AtlasTypesDef
ret
=
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
ImmutableList
.
of
(
addressDetails
),
ImmutableList
.
of
(
securityClearanceTypeDef
),
ImmutableList
.
of
(
deptTypeDef
,
personTypeDef
,
employeeTypeDef
,
managerTypeDef
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
AtlasTypesDef
defineInvalidUpdatedDeptEmployeeTypes
()
{
...
...
@@ -322,10 +338,14 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createOptionalAttrDef
(
"approximationOfPi"
,
"bigdecimal"
)
);
return
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
AtlasTypesDef
ret
=
new
AtlasTypesDef
(
ImmutableList
.
of
(
orgLevelEnum
),
ImmutableList
.
of
(
addressDetails
),
ImmutableList
.<
AtlasClassificationDef
>
of
(),
ImmutableList
.
of
(
deptTypeDef
,
personTypeDef
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
final
String
DEPARTMENT_TYPE
=
"Department"
;
...
...
@@ -541,8 +561,12 @@ public final class TestUtilsV2 {
AtlasEnumDef
enumTypeDefinition
=
new
AtlasEnumDef
(
"e_type"
,
"enumType"
,
"1.0"
,
Arrays
.
asList
(
new
AtlasEnumElementDef
(
"ONE"
,
"Element Description"
,
1
)));
return
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
ImmutableList
.
of
(
structTypeDefinition
),
AtlasTypesDef
ret
=
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
ImmutableList
.
of
(
structTypeDefinition
),
ImmutableList
.
of
(
traitTypeDefinition
),
ImmutableList
.
of
(
superTypeDefinition
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
AtlasTypesDef
simpleTypeUpdated
(){
...
...
@@ -562,8 +586,12 @@ public final class TestUtilsV2 {
AtlasEnumDef
enumTypeDefinition
=
new
AtlasEnumDef
(
"e_type"
,
"enumType"
,
Arrays
.
asList
(
new
AtlasEnumElementDef
(
"ONE"
,
"Element Description"
,
1
)));
return
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
ImmutableList
.
of
(
structTypeDefinition
),
AtlasTypesDef
ret
=
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
ImmutableList
.
of
(
structTypeDefinition
),
ImmutableList
.
of
(
traitTypeDefinition
),
ImmutableList
.
of
(
superTypeDefinition
,
newSuperTypeDefinition
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
AtlasTypesDef
simpleTypeUpdatedDiff
()
{
...
...
@@ -571,10 +599,14 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createClassTypeDef
(
"new_h_type"
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createOptionalAttrDef
(
"attr"
,
"string"
));
return
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.<
AtlasEnumDef
>
of
(),
AtlasTypesDef
ret
=
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.<
AtlasEnumDef
>
of
(),
ImmutableList
.<
AtlasStructDef
>
of
(),
ImmutableList
.<
AtlasClassificationDef
>
of
(),
ImmutableList
.
of
(
newSuperTypeDefinition
));
populateSystemAttributes
(
ret
);
return
ret
;
}
...
...
@@ -793,11 +825,15 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createRequiredAttrDef
(
"booleanAttr"
,
"boolean"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"integerAttr"
,
"int"
));
return
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
AtlasTypesDef
ret
=
AtlasTypeUtil
.
getTypesDef
(
ImmutableList
.
of
(
enumTypeDefinition
),
ImmutableList
.
of
(
structTypeDefinition
,
partitionDefinition
),
ImmutableList
.
of
(
classificationTypeDefinition
,
fetlClassificationTypeDefinition
,
piiTypeDefinition
,
phiTypeDefinition
),
ImmutableList
.
of
(
superTypeDefinition
,
databaseTypeDefinition
,
columnsDefinition
,
tableTypeDefinition
,
storageDescClsDef
,
partClsDef
,
processClsType
));
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
final
String
randomString
()
{
...
...
@@ -926,6 +962,8 @@ public final class TestUtilsV2 {
newtestEntityDef
.
addAttribute
(
attrDiskUsage
);
newtestEntityDef
.
addAttribute
(
attrisStoreUse
);
populateSystemAttributes
(
newtestEntityDef
);
return
newtestEntityDef
;
}
...
...
@@ -959,8 +997,13 @@ public final class TestUtilsV2 {
AtlasTypeUtil
.
createTraitTypeDef
(
"JanitorClearance"
,
"JanitorClearance_description"
,
ImmutableSet
.
of
(
"SecurityClearance1"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"level"
,
"int"
));
return
Arrays
.
asList
(
securityClearanceTypeDef
,
janitorSecurityClearanceTypeDef
);
List
<
AtlasClassificationDef
>
ret
=
Arrays
.
asList
(
securityClearanceTypeDef
,
janitorSecurityClearanceTypeDef
);
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
List
<
AtlasClassificationDef
>
getClassificationWithValidAttribute
(){
return
getClassificationWithValidSuperType
();
}
...
...
@@ -971,7 +1014,11 @@ public final class TestUtilsV2 {
1
,
10
,
false
,
false
,
Collections
.<
AtlasConstraintDef
>
emptyList
()));
return
Arrays
.
asList
(
developerTypeDef
);
List
<
AtlasEntityDef
>
ret
=
Arrays
.
asList
(
developerTypeDef
);
populateSystemAttributes
(
ret
);
return
ret
;
}
public
static
List
<
AtlasEntityDef
>
getEntityWithValidAttribute
()
{
...
...
@@ -991,4 +1038,25 @@ public final class TestUtilsV2 {
entityDef
.
addSuperType
(
"!@#$%"
);
return
entityDef
;
}
public
static
void
populateSystemAttributes
(
AtlasTypesDef
typesDef
)
{
populateSystemAttributes
(
typesDef
.
getEnumDefs
());
populateSystemAttributes
(
typesDef
.
getStructDefs
());
populateSystemAttributes
(
typesDef
.
getClassificationDefs
());
populateSystemAttributes
(
typesDef
.
getEntityDefs
());
populateSystemAttributes
(
typesDef
.
getRelationshipDefs
());
}
public
static
void
populateSystemAttributes
(
List
<?
extends
AtlasBaseTypeDef
>
typeDefs
)
{
if
(
CollectionUtils
.
isNotEmpty
(
typeDefs
))
{
for
(
AtlasBaseTypeDef
typeDef
:
typeDefs
)
{
populateSystemAttributes
(
typeDef
);
}
}
}
public
static
void
populateSystemAttributes
(
AtlasBaseTypeDef
typeDef
)
{
typeDef
.
setCreatedBy
(
TestUtilsV2
.
TEST_USER
);
typeDef
.
setUpdatedBy
(
TestUtilsV2
.
TEST_USER
);
}
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
52489d60
...
...
@@ -320,6 +320,12 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
AtlasTypesDef
ret
=
addToGraphStore
(
typesDef
,
ttr
);
try
{
ttr
.
updateTypes
(
ret
);
}
catch
(
AtlasBaseException
e
)
{
// this shouldn't happen, as the types were already validated
LOG
.
error
(
"failed to update the registry after updating the store"
,
e
);
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships={})"
,
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
View file @
52489d60
...
...
@@ -31,6 +31,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.UUID
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
...
...
@@ -205,7 +206,9 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
StringUtils
.
isNotBlank
(
typeDef
.
getDescription
())
?
typeDef
.
getDescription
()
:
typeDef
.
getName
());
ret
.
setProperty
(
Constants
.
TYPEVERSION_PROPERTY_KEY
,
typeDef
.
getTypeVersion
());
ret
.
setProperty
(
Constants
.
GUID_PROPERTY_KEY
,
typeDef
.
getGuid
());
ret
.
setProperty
(
Constants
.
CREATED_BY_KEY
,
getCurrentUser
());
ret
.
setProperty
(
Constants
.
TIMESTAMP_PROPERTY_KEY
,
typeDef
.
getCreateTime
().
getTime
());
ret
.
setProperty
(
Constants
.
MODIFIED_BY_KEY
,
getCurrentUser
());
ret
.
setProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
typeDef
.
getUpdateTime
().
getTime
());
ret
.
setProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
typeDef
.
getVersion
());
ret
.
setProperty
(
Constants
.
TYPEOPTIONS_PROPERTY_KEY
,
AtlasType
.
toJson
(
typeDef
.
getOptions
()));
...
...
@@ -284,6 +287,8 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
String
description
=
vertex
.
getProperty
(
Constants
.
TYPEDESCRIPTION_PROPERTY_KEY
,
String
.
class
);
String
typeVersion
=
vertex
.
getProperty
(
Constants
.
TYPEVERSION_PROPERTY_KEY
,
String
.
class
);
String
guid
=
vertex
.
getProperty
(
Constants
.
GUID_PROPERTY_KEY
,
String
.
class
);
String
createdBy
=
vertex
.
getProperty
(
Constants
.
CREATED_BY_KEY
,
String
.
class
);
String
updatedBy
=
vertex
.
getProperty
(
Constants
.
MODIFIED_BY_KEY
,
String
.
class
);
Long
createTime
=
vertex
.
getProperty
(
Constants
.
TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
Long
updateTime
=
vertex
.
getProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
Long
version
=
vertex
.
getProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
Long
.
class
);
...
...
@@ -293,6 +298,8 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
typeDef
.
setDescription
(
description
);
typeDef
.
setTypeVersion
(
typeVersion
);
typeDef
.
setGuid
(
guid
);
typeDef
.
setCreatedBy
(
createdBy
);
typeDef
.
setUpdatedBy
(
updatedBy
);
if
(
createTime
!=
null
)
{
typeDef
.
setCreateTime
(
new
Date
(
createTime
));
...
...
@@ -456,7 +463,22 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
Number
currVersion
=
vertex
.
getProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
Number
.
class
);
long
newVersion
=
currVersion
==
null
?
1
:
(
currVersion
.
longValue
()
+
1
);
vertex
.
setProperty
(
Constants
.
MODIFIED_BY_KEY
,
getCurrentUser
());
vertex
.
setProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
now
.
getTime
());
vertex
.
setProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
newVersion
);
}
private
String
getCurrentUser
()
{
String
ret
=
RequestContextV1
.
get
().
getUser
();
if
(
StringUtils
.
isBlank
(
ret
))
{
ret
=
System
.
getProperty
(
"user.name"
);
if
(
StringUtils
.
isBlank
(
ret
))
{
ret
=
"atlas"
;
}
}
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
View file @
52489d60
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
repository
.
impexp
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.exception.AtlasBaseException
;
...
...
@@ -42,6 +43,7 @@ import org.slf4j.LoggerFactory;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeTest
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
scala.actors.threadpool.Arrays
;
...
...
@@ -79,6 +81,12 @@ public class ExportServiceTest {
private
AtlasEntityChangeNotifier
mockChangeNotifier
=
mock
(
AtlasEntityChangeNotifier
.
class
);
private
AtlasEntityStoreV1
entityStore
;
@BeforeTest
public
void
setupTest
()
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@BeforeClass
public
void
setupSampleData
()
throws
AtlasBaseException
{
entityStore
=
new
AtlasEntityStoreV1
(
deleteHandler
,
typeRegistry
,
mockChangeNotifier
,
graphMapper
);;
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
View file @
52489d60
...
...
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.impexp;
import
com.google.inject.Inject
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
...
...
@@ -28,6 +29,7 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.ITestContext
;
import
org.testng.annotations.BeforeTest
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
...
...
@@ -53,6 +55,12 @@ public class ImportServiceTest {
@Inject
private
AtlasEntityStore
entityStore
;
@BeforeTest
public
void
setupTest
()
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@DataProvider
(
name
=
"sales"
)
public
static
Object
[][]
getDataFromQuickStart_v1_Sales
(
ITestContext
context
)
throws
IOException
{
return
getZipSource
(
"sales-v1-full.zip"
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
View file @
52489d60
...
...
@@ -19,6 +19,7 @@ package org.apache.atlas.repository.impexp;
import
com.google.common.collect.Sets
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.impexp.AtlasExportResult
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
...
...
@@ -151,6 +152,7 @@ public class ZipFileResourceTestUtils {
List
<
String
>
creationOrder
=
zipSource
.
getCreationOrder
();
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
AtlasImportRequest
request
=
getDefaultImportRequest
();
AtlasImportResult
result
=
runImportWithParameters
(
importService
,
request
,
zipSource
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
View file @
52489d60
...
...
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.store.graph;
import
com.google.inject.Inject
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
...
...
@@ -33,6 +34,7 @@ import org.apache.atlas.type.AtlasType;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeTest
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
...
...
@@ -52,6 +54,12 @@ public class AtlasTypeDefGraphStoreTest {
private
AtlasTypeDefStore
typeDefStore
;
@BeforeTest
public
void
setupTest
()
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@Test
(
priority
=
1
)
public
void
testGet
()
{
try
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
View file @
52489d60
...
...
@@ -101,6 +101,9 @@ public abstract class AtlasDeleteHandlerV1Test {
@BeforeClass
public
void
setUp
()
throws
Exception
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
metadataService
=
TestUtils
.
addSessionCleanupWrapper
(
metadataService
);
final
AtlasTypesDef
deptTypesDef
=
TestUtilsV2
.
defineDeptEmployeeTypes
();
typeDefStore
.
createTypesDef
(
deptTypesDef
);
...
...
@@ -143,7 +146,7 @@ public abstract class AtlasDeleteHandlerV1Test {
@BeforeTest
public
void
init
()
throws
Exception
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@AfterClass
...
...
@@ -335,7 +338,6 @@ public abstract class AtlasDeleteHandlerV1Test {
AtlasEntity
.
AtlasEntitiesWithExtInfo
hrDept
=
TestUtilsV2
.
createDeptEg2
();
init
();
RequestContextV1
.
clear
();
final
EntityMutationResponse
hrDeptCreationResponse
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
hrDept
),
false
);
final
AtlasEntityHeader
deptCreated
=
hrDeptCreationResponse
.
getFirstUpdatedEntityByTypeName
(
DEPARTMENT_TYPE
);
final
AtlasEntityHeader
maxEmployeeCreated
=
hrDeptCreationResponse
.
getCreatedEntityByTypeNameAndAttribute
(
TestUtilsV2
.
EMPLOYEE_TYPE
,
NAME
,
"Max"
);
...
...
@@ -893,7 +895,7 @@ public abstract class AtlasDeleteHandlerV1Test {
object
=
mapOwnerVertex
.
getProperty
(
atlasEdgeLabel
.
getQualifiedMapKey
(),
Object
.
class
);
Assert
.
assertNotNull
(
object
);
RequestContextV1
.
clear
();
init
();
List
<
AtlasEntityHeader
>
deletedEntities
=
entityStore
.
deleteById
(
mapOwnerGuid
).
getDeletedEntities
();
Assert
.
assertEquals
(
deletedEntities
.
size
(),
2
);
Assert
.
assertTrue
(
extractGuids
(
deletedEntities
).
contains
(
mapOwnerGuid
));
...
...
@@ -927,6 +929,8 @@ public abstract class AtlasDeleteHandlerV1Test {
ImmutableList
.<
AtlasClassificationDef
>
of
(),
ImmutableList
.<
AtlasEntityDef
>
of
(
mapValueDef
,
mapOwnerDef
));
TestUtilsV2
.
populateSystemAttributes
(
typesDef
);
typeDefStore
.
createTypesDef
(
typesDef
);
AtlasEntityType
mapOwnerType
=
typeRegistry
.
getEntityTypeByName
(
"RequiredMapOwner"
);
...
...
@@ -1033,7 +1037,7 @@ public abstract class AtlasDeleteHandlerV1Test {
String
mapValueGuid
=
mapValueInstance
.
getId
().
_getId
();
// Create instance of MapValueReferencerContainer
RequestContextV1
.
clear
();
init
();
AtlasEntity
mapValueReferencer
=
new
AtlasEntity
(
mapValueDef
.
getName
());
mapValueReferencer
.
setAttribute
(
"refToMapValue"
,
new
AtlasObjectId
(
mapValueInstance
.
getId
().
_getId
(),
mapValueInstance
.
getTypeName
()));
AtlasEntity
.
AtlasEntitiesWithExtInfo
entities
=
new
AtlasEntity
.
AtlasEntitiesWithExtInfo
();
...
...
@@ -1051,7 +1055,7 @@ public abstract class AtlasDeleteHandlerV1Test {
mapValueReferenceContainer
.
setAttribute
(
"requiredMap"
,
Collections
.
singletonMap
(
"value1"
,
AtlasTypeUtil
.
getAtlasObjectId
(
mapValueReferencer
)));
RequestContextV1
.
clear
();
init
();
EntityMutationResponse
updateEntitiesResult
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entities
),
false
);
String
mapValueReferencerContainerGuid
=
updateEntitiesResult
.
getCreatedEntitiesByTypeName
(
"MapValueReferencerContainer"
).
get
(
0
).
getGuid
();
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
View file @
52489d60
...
...
@@ -114,6 +114,9 @@ public class AtlasEntityStoreV1Test {
@BeforeClass
public
void
setUp
()
throws
Exception
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
metadataService
=
TestUtils
.
addSessionCleanupWrapper
(
metadataService
);
new
GraphBackedSearchIndexer
(
typeRegistry
);
...
...
@@ -151,6 +154,7 @@ public class AtlasEntityStoreV1Test {
public
void
init
()
throws
Exception
{
entityStore
=
new
AtlasEntityStoreV1
(
deleteHandler
,
typeRegistry
,
mockChangeNotifier
,
graphMapper
);
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@Test
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
View file @
52489d60
...
...
@@ -20,6 +20,7 @@ package org.apache.atlas.repository.store.graph.v1;
import
com.google.common.collect.ImmutableList
;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo
;
...
...
@@ -113,6 +114,7 @@ public abstract class AtlasRelationshipStoreV1Test {
relationshipStore
=
new
AtlasRelationshipStoreV1
(
typeRegistry
);
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@AfterClass
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
View file @
52489d60
...
...
@@ -76,6 +76,9 @@ public abstract class InverseReferenceUpdateV1Test {
@BeforeClass
public
void
setUp
()
throws
Exception
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
metadataService
=
TestUtils
.
addSessionCleanupWrapper
(
metadataService
);
AtlasTypesDef
[]
testTypesDefs
=
new
AtlasTypesDef
[]
{
TestUtilsV2
.
defineDeptEmployeeTypes
(),
...
...
@@ -106,6 +109,7 @@ public abstract class InverseReferenceUpdateV1Test {
@BeforeMethod
public
void
init
()
throws
Exception
{
RequestContextV1
.
clear
();
RequestContextV1
.
get
().
setUser
(
TestUtilsV2
.
TEST_USER
);
}
@Test
...
...
This diff is collapsed.
Click to expand it.
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