Search in sources :

Example 91 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class NotificationHookConsumerKafkaTest method createEntity.

Referenceable createEntity() {
    final Referenceable entity = new Referenceable(AtlasClient.DATA_SET_SUPER_TYPE);
    entity.set(NAME, "db" + randomString());
    entity.set(DESCRIPTION, randomString());
    entity.set(QUALIFIED_NAME, randomString());
    return entity;
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable)

Example 92 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class NotificationHookConsumerTest method testCommitIsCalledWhenMessageIsProcessed.

@Test
public void testCommitIsCalledWhenMessageIsProcessed() throws AtlasServiceException, AtlasException {
    NotificationHookConsumer notificationHookConsumer = new NotificationHookConsumer(notificationInterface, atlasEntityStore, serviceState, instanceConverter, typeRegistry);
    NotificationConsumer consumer = mock(NotificationConsumer.class);
    NotificationHookConsumer.HookConsumer hookConsumer = notificationHookConsumer.new HookConsumer(consumer);
    HookNotification.EntityCreateRequest message = mock(HookNotification.EntityCreateRequest.class);
    when(message.getUser()).thenReturn("user");
    when(message.getType()).thenReturn(HookNotification.HookNotificationType.ENTITY_CREATE);
    Referenceable mock = mock(Referenceable.class);
    when(message.getEntities()).thenReturn(Arrays.asList(mock));
    hookConsumer.handleMessage(message);
    verify(consumer).commit();
}
Also used : HookNotification(org.apache.atlas.notification.hook.HookNotification) Referenceable(org.apache.atlas.typesystem.Referenceable) Test(org.testng.annotations.Test)

Example 93 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class NotificationHookConsumerIT method testUpdateEntityFullUpdate.

@Test
public void testUpdateEntityFullUpdate() throws Exception {
    Referenceable entity = new Referenceable(DATABASE_TYPE_BUILTIN);
    final String dbName = "db" + randomString();
    entity.set(NAME, dbName);
    entity.set(DESCRIPTION, randomString());
    entity.set(QUALIFIED_NAME, dbName);
    entity.set(CLUSTER_NAME, randomString());
    atlasClientV1.createEntity(entity);
    final Referenceable newEntity = new Referenceable(DATABASE_TYPE_BUILTIN);
    newEntity.set(NAME, randomString());
    newEntity.set(DESCRIPTION, randomString());
    newEntity.set("owner", randomString());
    newEntity.set(QUALIFIED_NAME, dbName);
    newEntity.set(CLUSTER_NAME, randomString());
    //updating unique attribute
    sendHookMessage(new HookNotification.EntityUpdateRequest(TEST_USER, newEntity));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE_BUILTIN, newEntity.get(QUALIFIED_NAME)));
            return results.length() == 1;
        }
    });
    Referenceable actualEntity = atlasClientV1.getEntity(DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName);
    assertEquals(actualEntity.get(DESCRIPTION), newEntity.get(DESCRIPTION));
    assertEquals(actualEntity.get("owner"), newEntity.get("owner"));
}
Also used : HookNotification(org.apache.atlas.notification.hook.HookNotification) Referenceable(org.apache.atlas.typesystem.Referenceable) JSONArray(org.codehaus.jettison.json.JSONArray) Test(org.testng.annotations.Test)

Example 94 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class NotificationHookConsumerIT method testUpdatePartialUpdatingQualifiedName.

@Test
public void testUpdatePartialUpdatingQualifiedName() throws Exception {
    final Referenceable entity = new Referenceable(DATABASE_TYPE_BUILTIN);
    final String dbName = "db" + randomString();
    entity.set(NAME, dbName);
    entity.set(DESCRIPTION, randomString());
    entity.set(QUALIFIED_NAME, dbName);
    entity.set(CLUSTER_NAME, randomString());
    atlasClientV1.createEntity(entity);
    final Referenceable newEntity = new Referenceable(DATABASE_TYPE_BUILTIN);
    final String newName = "db" + randomString();
    newEntity.set(QUALIFIED_NAME, newName);
    sendHookMessage(new HookNotification.EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName, newEntity));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE_BUILTIN, newName));
            return results.length() == 1;
        }
    });
    //no entity with the old qualified name
    JSONArray results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE_BUILTIN, dbName));
    assertEquals(results.length(), 0);
}
Also used : HookNotification(org.apache.atlas.notification.hook.HookNotification) Referenceable(org.apache.atlas.typesystem.Referenceable) JSONArray(org.codehaus.jettison.json.JSONArray) Test(org.testng.annotations.Test)

Example 95 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class BaseResourceIT method createHiveDBInstanceBuiltIn.

protected Referenceable createHiveDBInstanceBuiltIn(String dbName) {
    Referenceable databaseInstance = new Referenceable(DATABASE_TYPE_BUILTIN);
    databaseInstance.set(NAME, dbName);
    databaseInstance.set(QUALIFIED_NAME, dbName);
    databaseInstance.set(CLUSTER_NAME, randomString());
    databaseInstance.set(DESCRIPTION, "foo database");
    return databaseInstance;
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable)

Aggregations

Referenceable (org.apache.atlas.typesystem.Referenceable)235 Test (org.testng.annotations.Test)114 Id (org.apache.atlas.typesystem.persistence.Id)50 ArrayList (java.util.ArrayList)45 List (java.util.List)25 Struct (org.apache.atlas.typesystem.Struct)25 HashMap (java.util.HashMap)24 BeforeTest (org.testng.annotations.BeforeTest)24 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)22 AfterTest (org.testng.annotations.AfterTest)22 HookNotification (org.apache.atlas.notification.hook.HookNotification)20 IStruct (org.apache.atlas.typesystem.IStruct)18 ClassType (org.apache.atlas.typesystem.types.ClassType)16 JSONObject (org.codehaus.jettison.json.JSONObject)16 ImmutableList (com.google.common.collect.ImmutableList)15 AtlasServiceException (org.apache.atlas.AtlasServiceException)14 TraitType (org.apache.atlas.typesystem.types.TraitType)12 WriteEntity (org.apache.hadoop.hive.ql.hooks.WriteEntity)12 Date (java.util.Date)11 AtlasException (org.apache.atlas.AtlasException)11