Java Code Examples for org.apache.atlas.type.AtlasTypeRegistry#AtlasTransientTypeRegistry

The following examples show how to use org.apache.atlas.type.AtlasTypeRegistry#AtlasTransientTypeRegistry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassificationAssociatorTest.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void updaterEntityWithUniqueName() throws IOException, AtlasBaseException {
    AtlasEntityDef ed = getAtlasEntityDefFromFile("col-entity-def-unique-name");

    AtlasEntityHeaders entityHeaderMap = getEntityHeaderMapFromFile("header-PII-no-qualifiedName");
    AtlasEntityStore entitiesStore = mock(AtlasEntityStore.class);
    AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
    AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = typeRegistry.lockTypeRegistryForUpdate();
    ttr.addTypes(CollectionUtils.newSingletonArrayList(ed));
    AtlasGraph atlasGraph = mock(AtlasGraph.class);

    ClassificationAssociatorUpdaterForSpy updater = new ClassificationAssociatorUpdaterForSpy(atlasGraph, ttr, entitiesStore, "col-entity-PII");
    String summary = updater.setClassifications(entityHeaderMap.getGuidHeaderMap());

    TypeReference<String[]> typeReference = new TypeReference<String[]>() {};
    String[] summaryArray = AtlasJson.fromJson(summary, typeReference);
    assertEquals(summaryArray.length, 1);
    assertSummaryElement(summaryArray[0], "Update", STATUS_DONE, "PII");
}
 
Example 2
Source File: EntityDiscoveryServiceTest.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public void init() throws AtlasBaseException {
    typeTest         = new AtlasEntityDef(TEST_TYPE);
    typeTest1        = new AtlasEntityDef(TEST_TYPE1);
    typeTest2        = new AtlasEntityDef(TEST_TYPE2);
    typeTest3        = new AtlasEntityDef(TEST_TYPE3);
    typeWithSubTypes = new AtlasEntityDef(TEST_TYPE_WITH_SUB_TYPES);

    typeTest1.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
    typeTest2.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
    typeTest3.addSuperType(TEST_TYPE_WITH_SUB_TYPES);

    AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = typeRegistry.lockTypeRegistryForUpdate();

    ttr.addType(typeTest);
    ttr.addType(typeWithSubTypes);
    ttr.addType(typeTest1);
    ttr.addType(typeTest2);
    ttr.addType(typeTest3);

    typeRegistry.releaseTypeRegistryForUpdate(ttr, true);
}
 
Example 3
Source File: TransformationHandlerTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private AtlasTypeRegistry getTypeRegistry() {
    AtlasTypeRegistry ret = new AtlasTypeRegistry();

    AtlasEntityDef defReferenceable = new AtlasEntityDef(TYPENAME_REFERENCEABLE);
    AtlasEntityDef defAsset         = new AtlasEntityDef(TYPENAME_ASSET);
    AtlasEntityDef defHdfsPath      = new AtlasEntityDef(HDFS_PATH);
    AtlasEntityDef defHiveDb        = new AtlasEntityDef(HIVE_DATABASE);
    AtlasEntityDef defHiveTable     = new AtlasEntityDef(HIVE_TABLE);
    AtlasEntityDef defHiveColumn    = new AtlasEntityDef(HIVE_COLUMN);
    AtlasEntityDef defHiveStorDesc  = new AtlasEntityDef(HIVE_STORAGE_DESCRIPTOR);
    AtlasEntityDef defNonAsset      = new AtlasEntityDef(TYPENAME_NON_ASSET);

    defAsset.addSuperType(TYPENAME_REFERENCEABLE);
    defHdfsPath.addSuperType(TYPENAME_ASSET);
    defHiveDb.addSuperType(TYPENAME_ASSET);
    defHiveTable.addSuperType(TYPENAME_ASSET);
    defHiveColumn.addSuperType(TYPENAME_ASSET);
    defNonAsset.addSuperType(TYPENAME_REFERENCEABLE);

    AtlasTypesDef typesDef = new AtlasTypesDef();

    typesDef.setEntityDefs(Arrays.asList(defReferenceable, defAsset, defHdfsPath, defHiveDb, defHiveTable, defHiveColumn, defHiveStorDesc, defNonAsset));

    try {
        AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = ret.lockTypeRegistryForUpdate();

        ttr.addTypes(typesDef);

        ret.releaseTypeRegistryForUpdate(ttr, true);
    } catch (AtlasBaseException excp) {
        LOG.warn("failed to initialize type-registry", excp);
    }

    return ret;
}