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/05 20:31:24 UTC
[02/40] 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/0877e47c/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
index 7e94330..295d9ea 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
@@ -21,16 +21,12 @@ package org.apache.atlas.notification;
import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.kafka.NotificationProvider;
+import org.apache.atlas.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.model.v1.typedef.TraitTypeDefinition;
import org.apache.atlas.notification.entity.EntityNotification;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
-import org.apache.atlas.typesystem.json.TypesSerialization$;
-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.type.AtlasType;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.atlas.web.integration.BaseResourceIT;
import org.testng.annotations.BeforeClass;
@@ -119,7 +115,7 @@ public class EntityNotificationIT extends BaseResourceIT {
createTrait(traitName, superTraitName);
Struct traitInstance = new Struct(traitName);
- String traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
+ String traitInstanceJSON = AtlasType.toV1Json(traitInstance);
LOG.debug("Trait instance = {}", traitInstanceJSON);
final String guid = tableId._getId();
@@ -129,13 +125,13 @@ public class EntityNotificationIT extends BaseResourceIT {
EntityNotification entityNotification = waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.TRAIT_ADD, HIVE_TABLE_TYPE_BUILTIN, guid));
- IReferenceableInstance entity = entityNotification.getEntity();
- assertTrue(entity.getTraits().contains(traitName));
+ Referenceable entity = entityNotification.getEntity();
+ assertTrue(entity.getTraitNames().contains(traitName));
- List<IStruct> allTraits = entityNotification.getAllTraits();
+ List<Struct> allTraits = entityNotification.getAllTraits();
List<String> allTraitNames = new LinkedList<>();
- for (IStruct struct : allTraits) {
+ for (Struct struct : allTraits) {
allTraitNames.add(struct.getTypeName());
}
assertTrue(allTraitNames.contains(traitName));
@@ -146,7 +142,7 @@ public class EntityNotificationIT extends BaseResourceIT {
createTrait(anotherTraitName, superTraitName);
traitInstance = new Struct(anotherTraitName);
- traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
+ traitInstanceJSON = AtlasType.toV1Json(traitInstance);
LOG.debug("Trait instance = {}", traitInstanceJSON);
atlasClientV1.addTrait(guid, traitInstance);
@@ -157,7 +153,7 @@ public class EntityNotificationIT extends BaseResourceIT {
allTraits = entityNotification.getAllTraits();
allTraitNames = new LinkedList<>();
- for (IStruct struct : allTraits) {
+ for (Struct struct : allTraits) {
allTraitNames.add(struct.getTypeName());
}
assertTrue(allTraitNames.contains(traitName));
@@ -174,17 +170,17 @@ public class EntityNotificationIT extends BaseResourceIT {
EntityNotification entityNotification = waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.TRAIT_DELETE, HIVE_TABLE_TYPE_BUILTIN, guid));
- assertFalse(entityNotification.getEntity().getTraits().contains(traitName));
+ assertFalse(entityNotification.getEntity().getTraitNames().contains(traitName));
}
// ----- helper methods ---------------------------------------------------
private void createTrait(String traitName, String ... superTraitNames) throws Exception {
- HierarchicalTypeDefinition<TraitType> trait =
- TypesUtil.createTraitTypeDef(traitName, ImmutableSet.copyOf(superTraitNames));
+ TraitTypeDefinition trait =
+ TypesUtil.createTraitTypeDef(traitName, null, ImmutableSet.copyOf(superTraitNames));
- String traitDefinitionJSON = TypesSerialization$.MODULE$.toJson(trait, true);
+ String traitDefinitionJSON = AtlasType.toV1Json(trait);
LOG.debug("Trait definition = {}", traitDefinitionJSON);
createType(traitDefinitionJSON);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/notification/NotificationEntityChangeListenerTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationEntityChangeListenerTest.java b/webapp/src/test/java/org/apache/atlas/notification/NotificationEntityChangeListenerTest.java
index a988915..45356d5 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationEntityChangeListenerTest.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationEntityChangeListenerTest.java
@@ -18,11 +18,10 @@
package org.apache.atlas.notification;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.TypeSystem;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasClassificationType;
+import org.apache.atlas.type.AtlasTypeRegistry;
import org.testng.annotations.Test;
import java.util.Collections;
@@ -41,45 +40,45 @@ public class NotificationEntityChangeListenerTest {
@Test
public void testGetAllTraitsSuperTraits() throws Exception {
- TypeSystem typeSystem = mock(TypeSystem.class);
+ AtlasTypeRegistry typeSystem = mock(AtlasTypeRegistry.class);
String traitName = "MyTrait";
- IStruct myTrait = new Struct(traitName);
+ Struct myTrait = new Struct(traitName);
String superTraitName = "MySuperTrait";
- TraitType traitDef = mock(TraitType.class);
+ AtlasClassificationType traitDef = mock(AtlasClassificationType.class);
Set<String> superTypeNames = Collections.singleton(superTraitName);
- TraitType superTraitDef = mock(TraitType.class);
+ AtlasClassificationType superTraitDef = mock(AtlasClassificationType.class);
Set<String> superSuperTypeNames = Collections.emptySet();
Referenceable entity = getEntity("id", myTrait);
- when(typeSystem.getDataType(TraitType.class, traitName)).thenReturn(traitDef);
- when(typeSystem.getDataType(TraitType.class, superTraitName)).thenReturn(superTraitDef);
+ when(typeSystem.getClassificationTypeByName(traitName)).thenReturn(traitDef);
+ when(typeSystem.getClassificationTypeByName(superTraitName)).thenReturn(superTraitDef);
- when(traitDef.getAllSuperTypeNames()).thenReturn(superTypeNames);
- when(superTraitDef.getAllSuperTypeNames()).thenReturn(superSuperTypeNames);
+ when(traitDef.getAllSuperTypes()).thenReturn(superTypeNames);
+ when(superTraitDef.getAllSuperTypes()).thenReturn(superSuperTypeNames);
- List<IStruct> allTraits = NotificationEntityChangeListener.getAllTraits(entity, typeSystem);
+ List<Struct> allTraits = NotificationEntityChangeListener.getAllTraits(entity, typeSystem);
assertEquals(2, allTraits.size());
- for (IStruct trait : allTraits) {
+ for (Struct trait : allTraits) {
String typeName = trait.getTypeName();
assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName));
}
}
- private Referenceable getEntity(String id, IStruct... traits) {
+ private Referenceable getEntity(String id, Struct... traits) {
String typeName = "typeName";
Map<String, Object> values = new HashMap<>();
List<String> traitNames = new LinkedList<>();
- Map<String, IStruct> traitMap = new HashMap<>();
+ Map<String, Struct> traitMap = new HashMap<>();
- for (IStruct trait : traits) {
+ for (Struct trait : traits) {
String traitName = trait.getTypeName();
traitNames.add(traitName);
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
index d41db3e..cee7bf6 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
@@ -20,14 +20,14 @@ package org.apache.atlas.notification;
import org.apache.atlas.EntityAuditEvent;
import org.apache.atlas.kafka.NotificationProvider;
+import org.apache.atlas.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.hook.HookNotification;
import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
import org.apache.atlas.notification.hook.HookNotification.EntityDeleteRequest;
import org.apache.atlas.notification.hook.HookNotification.EntityPartialUpdateRequest;
import org.apache.atlas.notification.hook.HookNotification.EntityCreateRequest;
import org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequest;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.web.integration.BaseResourceIT;
import org.codehaus.jettison.json.JSONArray;
import org.testng.annotations.AfterClass;
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
index eb37fa8..c384cc3 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
@@ -26,13 +26,13 @@ import org.apache.atlas.kafka.AtlasKafkaMessage;
import org.apache.atlas.kafka.KafkaNotification;
import org.apache.atlas.kafka.NotificationProvider;
import org.apache.atlas.model.instance.AtlasEntity;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.hook.HookNotification;
import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.EntityStream;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.web.service.ServiceState;
import org.apache.commons.lang.RandomStringUtils;
import org.mockito.Mock;
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
index e2d1022..526a8e7 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
@@ -24,13 +24,13 @@ import org.apache.atlas.ha.HAConfiguration;
import org.apache.atlas.kafka.AtlasKafkaMessage;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.EntityMutationResponse;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.hook.HookNotification;
import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.EntityStream;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.web.service.ServiceState;
import org.apache.commons.configuration.Configuration;
import org.apache.kafka.common.TopicPartition;
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/util/RestUtilsTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/util/RestUtilsTest.java b/webapp/src/test/java/org/apache/atlas/util/RestUtilsTest.java
deleted file mode 100644
index 87259df..0000000
--- a/webapp/src/test/java/org/apache/atlas/util/RestUtilsTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.util;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.model.typedef.AtlasEntityDef;
-import org.apache.atlas.model.typedef.AtlasStructDef;
-import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
-import org.apache.atlas.model.typedef.AtlasTypesDef;
-import org.apache.atlas.repository.Constants;
-import org.apache.atlas.repository.converters.TypeConverterUtil;
-import org.apache.atlas.repository.graphdb.AtlasVertex;
-import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
-import org.apache.atlas.repository.store.graph.v1.AtlasStructDefStoreV1;
-import org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1;
-import org.apache.atlas.type.AtlasEntityType;
-import org.apache.atlas.type.AtlasStructType;
-import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
-import org.apache.atlas.type.AtlasType;
-import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.json.TypesSerialization;
-import org.apache.atlas.typesystem.types.AttributeDefinition;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
-import org.apache.atlas.typesystem.types.Multiplicity;
-import org.apache.atlas.typesystem.types.StructTypeDefinition;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.utils.TypesUtil;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Validates that conversion from V1 to legacy types (and back) is consistent. This also tests
- * that the conversion logic in AtlasStructDefStoreV1 is consistent with the conversion logic
- * in RestUtils. This tests particularly focuses on composite attributes, since a defect was
- * found in that area.
- */
-public class RestUtilsTest {
-
- @Test(enabled=false)
- // FIXME: On conversion back to V1, reverse attribute name
- // "containingDatabase"
- // in tables attribute in "database" type is lost. See ATLAS-1528.
- public void testBidirectonalCompositeMappingConsistent() throws AtlasBaseException {
-
- HierarchicalTypeDefinition<ClassType> dbV1Type = TypesUtil.createClassTypeDef("database",
- ImmutableSet.<String> of(), new AttributeDefinition("tables", DataTypes.arrayTypeName("table"),
- Multiplicity.OPTIONAL, true, "containingDatabase"));
-
- HierarchicalTypeDefinition<ClassType> tableV1Type = TypesUtil.createClassTypeDef("table",
- ImmutableSet.<String> of(),
- new AttributeDefinition("containingDatabase", "database", Multiplicity.OPTIONAL, false, "tables"));
-
- testV1toV2toV1Conversion(Arrays.asList(dbV1Type, tableV1Type), new boolean[] { true, false });
- }
-
- @Test(enabled=false)
- // FIXME: On conversion back to V1, reverse attribute name
- // "containingDatabase" is lost
- // in "table" attribute in "database". See ATLAS-1528.
- public void testBidirectonalNonCompositeMappingConsistent() throws AtlasBaseException {
-
- HierarchicalTypeDefinition<ClassType> dbV1Type = TypesUtil.createClassTypeDef("database",
- ImmutableSet.<String> of(), new AttributeDefinition("tables", DataTypes.arrayTypeName("table"),
- Multiplicity.OPTIONAL, false, "containingDatabase"));
-
- HierarchicalTypeDefinition<ClassType> tableV1Type = TypesUtil.createClassTypeDef("table",
- ImmutableSet.<String> of(),
- new AttributeDefinition("containingDatabase", "database", Multiplicity.OPTIONAL, false, "tables"));
-
- testV1toV2toV1Conversion(Arrays.asList(dbV1Type, tableV1Type), new boolean[] { false, false });
- }
-
- private AtlasTypeDefGraphStoreV1 makeTypeStore(AtlasTypeRegistry reg) {
-
- AtlasTypeDefGraphStoreV1 result = mock(AtlasTypeDefGraphStoreV1.class);
-
- for (AtlasEntityType type : reg.getAllEntityTypes()) {
- String typeName = type.getTypeName();
- AtlasVertex typeVertex = mock(AtlasVertex.class);
- when(result.isTypeVertex(eq(typeVertex), any(TypeCategory.class))).thenReturn(true);
- when(typeVertex.getProperty(eq(Constants.TYPE_CATEGORY_PROPERTY_KEY), eq(TypeCategory.class)))
- .thenReturn(TypeCategory.CLASS);
-
- String attributeListPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName);
- when(typeVertex.getProperty(eq(attributeListPropertyKey), eq(List.class)))
- .thenReturn(new ArrayList<>(type.getAllAttributes().keySet()));
- for (AtlasAttribute attribute : type.getAllAttributes().values()) {
- String attributeDefPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName, attribute.getName());
- String attributeJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute);
- when(typeVertex.getProperty(eq(attributeDefPropertyKey), eq(String.class))).thenReturn(attributeJson);
- }
- when(result.findTypeVertexByName(eq(typeName))).thenReturn(typeVertex);
- }
- return result;
- }
-
- private AtlasAttributeDef convertToJsonAndBack(AtlasTypeRegistry registry, AtlasStructDef structDef,
- AtlasAttributeDef attributeDef, boolean compositeExpected) throws AtlasBaseException {
-
- AtlasTypeDefGraphStoreV1 typeDefStore = makeTypeStore(registry);
- AtlasStructType structType = (AtlasStructType) registry.getType(structDef.getName());
- AtlasAttribute attribute = structType.getAttribute(attributeDef.getName());
- String attribJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute);
-
- Map attrInfo = AtlasType.fromJson(attribJson, Map.class);
- Assert.assertEquals(attrInfo.get("isComposite"), compositeExpected);
- return AtlasStructDefStoreV1.toAttributeDefFromJson(structDef, attrInfo, typeDefStore);
- }
-
- private void testV1toV2toV1Conversion(List<HierarchicalTypeDefinition<ClassType>> typesToTest,
- boolean[] compositeExpected) throws AtlasBaseException {
-
- List<AtlasEntityDef> convertedEntityDefs = convertV1toV2(typesToTest);
-
- AtlasTypeRegistry registry = createRegistry(convertedEntityDefs);
- for(int i = 0 ; i < convertedEntityDefs.size(); i++) {
- AtlasEntityDef def = convertedEntityDefs.get(i);
- for (AtlasAttributeDef attrDef : def.getAttributeDefs()) {
- AtlasAttributeDef converted = convertToJsonAndBack(registry, def, attrDef, compositeExpected[i]);
- Assert.assertEquals(converted, attrDef);
- }
- }
-
- List<HierarchicalTypeDefinition<ClassType>> convertedBackTypeDefs = convertV2toV1(convertedEntityDefs);
-
- for (int i = 0; i < typesToTest.size(); i++) {
-
- HierarchicalTypeDefinition<ClassType> convertedBack = convertedBackTypeDefs.get(i);
- Assert.assertEquals(convertedBack, typesToTest.get(i));
- AttributeDefinition[] attributeDefinitions = convertedBack.attributeDefinitions;
- if (attributeDefinitions.length > 0) {
- Assert.assertEquals(attributeDefinitions[0].isComposite, compositeExpected[i]);
- }
- }
-
- }
-
- private List<HierarchicalTypeDefinition<ClassType>> convertV2toV1(List<AtlasEntityDef> toConvert)
- throws AtlasBaseException {
-
- AtlasTypeRegistry reg = createRegistry(toConvert);
-
- List<HierarchicalTypeDefinition<ClassType>> result = new ArrayList<>(toConvert.size());
- for (int i = 0; i < toConvert.size(); i++) {
- AtlasEntityDef entityDef = toConvert.get(i);
- AtlasEntityType entity = reg.getEntityTypeByName(entityDef.getName());
- HierarchicalTypeDefinition<ClassType> converted = TypeConverterUtil.toTypesDef(entity, reg)
- .classTypesAsJavaList().get(0);
- result.add(converted);
- }
- return result;
- }
-
- private AtlasTypeRegistry createRegistry(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
- AtlasTypeRegistry reg = new AtlasTypeRegistry();
- AtlasTransientTypeRegistry tmp = reg.lockTypeRegistryForUpdate();
- tmp.addTypes(toConvert);
- reg.releaseTypeRegistryForUpdate(tmp, true);
- return reg;
- }
-
- private List<AtlasEntityDef> convertV1toV2(List<HierarchicalTypeDefinition<ClassType>> types)
- throws AtlasBaseException {
-
- ImmutableList<HierarchicalTypeDefinition<ClassType>> classTypeList = ImmutableList
- .<HierarchicalTypeDefinition<ClassType>> builder().addAll(types).build();
-
- TypesDef toConvert = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition> of(),
- ImmutableList.<StructTypeDefinition> of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>> of(),
- classTypeList);
-
- String json = TypesSerialization.toJson(toConvert);
- AtlasTypeRegistry emptyRegistry = new AtlasTypeRegistry();
- AtlasTypesDef converted = TypeConverterUtil.toAtlasTypesDef(json, emptyRegistry);
- List<AtlasEntityDef> convertedEntityDefs = converted.getEntityDefs();
- return convertedEntityDefs;
- }
-}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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/0877e47c/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/0877e47c/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/0877e47c/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..b017c4e 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
@@ -32,25 +32,20 @@ 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.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.model.v1.typedef.*;
+import org.apache.atlas.model.v1.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.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.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker;
@@ -172,47 +167,44 @@ public abstract class BaseResourceIT {
protected List<String> createType(TypesDef typesDef) throws Exception {
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 {
@@ -231,19 +223,19 @@ public abstract class BaseResourceIT {
protected TypesDef getTypesDef(ImmutableList<EnumTypeDefinition> enums,
ImmutableList<StructTypeDefinition> structs,
- ImmutableList<HierarchicalTypeDefinition<TraitType>> traits,
- ImmutableList<HierarchicalTypeDefinition<ClassType>> classes){
+ ImmutableList<TraitTypeDefinition> traits,
+ ImmutableList<ClassTypeDefinition> classes){
enums = (enums != null) ? enums : ImmutableList
.<EnumTypeDefinition>of();
structs =
(structs != null) ? structs : ImmutableList.<StructTypeDefinition>of();
traits = (traits != null) ? traits : ImmutableList
- .<HierarchicalTypeDefinition<TraitType>>of();
+ .<TraitTypeDefinition>of();
classes = (classes != null) ? classes : ImmutableList
- .<HierarchicalTypeDefinition<ClassType>>of();
- return TypesUtil.getTypesDef(enums, structs, traits, classes);
+ .<ClassTypeDefinition>of();
+ return new TypesDef(enums, structs, traits, classes);
}
@@ -294,72 +286,72 @@ public abstract class BaseResourceIT {
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, ImmutableSet.of("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());
+ ClassTypeDefinition loadProcessClsDef = TypesUtil
+ .createClassTypeDef(HIVE_PROCESS_TYPE, null, ImmutableSet.of("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, ImmutableSet.<String>of(),
+ TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TraitTypeDefinition piiTrait =
+ TypesUtil.createTraitTypeDef(PII_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition phiTrait =
+ TypesUtil.createTraitTypeDef(PHI_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition pciTrait =
+ TypesUtil.createTraitTypeDef(PCI_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition soxTrait =
+ TypesUtil.createTraitTypeDef(SOX_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition secTrait =
+ TypesUtil.createTraitTypeDef(SEC_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition financeTrait =
+ TypesUtil.createTraitTypeDef(FINANCE_TAG, null, ImmutableSet.<String>of());
+ TraitTypeDefinition factTrait =
+ TypesUtil.createTraitTypeDef("Fact" + randomString(), null, ImmutableSet.<String>of());
+ TraitTypeDefinition etlTrait =
+ TypesUtil.createTraitTypeDef("ETL" + randomString(), null, ImmutableSet.<String>of());
+ TraitTypeDefinition dimensionTrait =
+ TypesUtil.createTraitTypeDef("Dimension" + randomString(), null, ImmutableSet.<String>of());
+ TraitTypeDefinition metricTrait =
+ TypesUtil.createTraitTypeDef("Metric" + randomString(), null, ImmutableSet.<String>of());
createType(getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition),
ImmutableList.of(classificationTrait, piiTrait, phiTrait, pciTrait,
@@ -385,7 +377,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))
@@ -421,7 +413,7 @@ 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"));
@@ -461,19 +453,19 @@ public abstract class BaseResourceIT {
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,
+ 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() {
@@ -516,7 +508,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;
@@ -636,7 +628,7 @@ public abstract class BaseResourceIT {
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 TypesUtil.Pair<EntityNotification, String> pair = TypesUtil.Pair.of(null, null);
final long maxCurrentTime = System.currentTimeMillis() + maxWait;
waitFor(maxWait, new Predicate() {
@Override
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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..a60ab95 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
@@ -22,12 +22,11 @@ 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.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.model.v1.typedef.TraitTypeDefinition;
+import org.apache.atlas.type.AtlasType;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
@@ -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,14 +186,14 @@ 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());
+ TraitTypeDefinition factTrait =
+ TypesUtil.createTraitTypeDef(FACT, null, ImmutableSet.<String>of());
+ TraitTypeDefinition etlTrait =
+ TypesUtil.createTraitTypeDef(ETL, null, ImmutableSet.<String>of());
+ TraitTypeDefinition dimensionTrait =
+ TypesUtil.createTraitTypeDef(DIMENSION, null, ImmutableSet.<String>of());
+ TraitTypeDefinition metricTrait =
+ TypesUtil.createTraitTypeDef(METRIC, null, ImmutableSet.<String>of());
createType(getTypesDef(null, null,
ImmutableList.of(factTrait, etlTrait, dimensionTrait, metricTrait), null));
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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..9b30767 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
@@ -27,13 +27,8 @@ 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.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.model.v1.typedef.*;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -196,15 +191,15 @@ 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(),
+ ClassTypeDefinition dslTestTypeDefinition = TypesUtil
+ .createClassTypeDef("dsl_test_type", null, ImmutableSet.<String>of(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+
+ TraitTypeDefinition classificationTraitDefinition = TypesUtil
+ .createTraitTypeDef("Classification", null, ImmutableSet.<String>of(),
+ TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typesDef = new TypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
createType(typesDef);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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..a21152e 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
@@ -27,21 +27,13 @@ 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.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.model.v1.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.type.AtlasType;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.lang.RandomStringUtils;
@@ -193,7 +185,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,22 +236,22 @@ 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, ImmutableSet.<String>of(),
+ 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(),
+ typeDefinition = TypesUtil.createClassTypeDef(typeDefinition.getTypeName(), null, ImmutableSet.<String>of(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createOptionalAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typeDef = new TypesDef(ImmutableList.<EnumTypeDefinition>of(),
+ ImmutableList.<StructTypeDefinition>of(), ImmutableList.<TraitTypeDefinition>of(),
ImmutableList.of(typeDefinition));
atlasClientV1.updateType(typeDef);
@@ -537,12 +529,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, ImmutableSet.<String>of(),
+ 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 +577,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, ImmutableSet.<String>of());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -614,9 +606,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, ImmutableSet.<String>of());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -648,9 +640,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, ImmutableSet.<String>of());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -682,10 +674,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, ImmutableSet.<String>of(),
+ TypesUtil.createRequiredAttrDef("type", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -705,13 +697,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, ImmutableSet.<String>of());
+ 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 +726,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, ImmutableSet.<String>of());
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
@@ -794,10 +786,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, ImmutableSet.<String>of(),
+ TypesUtil.createRequiredAttrDef("type", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
createType(traitDefinitionAsJSON);
try {
@@ -821,11 +813,11 @@ 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(),
+ ClassTypeDefinition classTypeDefinition = TypesUtil
+ .createClassTypeDef(classType, null, ImmutableSet.<String>of(),
+ TypesUtil.createUniqueRequiredAttrDef(attrName, AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typesDef = new TypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
+ ImmutableList.<TraitTypeDefinition>of(),
ImmutableList.of(classTypeDefinition));
createType(typesDef);
@@ -834,7 +826,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 +874,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/0877e47c/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..ed29e08 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
@@ -25,8 +25,8 @@ 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.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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..aceed9c 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
@@ -25,7 +25,6 @@ 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 +36,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.typesystem.types.utils.TypesUtil;
import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.joda.time.DateTime;
@@ -83,7 +79,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);
@@ -419,10 +415,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 {
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java
index a13f069..f0c4487 100755
--- a/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java
@@ -24,16 +24,11 @@ import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.core.util.MultivaluedMapImpl;
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.TypesDef;
-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.model.typedef.AtlasBaseTypeDef;
+import org.apache.atlas.model.v1.instance.Id;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.model.v1.typedef.*;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
@@ -236,15 +231,15 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
private void createTypes() throws Exception {
createTypeDefinitionsV1();
- HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil
- .createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(),
- TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
- TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
+ ClassTypeDefinition dslTestTypeDefinition = TypesUtil
+ .createClassTypeDef("dsl_test_type", null, ImmutableSet.<String>of(),
+ TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING),
+ TypesUtil.createRequiredAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
- 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(),
+ TraitTypeDefinition classificationTraitDefinition = TypesUtil
+ .createTraitTypeDef("Classification", null, ImmutableSet.<String>of(),
+ TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
+ TypesDef typesDef = new TypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
createType(typesDef);
}
@@ -259,7 +254,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
tagName = randomString();
traitInstance.set("tag", tagName);
- List<String> traits = entityInstance.getTraits();
+ List<String> traits = entityInstance.getTraitNames();
assertEquals(traits.size(), 1);
return createInstance(entityInstance);
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
index c46689c..d31c9af 100644
--- a/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
@@ -33,7 +33,6 @@ import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.type.AtlasTypeUtil;
-import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@@ -306,10 +305,10 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
createClassTypeDef("table", ImmutableSet.<String>of(),
AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"),
AtlasTypeUtil.createRequiredAttrDef("description", "string"),
- AtlasTypeUtil.createOptionalAttrDef("columnNames", DataTypes.arrayTypeName("string")),
+ AtlasTypeUtil.createOptionalAttrDef("columnNames", AtlasBaseTypeDef.getArrayTypeName("string")),
AtlasTypeUtil.createOptionalAttrDef("created", "date"),
AtlasTypeUtil.createOptionalAttrDef("parameters",
- DataTypes.mapTypeName("string", "string")),
+ AtlasBaseTypeDef.getMapTypeName("string", "string")),
AtlasTypeUtil.createRequiredAttrDef("type", "string"),
new AtlasAttributeDef("database", "database",
false,