use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.
the class QueryProcessorTest method findTypeLookupsDuringQueryParsing.
private ValidatingTypeCache findTypeLookupsDuringQueryParsing(String query) throws AtlasException {
TypeSystem typeSystem = TypeSystem.getInstance();
ValidatingTypeCache result = new ValidatingTypeCache();
typeSystem.setTypeCache(result);
typeSystem.reset();
HierarchicalTypeDefinition<ClassType> hiveTypeDef = createClassTypeDef("hive_db", "", ImmutableSet.<String>of(), createRequiredAttrDef("name", DataTypes.STRING_TYPE), createRequiredAttrDef("tableCount", DataTypes.INT_TYPE));
typeSystem.defineClassType(hiveTypeDef);
Either<Parsers.NoSuccess, Expressions.Expression> either = QueryParser.apply(query, null);
Expressions.Expression expression = either.right().get();
QueryProcessor.validate(expression);
return result;
}
use of org.apache.atlas.typesystem.types.ClassType 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);
}
use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.
the class StoreBackedTypeCacheTest method setUp.
@BeforeClass
public void setUp() throws Exception {
//force graph to be initialized up front
TestUtils.getGraph();
ts = TypeSystem.getInstance();
ts.reset();
ts.setTypeCache(typeCache);
// Populate the type store for testing.
TestUtils.defineDeptEmployeeTypes(ts);
TestUtils.createHiveTypes(ts);
ImmutableList<String> typeNames = ts.getTypeNames();
typeStore.store(ts, typeNames);
ClassType type = ts.getDataType(ClassType.class, "Manager");
classTypesToTest.put("Manager", type);
type = ts.getDataType(ClassType.class, TestUtils.TABLE_TYPE);
classTypesToTest.put(TestUtils.TABLE_TYPE, type);
}
use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method createTypes.
private void createTypes() throws Exception {
createTypeDefinitionsV1();
HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil.createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil.createTraitTypeDef("Classification", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
createType(typesDef);
}
use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.
the class TypesJerseyResourceIT method testUpdate.
@Test
public void testUpdate() throws Exception {
HierarchicalTypeDefinition<ClassType> typeDefinition = TypesUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
List<String> typesCreated = atlasClientV1.createType(TypesSerialization.toJson(typeDefinition, false));
assertEquals(typesCreated.size(), 1);
assertEquals(typesCreated.get(0), typeDefinition.typeName);
//Add attribute description
typeDefinition = TypesUtil.createClassTypeDef(typeDefinition.typeName, ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), createOptionalAttrDef(DESCRIPTION, DataTypes.STRING_TYPE));
TypesDef typeDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(typeDefinition));
List<String> typesUpdated = atlasClientV1.updateType(typeDef);
assertEquals(typesUpdated.size(), 1);
Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
TypesDef updatedTypeDef = atlasClientV1.getType(typeDefinition.typeName);
assertNotNull(updatedTypeDef);
HierarchicalTypeDefinition<ClassType> updatedType = updatedTypeDef.classTypesAsJavaList().get(0);
assertEquals(updatedType.attributeDefinitions.length, 2);
}
Aggregations