Search in sources :

Example 31 with Referenceable

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

the class NotificationHookConsumerIT method testDeleteByQualifiedName.

@Test
public void testDeleteByQualifiedName() 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());
    final String dbId = atlasClientV1.createEntity(entity).get(0);
    sendHookMessage(new EntityDeleteRequest(TEST_USER, DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, dbName));
    waitFor(MAX_WAIT_TIME, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            Referenceable getEntity = atlasClientV1.getEntity(dbId);
            return getEntity.getId().getState() == Id.EntityState.DELETED;
        }
    });
}
Also used : EntityDeleteRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Test(org.testng.annotations.Test)

Example 32 with Referenceable

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

the class NotificationHookConsumerIT method testCreateEntity.

@Test
public void testCreateEntity() 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());
    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 qualifiedName='%s'", DATABASE_TYPE_BUILTIN, entity.get(QUALIFIED_NAME)));
            return results.size() == 1;
        }
    });
    // Assert that user passed in hook message is used in audit
    Referenceable instance = atlasClientV1.getEntity(DATABASE_TYPE_BUILTIN, QUALIFIED_NAME, (String) entity.get(QUALIFIED_NAME));
    List<EntityAuditEvent> events = atlasClientV1.getEntityAuditEvents(instance.getId()._getId(), (short) 1);
    assertEquals(events.size(), 1);
    assertEquals(events.get(0).getUser(), TEST_USER);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) Test(org.testng.annotations.Test)

Example 33 with Referenceable

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

the class QuickStartIT method testViewIsAdded.

@Test
public void testViewIsAdded() throws AtlasServiceException {
    Referenceable view = atlasClientV1.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);
    assertEquals(QuickStart.PRODUCT_DIM_VIEW, view.get(AtlasClient.NAME));
    Id productDimId = getTable(QuickStart.PRODUCT_DIM_TABLE).getId();
    Id inputTableId = ((List<Id>) view.get(QuickStart.INPUT_TABLES_ATTRIBUTE)).get(0);
    assertEquals(productDimId, inputTableId);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) List(java.util.List) Id(org.apache.atlas.v1.model.instance.Id) Test(org.testng.annotations.Test)

Example 34 with Referenceable

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

the class QuickStartIT method verifyDBIsLinkedToTable.

private void verifyDBIsLinkedToTable(Referenceable table) throws AtlasServiceException {
    Referenceable db = getDB(QuickStart.SALES_DB);
    assertEquals(db.getId(), table.get(QuickStart.DB_ATTRIBUTE));
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Example 35 with Referenceable

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

the class QuickStartIT method verifyColumnsAreAddedToTable.

private void verifyColumnsAreAddedToTable(Referenceable table) {
    List<Referenceable> columns = (List<Referenceable>) table.get(QuickStart.COLUMNS_ATTRIBUTE);
    assertEquals(4, columns.size());
    Referenceable column = columns.get(0);
    assertEquals(QuickStart.TIME_ID_COLUMN, column.get("name"));
    assertEquals("int", column.get("dataType"));
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) List(java.util.List)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)143 Test (org.testng.annotations.Test)64 Id (org.apache.atlas.v1.model.instance.Id)37 Struct (org.apache.atlas.v1.model.instance.Struct)23 ArrayList (java.util.ArrayList)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 HashMap (java.util.HashMap)12 List (java.util.List)10 AtlasException (org.apache.atlas.AtlasException)10 HookNotification (org.apache.atlas.model.notification.HookNotification)10 Map (java.util.Map)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 AtlasServiceException (org.apache.atlas.AtlasServiceException)8 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)8 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)7 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)5