atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject atlas git commit: ATLAS-2014: populate createdBy, updatedBy fields on type create and update
Date Wed, 02 Aug 2017 06:42:02 GMT
Repository: atlas
Updated Branches:
  refs/heads/master eb82ef9b7 -> 52489d600


ATLAS-2014: populate createdBy, updatedBy fields on type create and update


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

Branch: refs/heads/master
Commit: 52489d6003ac8c227e048d808175024dc9fe6724
Parents: eb82ef9
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Tue Aug 1 15:47:34 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Tue Aug 1 23:41:49 2017 -0700

----------------------------------------------------------------------
 .../test/java/org/apache/atlas/TestUtilsV2.java | 88 +++++++++++++++++---
 .../store/graph/AtlasTypeDefGraphStore.java     |  6 ++
 .../graph/v1/AtlasTypeDefGraphStoreV1.java      | 22 +++++
 .../repository/impexp/ExportServiceTest.java    |  8 ++
 .../repository/impexp/ImportServiceTest.java    |  8 ++
 .../impexp/ZipFileResourceTestUtils.java        |  2 +
 .../store/graph/AtlasTypeDefGraphStoreTest.java |  8 ++
 .../graph/v1/AtlasDeleteHandlerV1Test.java      | 14 ++--
 .../store/graph/v1/AtlasEntityStoreV1Test.java  |  4 +
 .../graph/v1/AtlasRelationshipStoreV1Test.java  |  2 +
 .../graph/v1/InverseReferenceUpdateV1Test.java  |  4 +
 11 files changed, 151 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/intg/src/test/java/org/apache/atlas/TestUtilsV2.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java
index 14614f1..fc65af0 100755
--- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java
+++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 3638e19..7a0bbca 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -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()),

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
index 6037d43..50a4216 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
@@ -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;
+    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
index b835d22..8eb7a51 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
@@ -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);;

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
index 7210799..b96197b 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
@@ -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");

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
b/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
index 82692cf..3ccbd8e 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
index 485ec20..8638a7f 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
@@ -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 {

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
index 62ef21c..718538a 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
index 2ac0fc6..62fad5b 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
@@ -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

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
index 263ad5b..77a591a 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1Test.java
@@ -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

http://git-wip-us.apache.org/repos/asf/atlas/blob/52489d60/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
index e2a8010..6475639 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java
@@ -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


Mime
View raw message