use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestUtilsV2 method getEntityWithInvalidSuperType.
public static AtlasEntityDef getEntityWithInvalidSuperType() {
AtlasEntityDef entityDef = simpleType().getEntityDefs().get(0);
entityDef.addSuperType("!@#$%");
return entityDef;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestUtilsV2 method simpleTypeUpdated.
public static AtlasTypesDef simpleTypeUpdated() {
AtlasEntityDef superTypeDefinition = AtlasTypeUtil.createClassTypeDef("h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasEntityDef newSuperTypeDefinition = AtlasTypeUtil.createClassTypeDef("new_h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0", Arrays.asList(AtlasTypeUtil.createRequiredAttrDef("name", "string")));
AtlasClassificationDef traitTypeDefinition = AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", ImmutableSet.<String>of());
AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType", Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
return AtlasTypeUtil.getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition), ImmutableList.of(traitTypeDefinition), ImmutableList.of(superTypeDefinition, newSuperTypeDefinition));
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class EntityDiscoveryServiceTest method init.
@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);
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method addNewType.
private String addNewType() throws Exception {
String typeName = "test" + randomString();
AtlasEntityDef classTypeDef = AtlasTypeUtil.createClassTypeDef(typeName, ImmutableSet.<String>of(), AtlasTypeUtil.createRequiredAttrDef("name", "string"), AtlasTypeUtil.createRequiredAttrDef("description", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(classTypeDef);
createType(typesDef);
return typeName;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testEntityDefinitionAcrossTypeUpdate.
@Test
public void testEntityDefinitionAcrossTypeUpdate() throws Exception {
//create type
AtlasEntityDef entityDef = AtlasTypeUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(entityDef);
AtlasTypesDef created = atlasClientV2.createAtlasTypeDefs(typesDef);
assertNotNull(created);
assertNotNull(created.getEntityDefs());
assertEquals(created.getEntityDefs().size(), 1);
//create entity for the type
AtlasEntity instance = new AtlasEntity(entityDef.getName());
instance.setAttribute("name", randomString());
EntityMutationResponse mutationResponse = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(instance));
assertNotNull(mutationResponse);
assertNotNull(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
assertEquals(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size(), 1);
String guid = mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0).getGuid();
//update type - add attribute
entityDef = AtlasTypeUtil.createClassTypeDef(entityDef.getName(), ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("description", "string"));
typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(entityDef);
AtlasTypesDef updated = atlasClientV2.updateAtlasTypeDefs(typesDef);
assertNotNull(updated);
assertNotNull(updated.getEntityDefs());
assertEquals(updated.getEntityDefs().size(), 1);
//Get definition after type update - new attributes should be null
AtlasEntity entityByGuid = getEntityByGuid(guid);
assertNull(entityByGuid.getAttribute("description"));
assertEquals(entityByGuid.getAttribute("name"), instance.getAttribute("name"));
}
Aggregations