use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityJerseyResourceIT method testAddNullPropertyValue.
@Test(enabled = false)
public void testAddNullPropertyValue() 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);
}
// add property
try {
addProperty(guid, "description", null);
Assert.fail("Expected AtlasServiceException");
} catch (AtlasServiceException e) {
Assert.assertEquals(e.getStatus().getStatusCode(), Response.Status.BAD_REQUEST.getStatusCode());
}
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityJerseyResourceIT method testDeleteEntitiesViaClientApi.
@Test
public void testDeleteEntitiesViaClientApi() throws Exception {
// Create 2 database entities
Referenceable db1 = new Referenceable(DATABASE_TYPE_BUILTIN);
String dbName = randomString();
db1.set("name", dbName);
db1.set("description", randomString());
db1.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName);
db1.set("owner", "user1");
db1.set(CLUSTER_NAME, "cl1");
db1.set("parameters", Collections.EMPTY_MAP);
db1.set("location", "/tmp");
Id db1Id = createInstance(db1);
Referenceable db2 = new Referenceable(DATABASE_TYPE_BUILTIN);
String dbName2 = randomString();
db2.set("name", dbName2);
db2.set(QUALIFIED_NAME, dbName2);
db2.set(CLUSTER_NAME, randomString());
db2.set("description", randomString());
db2.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName2);
db2.set("owner", "user2");
db2.set("clusterName", "cl1");
db2.set("parameters", Collections.EMPTY_MAP);
db2.set("location", "/tmp");
Id db2Id = createInstance(db2);
// Delete the database entities
List<String> deletedGuidsList = atlasClientV1.deleteEntities(db1Id._getId(), db2Id._getId()).getDeletedEntities();
// Verify that deleteEntities() response has database entity guids
Assert.assertEquals(deletedGuidsList.size(), 2);
Assert.assertTrue(deletedGuidsList.contains(db1Id._getId()));
Assert.assertTrue(deletedGuidsList.contains(db2Id._getId()));
// Verify entities were deleted from the repository.
for (String guid : deletedGuidsList) {
Referenceable entity = atlasClientV1.getEntity(guid);
assertEquals(entity.getId().getState(), Id.EntityState.DELETED);
}
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityJerseyResourceIT method testAddNullProperty.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testAddNullProperty() 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);
}
// add property
addProperty(guid, null, "foo bar");
Assert.fail();
}
use of org.apache.atlas.v1.model.instance.Id 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.Id 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);
}
Aggregations