Search in sources :

Example 61 with Id

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

the class EntityNotificationTest method testGetEntity.

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

Example 62 with Id

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

the class EntityNotificationTest method getEntity.

public static Referenceable getEntity(String id, Struct... traits) {
    String typeName = "typeName";
    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, new HashMap<String, Object>(), traitNames, traitMap);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 63 with Id

use of org.apache.atlas.v1.model.instance.Id 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 64 with Id

use of org.apache.atlas.v1.model.instance.Id 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 65 with Id

use of org.apache.atlas.v1.model.instance.Id 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)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)62 Test (org.testng.annotations.Test)39 Id (org.apache.atlas.v1.model.instance.Id)38 Struct (org.apache.atlas.v1.model.instance.Struct)15 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)11 List (java.util.List)7 AtlasException (org.apache.atlas.AtlasException)6 AtlasServiceException (org.apache.atlas.AtlasServiceException)6 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)5 HashMap (java.util.HashMap)4 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)4 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)4 Feed (org.apache.falcon.entity.v0.feed.Feed)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Consumes (javax.ws.rs.Consumes)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3