public static AtlasEntityDef getEntityWithInvalidSuperType() { AtlasEntityDef entityDef = simpleType().getEntityDefs().get(0); entityDef.addSuperType("!@#$%"); return entityDef; } }
public static AtlasEntityDef getEntityWithInvalidSuperType() { AtlasEntityDef entityDef = simpleType().getEntityDefs().get(0); entityDef.addSuperType("!@#$%"); return entityDef; }
@Test public void testEntityDefAddSuperType() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDef(); String newSuperType = "newType-abcd-1234"; entityDef.addSuperType(newSuperType); assertTrue(entityDef.hasSuperType(newSuperType)); entityDef.removeSuperType(newSuperType); }
@Test public void testEntityDefAddSuperType() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDef(); String newSuperType = "newType-abcd-1234"; entityDef.addSuperType(newSuperType); assertTrue(entityDef.hasSuperType(newSuperType)); entityDef.removeSuperType(newSuperType); }
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; }
AtlasEntityDef entL2_4 = new AtlasEntityDef("L2-4"); entL1_1.addSuperType(entL0.getName()); entL1_2.addSuperType(entL0.getName()); entL2_1.addSuperType(entL1_1.getName()); entL2_2.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_2.getName()); entL2_4.addSuperType(entL1_2.getName()); entL0.addSuperType(entL2_3.getName()); // circular-ref
@Test public void testEntityDefInvalidHierarchy_Self() { AtlasEntityDef entDef1 = new AtlasEntityDef("entDef-1"); entDef1.addSuperType(entDef1.getName()); AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; String failureMsg = null; try { ttr = typeRegistry.lockTypeRegistryForUpdate(); ttr.addType(entDef1); commit = true; } catch (AtlasBaseException excp) { failureMsg = excp.getMessage(); } finally { typeRegistry.releaseTypeRegistryForUpdate(ttr, commit); } assertNotNull(failureMsg, "expected invalid supertype failure"); }
AtlasEntityDef entL2_4 = new AtlasEntityDef("L2-4"); entL1_1.addSuperType(entL0.getName()); entL1_2.addSuperType(entL0.getName()); entL2_1.addSuperType(entL1_1.getName()); entL2_2.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_2.getName()); entL2_4.addSuperType(entL1_2.getName());
AtlasEntityDef entL2_4 = new AtlasEntityDef("L2-4"); entL1_1.addSuperType(entL0.getName()); entL1_2.addSuperType(entL0.getName()); entL2_1.addSuperType(entL1_1.getName()); entL2_2.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_1.getName()); entL2_3.addSuperType(entL1_2.getName()); entL2_4.addSuperType(entL1_2.getName());
AtlasEntityDef entL1 = new AtlasEntityDef("L1"); entL1.addSuperType(entL0.getName()); entL2.addSuperType(entL0.getName()); entL2.addSuperType(entL1.getName()); entL2.addSuperType(entL2.getName());
public static AtlasEntityDef newEntityDef(AtlasTypeRegistry typesRegistry, AtlasEntityDef[] superTypes) { int entDefIdx = IDX_ENTITY_DEF.getAndIncrement(); AtlasEntityDef ret = new AtlasEntityDef(); ret.setName(PREFIX_ENTITY_DEF + entDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); if (superTypes != null) { for (AtlasEntityDef superType : superTypes) { ret.addSuperType(superType.getName()); } } AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create entity-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }
public static AtlasEntityDef newEntityDef(AtlasTypeRegistry typesRegistry, AtlasEntityDef[] superTypes) { int entDefIdx = IDX_ENTITY_DEF.getAndIncrement(); AtlasEntityDef ret = new AtlasEntityDef(); ret.setName(PREFIX_ENTITY_DEF + entDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); if (superTypes != null) { for (AtlasEntityDef superType : superTypes) { ret.addSuperType(superType.getName()); } } AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create entity-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }