use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class ImportTransformsTest method transformEntityWithExtInfo.
@Test
public void transformEntityWithExtInfo() throws AtlasBaseException {
addColumnTransform(transform);
AtlasEntityWithExtInfo entityWithExtInfo = getAtlasEntityWithExtInfo();
AtlasEntity entity = entityWithExtInfo.getEntity();
String attrValue = (String) entity.getAttribute(qualifiedName);
String[] expectedValues = getExtEntityExpectedValues(entityWithExtInfo);
transform.apply(entityWithExtInfo);
assertEquals(entityWithExtInfo.getEntity().getAttribute(qualifiedName), applyDefaultTransform(attrValue));
for (int i = 0; i < expectedValues.length; i++) {
assertEquals(entityWithExtInfo.getReferredEntities().get(Integer.toString(i)).getAttribute(qualifiedName), expectedValues[i]);
}
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class TestEntitiesREST method testUpdateWithSerializedEntities.
@Test
public void testUpdateWithSerializedEntities() throws Exception {
//Check with serialization and deserialization of entity attributes for the case
// where attributes which are de-serialized into a map
AtlasEntity dbEntity = TestUtilsV2.createDBEntity();
AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity);
final AtlasEntity colEntity = TestUtilsV2.createColumnEntity(tableEntity);
List<AtlasEntity> columns = new ArrayList<AtlasEntity>() {
{
add(colEntity);
}
};
tableEntity.setAttribute("columns", getObjIdList(columns));
AtlasEntity newDBEntity = serDeserEntity(dbEntity);
AtlasEntity newTableEntity = serDeserEntity(tableEntity);
AtlasEntitiesWithExtInfo newEntities = new AtlasEntitiesWithExtInfo();
newEntities.addEntity(newDBEntity);
newEntities.addEntity(newTableEntity);
for (AtlasEntity column : columns) {
newEntities.addReferredEntity(serDeserEntity(column));
}
EntityMutationResponse response2 = entityREST.createOrUpdate(newEntities);
List<AtlasEntityHeader> newGuids = response2.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE);
Assert.assertNotNull(newGuids);
Assert.assertEquals(newGuids.size(), 3);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method getProcess.
private AtlasEntity getProcess(String processName) throws AtlasServiceException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, processName);
AtlasEntity processEntity = atlasClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
return processEntity;
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method verifyDBIsLinkedToTable.
private void verifyDBIsLinkedToTable(AtlasEntity table) throws AtlasServiceException, JSONException {
AtlasEntity db = getDB(QuickStartV2.SALES_DB);
Map<String, Object> tableAttributes = table.getAttributes();
Map dbFromTable = (Map) tableAttributes.get("db");
assertEquals(db.getGuid(), dbFromTable.get("guid"));
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method testProcessIsAdded.
@Test
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.LOAD_SALES_DAILY_PROCESS);
AtlasEntity loadProcess = atlasClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
Map loadProcessAttribs = loadProcess.getAttributes();
assertEquals(QuickStartV2.LOAD_SALES_DAILY_PROCESS, loadProcessAttribs.get(AtlasClient.NAME));
assertEquals("hive query for daily summary", loadProcessAttribs.get("description"));
List inputs = (List) loadProcessAttribs.get("inputs");
List outputs = (List) loadProcessAttribs.get("outputs");
assertEquals(2, inputs.size());
String salesFactTableId = getTableId(QuickStartV2.SALES_FACT_TABLE);
String timeDimTableId = getTableId(QuickStartV2.TIME_DIM_TABLE);
String salesFactDailyMVId = getTableId(QuickStartV2.SALES_FACT_DAILY_MV_TABLE);
assertEquals(salesFactTableId, ((Map) inputs.get(0)).get("guid"));
assertEquals(timeDimTableId, ((Map) inputs.get(1)).get("guid"));
assertEquals(salesFactDailyMVId, ((Map) outputs.get(0)).get("guid"));
}
Aggregations