use of org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications in project incubator-atlas by apache.
the class TestEntityREST method testAddAndUpdateClassificationWithAttributes.
@Test(dependsOnMethods = "testGetEntityById")
public void testAddAndUpdateClassificationWithAttributes() throws Exception {
phiClassification = new AtlasClassification(TestUtilsV2.PHI, new HashMap<String, Object>() {
{
put("stringAttr", "sample_string");
put("booleanAttr", true);
put("integerAttr", 100);
}
});
testClassification = new AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() {
{
put("tag", "tagName");
}
});
entityREST.addClassifications(dbEntity.getGuid(), new ArrayList<>(Arrays.asList(phiClassification)));
final AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());
Assert.assertNotNull(retrievedClassifications);
final List<AtlasClassification> retrievedClassificationsList = retrievedClassifications.getList();
Assert.assertNotNull(retrievedClassificationsList);
final AtlasClassification retrievedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.PHI);
Assert.assertNotNull(retrievedClassification);
Assert.assertEquals(retrievedClassification, phiClassification);
for (String attrName : retrievedClassification.getAttributes().keySet()) {
Assert.assertEquals(retrievedClassification.getAttribute(attrName), phiClassification.getAttribute(attrName));
}
// update multiple tags attributes
phiClassification = new AtlasClassification(TestUtilsV2.PHI, new HashMap<String, Object>() {
{
put("stringAttr", "sample_string_v2");
put("integerAttr", 200);
}
});
testClassification = new AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() {
{
put("tag", "tagName_updated");
}
});
entityREST.updateClassification(dbEntity.getGuid(), new ArrayList<>(Arrays.asList(phiClassification, testClassification)));
AtlasClassification updatedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.PHI);
Assert.assertNotNull(updatedClassification);
Assert.assertEquals(updatedClassification.getAttribute("stringAttr"), "sample_string_v2");
Assert.assertEquals(updatedClassification.getAttribute("integerAttr"), 200);
Assert.assertEquals(updatedClassification.getAttribute("booleanAttr"), true);
updatedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);
Assert.assertNotNull(updatedClassification);
Assert.assertEquals(updatedClassification.getAttribute("tag"), testClassification.getAttribute("tag"));
entityREST.deleteClassification(dbEntity.getGuid(), TestUtilsV2.PHI);
}
use of org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testGetTraitNames.
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitNames() throws Exception {
AtlasClassifications classifications = atlasClientV2.getClassifications(createHiveTable().getGuid());
assertNotNull(classifications);
assertTrue(classifications.getList().size() > 0);
assertEquals(classifications.getList().size(), 8);
}
use of org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications 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