Search in sources :

Example 1 with AtlasClassifications

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);
}
Also used : HashMap(java.util.HashMap) AtlasClassifications(org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications) AtlasClassification(org.apache.atlas.model.instance.AtlasClassification) Test(org.testng.annotations.Test)

Example 2 with AtlasClassifications

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);
}
Also used : AtlasClassifications(org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications) Test(org.testng.annotations.Test)

Example 3 with AtlasClassifications

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);
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasClassifications(org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications) AtlasClassification(org.apache.atlas.model.instance.AtlasClassification) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Aggregations

AtlasClassifications (org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications)3 Test (org.testng.annotations.Test)3 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)2 HashMap (java.util.HashMap)1 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)1 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)1 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)1