use of org.apache.atlas.model.typedef.AtlasClassificationDef 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);
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testDeleteExistentTraitNonExistentForEntity.
@Test(dependsOnMethods = "testSubmitEntity")
public void testDeleteExistentTraitNonExistentForEntity() throws Exception {
final String guid = createHiveTable().getGuid();
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);
try {
atlasClientV2.deleteClassification(guid, traitName);
fail("Deletion should've failed for non-existent trait association");
} catch (AtlasServiceException ex) {
Assert.assertNotNull(ex.getStatus());
assertEquals(ex.getStatus(), ClientResponse.Status.NOT_FOUND);
}
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class TypedefsJerseyResourceIT method testInvalidGets.
@Test
public void testInvalidGets() throws Exception {
try {
AtlasEnumDef byName = clientV2.getEnumDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEnumDef byGuid = clientV2.getEnumDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasStructDef byName = clientV2.getStructDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasStructDef byGuid = clientV2.getStructDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasClassificationDef byName = clientV2.getClassificationDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasClassificationDef byGuid = clientV2.getClassificationDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEntityDef byName = clientV2.getEntityDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEntityDef byGuid = clientV2.getEntityDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class TestAtlasClassification method testClassificationSerDeWithSuperType.
@Test
public void testClassificationSerDeWithSuperType() throws AtlasBaseException {
AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperType();
AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classificationDef.getName());
assertNotNull(classificationType);
AtlasClassification ent1 = classificationType.createDefaultValue();
String jsonString = AtlasType.toJson(ent1);
AtlasClassification ent2 = AtlasType.fromJson(jsonString, AtlasClassification.class);
classificationType.normalizeAttributeValues(ent2);
assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasClassification with superType");
}
use of org.apache.atlas.model.typedef.AtlasClassificationDef in project incubator-atlas by apache.
the class TestAtlasClassification method testClassificationSerDeWithSuperTypes.
@Test
public void testClassificationSerDeWithSuperTypes() throws AtlasBaseException {
AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes();
AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classificationDef.getName());
assertNotNull(classificationType);
AtlasClassification ent1 = classificationType.createDefaultValue();
String jsonString = AtlasType.toJson(ent1);
AtlasClassification ent2 = AtlasType.fromJson(jsonString, AtlasClassification.class);
classificationType.normalizeAttributeValues(ent2);
assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasClassification with superTypes");
}
Aggregations