use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityJerseyResourceIT method testSubmitEntity.
@Test
public void testSubmitEntity() throws Exception {
String dbName = "db" + randomString();
String tableName = "table" + randomString();
Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
Id dbId = createInstance(hiveDBInstance);
Referenceable referenceable = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
Id id = createInstance(referenceable);
final String guid = id._getId();
try {
Assert.assertNotNull(UUID.fromString(guid));
} catch (IllegalArgumentException e) {
Assert.fail("Response is not a guid, " + guid);
}
}
use of org.apache.atlas.v1.model.instance.Referenceable in project 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();
TraitTypeDefinition piiTrait = TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet());
String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
TypesDef typesDef = new TypesDef(Collections.emptyList(), Collections.emptyList(), Collections.singletonList(piiTrait), Collections.emptyList());
createType(typesDef);
Struct traitInstance = new Struct(traitName);
atlasClientV1.addTrait(guid, traitInstance);
assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_ADD);
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityJerseyResourceIT method testGetEntityDefinition.
@Test
public void testGetEntityDefinition() 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);
}
Referenceable entity = atlasClientV1.getEntity(guid);
Assert.assertNotNull(entity);
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityJerseyResourceIT method testGetTraitNames.
@Test
public void testGetTraitNames() 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);
}
List<String> traits = atlasClientV1.listTraits(guid);
assertNotNull(traits);
Assert.assertEquals(traits.size(), 7);
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityJerseyResourceIT method testAddTraitWithAttribute.
@Test
public void testAddTraitWithAttribute() 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);
}
final String traitName = "PII_Trait" + randomString();
TraitTypeDefinition piiTrait = TypesUtil.createTraitTypeDef(traitName, null, Collections.<String>emptySet(), TypesUtil.createRequiredAttrDef("type", AtlasBaseTypeDef.ATLAS_TYPE_STRING));
String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
TypesDef typesDef = new TypesDef(Collections.emptyList(), Collections.emptyList(), Collections.singletonList(piiTrait), Collections.emptyList());
createType(typesDef);
Struct traitInstance = new Struct(traitName);
traitInstance.set("type", "SSN");
atlasClientV1.addTrait(guid, traitInstance);
// verify the response
Referenceable entity = atlasClientV1.getEntity(guid);
Assert.assertNotNull(entity);
Assert.assertEquals(entity.getId()._getId(), guid);
assertNotNull(entity.getTrait(traitName));
assertEquals(entity.getTrait(traitName).get("type"), traitInstance.get("type"));
}
Aggregations