Search in sources :

Example 71 with Id

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

the class GraphBackedDiscoveryServiceTest method setUp.

@Override
@BeforeClass
public void setUp() throws Exception {
    super.setUp();
    repositoryService = TestUtils.addTransactionWrapper(repositoryService);
    final TypeSystem typeSystem = TypeSystem.getInstance();
    Collection<String> oldTypeNames = new HashSet<>();
    oldTypeNames.addAll(typeSystem.getTypeNames());
    TestUtils.defineDeptEmployeeTypes(typeSystem);
    addIndexesForNewTypes(oldTypeNames, typeSystem);
    ITypedReferenceableInstance hrDept = TestUtils.createDeptEg1(typeSystem);
    repositoryService.createEntities(hrDept);
    ITypedReferenceableInstance jane = repositoryService.getEntityDefinition("Manager", "name", "Jane");
    Id janeGuid = jane.getId();
    ClassType personType = typeSystem.getDataType(ClassType.class, "Person");
    ITypedReferenceableInstance instance = personType.createInstance(janeGuid);
    instance.set("orgLevel", "L1");
    repositoryService.updatePartial(instance);
}
Also used : TypeSystem(org.apache.atlas.typesystem.types.TypeSystem) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) Id(org.apache.atlas.typesystem.persistence.Id) ClassType(org.apache.atlas.typesystem.types.ClassType) BeforeClass(org.testng.annotations.BeforeClass)

Example 72 with Id

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

the class DefaultMetadataServiceTest method setUp.

@BeforeTest
public void setUp() throws Exception {
    typeDefChangeListener = (DefaultMetadataService) metadataService;
    metadataService = TestUtils.addSessionCleanupWrapper(metadataService);
    if (auditRepository instanceof HBaseBasedAuditRepository) {
        HBaseTestUtils.startCluster();
        ((HBaseBasedAuditRepository) auditRepository).start();
    }
    TestUtils.resetRequestContext();
    RequestContext.get().setUser("testuser");
    TypesDef typesDef = TestUtils.defineHiveTypes();
    try {
        metadataService.getTypeDefinition(TestUtils.TABLE_TYPE);
    } catch (TypeNotFoundException e) {
        metadataService.createType(TypesSerialization.toJson(typesDef));
    }
    String dbGUid = TestUtils.createInstance(metadataService, db);
    table = createTableEntity(dbGUid);
    String tableGuid = TestUtils.createInstance(metadataService, table);
    String tableDefinitionJson = metadataService.getEntityDefinition(TestUtils.TABLE_TYPE, NAME, (String) table.get(NAME));
    table = InstanceSerialization.fromJsonReferenceable(tableDefinitionJson, true);
    tableId = new Id(tableGuid, 0, TestUtils.TABLE_TYPE);
}
Also used : HBaseBasedAuditRepository(org.apache.atlas.repository.audit.HBaseBasedAuditRepository) TypesDef(org.apache.atlas.typesystem.TypesDef) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) Id(org.apache.atlas.typesystem.persistence.Id) BeforeTest(org.testng.annotations.BeforeTest)

Example 73 with Id

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

the class SoftDeleteHandlerV1Test method assertTableForTestDeleteReference.

@Override
protected void assertTableForTestDeleteReference(final String tableId) throws Exception {
    ITypedReferenceableInstance table = metadataService.getEntityDefinition(tableId);
    assertNotNull(table.get(NAME));
    assertNotNull(table.get("description"));
    assertNotNull(table.get("type"));
    assertNotNull(table.get("tableType"));
    assertNotNull(table.get("created"));
    Id dbId = (Id) table.get("database");
    assertNotNull(dbId);
    ITypedReferenceableInstance db = metadataService.getEntityDefinition(dbId.getId()._getId());
    assertNotNull(db);
    assertEquals(db.getId().getState(), Id.EntityState.ACTIVE);
}
Also used : ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Id(org.apache.atlas.typesystem.persistence.Id)

Example 74 with Id

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

the class QuickStartIT method testProcessIsAdded.

@Test
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
    Referenceable loadProcess = atlasClientV1.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.LOAD_SALES_DAILY_PROCESS);
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS, loadProcess.get(AtlasClient.NAME));
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS_DESCRIPTION, loadProcess.get("description"));
    List<Id> inputs = (List<Id>) loadProcess.get(QuickStart.INPUTS_ATTRIBUTE);
    List<Id> outputs = (List<Id>) loadProcess.get(QuickStart.OUTPUTS_ATTRIBUTE);
    assertEquals(2, inputs.size());
    String salesFactTableId = getTableId(QuickStart.SALES_FACT_TABLE);
    String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(QuickStart.SALES_FACT_DAILY_MV_TABLE);
    assertEquals(salesFactTableId, inputs.get(0)._getId());
    assertEquals(timeDimTableId, inputs.get(1)._getId());
    assertEquals(salesFactDailyMVId, outputs.get(0)._getId());
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) List(java.util.List) Id(org.apache.atlas.typesystem.persistence.Id) Test(org.testng.annotations.Test)

Example 75 with Id

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

the class EntityJerseyResourceIT method testAddTrait.

@Test
public void testAddTrait() throws Exception {
    String dbName = "db" + randomString();
    String tableName = "table" + randomString();
    Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
    Id dbId = createInstance(hiveDBInstance);
    Referenceable hiveTableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
    Id id = createInstance(hiveTableInstance);
    final String guid = id._getId();
    try {
        Assert.assertNotNull(UUID.fromString(guid));
    } catch (IllegalArgumentException e) {
        Assert.fail("Response is not a guid, " + guid);
    }
    String traitName = "PII_Trait" + randomString();
    HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
    String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
    LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
    createType(traitDefinitionAsJSON);
    Struct traitInstance = new Struct(traitName);
    atlasClientV1.addTrait(guid, traitInstance);
    assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_ADD);
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) TraitType(org.apache.atlas.typesystem.types.TraitType) Id(org.apache.atlas.typesystem.persistence.Id) Struct(org.apache.atlas.typesystem.Struct) Test(org.testng.annotations.Test)

Aggregations

Id (org.apache.atlas.typesystem.persistence.Id)94 Referenceable (org.apache.atlas.typesystem.Referenceable)50 Test (org.testng.annotations.Test)37 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)28 List (java.util.List)17 ArrayList (java.util.ArrayList)12 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)12 IReferenceableInstance (org.apache.atlas.typesystem.IReferenceableInstance)12 ImmutableList (com.google.common.collect.ImmutableList)10 TraitType (org.apache.atlas.typesystem.types.TraitType)10 JSONObject (org.codehaus.jettison.json.JSONObject)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AtlasServiceException (org.apache.atlas.AtlasServiceException)7 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)7 Struct (org.apache.atlas.typesystem.Struct)7 ClassType (org.apache.atlas.typesystem.types.ClassType)7 AtlasException (org.apache.atlas.AtlasException)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)5