use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method testTablesAreAdded.
@Test
public void testTablesAreAdded() throws AtlasServiceException, JSONException {
AtlasEntity table = getTable(QuickStart.SALES_FACT_TABLE);
verifySimpleTableAttributes(table);
verifyDBIsLinkedToTable(table);
verifyColumnsAreAddedToTable(table);
verifyTrait(table);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method testViewIsAdded.
@Test
public void testViewIsAdded() throws AtlasServiceException, JSONException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.PRODUCT_DIM_VIEW);
AtlasEntity view = atlasClientV2.getEntityByAttribute(QuickStartV2.VIEW_TYPE, attributes).getEntity();
Map<String, Object> viewAttributes = view.getAttributes();
assertEquals(QuickStartV2.PRODUCT_DIM_VIEW, viewAttributes.get(AtlasClient.NAME));
String productDimId = getTable(QuickStartV2.PRODUCT_DIM_TABLE).getGuid();
List inputTables = (List) viewAttributes.get("inputTables");
Map inputTablesMap = (Map) inputTables.get(0);
assertEquals(productDimId, inputTablesMap.get("guid"));
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class QuickStartV2IT method testDBIsAdded.
@Test
public void testDBIsAdded() throws Exception {
AtlasEntity db = getDB(QuickStartV2.SALES_DB);
Map<String, Object> dbAttributes = db.getAttributes();
assertEquals(QuickStartV2.SALES_DB, dbAttributes.get("name"));
assertEquals("sales database", dbAttributes.get("description"));
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testAddTraitWithAttribute.
@Test(dependsOnMethods = "testGetTraitNames")
public void testAddTraitWithAttribute() throws Exception {
final String traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of(), AtlasTypeUtil.createRequiredAttrDef("type", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
AtlasClassification traitInstance = new AtlasClassification(traitName);
traitInstance.setAttribute("type", "SSN");
final String guid = createHiveTable().getGuid();
atlasClientV2.addClassifications(guid, ImmutableList.of(traitInstance));
// verify the response
AtlasEntity withAssociationByGuid = atlasClientV2.getEntityByGuid(guid).getEntity();
assertNotNull(withAssociationByGuid);
assertFalse(withAssociationByGuid.getClassifications().isEmpty());
boolean found = false;
for (AtlasClassification atlasClassification : withAssociationByGuid.getClassifications()) {
String attribute = (String) atlasClassification.getAttribute("type");
if (attribute != null && attribute.equals("SSN")) {
found = true;
break;
}
}
assertTrue(found);
}
use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testGetTraitDefinitionForEntity.
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitDefinitionForEntity() throws Exception {
traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
AtlasClassificationDef classificationByName = atlasClientV2.getClassificationDefByName(traitName);
assertNotNull(classificationByName);
AtlasEntity hiveTable = createHiveTable();
assertEquals(hiveTable.getClassifications().size(), 7);
AtlasClassification piiClassification = new AtlasClassification(piiTrait.getName());
atlasClientV2.addClassifications(hiveTable.getGuid(), Lists.newArrayList(piiClassification));
AtlasClassifications classifications = atlasClientV2.getClassifications(hiveTable.getGuid());
assertNotNull(classifications);
assertTrue(classifications.getList().size() > 0);
assertEquals(classifications.getList().size(), 8);
}
Aggregations