Repository: atlas Updated Branches: refs/heads/ATLAS-2251 3f44770da -> 64e739da7
http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java ---------------------------------------------------------------------- diff --git a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java deleted file mode 100644 index 81a0784..0000000 --- a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java +++ /dev/null @@ -1,147 +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.notification.entity; - -import org.apache.atlas.v1.model.instance.Referenceable; -import org.apache.atlas.v1.model.instance.Struct; -import org.apache.atlas.type.AtlasClassificationType; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.testng.annotations.Test; - -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -/** - * EntityNotificationImpl tests. - */ -public class EntityNotificationImplTest { - - @Test - public void testGetEntity() throws Exception { - Referenceable entity = getEntity("id"); - - EntityNotificationImpl entityNotification = - new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, - Collections.<Struct>emptyList()); - - assertEquals(entity, entityNotification.getEntity()); - } - - @Test - public void testGetOperationType() throws Exception { - Referenceable entity = getEntity("id"); - - EntityNotificationImpl entityNotification = - new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, - Collections.<Struct>emptyList()); - - assertEquals(EntityNotification.OperationType.ENTITY_CREATE, entityNotification.getOperationType()); - } - - @Test - public void testGetAllTraits() throws Exception { - Referenceable entity = getEntity("id"); - String traitName = "MyTrait"; - List<Struct> traitInfo = new LinkedList<>(); - Struct trait = new Struct(traitName, Collections.<String, Object>emptyMap()); - traitInfo.add(trait); - - EntityNotificationImpl entityNotification = - new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, traitInfo); - - assertEquals(traitInfo, entityNotification.getAllTraits()); - } - - @Test - public void testGetAllTraitsSuperTraits() throws Exception { - AtlasTypeRegistry typeRegistry = mock(AtlasTypeRegistry.class); - - String traitName = "MyTrait"; - Struct myTrait = new Struct(traitName); - - String superTraitName = "MySuperTrait"; - - AtlasClassificationType traitType = mock(AtlasClassificationType.class); - Set<String> superTypeNames = Collections.singleton(superTraitName); - - AtlasClassificationType superTraitType = mock(AtlasClassificationType.class); - Set<String> superSuperTypeNames = Collections.emptySet(); - - Referenceable entity = getEntity("id", myTrait); - - when(typeRegistry.getClassificationTypeByName(traitName)).thenReturn(traitType); - when(typeRegistry.getClassificationTypeByName(superTraitName)).thenReturn(superTraitType); - - when(traitType.getAllSuperTypes()).thenReturn(superTypeNames); - when(superTraitType.getAllSuperTypes()).thenReturn(superSuperTypeNames); - - EntityNotificationImpl entityNotification = - new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, typeRegistry); - - List<Struct> allTraits = entityNotification.getAllTraits(); - - assertEquals(2, allTraits.size()); - - for (Struct trait : allTraits) { - String typeName = trait.getTypeName(); - assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName)); - } - } - - @Test - public void testEquals() throws Exception { - Referenceable entity = getEntity("id"); - - EntityNotificationImpl entityNotification2 = - new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, - Collections.<Struct>emptyList()); - - EntityNotificationImpl entityNotification = - new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE, - Collections.<Struct>emptyList()); - - assertTrue(entityNotification.equals(entityNotification2)); - assertTrue(entityNotification2.equals(entityNotification)); - } - - public static Referenceable getEntity(String id, Struct... traits) { - String typeName = "typeName"; - Map<String, Object> values = new HashMap<>(); - - List<String> traitNames = new LinkedList<>(); - Map<String, Struct> traitMap = new HashMap<>(); - - for (Struct trait : traits) { - String traitName = trait.getTypeName(); - - traitNames.add(traitName); - traitMap.put(traitName, trait); - } - return new Referenceable(id, typeName, values, traitNames, traitMap); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationTest.java ---------------------------------------------------------------------- diff --git a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationTest.java b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationTest.java new file mode 100644 index 0000000..cedfc01 --- /dev/null +++ b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationTest.java @@ -0,0 +1,148 @@ +/** + * 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.notification.entity; + +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.instance.Struct; +import org.apache.atlas.type.AtlasClassificationType; +import org.apache.atlas.type.AtlasTypeRegistry; +import org.apache.atlas.v1.model.notification.EntityNotification; +import org.testng.annotations.Test; + +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * EntityNotification tests. + */ +public class EntityNotificationTest { + + @Test + public void testGetEntity() throws Exception { + Referenceable entity = getEntity("id"); + + EntityNotification entityNotification = + new EntityNotification(entity, EntityNotification.OperationType.ENTITY_CREATE, + Collections.<Struct>emptyList()); + + assertEquals(entity, entityNotification.getEntity()); + } + + @Test + public void testGetOperationType() throws Exception { + Referenceable entity = getEntity("id"); + + EntityNotification entityNotification = + new EntityNotification(entity, EntityNotification.OperationType.ENTITY_CREATE, + Collections.<Struct>emptyList()); + + assertEquals(EntityNotification.OperationType.ENTITY_CREATE, entityNotification.getOperationType()); + } + + @Test + public void testGetAllTraits() throws Exception { + Referenceable entity = getEntity("id"); + String traitName = "MyTrait"; + List<Struct> traitInfo = new LinkedList<>(); + Struct trait = new Struct(traitName, Collections.<String, Object>emptyMap()); + traitInfo.add(trait); + + EntityNotification entityNotification = + new EntityNotification(entity, EntityNotification.OperationType.TRAIT_ADD, traitInfo); + + assertEquals(traitInfo, entityNotification.getAllTraits()); + } + + @Test + public void testGetAllTraitsSuperTraits() throws Exception { + AtlasTypeRegistry typeRegistry = mock(AtlasTypeRegistry.class); + + String traitName = "MyTrait"; + Struct myTrait = new Struct(traitName); + + String superTraitName = "MySuperTrait"; + + AtlasClassificationType traitType = mock(AtlasClassificationType.class); + Set<String> superTypeNames = Collections.singleton(superTraitName); + + AtlasClassificationType superTraitType = mock(AtlasClassificationType.class); + Set<String> superSuperTypeNames = Collections.emptySet(); + + Referenceable entity = getEntity("id", myTrait); + + when(typeRegistry.getClassificationTypeByName(traitName)).thenReturn(traitType); + when(typeRegistry.getClassificationTypeByName(superTraitName)).thenReturn(superTraitType); + + when(traitType.getAllSuperTypes()).thenReturn(superTypeNames); + when(superTraitType.getAllSuperTypes()).thenReturn(superSuperTypeNames); + + EntityNotification entityNotification = + new EntityNotification(entity, EntityNotification.OperationType.TRAIT_ADD, typeRegistry); + + List<Struct> allTraits = entityNotification.getAllTraits(); + + assertEquals(2, allTraits.size()); + + for (Struct trait : allTraits) { + String typeName = trait.getTypeName(); + assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName)); + } + } + + @Test + public void testEquals() throws Exception { + Referenceable entity = getEntity("id"); + + EntityNotification entityNotification2 = + new EntityNotification(entity, EntityNotification.OperationType.ENTITY_CREATE, + Collections.<Struct>emptyList()); + + EntityNotification entityNotification = + new EntityNotification(entity, EntityNotification.OperationType.ENTITY_CREATE, + Collections.<Struct>emptyList()); + + assertTrue(entityNotification.equals(entityNotification2)); + assertTrue(entityNotification2.equals(entityNotification)); + } + + public static Referenceable getEntity(String id, Struct... traits) { + String typeName = "typeName"; + Map<String, Object> values = new HashMap<>(); + + List<String> traitNames = new LinkedList<>(); + Map<String, Struct> traitMap = new HashMap<>(); + + for (Struct trait : traits) { + String traitName = trait.getTypeName(); + + traitNames.add(traitName); + traitMap.put(traitName, trait); + } + return new Referenceable(id, typeName, values, traitNames, traitMap); + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/notification/src/test/java/org/apache/atlas/notification/hook/HookMessageDeserializerTest.java ---------------------------------------------------------------------- diff --git a/notification/src/test/java/org/apache/atlas/notification/hook/HookMessageDeserializerTest.java b/notification/src/test/java/org/apache/atlas/notification/hook/HookMessageDeserializerTest.java index 758abad..17facf8 100644 --- a/notification/src/test/java/org/apache/atlas/notification/hook/HookMessageDeserializerTest.java +++ b/notification/src/test/java/org/apache/atlas/notification/hook/HookMessageDeserializerTest.java @@ -18,12 +18,12 @@ package org.apache.atlas.notification.hook; +import org.apache.atlas.notification.entity.EntityNotificationTest; import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.v1.model.instance.Struct; import org.apache.atlas.notification.AbstractNotification; -import org.apache.atlas.notification.entity.EntityNotificationImplTest; -import org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequest; -import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage; +import org.apache.atlas.v1.model.notification.HookNotification.EntityUpdateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.HookNotificationMessage; import org.apache.atlas.type.AtlasType; import org.apache.commons.lang3.RandomStringUtils; import org.testng.annotations.Test; @@ -40,7 +40,7 @@ import static org.testng.Assert.assertTrue; * HookMessageDeserializer tests. */ public class HookMessageDeserializerTest { - HookMessageDeserializer deserializer = new HookMessageDeserializer(); + private HookMessageDeserializer deserializer = new HookMessageDeserializer(); @Test public void testDeserialize() throws Exception { @@ -63,7 +63,7 @@ public class HookMessageDeserializerTest { EntityUpdateRequest message = new EntityUpdateRequest("user1", entity); String jsonMsg = AtlasType.toV1Json(message); - HookNotificationMessage deserializedMessage = deserializer.deserialize(jsonMsg); + HookNotificationMessage deserializedMessage = deserialize(Collections.singletonList(jsonMsg)); assertEqualMessage(deserializedMessage, message); } @@ -106,7 +106,7 @@ public class HookMessageDeserializerTest { } private Referenceable generateEntityWithTrait() { - Referenceable ret = EntityNotificationImplTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); + Referenceable ret = EntityNotificationTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); return ret; } @@ -145,7 +145,7 @@ public class HookMessageDeserializerTest { } private Referenceable generateLargeEntityWithTrait() { - Referenceable ret = EntityNotificationImplTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); + Referenceable ret = EntityNotificationTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); // add 100 attributes, each with value of size 10k // Json Size=1,027,984; GZipped Size=16,387 ==> will compress, but not split @@ -158,7 +158,7 @@ public class HookMessageDeserializerTest { } private Referenceable generateVeryLargeEntityWithTrait() { - Referenceable ret = EntityNotificationImplTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); + Referenceable ret = EntityNotificationTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap())); // add 300 attributes, each with value of size 10k // Json Size=3,082,384; GZipped Size=2,313,357 ==> will compress & split http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java ---------------------------------------------------------------------- diff --git a/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java b/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java index 9ea688c..ec2218c 100644 --- a/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java +++ b/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java @@ -19,6 +19,7 @@ package org.apache.atlas.notification.hook; import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.type.AtlasType; +import org.apache.atlas.v1.model.notification.HookNotification; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; @@ -26,8 +27,6 @@ import static org.testng.Assert.assertNull; public class HookNotificationTest { - public static final HookMessageDeserializer HOOK_MESSAGE_DESERIALIZER = new HookMessageDeserializer(); - @Test public void testNewMessageSerDe() throws Exception { Referenceable entity1 = new Referenceable("sometype"); @@ -38,8 +37,7 @@ public class HookNotificationTest { HookNotification.EntityCreateRequest request = new HookNotification.EntityCreateRequest(user, entity1, entity2); String notificationJson = AtlasType.toV1Json(request); - HookNotification.HookNotificationMessage actualNotification = - HOOK_MESSAGE_DESERIALIZER.deserialize(notificationJson); + HookNotification.HookNotificationMessage actualNotification = AtlasType.fromV1Json(notificationJson, HookNotification.HookNotificationMessage.class); assertEquals(actualNotification.getType(), HookNotification.HookNotificationType.ENTITY_CREATE); assertEquals(actualNotification.getUser(), user); @@ -49,7 +47,9 @@ public class HookNotificationTest { Referenceable actualEntity1 = createRequest.getEntities().get(0); assertEquals(actualEntity1.getTypeName(), "sometype"); + /* TODO: assertEquals(((Referenceable)actualEntity1.get("complex")).getTypeName(), "othertype"); + */ assertEquals(createRequest.getEntities().get(1).getTypeName(), "newtype"); } @@ -87,11 +87,9 @@ public class HookNotificationTest { + "}"; - HookNotification.HookNotificationMessage actualNotification = - HOOK_MESSAGE_DESERIALIZER.deserialize(notificationJson); + HookNotification.HookNotificationMessage actualNotification = AtlasType.fromV1Json(notificationJson, HookNotification.HookNotificationMessage.class); assertEquals(actualNotification.getType(), HookNotification.HookNotificationType.ENTITY_CREATE); - assertNull(actualNotification.user); assertEquals(actualNotification.getUser(), HookNotification.HookNotificationMessage.UNKNOW_USER); } } http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/repository/src/test/java/org/apache/atlas/DBSandboxer.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/DBSandboxer.java b/repository/src/test/java/org/apache/atlas/DBSandboxer.java new file mode 100644 index 0000000..f4f099a --- /dev/null +++ b/repository/src/test/java/org/apache/atlas/DBSandboxer.java @@ -0,0 +1,53 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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; + +import org.apache.atlas.graph.GraphSandboxUtil; +import org.apache.atlas.repository.graph.AtlasGraphProvider; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.testng.ITestContext; +import org.testng.TestListenerAdapter; +import org.testng.xml.XmlClass; + +import java.util.List; + +public class DBSandboxer extends TestListenerAdapter { + @Override + public void onStart(ITestContext context) { + // This will only work if each test is run individually (test suite has only one running test) + // If there are multiple tests the the sandbox folder name is not provided and the GraphSandboxUtil provisions + // a unique name + List<XmlClass> testClassesToRun = context.getCurrentXmlTest().getClasses(); + if (CollectionUtils.isNotEmpty(testClassesToRun) && 1 == testClassesToRun.size()) { + XmlClass currentTestClass = testClassesToRun.get(0); + if (null != currentTestClass && StringUtils.isNotEmpty(currentTestClass.getName())) { + GraphSandboxUtil.create(currentTestClass.getName()); + } else { + GraphSandboxUtil.create(); + } + } else { + GraphSandboxUtil.create(); + } + } + + @Override + public void onFinish(ITestContext context) { + AtlasGraphProvider.cleanup(); + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java index 8f374b9..acbc996 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -23,8 +23,7 @@ import org.apache.atlas.AtlasException; import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.atlas.v1.model.instance.Struct; -import org.apache.atlas.notification.entity.EntityNotification; -import org.apache.atlas.notification.entity.EntityNotificationImpl; +import org.apache.atlas.v1.model.notification.EntityNotification; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasTypeRegistry; @@ -41,13 +40,13 @@ import java.util.*; */ @Component public class NotificationEntityChangeListener implements EntityChangeListener { + private static final String ATLAS_ENTITY_NOTIFICATION_PROPERTY = "atlas.notification.entity"; - private final NotificationInterface notificationInterface; - private final AtlasTypeRegistry typeRegistry; + private final NotificationInterface notificationInterface; + private final AtlasTypeRegistry typeRegistry; + private final Map<String, List<String>> notificationAttributesCache = new HashMap<>(); - private Map<String, List<String>> notificationAttributesCache = new HashMap<>(); - private static final String ATLAS_ENTITY_NOTIFICATION_PROPERTY = "atlas.notification.entity"; - static Configuration APPLICATION_PROPERTIES = null; + private static Configuration APPLICATION_PROPERTIES = null; @@ -122,11 +121,17 @@ public class NotificationEntityChangeListener implements EntityChangeListener { AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName); if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) { - Map<String, Object> attributes = new HashMap<>(); + Map<String, Object> superTypeTraitAttributes = new HashMap<>(); + + for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) { + String attrName = attrEntry.getKey(); - // TODO: add superTypeTrait attributess + if (superType.getAllAttributes().containsKey(attrName)) { + superTypeTraitAttributes.put(attrName, attrEntry.getValue()); + } + } - superTypeTrait.setValues(attributes); + superTypeTrait.setValues(superTypeTraitAttributes); } } @@ -160,7 +165,7 @@ public class NotificationEntityChangeListener implements EntityChangeListener { } } - EntityNotificationImpl notification = new EntityNotificationImpl(entity, operationType, getAllTraits(entity, typeRegistry)); + EntityNotification notification = new EntityNotification(entity, operationType, getAllTraits(entity, typeRegistry)); messages.add(notification); } http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java index 463a587..779298a 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java @@ -31,11 +31,11 @@ import org.apache.atlas.kafka.AtlasKafkaMessage; import org.apache.atlas.listener.ActiveStateChangeHandler; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.v1.model.instance.Referenceable; -import org.apache.atlas.notification.hook.HookNotification.EntityCreateRequest; -import org.apache.atlas.notification.hook.HookNotification.EntityDeleteRequest; -import org.apache.atlas.notification.hook.HookNotification.EntityPartialUpdateRequest; -import org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequest; -import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage; +import org.apache.atlas.v1.model.notification.HookNotification.EntityCreateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityDeleteRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityPartialUpdateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityUpdateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.HookNotificationMessage; import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; @@ -362,7 +362,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl audit(messageUser, api.getMethod(), api.getNormalizedPath()); } - // TODO: entities = instanceConverter.toAtlasEntities(createRequest.getEntities()); + entities = instanceConverter.toAtlasEntities(createRequest.getEntities()); atlasEntityStore.createOrUpdate(new AtlasEntityStream(entities), false); break; @@ -377,7 +377,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl } Referenceable referenceable = partialUpdateRequest.getEntity(); - // TODO: entities = instanceConverter.toAtlasEntity(referenceable); + entities = instanceConverter.toAtlasEntity(referenceable); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(partialUpdateRequest.getTypeName()); String guid = AtlasGraphUtilsV1.getGuidByUniqueAttributes(entityType, new HashMap<String, Object>() { @@ -420,7 +420,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl audit(messageUser, api.getMethod(), api.getNormalizedPath()); } - // TODO: entities = instanceConverter.toAtlasEntities(updateRequest.getEntities()); + entities = instanceConverter.toAtlasEntities(updateRequest.getEntities()); atlasEntityStore.createOrUpdate(new AtlasEntityStream(entities), false); break; http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/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 9f25b15..517d25f 100644 --- a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java +++ b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java @@ -25,7 +25,7 @@ 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.notification.entity.EntityNotification; +import org.apache.atlas.v1.model.notification.EntityNotification; import org.apache.atlas.type.AtlasType; import org.apache.atlas.v1.typesystem.types.utils.TypesUtil; import org.apache.atlas.web.integration.BaseResourceIT; http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/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 d77014a..1f045e4 100644 --- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java +++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java @@ -22,12 +22,12 @@ import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.kafka.NotificationProvider; import org.apache.atlas.v1.model.instance.Id; import org.apache.atlas.v1.model.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.v1.model.notification.HookNotification; +import org.apache.atlas.v1.model.notification.HookNotification.HookNotificationMessage; +import org.apache.atlas.v1.model.notification.HookNotification.EntityDeleteRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityPartialUpdateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityCreateRequest; +import org.apache.atlas.v1.model.notification.HookNotification.EntityUpdateRequest; 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/64e739da/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 25161f5..68497e0 100644 --- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java +++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java @@ -27,7 +27,7 @@ import org.apache.atlas.kafka.KafkaNotification; import org.apache.atlas.kafka.NotificationProvider; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.v1.model.instance.Referenceable; -import org.apache.atlas.notification.hook.HookNotification; +import org.apache.atlas.v1.model.notification.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; @@ -41,7 +41,7 @@ import org.testng.Assert; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import static org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage; +import static org.apache.atlas.v1.model.notification.HookNotification.HookNotificationMessage; import java.util.List; import org.apache.atlas.kafka.AtlasKafkaConsumer; http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/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 6b13915..2d3d5ba 100644 --- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java +++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java @@ -25,7 +25,7 @@ import org.apache.atlas.kafka.AtlasKafkaMessage; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.v1.model.instance.Referenceable; -import org.apache.atlas.notification.hook.HookNotification; +import org.apache.atlas.v1.model.notification.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; http://git-wip-us.apache.org/repos/asf/atlas/blob/64e739da/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 4360a69..e63099d 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 @@ -43,7 +43,7 @@ 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.v1.model.notification.EntityNotification; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;