Search in sources :

Example 36 with Struct

use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.

the class EntityNotificationTest method testGetOperationType.

@Test
public void testGetOperationType() throws Exception {
    Referenceable entity = getEntity("id");
    EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
    assertEquals(EntityNotificationV1.OperationType.ENTITY_CREATE, entityNotification.getOperationType());
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Test(org.testng.annotations.Test)

Example 37 with Struct

use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.

the class EntityNotificationTest method testEquals.

@Test
public void testEquals() throws Exception {
    Referenceable entity = getEntity("id");
    EntityNotificationV1 entityNotification2 = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
    EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
    assertTrue(entityNotification.equals(entityNotification2));
    assertTrue(entityNotification2.equals(entityNotification));
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Test(org.testng.annotations.Test)

Example 38 with Struct

use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.

the class EntityNotificationTest method testGetAllTraitsSuperTraits.

@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);
    EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, 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));
    }
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasClassificationType(org.apache.atlas.type.AtlasClassificationType) Struct(org.apache.atlas.v1.model.instance.Struct) Test(org.testng.annotations.Test)

Example 39 with Struct

use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.

the class EntityNotificationTest method testGetAllTraits.

@Test
public void testGetAllTraits() throws Exception {
    Referenceable entity = getEntity("id");
    String traitName = "MyTrait";
    List<Struct> traitInfo = Collections.singletonList(new Struct(traitName, Collections.<String, Object>emptyMap()));
    EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.TRAIT_ADD, traitInfo);
    assertEquals(traitInfo, entityNotification.getAllTraits());
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Struct(org.apache.atlas.v1.model.instance.Struct) Test(org.testng.annotations.Test)

Aggregations

Struct (org.apache.atlas.v1.model.instance.Struct)36 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)22 Test (org.testng.annotations.Test)17 HashMap (java.util.HashMap)9 Map (java.util.Map)9 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)9 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 AtlasClassificationType (org.apache.atlas.type.AtlasClassificationType)6 Id (org.apache.atlas.v1.model.instance.Id)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)3 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 AtlasException (org.apache.atlas.AtlasException)2 AtlasServiceException (org.apache.atlas.AtlasServiceException)2 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)2 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)2 EntityChangeListenerV2 (org.apache.atlas.listener.EntityChangeListenerV2)2