Search in sources :

Example 1 with EntityPartialUpdateRequest

use of org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest in project atlas by apache.

the class NotificationHookConsumerIT method testUpdateEntityPartial.

@Test
public void testUpdateEntityPartial() 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);
    newEntity.set("owner", randomString());
    sendHookMessage(new EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName, newEntity));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            Referenceable localEntity = atlasClientV1.getEntity(DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName);
            return (localEntity.get("owner") != null && localEntity.get("owner").equals(newEntity.get("owner")));
        }
    });
    // Its partial update and un-set fields are not updated
    Referenceable actualEntity = atlasClientV1.getEntity(DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName);
    assertEquals(actualEntity.get(DESCRIPTION), entity.get(DESCRIPTION));
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityPartialUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest) Test(org.testng.annotations.Test)

Example 2 with EntityPartialUpdateRequest

use of org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest in project atlas by apache.

the class NotificationHookConsumerIT method testMessageHandleFailureConsumerContinues.

@Test
public void testMessageHandleFailureConsumerContinues() throws Exception {
    // send invalid message - update with invalid type
    sendHookMessage(new EntityPartialUpdateRequest(TEST_USER, randomString(), null, null, new Referenceable(randomString())));
    // send valid message
    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());
    sendHookMessage(new EntityCreateRequest(TEST_USER, entity));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            ArrayNode results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE_BUILTIN, entity.get(NAME)));
            return results.size() == 1;
        }
    });
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityPartialUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) Test(org.testng.annotations.Test)

Example 3 with EntityPartialUpdateRequest

use of org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest in project 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 EntityPartialUpdateRequest(TEST_USER, DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName, newEntity));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            ArrayNode results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE_BUILTIN, newName));
            return results.size() == 1;
        }
    });
    // no entity with the old qualified name
    ArrayNode results = searchByDSL(String.format("%s where qualifiedName='%s'", DATABASE_TYPE_BUILTIN, dbName));
    assertEquals(results.size(), 0);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityPartialUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.testng.annotations.Test)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)3 EntityPartialUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest)3 Test (org.testng.annotations.Test)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)1