use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testEntityDeduping.
@Test
public void testEntityDeduping() throws Exception {
JSONArray results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE_V2, DATABASE_NAME));
assertEquals(results.length(), 1);
final AtlasEntity hiveDBInstanceV2 = createHiveDB();
// Do the notification thing here
waitForNotification(notificationConsumer, MAX_WAIT_TIME, new NotificationPredicate() {
@Override
public boolean evaluate(EntityNotification notification) throws Exception {
return notification != null && notification.getEntity().getId()._getId().equals(hiveDBInstanceV2.getGuid());
}
});
results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE_V2, DATABASE_NAME));
assertEquals(results.length(), 1);
//Test the same across references
final String tableName = randomString();
AtlasEntity hiveTableInstanceV2 = createHiveTableInstanceV2(hiveDBInstanceV2, tableName);
hiveTableInstanceV2.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
EntityMutationResponse entity = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(hiveTableInstanceV2));
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE_V2, DATABASE_NAME));
assertEquals(results.length(), 1);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testEntityInvalidValue.
@Test
public void testEntityInvalidValue() throws Exception {
AtlasEntity databaseInstance = new AtlasEntity(DATABASE_TYPE_V2);
String dbName = randomString();
String nullString = null;
String emptyString = "";
databaseInstance.setAttribute("name", dbName);
databaseInstance.setAttribute("description", nullString);
AtlasEntityHeader created = createEntity(databaseInstance);
// null valid value for required attr - description
assertNull(created);
databaseInstance.setAttribute("description", emptyString);
created = createEntity(databaseInstance);
// empty string valid value for required attr
assertNotNull(created);
databaseInstance.setGuid(created.getGuid());
databaseInstance.setAttribute("owner", nullString);
databaseInstance.setAttribute("locationUri", emptyString);
created = updateEntity(databaseInstance);
// null/empty string valid value for optional attr
assertNotNull(created);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method addProperty.
private void addProperty(String guid, String property, Object value) throws AtlasServiceException {
AtlasEntity entityByGuid = getEntityByGuid(guid);
entityByGuid.setAttribute(property, value);
EntityMutationResponse response = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(entityByGuid));
assertNotNull(response);
assertNotNull(response.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testGetEntityByAttribute.
@Test
public void testGetEntityByAttribute() throws Exception {
AtlasEntity hiveDB = createHiveDB();
String qualifiedName = (String) hiveDB.getAttribute(NAME);
//get entity by attribute
AtlasEntity byAttribute = atlasClientV2.getEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, qualifiedName)).getEntity();
assertEquals(byAttribute.getTypeName(), DATABASE_TYPE_V2);
assertEquals(byAttribute.getAttribute(NAME), qualifiedName);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testDeleteEntityByUniqAttribute.
@Test
public void testDeleteEntityByUniqAttribute() throws Exception {
// Create database entity
AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + random());
// Delete the database entity
EntityMutationResponse deleteResponse = atlasClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) hiveDB.getAttribute(NAME)));
// Verify that deleteEntities() response has database entity guids
assertNotNull(deleteResponse);
assertNotNull(deleteResponse.getEntitiesByOperation(EntityMutations.EntityOperation.DELETE));
assertEquals(deleteResponse.getEntitiesByOperation(EntityMutations.EntityOperation.DELETE).size(), 1);
// Verify entities were deleted from the repository.
}
Aggregations