You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/11/12 18:14:11 UTC
[02/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related
implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
index e753881..98df12b 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
@@ -18,7 +18,6 @@
package org.apache.atlas.web.adapters;
import org.apache.atlas.AtlasClient;
-import org.apache.atlas.RequestContext;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2;
@@ -99,7 +98,6 @@ public class TestEntitiesREST {
@AfterMethod
public void cleanup() throws Exception {
- RequestContext.clear();
RequestContextV1.clear();
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
index b90ea64..ea6fe31 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java
@@ -18,7 +18,6 @@
package org.apache.atlas.web.adapters;
import org.apache.atlas.TestModules;
-import org.apache.atlas.RequestContext;
import org.apache.atlas.RequestContextV1;
import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.model.instance.AtlasClassification;
@@ -77,7 +76,6 @@ public class TestEntityREST {
@AfterMethod
public void cleanup() throws Exception {
- RequestContext.clear();
RequestContextV1.clear();
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java
index 5628b17..a3f5601 100644
--- a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java
+++ b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.atlas.web.filters;
-import org.apache.atlas.RequestContext;
+import org.apache.atlas.RequestContextV1;
import org.apache.atlas.web.security.BaseSecurityTest;
import org.apache.atlas.web.service.EmbeddedServer;
import org.apache.commons.configuration.PropertiesConfiguration;
@@ -111,7 +111,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest {
connection.connect();
assertEquals(connection.getResponseCode(), 200);
- assertEquals(RequestContext.get().getUser(), TESTUSER);
+ assertEquals(RequestContextV1.get().getUser(), TESTUSER);
return null;
}
});
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
index 512750f..ab27612 100755
--- a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
@@ -19,8 +19,6 @@
package org.apache.atlas.web.integration;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasClientV2;
@@ -32,26 +30,21 @@ import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
-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.AtlasStructDef;
+import org.apache.atlas.model.typedef.*;
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.v1.model.instance.Id;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.instance.Struct;
+import org.apache.atlas.v1.model.typedef.*;
+import org.apache.atlas.v1.model.typedef.EnumTypeDefinition.EnumValue;
import org.apache.atlas.notification.NotificationConsumer;
import org.apache.atlas.kafka.*;
-import org.apache.atlas.notification.entity.EntityNotification;
-import org.apache.atlas.notification.hook.HookNotification;
+import org.apache.atlas.v1.model.notification.EntityNotificationV1;
+import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeUtil;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.json.TypesSerialization;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.*;
-import org.apache.atlas.typesystem.types.utils.TypesUtil;
+import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker;
import org.apache.commons.configuration.Configuration;
@@ -80,31 +73,30 @@ import static org.testng.Assert.assertTrue;
* Sets up the web resource and has helper methods to created type and entity.
*/
public abstract class BaseResourceIT {
+ public static final Logger LOG = LoggerFactory.getLogger(BaseResourceIT.class);
public static final String ATLAS_REST_ADDRESS = "atlas.rest.address";
- public static final String NAME = "name";
- public static final String QUALIFIED_NAME = "qualifiedName";
- public static final String CLUSTER_NAME = "clusterName";
- public static final String DESCRIPTION = "description";
- public static final String PII_TAG = "pii_Tag";
- public static final String PHI_TAG = "phi_Tag";
- public static final String PCI_TAG = "pci_Tag";
- public static final String SOX_TAG = "sox_Tag";
- public static final String SEC_TAG = "sec_Tag";
- public static final String FINANCE_TAG = "finance_Tag";
- public static final String CLASSIFICATION = "classification";
+ public static final String NAME = "name";
+ public static final String QUALIFIED_NAME = "qualifiedName";
+ public static final String CLUSTER_NAME = "clusterName";
+ public static final String DESCRIPTION = "description";
+ public static final String PII_TAG = "pii_Tag";
+ public static final String PHI_TAG = "phi_Tag";
+ public static final String PCI_TAG = "pci_Tag";
+ public static final String SOX_TAG = "sox_Tag";
+ public static final String SEC_TAG = "sec_Tag";
+ public static final String FINANCE_TAG = "finance_Tag";
+ public static final String CLASSIFICATION = "classification";
+
+ protected static final int MAX_WAIT_TIME = 60000;
// All service clients
- protected AtlasClient atlasClientV1;
+ protected AtlasClient atlasClientV1;
protected AtlasClientV2 atlasClientV2;
-
- public static final Logger LOG = LoggerFactory.getLogger(BaseResourceIT.class);
- protected static final int MAX_WAIT_TIME = 60000;
- protected String[] atlasUrls;
+ protected String[] atlasUrls;
@BeforeClass
public void setUp() throws Exception {
-
//set high timeouts so that tests do not fail due to read timeouts while you
//are stepping through the code in a debugger
ApplicationProperties.get().setProperty("atlas.client.readTimeoutMSecs", "100000000");
@@ -112,6 +104,7 @@ public abstract class BaseResourceIT {
Configuration configuration = ApplicationProperties.get();
+
atlasUrls = configuration.getStringArray(ATLAS_REST_ADDRESS);
if (atlasUrls == null || atlasUrls.length == 0) {
@@ -129,6 +122,7 @@ public abstract class BaseResourceIT {
protected void batchCreateTypes(AtlasTypesDef typesDef) throws AtlasServiceException {
AtlasTypesDef toCreate = new AtlasTypesDef();
+
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
if (atlasClientV2.typeWithNameExists(enumDef.getName())) {
LOG.warn("Type with name {} already exists. Skipping", enumDef.getName());
@@ -170,103 +164,107 @@ public abstract class BaseResourceIT {
}
protected List<String> createType(TypesDef typesDef) throws Exception {
- List<EnumTypeDefinition> enumTypes = new ArrayList<>();
+ List<EnumTypeDefinition> enumTypes = new ArrayList<>();
List<StructTypeDefinition> structTypes = new ArrayList<>();
- List<HierarchicalTypeDefinition<TraitType>> traitTypes = new ArrayList<>();
- List<HierarchicalTypeDefinition<ClassType>> classTypes = new ArrayList<>();
+ List<TraitTypeDefinition> traitTypes = new ArrayList<>();
+ List<ClassTypeDefinition> classTypes = new ArrayList<>();
- for (EnumTypeDefinition enumTypeDefinition : typesDef.enumTypesAsJavaList()) {
- if (atlasClientV2.typeWithNameExists(enumTypeDefinition.name)) {
- LOG.warn("Type with name {} already exists. Skipping", enumTypeDefinition.name);
+ for (EnumTypeDefinition enumTypeDefinition : typesDef.getEnumTypes()) {
+ if (atlasClientV2.typeWithNameExists(enumTypeDefinition.getName())) {
+ LOG.warn("Type with name {} already exists. Skipping", enumTypeDefinition.getName());
} else {
enumTypes.add(enumTypeDefinition);
}
}
- for (StructTypeDefinition structTypeDefinition : typesDef.structTypesAsJavaList()) {
- if (atlasClientV2.typeWithNameExists(structTypeDefinition.typeName)) {
- LOG.warn("Type with name {} already exists. Skipping", structTypeDefinition.typeName);
+
+ for (StructTypeDefinition structTypeDefinition : typesDef.getStructTypes()) {
+ if (atlasClientV2.typeWithNameExists(structTypeDefinition.getTypeName())) {
+ LOG.warn("Type with name {} already exists. Skipping", structTypeDefinition.getTypeName());
} else {
structTypes.add(structTypeDefinition);
}
}
- for (HierarchicalTypeDefinition<TraitType> hierarchicalTypeDefinition : typesDef.traitTypesAsJavaList()) {
- if (atlasClientV2.typeWithNameExists(hierarchicalTypeDefinition.typeName)) {
- LOG.warn("Type with name {} already exists. Skipping", hierarchicalTypeDefinition.typeName);
+
+ for (TraitTypeDefinition hierarchicalTypeDefinition : typesDef.getTraitTypes()) {
+ if (atlasClientV2.typeWithNameExists(hierarchicalTypeDefinition.getTypeName())) {
+ LOG.warn("Type with name {} already exists. Skipping", hierarchicalTypeDefinition.getTypeName());
} else {
traitTypes.add(hierarchicalTypeDefinition);
}
}
- for (HierarchicalTypeDefinition<ClassType> hierarchicalTypeDefinition : typesDef.classTypesAsJavaList()) {
- if (atlasClientV2.typeWithNameExists(hierarchicalTypeDefinition.typeName)) {
- LOG.warn("Type with name {} already exists. Skipping", hierarchicalTypeDefinition.typeName);
+
+ for (ClassTypeDefinition hierarchicalTypeDefinition : typesDef.getClassTypes()) {
+ if (atlasClientV2.typeWithNameExists(hierarchicalTypeDefinition.getTypeName())) {
+ LOG.warn("Type with name {} already exists. Skipping", hierarchicalTypeDefinition.getTypeName());
} else {
classTypes.add(hierarchicalTypeDefinition);
}
}
- TypesDef toCreate = TypesUtil.getTypesDef(ImmutableList.copyOf(enumTypes),
- ImmutableList.copyOf(structTypes),
- ImmutableList.copyOf(traitTypes),
- ImmutableList.copyOf(classTypes));
+ TypesDef toCreate = new TypesDef(enumTypes, structTypes, traitTypes, classTypes);
+
return atlasClientV1.createType(toCreate);
}
protected List<String> createType(String typesAsJSON) throws Exception {
- return createType(TypesSerialization.fromJson(typesAsJSON));
+ return createType(AtlasType.fromV1Json(typesAsJSON, TypesDef.class));
}
protected Id createInstance(Referenceable referenceable) throws Exception {
String typeName = referenceable.getTypeName();
+
System.out.println("creating instance of type " + typeName);
List<String> guids = atlasClientV1.createEntity(referenceable);
+
System.out.println("created instance for type " + typeName + ", guid: " + guids);
// return the reference to created instance with guid
if (guids.size() > 0) {
return new Id(guids.get(guids.size() - 1), 0, referenceable.getTypeName());
}
+
return null;
}
- protected TypesDef getTypesDef(ImmutableList<EnumTypeDefinition> enums,
- ImmutableList<StructTypeDefinition> structs,
- ImmutableList<HierarchicalTypeDefinition<TraitType>> traits,
- ImmutableList<HierarchicalTypeDefinition<ClassType>> classes){
- enums = (enums != null) ? enums : ImmutableList
- .<EnumTypeDefinition>of();
- structs =
- (structs != null) ? structs : ImmutableList.<StructTypeDefinition>of();
-
- traits = (traits != null) ? traits : ImmutableList
- .<HierarchicalTypeDefinition<TraitType>>of();
-
- classes = (classes != null) ? classes : ImmutableList
- .<HierarchicalTypeDefinition<ClassType>>of();
- return TypesUtil.getTypesDef(enums, structs, traits, classes);
+ protected TypesDef getTypesDef(List<EnumTypeDefinition> enums,
+ List<StructTypeDefinition> structs,
+ List<TraitTypeDefinition> traits,
+ List<ClassTypeDefinition> classes){
+ enums = (enums != null) ? enums : Collections.<EnumTypeDefinition>emptyList();
+ structs = (structs != null) ? structs : Collections.<StructTypeDefinition>emptyList();
+ traits = (traits != null) ? traits : Collections.<TraitTypeDefinition>emptyList();
+ classes = (classes != null) ? classes : Collections.<ClassTypeDefinition>emptyList();
+ return new TypesDef(enums, structs, traits, classes);
}
protected AtlasEntityHeader modifyEntity(AtlasEntity atlasEntity, boolean update) {
EntityMutationResponse entity = null;
+
try {
if (!update) {
entity = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(atlasEntity));
+
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size() > 0);
+
return entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0);
} else {
entity = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(atlasEntity));
+
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).size() > 0);
+
return entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).get(0);
}
} catch (AtlasServiceException e) {
LOG.error("Entity {} failed", update ? "update" : "creation", entity);
}
+
return null;
}
@@ -278,101 +276,89 @@ public abstract class BaseResourceIT {
return modifyEntity(atlasEntity, true);
}
- protected static final String DATABASE_TYPE_V2 = "hive_db_v2";
- protected static final String HIVE_TABLE_TYPE_V2 = "hive_table_v2";
- protected static final String COLUMN_TYPE_V2 = "hive_column_v2";
+ protected static final String DATABASE_TYPE_V2 = "hive_db_v2";
+ protected static final String HIVE_TABLE_TYPE_V2 = "hive_table_v2";
+ protected static final String COLUMN_TYPE_V2 = "hive_column_v2";
protected static final String HIVE_PROCESS_TYPE_V2 = "hive_process_v2";
- protected static final String DATABASE_TYPE = "hive_db_v1";
- protected static final String HIVE_TABLE_TYPE = "hive_table_v1";
- protected static final String COLUMN_TYPE = "hive_column_v1";
+ protected static final String DATABASE_TYPE = "hive_db_v1";
+ protected static final String HIVE_TABLE_TYPE = "hive_table_v1";
+ protected static final String COLUMN_TYPE = "hive_column_v1";
protected static final String HIVE_PROCESS_TYPE = "hive_process_v1";
- protected static final String DATABASE_TYPE_BUILTIN = "hive_db";
- protected static final String HIVE_TABLE_TYPE_BUILTIN = "hive_table";
- protected static final String COLUMN_TYPE_BUILTIN = "hive_column";
+ protected static final String DATABASE_TYPE_BUILTIN = "hive_db";
+ protected static final String HIVE_TABLE_TYPE_BUILTIN = "hive_table";
+ protected static final String COLUMN_TYPE_BUILTIN = "hive_column";
protected static final String HIVE_PROCESS_TYPE_BUILTIN = "hive_process";
protected void createTypeDefinitionsV1() throws Exception {
- HierarchicalTypeDefinition<ClassType> dbClsDef = TypesUtil
- .createClassTypeDef(DATABASE_TYPE, null,
- TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef(DESCRIPTION, DataTypes.STRING_TYPE),
- attrDef("locationUri", DataTypes.STRING_TYPE),
- attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.INT_TYPE),
- new AttributeDefinition("tables", DataTypes.arrayTypeName(HIVE_TABLE_TYPE),
+ ClassTypeDefinition dbClsDef = TypesUtil
+ .createClassTypeDef(DATABASE_TYPE, null, null,
+ TypesUtil.createUniqueRequiredAttrDef(NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef(DESCRIPTION, AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ attrDef("locationUri", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ attrDef("owner", AtlasBaseTypeDef.ATLAS_TYPE_STRING), attrDef("createTime", AtlasBaseTypeDef.ATLAS_TYPE_INT),
+ new AttributeDefinition("tables", AtlasBaseTypeDef.getArrayTypeName(HIVE_TABLE_TYPE),
Multiplicity.OPTIONAL, false, "db")
);
- HierarchicalTypeDefinition<ClassType> columnClsDef = TypesUtil
- .createClassTypeDef(COLUMN_TYPE, null, attrDef(NAME, DataTypes.STRING_TYPE),
- attrDef("dataType", DataTypes.STRING_TYPE), attrDef("comment", DataTypes.STRING_TYPE));
+ ClassTypeDefinition columnClsDef = TypesUtil
+ .createClassTypeDef(COLUMN_TYPE, null, null, attrDef(NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ attrDef("dataType", AtlasBaseTypeDef.ATLAS_TYPE_STRING), attrDef("comment", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
- StructTypeDefinition structTypeDefinition = new StructTypeDefinition("serdeType",
- new AttributeDefinition[]{TypesUtil.createRequiredAttrDef(NAME, DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)});
+ StructTypeDefinition structTypeDefinition = new StructTypeDefinition("serdeType", null,
+ Arrays.asList(new AttributeDefinition[]{TypesUtil.createRequiredAttrDef(NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef("serde", AtlasBaseTypeDef.ATLAS_TYPE_STRING)}));
EnumValue values[] = {new EnumValue("MANAGED", 1), new EnumValue("EXTERNAL", 2),};
- EnumTypeDefinition enumTypeDefinition = new EnumTypeDefinition("tableType", values);
+ EnumTypeDefinition enumTypeDefinition = new EnumTypeDefinition("tableType", null, null, Arrays.asList(values));
- HierarchicalTypeDefinition<ClassType> tblClsDef = TypesUtil
- .createClassTypeDef(HIVE_TABLE_TYPE, ImmutableSet.of("DataSet"),
- attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE),
- attrDef("lastAccessTime", DataTypes.DATE_TYPE),
- attrDef("temporary", DataTypes.BOOLEAN_TYPE),
+ ClassTypeDefinition tblClsDef = TypesUtil
+ .createClassTypeDef(HIVE_TABLE_TYPE, null, Collections.singleton("DataSet"),
+ attrDef("owner", AtlasBaseTypeDef.ATLAS_TYPE_STRING), attrDef("createTime", AtlasBaseTypeDef.ATLAS_TYPE_LONG),
+ attrDef("lastAccessTime", AtlasBaseTypeDef.ATLAS_TYPE_DATE),
+ attrDef("temporary", AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN),
new AttributeDefinition("db", DATABASE_TYPE, Multiplicity.OPTIONAL, true, "tables"),
- new AttributeDefinition("columns", DataTypes.arrayTypeName(COLUMN_TYPE),
+ new AttributeDefinition("columns", AtlasBaseTypeDef.getArrayTypeName(COLUMN_TYPE),
Multiplicity.OPTIONAL, true, null),
new AttributeDefinition("tableType", "tableType", Multiplicity.OPTIONAL, false, null),
new AttributeDefinition("serde1", "serdeType", Multiplicity.OPTIONAL, false, null),
new AttributeDefinition("serde2", "serdeType", Multiplicity.OPTIONAL, false, null));
- HierarchicalTypeDefinition<ClassType> loadProcessClsDef = TypesUtil
- .createClassTypeDef(HIVE_PROCESS_TYPE, ImmutableSet.of("Process"),
- attrDef("userName", DataTypes.STRING_TYPE), attrDef("startTime", DataTypes.INT_TYPE),
- attrDef("endTime", DataTypes.LONG_TYPE),
- attrDef("queryText", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
- attrDef("queryPlan", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
- attrDef("queryId", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
- attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED));
-
- HierarchicalTypeDefinition<TraitType> classificationTrait = TypesUtil
- .createTraitTypeDef("classification", ImmutableSet.<String>of(),
- TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(PII_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> phiTrait =
- TypesUtil.createTraitTypeDef(PHI_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> pciTrait =
- TypesUtil.createTraitTypeDef(PCI_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> soxTrait =
- TypesUtil.createTraitTypeDef(SOX_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> secTrait =
- TypesUtil.createTraitTypeDef(SEC_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> financeTrait =
- TypesUtil.createTraitTypeDef(FINANCE_TAG, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> factTrait =
- TypesUtil.createTraitTypeDef("Fact" + randomString(), ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> etlTrait =
- TypesUtil.createTraitTypeDef("ETL" + randomString(), ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> dimensionTrait =
- TypesUtil.createTraitTypeDef("Dimension" + randomString(), ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> metricTrait =
- TypesUtil.createTraitTypeDef("Metric" + randomString(), ImmutableSet.<String>of());
-
- createType(getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition),
- ImmutableList.of(classificationTrait, piiTrait, phiTrait, pciTrait,
- soxTrait, secTrait, financeTrait, factTrait, etlTrait, dimensionTrait, metricTrait),
- ImmutableList.of(dbClsDef, columnClsDef, tblClsDef, loadProcessClsDef)));
+ ClassTypeDefinition loadProcessClsDef = TypesUtil
+ .createClassTypeDef(HIVE_PROCESS_TYPE, null, Collections.singleton("Process"),
+ attrDef("userName", AtlasBaseTypeDef.ATLAS_TYPE_STRING), attrDef("startTime", AtlasBaseTypeDef.ATLAS_TYPE_INT),
+ attrDef("endTime", AtlasBaseTypeDef.ATLAS_TYPE_LONG),
+ attrDef("queryText", AtlasBaseTypeDef.ATLAS_TYPE_STRING, Multiplicity.REQUIRED),
+ attrDef("queryPlan", AtlasBaseTypeDef.ATLAS_TYPE_STRING, Multiplicity.REQUIRED),
+ attrDef("queryId", AtlasBaseTypeDef.ATLAS_TYPE_STRING, Multiplicity.REQUIRED),
+ attrDef("queryGraph", AtlasBaseTypeDef.ATLAS_TYPE_STRING, Multiplicity.REQUIRED));
+
+ TraitTypeDefinition classificationTrait = TypesUtil
+ .createTraitTypeDef("classification", null, Collections.<String>emptySet(),
+ TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+
+ TraitTypeDefinition piiTrait = TypesUtil.createTraitTypeDef(PII_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition phiTrait = TypesUtil.createTraitTypeDef(PHI_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition pciTrait = TypesUtil.createTraitTypeDef(PCI_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition soxTrait = TypesUtil.createTraitTypeDef(SOX_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition secTrait = TypesUtil.createTraitTypeDef(SEC_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition financeTrait = TypesUtil.createTraitTypeDef(FINANCE_TAG, null, Collections.<String>emptySet());
+ TraitTypeDefinition factTrait = TypesUtil.createTraitTypeDef("Fact" + randomString(), null, Collections.<String>emptySet());
+ TraitTypeDefinition etlTrait = TypesUtil.createTraitTypeDef("ETL" + randomString(), null, Collections.<String>emptySet());
+ TraitTypeDefinition dimensionTrait = TypesUtil.createTraitTypeDef("Dimension" + randomString(), null, Collections.<String>emptySet());
+ TraitTypeDefinition metricTrait = TypesUtil.createTraitTypeDef("Metric" + randomString(), null, Collections.<String>emptySet());
+
+ createType(getTypesDef(Collections.singletonList(enumTypeDefinition),
+ Collections.singletonList(structTypeDefinition),
+ Arrays.asList(classificationTrait, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, financeTrait, factTrait, etlTrait, dimensionTrait, metricTrait),
+ Arrays.asList(dbClsDef, columnClsDef, tblClsDef, loadProcessClsDef)));
}
protected void createTypeDefinitionsV2() throws Exception {
-
AtlasConstraintDef isCompositeSourceConstraint = new AtlasConstraintDef(CONSTRAINT_TYPE_OWNED_REF);
-
- AtlasConstraintDef isCompositeTargetConstraint = new AtlasConstraintDef(CONSTRAINT_TYPE_INVERSE_REF,
- Collections.<String, Object>singletonMap(CONSTRAINT_PARAM_ATTRIBUTE, "randomTable"));
+ AtlasConstraintDef isCompositeTargetConstraint = new AtlasConstraintDef(CONSTRAINT_TYPE_INVERSE_REF, Collections.<String, Object>singletonMap(CONSTRAINT_PARAM_ATTRIBUTE, "randomTable"));
AtlasEntityDef dbClsTypeDef = AtlasTypeUtil.createClassTypeDef(
DATABASE_TYPE_V2,
@@ -385,7 +371,7 @@ public abstract class BaseResourceIT {
AtlasTypeUtil.createOptionalAttrDef("createTime", "int"),
//there is a serializ
new AtlasAttributeDef("randomTable",
- DataTypes.arrayTypeName(HIVE_TABLE_TYPE_V2),
+ AtlasBaseTypeDef.getArrayTypeName(HIVE_TABLE_TYPE_V2),
true,
Cardinality.SET,
0, -1, false, true, Collections.singletonList(isCompositeSourceConstraint))
@@ -409,7 +395,7 @@ public abstract class BaseResourceIT {
AtlasEntityDef tblClsDef = AtlasTypeUtil
.createClassTypeDef(HIVE_TABLE_TYPE_V2,
- ImmutableSet.of("DataSet"),
+ Collections.singleton("DataSet"),
AtlasTypeUtil.createOptionalAttrDef("owner", "string"),
AtlasTypeUtil.createOptionalAttrDef("createTime", "long"),
AtlasTypeUtil.createOptionalAttrDef("lastAccessTime", "date"),
@@ -421,14 +407,14 @@ public abstract class BaseResourceIT {
0, 1, false, true, Collections.singletonList(isCompositeTargetConstraint)),
//some tests don't set the columns field or set it to null...
- AtlasTypeUtil.createOptionalAttrDef("columns", DataTypes.arrayTypeName(COLUMN_TYPE_V2)),
+ AtlasTypeUtil.createOptionalAttrDef("columns", AtlasBaseTypeDef.getArrayTypeName(COLUMN_TYPE_V2)),
AtlasTypeUtil.createOptionalAttrDef("tableType", "tableType"),
AtlasTypeUtil.createOptionalAttrDef("serde1", "serdeType"),
AtlasTypeUtil.createOptionalAttrDef("serde2", "serdeType"));
AtlasEntityDef loadProcessClsDef = AtlasTypeUtil
.createClassTypeDef(HIVE_PROCESS_TYPE_V2,
- ImmutableSet.of("Process"),
+ Collections.singleton("Process"),
AtlasTypeUtil.createOptionalAttrDef("userName", "string"),
AtlasTypeUtil.createOptionalAttrDef("startTime", "int"),
AtlasTypeUtil.createOptionalAttrDef("endTime", "long"),
@@ -438,42 +424,36 @@ public abstract class BaseResourceIT {
AtlasTypeUtil.createRequiredAttrDef("queryGraph", "string"));
AtlasClassificationDef classificationTrait = AtlasTypeUtil
- .createTraitTypeDef("classification",ImmutableSet.<String>of(),
+ .createTraitTypeDef("classification", Collections.<String>emptySet(),
AtlasTypeUtil.createRequiredAttrDef("tag", "string"));
- AtlasClassificationDef piiTrait =
- AtlasTypeUtil.createTraitTypeDef(PII_TAG, ImmutableSet.<String>of());
- AtlasClassificationDef phiTrait =
- AtlasTypeUtil.createTraitTypeDef(PHI_TAG, ImmutableSet.<String>of());
- AtlasClassificationDef pciTrait =
- AtlasTypeUtil.createTraitTypeDef(PCI_TAG, ImmutableSet.<String>of());
- AtlasClassificationDef soxTrait =
- AtlasTypeUtil.createTraitTypeDef(SOX_TAG, ImmutableSet.<String>of());
- AtlasClassificationDef secTrait =
- AtlasTypeUtil.createTraitTypeDef(SEC_TAG, ImmutableSet.<String>of());
- AtlasClassificationDef financeTrait =
- AtlasTypeUtil.createTraitTypeDef(FINANCE_TAG, ImmutableSet.<String>of());
-
- AtlasTypesDef typesDef = new AtlasTypesDef(ImmutableList.of(enumDef),
- ImmutableList.of(structTypeDef),
- ImmutableList.of(classificationTrait, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, financeTrait),
- ImmutableList.of(dbClsTypeDef, columnClsDef, tblClsDef, loadProcessClsDef));
+ AtlasClassificationDef piiTrait = AtlasTypeUtil.createTraitTypeDef(PII_TAG, Collections.<String>emptySet());
+ AtlasClassificationDef phiTrait = AtlasTypeUtil.createTraitTypeDef(PHI_TAG, Collections.<String>emptySet());
+ AtlasClassificationDef pciTrait = AtlasTypeUtil.createTraitTypeDef(PCI_TAG, Collections.<String>emptySet());
+ AtlasClassificationDef soxTrait = AtlasTypeUtil.createTraitTypeDef(SOX_TAG, Collections.<String>emptySet());
+ AtlasClassificationDef secTrait = AtlasTypeUtil.createTraitTypeDef(SEC_TAG, Collections.<String>emptySet());
+ AtlasClassificationDef financeTrait = AtlasTypeUtil.createTraitTypeDef(FINANCE_TAG, Collections.<String>emptySet());
+
+ AtlasTypesDef typesDef = new AtlasTypesDef(Collections.singletonList(enumDef),
+ Collections.singletonList(structTypeDef),
+ Arrays.asList(classificationTrait, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, financeTrait),
+ Arrays.asList(dbClsTypeDef, columnClsDef, tblClsDef, loadProcessClsDef));
batchCreateTypes(typesDef);
}
- AttributeDefinition attrDef(String name, IDataType dT) {
+ AttributeDefinition attrDef(String name, String dT) {
return attrDef(name, dT, Multiplicity.OPTIONAL, false, null);
}
- AttributeDefinition attrDef(String name, IDataType dT, Multiplicity m) {
+ AttributeDefinition attrDef(String name, String dT, Multiplicity m) {
return attrDef(name, dT, m, false, null);
}
- AttributeDefinition attrDef(String name, IDataType dT, Multiplicity m, boolean isComposite,
- String reverseAttributeName) {
+ AttributeDefinition attrDef(String name, String dT, Multiplicity m, boolean isComposite, String reverseAttributeName) {
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(dT);
- return new AttributeDefinition(name, dT.getName(), m, isComposite, reverseAttributeName);
+
+ return new AttributeDefinition(name, dT, m, isComposite, reverseAttributeName);
}
protected String randomString() {
@@ -490,9 +470,9 @@ public abstract class BaseResourceIT {
values.put(CLUSTER_NAME, "cl1");
values.put("parameters", Collections.EMPTY_MAP);
values.put("location", "/tmp");
+
Referenceable databaseInstance = new Referenceable(dbId._getId(), dbId.getTypeName(), values);
- Referenceable tableInstance =
- new Referenceable(HIVE_TABLE_TYPE_BUILTIN, CLASSIFICATION, PII_TAG, PHI_TAG, PCI_TAG, SOX_TAG, SEC_TAG, FINANCE_TAG);
+ Referenceable tableInstance = new Referenceable(HIVE_TABLE_TYPE_BUILTIN, CLASSIFICATION, PII_TAG, PHI_TAG, PCI_TAG, SOX_TAG, SEC_TAG, FINANCE_TAG);
tableInstance.set(NAME, tableName);
tableInstance.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
tableInstance.set("db", databaseInstance);
@@ -516,7 +496,7 @@ public abstract class BaseResourceIT {
serde2Instance.set("serde", "serde2");
tableInstance.set("serde2", serde2Instance);
- List<String> traits = tableInstance.getTraits();
+ List<String> traits = tableInstance.getTraitNames();
Assert.assertEquals(traits.size(), 7);
return tableInstance;
@@ -564,30 +544,36 @@ public abstract class BaseResourceIT {
}
protected Referenceable createHiveDBInstanceBuiltIn(String dbName) {
Referenceable databaseInstance = new Referenceable(DATABASE_TYPE_BUILTIN);
+
databaseInstance.set(NAME, dbName);
databaseInstance.set(QUALIFIED_NAME, dbName);
databaseInstance.set(CLUSTER_NAME, randomString());
databaseInstance.set(DESCRIPTION, "foo database");
+
return databaseInstance;
}
protected Referenceable createHiveDBInstanceV1(String dbName) {
Referenceable databaseInstance = new Referenceable(DATABASE_TYPE);
+
databaseInstance.set(NAME, dbName);
databaseInstance.set(DESCRIPTION, "foo database");
databaseInstance.set(CLUSTER_NAME, "fooCluster");
+
return databaseInstance;
}
protected AtlasEntity createHiveDBInstanceV2(String dbName) {
AtlasEntity atlasEntity = new AtlasEntity(DATABASE_TYPE_V2);
+
atlasEntity.setAttribute(NAME, dbName);
atlasEntity.setAttribute(DESCRIPTION, "foo database");
atlasEntity.setAttribute(CLUSTER_NAME, "fooCluster");
atlasEntity.setAttribute("owner", "user1");
atlasEntity.setAttribute("locationUri", "/tmp");
atlasEntity.setAttribute("createTime",1000);
+
return atlasEntity;
}
@@ -611,7 +597,7 @@ public abstract class BaseResourceIT {
* @return the boolean result of the evaluation.
* @throws Exception thrown if the predicate evaluation could not evaluate.
*/
- boolean evaluate(EntityNotification notification) throws Exception;
+ boolean evaluate(EntityNotificationV1 notification) throws Exception;
}
/**
@@ -622,54 +608,62 @@ public abstract class BaseResourceIT {
*/
protected void waitFor(int timeout, Predicate predicate) throws Exception {
ParamChecker.notNull(predicate, "predicate");
- long mustEnd = System.currentTimeMillis() + timeout;
+ long mustEnd = System.currentTimeMillis() + timeout;
boolean eval;
+
while (!(eval = predicate.evaluate()) && System.currentTimeMillis() < mustEnd) {
LOG.info("Waiting up to {} msec", mustEnd - System.currentTimeMillis());
+
Thread.sleep(100);
}
+
if (!eval) {
throw new Exception("Waiting timed out after " + timeout + " msec");
}
}
- protected EntityNotification waitForNotification(final NotificationConsumer<EntityNotification> consumer, int maxWait,
- final NotificationPredicate predicate) throws Exception {
- final TypeUtils.Pair<EntityNotification, String> pair = TypeUtils.Pair.of(null, null);
- final long maxCurrentTime = System.currentTimeMillis() + maxWait;
+ protected EntityNotificationV1 waitForNotification(final NotificationConsumer<EntityNotificationV1> consumer, int maxWait,
+ final NotificationPredicate predicate) throws Exception {
+ final TypesUtil.Pair<EntityNotificationV1, String> pair = TypesUtil.Pair.of(null, null);
+ final long maxCurrentTime = System.currentTimeMillis() + maxWait;
+
waitFor(maxWait, new Predicate() {
@Override
public boolean evaluate() throws Exception {
try {
-
while (System.currentTimeMillis() < maxCurrentTime) {
- List<AtlasKafkaMessage<EntityNotification>> messageList = consumer.receive();
- if(messageList.size() > 0) {
- EntityNotification notification = messageList.get(0).getMessage();
- if (predicate.evaluate(notification)) {
- pair.left = notification;
- return true;
- }
- }else{
- LOG.info( System.currentTimeMillis()+ " messageList no records" +maxCurrentTime );
+ List<AtlasKafkaMessage<EntityNotificationV1>> messageList = consumer.receive();
+
+ if(messageList.size() > 0) {
+ EntityNotificationV1 notification = messageList.get(0).getMessage();
+
+ if (predicate.evaluate(notification)) {
+ pair.left = notification;
+
+ return true;
}
+ } else {
+ LOG.info( System.currentTimeMillis()+ " messageList no records" +maxCurrentTime );
+ }
}
} catch(Exception e) {
LOG.error(" waitForNotification", e);
//ignore
}
+
return false;
}
});
+
return pair.left;
}
- protected NotificationPredicate newNotificationPredicate(final EntityNotification.OperationType operationType,
+ protected NotificationPredicate newNotificationPredicate(final EntityNotificationV1.OperationType operationType,
final String typeName, final String guid) {
return new NotificationPredicate() {
@Override
- public boolean evaluate(EntityNotification notification) throws Exception {
+ public boolean evaluate(EntityNotificationV1 notification) throws Exception {
return notification != null &&
notification.getOperationType() == operationType &&
notification.getEntity().getTypeName().equals(typeName) &&
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java
index 5806a10..658be49 100644
--- a/webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java
@@ -17,7 +17,6 @@
*/
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.discovery.SearchParameters;
@@ -39,6 +38,7 @@ import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
@@ -61,7 +61,7 @@ public class BasicSearchIT extends BaseResourceIT {
// Create a test tag
if (!atlasClientV2.typeWithNameExists("fooTag")) {
- AtlasClassificationDef testClassificationDef = AtlasTypeUtil.createTraitTypeDef("fooTag", "Test tag", "1.0", ImmutableSet.<String>of());
+ AtlasClassificationDef testClassificationDef = AtlasTypeUtil.createTraitTypeDef("fooTag", "Test tag", "1.0", Collections.<String>emptySet());
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(testClassificationDef);
atlasClientV2.createAtlasTypeDefs(typesDef);
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/DataSetLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/DataSetLineageJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/DataSetLineageJerseyResourceIT.java
index 9a0d0dc..7e50480 100644
--- a/webapp/src/test/java/org/apache/atlas/web/integration/DataSetLineageJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/DataSetLineageJerseyResourceIT.java
@@ -18,23 +18,22 @@
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasServiceException;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.utils.TypesUtil;
+import org.apache.atlas.v1.model.instance.Id;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.instance.Struct;
+import org.apache.atlas.v1.model.typedef.TraitTypeDefinition;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -73,7 +72,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
JSONObject results = response.getJSONObject(AtlasClient.RESULTS);
Assert.assertNotNull(results);
- Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
+ Struct resultsInstance = AtlasType.fromV1Json(results.toString(), Struct.class);
Map<String, Struct> vertices = (Map<String, Struct>) resultsInstance.get("vertices");
Assert.assertEquals(vertices.size(), 4);
@@ -88,7 +87,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
JSONObject results = atlasClientV1.getInputGraphForEntity(tableId);
Assert.assertNotNull(results);
- Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
+ Struct resultsInstance = AtlasType.fromV1Json(results.toString(), Struct.class);
Map<String, Struct> vertices = (Map<String, Struct>) resultsInstance.get("vertices");
Assert.assertEquals(vertices.size(), 4);
Struct vertex = vertices.get(tableId);
@@ -109,7 +108,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
JSONObject results = response.getJSONObject(AtlasClient.RESULTS);
Assert.assertNotNull(results);
- Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
+ Struct resultsInstance = AtlasType.fromV1Json(results.toString(), Struct.class);
Map<String, Struct> vertices = (Map<String, Struct>) resultsInstance.get("vertices");
Assert.assertEquals(vertices.size(), 3);
@@ -124,7 +123,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
JSONObject results = atlasClientV1.getOutputGraphForEntity(tableId);
Assert.assertNotNull(results);
- Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
+ Struct resultsInstance = AtlasType.fromV1Json(results.toString(), Struct.class);
Map<String, Struct> vertices = (Map<String, Struct>) resultsInstance.get("vertices");
Assert.assertEquals(vertices.size(), 3);
Struct vertex = vertices.get(tableId);
@@ -187,31 +186,25 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
}
private void setupInstances() throws Exception {
- HierarchicalTypeDefinition<TraitType> factTrait =
- TypesUtil.createTraitTypeDef(FACT, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> etlTrait =
- TypesUtil.createTraitTypeDef(ETL, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> dimensionTrait =
- TypesUtil.createTraitTypeDef(DIMENSION, ImmutableSet.<String>of());
- HierarchicalTypeDefinition<TraitType> metricTrait =
- TypesUtil.createTraitTypeDef(METRIC, ImmutableSet.<String>of());
- createType(getTypesDef(null, null,
- ImmutableList.of(factTrait, etlTrait, dimensionTrait, metricTrait), null));
+ TraitTypeDefinition factTrait = TypesUtil.createTraitTypeDef(FACT, null, Collections.<String>emptySet());
+ TraitTypeDefinition etlTrait = TypesUtil.createTraitTypeDef(ETL, null, Collections.<String>emptySet());
+ TraitTypeDefinition dimensionTrait = TypesUtil.createTraitTypeDef(DIMENSION, null, Collections.<String>emptySet());
+ TraitTypeDefinition metricTrait = TypesUtil.createTraitTypeDef(METRIC, null, Collections.<String>emptySet());
+
+ createType(getTypesDef(null, null, Arrays.asList(factTrait, etlTrait, dimensionTrait, metricTrait), null));
salesDBName = "Sales" + randomString();
Id salesDB = database(salesDBName, "Sales Database", "John ETL",
"hdfs://host:8000/apps/warehouse/sales");
- List<Referenceable> salesFactColumns = ImmutableList
- .of(column("time_id", "int", "time id"), column("product_id", "int", "product id"),
+ List<Referenceable> salesFactColumns = Arrays.asList(column("time_id", "int", "time id"), column("product_id", "int", "product id"),
column("customer_id", "int", "customer id", PII),
column("sales", "double", "product id", METRIC));
salesFactTable = "sales_fact" + randomString();
Id salesFact = table(salesFactTable, "sales fact table", salesDB, "Joe", "MANAGED", salesFactColumns, FACT);
- List<Referenceable> timeDimColumns = ImmutableList
- .of(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"),
+ List<Referenceable> timeDimColumns = Arrays.asList(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"),
column("weekDay", "int", "week Day"));
Id timeDim =
@@ -226,16 +219,16 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
table("sales_fact_daily_mv" + randomString(), "sales fact daily materialized view", reportingDB,
"Joe BI", "MANAGED", salesFactColumns, METRIC);
- loadProcess("loadSalesDaily" + randomString(), "John ETL", ImmutableList.of(salesFact, timeDim),
- ImmutableList.of(salesFactDaily), "create table as select ", "plan", "id", "graph", ETL);
+ loadProcess("loadSalesDaily" + randomString(), "John ETL", Arrays.asList(salesFact, timeDim),
+ Collections.singletonList(salesFactDaily), "create table as select ", "plan", "id", "graph", ETL);
salesMonthlyTable = "sales_fact_monthly_mv" + randomString();
Id salesFactMonthly =
table(salesMonthlyTable, "sales fact monthly materialized view", reportingDB, "Jane BI",
"MANAGED", salesFactColumns, METRIC);
- loadProcess("loadSalesMonthly" + randomString(), "John ETL", ImmutableList.of(salesFactDaily),
- ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph", ETL);
+ loadProcess("loadSalesMonthly" + randomString(), "John ETL", Collections.singletonList(salesFactDaily),
+ Collections.singletonList(salesFactMonthly), "create table as select ", "plan", "id", "graph", ETL);
}
Id database(String name, String description, String owner, String locationUri, String... traitNames)
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java
index 157bf97..75d3872 100755
--- a/webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java
@@ -18,8 +18,6 @@
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.model.discovery.AtlasSearchResult;
@@ -27,18 +25,14 @@ import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasQueryType;
import org.apache.atlas.model.instance.AtlasEntity.Status;
import org.apache.atlas.model.instance.AtlasEntityHeader;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-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.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.v1.model.typedef.*;
+import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap;
+import java.util.Collections;
import java.util.List;
import static org.testng.Assert.assertEquals;
@@ -196,16 +190,16 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
}
private void createTypes() throws Exception {
- HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil
- .createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(),
- TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
-
- HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil
- .createTraitTypeDef("Classification", ImmutableSet.<String>of(),
- TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
- TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
- ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
+ ClassTypeDefinition dslTestTypeDefinition = TypesUtil
+ .createClassTypeDef("dsl_test_type", null, Collections.<String>emptySet(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+
+ TraitTypeDefinition classificationTraitDefinition = TypesUtil
+ .createTraitTypeDef("Classification", null, Collections.<String>emptySet(),
+ TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typesDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(),
+ Collections.singletonList(classificationTraitDefinition), Collections.singletonList(dslTestTypeDefinition));
createType(typesDef);
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
index cf44d4a..0f585f9 100755
--- a/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
@@ -18,8 +18,6 @@
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasClient;
@@ -27,22 +25,14 @@ import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.EntityAuditEvent;
import org.apache.atlas.kafka.NotificationProvider;
import org.apache.atlas.model.legacy.EntityResult;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.v1.model.instance.Id;
+import org.apache.atlas.v1.model.instance.Referenceable;
+import org.apache.atlas.v1.model.instance.Struct;
+import org.apache.atlas.v1.model.typedef.*;
import org.apache.atlas.notification.NotificationInterface;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
-import org.apache.atlas.typesystem.json.InstanceSerialization$;
-import org.apache.atlas.typesystem.json.TypesSerialization;
-import org.apache.atlas.typesystem.json.TypesSerialization$;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-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.type.AtlasType;
+import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray;
@@ -57,12 +47,7 @@ import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -193,7 +178,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
databaseInstance.set("location", "/tmp");
JSONObject response = atlasClientV1
- .callAPIWithBody(AtlasClient.API_V1.CREATE_ENTITY, InstanceSerialization.toJson(databaseInstance, true));
+ .callAPIWithBody(AtlasClient.API_V1.CREATE_ENTITY, AtlasType.toV1Json(databaseInstance));
assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
@@ -244,23 +229,23 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
public void testEntityDefinitionAcrossTypeUpdate() throws Exception {
//create type
- HierarchicalTypeDefinition<ClassType> typeDefinition = TypesUtil
- .createClassTypeDef(randomString(), ImmutableSet.<String>of(),
- TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE));
- atlasClientV1.createType(TypesSerialization.toJson(typeDefinition, false));
+ ClassTypeDefinition typeDefinition = TypesUtil
+ .createClassTypeDef(randomString(), null, Collections.<String>emptySet(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ atlasClientV1.createType(AtlasType.toV1Json(typeDefinition));
//create entity for the type
- Referenceable instance = new Referenceable(typeDefinition.typeName);
+ Referenceable instance = new Referenceable(typeDefinition.getTypeName());
instance.set("name", randomString());
String guid = atlasClientV1.createEntity(instance).get(0);
//update type - add attribute
- typeDefinition = TypesUtil.createClassTypeDef(typeDefinition.typeName, ImmutableSet.<String>of(),
- TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createOptionalAttrDef("description", DataTypes.STRING_TYPE));
- TypesDef typeDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),
- ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
- ImmutableList.of(typeDefinition));
+ typeDefinition = TypesUtil.createClassTypeDef(typeDefinition.getTypeName(), null, Collections.<String>emptySet(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createOptionalAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typeDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(),
+ Collections.<StructTypeDefinition>emptyList(), Collections.<TraitTypeDefinition>emptyList(),
+ Arrays.asList(typeDefinition));
atlasClientV1.updateType(typeDef);
//Get definition after type update - new attributes should be null
@@ -537,12 +522,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
private String addNewType() throws Exception {
String typeName = "test" + randomString();
- HierarchicalTypeDefinition<ClassType> testTypeDefinition = TypesUtil
- .createClassTypeDef(typeName, ImmutableSet.<String>of(),
- TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
+ ClassTypeDefinition testTypeDefinition = TypesUtil
+ .createClassTypeDef(typeName, null, Collections.<String>emptySet(),
+ TypesUtil.createRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
- String typesAsJSON = TypesSerialization.toJson(testTypeDefinition, false);
+ String typesAsJSON = AtlasType.toV1Json(testTypeDefinition);
createType(typesAsJSON);
return typeName;
}
@@ -585,9 +570,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -614,9 +599,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -648,9 +633,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -682,10 +667,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
final String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil
- .createTraitTypeDef(traitName, ImmutableSet.<String>of(),
- TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait = TypesUtil
+ .createTraitTypeDef(traitName, null, Collections.<String>emptySet(),
+ TypesUtil.createRequiredAttrDef("type", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -705,13 +690,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class)
public void testAddTraitWithNoRegistration() throws Exception {
final String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
Struct traitInstance = new Struct(traitName);
- String traitInstanceAsJSON = InstanceSerialization$.MODULE$.toJson(traitInstance, true);
+ String traitInstanceAsJSON = AtlasType.toV1Json(traitInstance);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API_V1.CREATE_ENTITY, traitInstanceAsJSON, "random", TRAITS);
@@ -734,9 +719,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -794,10 +779,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
final String traitName = "PII_Trait" + randomString();
- HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil
- .createTraitTypeDef(traitName, ImmutableSet.<String>of(),
- TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
- String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
+ TraitTypeDefinition piiTrait = TypesUtil
+ .createTraitTypeDef(traitName, null, Collections.<String>emptySet(),
+ TypesUtil.createRequiredAttrDef("type", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
createType(traitDefinitionAsJSON);
try {
@@ -821,12 +806,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String attrName = random();
String attrValue = random();
- HierarchicalTypeDefinition<ClassType> classTypeDefinition = TypesUtil
- .createClassTypeDef(classType, ImmutableSet.<String>of(),
- TypesUtil.createUniqueRequiredAttrDef(attrName, DataTypes.STRING_TYPE));
- TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
- ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
- ImmutableList.of(classTypeDefinition));
+ ClassTypeDefinition classTypeDefinition = TypesUtil
+ .createClassTypeDef(classType, null, Collections.<String>emptySet(),
+ TypesUtil.createUniqueRequiredAttrDef(attrName, AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typesDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(),
+ Collections.<TraitTypeDefinition>emptyList(),
+ Collections.singletonList(classTypeDefinition));
createType(typesDef);
Referenceable instance = new Referenceable(classType);
@@ -834,7 +819,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Id guid = createInstance(instance);
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API_V1.GET_ENTITY, null, guid._getId());
- Referenceable getReferenceable = InstanceSerialization.fromJsonReferenceable(response.getString(AtlasClient.DEFINITION), true);
+ Referenceable getReferenceable = AtlasType.fromV1Json(response.getString(AtlasClient.DEFINITION), Referenceable.class);
Assert.assertEquals(getReferenceable.get(attrName), attrValue);
}
@@ -882,7 +867,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Referenceable entity = atlasClientV1.getEntity(guid);
List<Referenceable> refs = (List<Referenceable>) entity.get("columns");
- Assert.assertTrue(refs.get(0).equalsContents(columns.get(0)));
+ Assert.assertTrue(refs.get(0).equals(columns.get(0)));
}
@Test
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/EntityLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/EntityLineageJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/EntityLineageJerseyResourceIT.java
index 3811390..4be0002 100644
--- a/webapp/src/test/java/org/apache/atlas/web/integration/EntityLineageJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/EntityLineageJerseyResourceIT.java
@@ -18,15 +18,14 @@
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableList;
-import com.google.gson.Gson;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasBaseClient;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.persistence.Id;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.v1.model.instance.Id;
+import org.apache.atlas.v1.model.instance.Referenceable;
import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
@@ -34,9 +33,7 @@ import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Entity Lineage v2 Integration Tests.
@@ -53,7 +50,6 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
private String salesFactTable;
private String salesMonthlyTable;
private String salesDBName;
- Gson gson = new Gson();
@BeforeClass
public void setUp() throws Exception {
@@ -76,7 +72,7 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
System.out.println("input lineage info = " + response
);
- AtlasLineageInfo inputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
+ AtlasLineageInfo inputLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);
Map<String, AtlasEntityHeader> entities = inputLineageInfo.getGuidEntityMap();
Assert.assertNotNull(entities);
@@ -104,7 +100,7 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
Assert.assertNotNull(response);
System.out.println("output lineage info = " + response);
- AtlasLineageInfo outputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
+ AtlasLineageInfo outputLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);
Map<String, AtlasEntityHeader> entities = outputLineageInfo.getGuidEntityMap();
Assert.assertNotNull(entities);
@@ -132,7 +128,7 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
Assert.assertNotNull(response);
System.out.println("both lineage info = " + response);
- AtlasLineageInfo bothLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
+ AtlasLineageInfo bothLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);
Map<String, AtlasEntityHeader> entities = bothLineageInfo.getGuidEntityMap();
Assert.assertNotNull(entities);
@@ -151,16 +147,14 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
salesDBName = "Sales" + randomString();
Id salesDB = database(salesDBName, "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales");
- List<Referenceable> salesFactColumns = ImmutableList
- .of(column("time_id", "int", "time id"), column("product_id", "int", "product id"),
- column("customer_id", "int", "customer id"),
- column("sales", "double", "product id"));
+ List<Referenceable> salesFactColumns = Arrays.asList(column("time_id", "int", "time id"), column("product_id", "int", "product id"),
+ column("customer_id", "int", "customer id"),
+ column("sales", "double", "product id"));
salesFactTable = "sales_fact" + randomString();
Id salesFact = table(salesFactTable, "sales fact table", salesDB, "Joe", "MANAGED", salesFactColumns);
- List<Referenceable> timeDimColumns = ImmutableList
- .of(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"),
+ List<Referenceable> timeDimColumns = Arrays.asList(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"),
column("weekDay", "int", "week Day"));
Id timeDim =
@@ -175,15 +169,15 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
table("sales_fact_daily_mv" + randomString(), "sales fact daily materialized view", reportingDB,
"Joe BI", "MANAGED", salesFactColumns);
- loadProcess("loadSalesDaily" + randomString(), "John ETL", ImmutableList.of(salesFact, timeDim),
- ImmutableList.of(salesFactDaily), "create table as select ", "plan", "id", "graph");
+ loadProcess("loadSalesDaily" + randomString(), "John ETL", Arrays.asList(salesFact, timeDim),
+ Collections.singletonList(salesFactDaily), "create table as select ", "plan", "id", "graph");
salesMonthlyTable = "sales_fact_monthly_mv" + randomString();
Id salesFactMonthly =
table(salesMonthlyTable, "sales fact monthly materialized view", reportingDB, "Jane BI",
"MANAGED", salesFactColumns);
- loadProcess("loadSalesMonthly" + randomString(), "John ETL", ImmutableList.of(salesFactDaily),
- ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph");
+ loadProcess("loadSalesMonthly" + randomString(), "John ETL", Collections.singletonList(salesFactDaily),
+ Collections.singletonList(salesFactMonthly), "create table as select ", "plan", "id", "graph");
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
index d61a9af..77a85f6 100755
--- a/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
@@ -18,14 +18,11 @@
package org.apache.atlas.web.integration;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.sun.jersey.api.client.ClientResponse;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.EntityAuditEvent;
-import org.apache.atlas.kafka.NotificationProvider;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
@@ -37,11 +34,8 @@ import org.apache.atlas.model.instance.EntityMutations;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
-import org.apache.atlas.notification.NotificationConsumer;
-import org.apache.atlas.notification.NotificationInterface;
-import org.apache.atlas.notification.entity.EntityNotification;
import org.apache.atlas.type.AtlasTypeUtil;
-import org.apache.atlas.typesystem.types.TypeUtils;
+import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.joda.time.DateTime;
@@ -51,11 +45,8 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.atlas.kafka.AtlasKafkaConsumer;
+import java.util.*;
+
import static org.testng.Assert.*;
@@ -83,7 +74,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
@Test
public void testSubmitEntity() throws Exception {
- TypeUtils.Pair dbAndTable = createDBAndTable();
+ TypesUtil.Pair dbAndTable = createDBAndTable();
assertNotNull(dbAndTable);
assertNotNull(dbAndTable.left);
assertNotNull(dbAndTable.right);
@@ -192,7 +183,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
//create type
AtlasEntityDef entityDef = AtlasTypeUtil
.createClassTypeDef(randomString(),
- ImmutableSet.<String>of(),
+ Collections.<String>emptySet(),
AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string")
);
AtlasTypesDef typesDef = new AtlasTypesDef();
@@ -213,7 +204,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
String guid = mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0).getGuid();
//update type - add attribute
- entityDef = AtlasTypeUtil.createClassTypeDef(entityDef.getName(), ImmutableSet.<String>of(),
+ entityDef = AtlasTypeUtil.createClassTypeDef(entityDef.getName(), Collections.<String>emptySet(),
AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"),
AtlasTypeUtil.createOptionalAttrDef("description", "string"));
@@ -366,7 +357,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
private String addNewType() throws Exception {
String typeName = "test" + randomString();
AtlasEntityDef classTypeDef = AtlasTypeUtil
- .createClassTypeDef(typeName, ImmutableSet.<String>of(),
+ .createClassTypeDef(typeName, Collections.<String>emptySet(),
AtlasTypeUtil.createRequiredAttrDef("name", "string"),
AtlasTypeUtil.createRequiredAttrDef("description", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
@@ -419,10 +410,10 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
return hiveDBInstanceV2;
}
- private TypeUtils.Pair<AtlasEntity, AtlasEntity> createDBAndTable() throws Exception {
+ private TypesUtil.Pair<AtlasEntity, AtlasEntity> createDBAndTable() throws Exception {
AtlasEntity dbInstanceV2 = createHiveDB();
AtlasEntity hiveTableInstanceV2 = createHiveTable();
- return TypeUtils.Pair.of(dbInstanceV2, hiveTableInstanceV2);
+ return TypesUtil.Pair.of(dbInstanceV2, hiveTableInstanceV2);
}
private AtlasEntity createHiveTable() throws Exception {
@@ -447,12 +438,12 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
public void testAddTrait() throws Exception {
traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait =
- AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
+ AtlasTypeUtil.createTraitTypeDef(traitName, Collections.<String>emptySet());
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
- atlasClientV2.addClassifications(createHiveTable().getGuid(), ImmutableList.of(new AtlasClassification(piiTrait.getName())));
+ atlasClientV2.addClassifications(createHiveTable().getGuid(), Collections.singletonList(new AtlasClassification(piiTrait.getName())));
assertEntityAudit(createHiveTable().getGuid(), EntityAuditEvent.EntityAuditAction.TAG_ADD);
}
@@ -461,7 +452,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
public void testGetTraitDefinitionForEntity() throws Exception{
traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait =
- AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
+ AtlasTypeUtil.createTraitTypeDef(traitName, Collections.<String>emptySet());
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
@@ -487,7 +478,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
public void testAddTraitWithAttribute() throws Exception {
final String traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil
- .createTraitTypeDef(traitName, ImmutableSet.<String>of(),
+ .createTraitTypeDef(traitName, Collections.<String>emptySet(),
AtlasTypeUtil.createRequiredAttrDef("type", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
@@ -497,7 +488,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
traitInstance.setAttribute("type", "SSN");
final String guid = createHiveTable().getGuid();
- atlasClientV2.addClassifications(guid, ImmutableList.of(traitInstance));
+ atlasClientV2.addClassifications(guid, Collections.singletonList(traitInstance));
// verify the response
AtlasEntity withAssociationByGuid = atlasClientV2.getEntityByGuid(guid).getEntity();
@@ -518,11 +509,11 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class)
public void testAddTraitWithNoRegistration() throws Exception {
final String traitName = "PII_Trait" + randomString();
- AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
+ AtlasTypeUtil.createTraitTypeDef(traitName, Collections.<String>emptySet());
AtlasClassification traitInstance = new AtlasClassification(traitName);
- atlasClientV2.addClassifications("random", ImmutableList.of(traitInstance));
+ atlasClientV2.addClassifications("random", Collections.singletonList(traitInstance));
}
@Test(dependsOnMethods = "testAddTrait")
@@ -558,7 +549,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
final String guid = createHiveTable().getGuid();
final String traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil
- .createTraitTypeDef(traitName, ImmutableSet.<String>of(),
+ .createTraitTypeDef(traitName, Collections.<String>emptySet(),
AtlasTypeUtil.createRequiredAttrDef("type", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
@@ -584,7 +575,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
String attrValue = random();
AtlasEntityDef classTypeDef = AtlasTypeUtil
- .createClassTypeDef(classType, ImmutableSet.<String>of(),
+ .createClassTypeDef(classType, Collections.<String>emptySet(),
AtlasTypeUtil.createUniqueRequiredAttrDef(attrName, "string"));
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(classTypeDef);
@@ -721,7 +712,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntityHeader entity2Header = createEntity(db2);
// Delete the database entities
- EntityMutationResponse deleteResponse = atlasClientV2.deleteEntitiesByGuids(ImmutableList.of(entity1Header.getGuid(), entity2Header.getGuid()));
+ EntityMutationResponse deleteResponse = atlasClientV2.deleteEntitiesByGuids(Arrays.asList(entity1Header.getGuid(), entity2Header.getGuid()));
// Verify that deleteEntities() response has database entity guids
assertNotNull(deleteResponse);