Search in sources :

Example 6 with EntityNotificationV1

use of org.apache.atlas.v1.model.notification.EntityNotificationV1 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 7 with EntityNotificationV1

use of org.apache.atlas.v1.model.notification.EntityNotificationV1 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 8 with EntityNotificationV1

use of org.apache.atlas.v1.model.notification.EntityNotificationV1 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 9 with EntityNotificationV1

use of org.apache.atlas.v1.model.notification.EntityNotificationV1 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

EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)9 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)8 Test (org.testng.annotations.Test)6 Struct (org.apache.atlas.v1.model.instance.Struct)4 ArrayList (java.util.ArrayList)1 EntityNotification (org.apache.atlas.model.notification.EntityNotification)1 AtlasClassificationType (org.apache.atlas.type.AtlasClassificationType)1 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)1