public AtlasClassificationDef(String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs, Set<String> superTypes, Set<String> entityTypes, Map<String, String> options) { super(TypeCategory.CLASSIFICATION, name, description, typeVersion, attributeDefs, options); setSuperTypes(superTypes); setEntityTypes(entityTypes); }
@Test(dependsOnMethods = "testGet") public void testCreateWithInvalidEntityType(){ final String classificationTypeName ="testCreateClassificationDefWithInvalidEntityTypeClassification1"; // Test Classification with entitytype List<AtlasClassificationDef> classificationDefs = TestUtilsV2.getClassificationWithName(classificationTypeName); Set<String> entityTypeNames = new HashSet<String>(); entityTypeNames.add("cccc"); classificationDefs.get(0).setEntityTypes(entityTypeNames); AtlasTypesDef toCreate = new AtlasTypesDef(Collections.<AtlasEnumDef>emptyList(), Collections.<AtlasStructDef>emptyList(), classificationDefs, Collections.<AtlasEntityDef>emptyList()); try { AtlasTypesDef created = typeDefStore.createTypesDef(toCreate); fail("Classification creation with invalid entitytype should've failed"); } catch (AtlasBaseException e) { } }
private AtlasClassificationDef toClassificationDef(AtlasVertex vertex) throws AtlasBaseException { AtlasClassificationDef ret = null; if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) { ret = new AtlasClassificationDef(); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); ret.setEntityTypes(typeDefStore.getEntityTypeNames(vertex)); } return ret; }
private AtlasClassificationDef toClassificationDef(AtlasVertex vertex) throws AtlasBaseException { AtlasClassificationDef ret = null; if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.TRAIT)) { ret = new AtlasClassificationDef(); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); ret.setEntityTypes(typeDefStore.getEntityTypeNames(vertex)); } return ret; }
@Test(dependsOnMethods = "testGet") public void testCreateClassificationDefWithValidEntityType(){ final String entityTypeName ="testCreateClassificationDefWithValidEntityTypeEntity1"; final String classificationTypeName ="testCreateClassificationDefWithValidEntityTypeClassification1"; List<AtlasEntityDef> entityDefs = TestUtilsV2.getEntityWithName(entityTypeName); // Test Classification with entitytype List<AtlasClassificationDef> classificationDefs = TestUtilsV2.getClassificationWithName(classificationTypeName); Set<String> entityTypeNames = new HashSet<String>(); entityTypeNames.add(entityTypeName); classificationDefs.get(0).setEntityTypes(entityTypeNames); AtlasTypesDef toCreate = new AtlasTypesDef(Collections.<AtlasEnumDef>emptyList(), Collections.<AtlasStructDef>emptyList(), classificationDefs, entityDefs); try { AtlasTypesDef created = typeDefStore.createTypesDef(toCreate); assertEquals(created.getClassificationDefs(), toCreate.getClassificationDefs(), "Classification creation with valid entitytype should've succeeded"); } catch (AtlasBaseException e) { fail("Classification creation with valid entitytype should've succeeded. Failed with " + e.getMessage()); } }
classificationDef1.setEntityTypes(entityTypeNames);
superTypes.add(classificationTypeName1); classificationDef1.setEntityTypes(entityTypeNames1); classificationDef2.setEntityTypes(entityTypeNames2);