use of org.apache.atlas.model.SearchFilter in project atlas by apache.
the class QuickStartV2 method verifyTypesCreated.
private void verifyTypesCreated() throws Exception {
MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();
for (String typeName : TYPES) {
searchParams.clear();
searchParams.add(SearchFilter.PARAM_NAME, typeName);
SearchFilter searchFilter = new SearchFilter(searchParams);
AtlasTypesDef searchDefs = atlasClientV2.getAllTypeDefs(searchFilter);
assert (!searchDefs.isEmpty());
System.out.println("Created type [" + typeName + "]");
}
}
use of org.apache.atlas.model.SearchFilter in project atlas by apache.
the class TypedefsJerseyResourceIT method testListTypesByFilter.
@Test
public void testListTypesByFilter() throws Exception {
AtlasAttributeDef attr = AtlasTypeUtil.createOptionalAttrDef("attr", "string");
AtlasEntityDef classDefA = AtlasTypeUtil.createClassTypeDef("A" + randomString(), Collections.<String>emptySet(), attr);
AtlasEntityDef classDefA1 = AtlasTypeUtil.createClassTypeDef("A1" + randomString(), Collections.singleton(classDefA.getName()), attr);
AtlasEntityDef classDefB = AtlasTypeUtil.createClassTypeDef("B" + randomString(), Collections.<String>emptySet(), attr);
AtlasEntityDef classDefC = AtlasTypeUtil.createClassTypeDef("C" + randomString(), new HashSet<>(Arrays.asList(classDefB.getName(), classDefA.getName())), attr);
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(classDefA);
atlasTypesDef.getEntityDefs().add(classDefA1);
atlasTypesDef.getEntityDefs().add(classDefB);
atlasTypesDef.getEntityDefs().add(classDefC);
AtlasTypesDef created = clientV2.createAtlasTypeDefs(atlasTypesDef);
assertNotNull(created);
assertEquals(created.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();
searchParams.add(SearchFilter.PARAM_TYPE, "CLASS");
searchParams.add(SearchFilter.PARAM_SUPERTYPE, classDefA.getName());
SearchFilter searchFilter = new SearchFilter(searchParams);
AtlasTypesDef searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs);
assertEquals(searchDefs.getEntityDefs().size(), 2);
searchParams.add(SearchFilter.PARAM_NOT_SUPERTYPE, classDefB.getName());
searchFilter = new SearchFilter(searchParams);
searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs);
assertEquals(searchDefs.getEntityDefs().size(), 1);
}
use of org.apache.atlas.model.SearchFilter in project atlas by apache.
the class TypedefsJerseyResourceIT method testUpdate.
@Test
public void testUpdate() throws Exception {
String entityType = randomString();
AtlasEntityDef typeDefinition = createClassTypeDef(entityType, Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(typeDefinition);
AtlasTypesDef createdTypeDefs = clientV2.createAtlasTypeDefs(atlasTypesDef);
assertNotNull(createdTypeDefs);
assertEquals(createdTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
// Add attribute description
typeDefinition = createClassTypeDef(typeDefinition.getName(), Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("description", "string"));
emptyTypeDefs(atlasTypesDef);
atlasTypesDef.getEntityDefs().add(typeDefinition);
AtlasTypesDef updatedTypeDefs = clientV2.updateAtlasTypeDefs(atlasTypesDef);
assertNotNull(updatedTypeDefs);
assertEquals(updatedTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName());
MultivaluedMap<String, String> filterParams = new MultivaluedMapImpl();
filterParams.add(SearchFilter.PARAM_TYPE, "ENTITY");
AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams));
assertNotNull(allTypeDefs);
Boolean entityDefFound = false;
for (AtlasEntityDef atlasEntityDef : allTypeDefs.getEntityDefs()) {
if (atlasEntityDef.getName().equals(typeDefinition.getName())) {
assertEquals(atlasEntityDef.getAttributeDefs().size(), 2);
entityDefFound = true;
break;
}
}
assertTrue(entityDefFound, "Required entityDef not found.");
}
use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testCreateDept.
@Test(dependsOnMethods = { "testGet" }, dataProvider = "validCreateDeptTypes")
public void testCreateDept(AtlasTypesDef atlasTypesDef) {
AtlasTypesDef existingTypesDef = null;
try {
existingTypesDef = typeDefStore.searchTypesDef(new SearchFilter());
} catch (AtlasBaseException e) {
// ignore
}
assertNotEquals(atlasTypesDef, existingTypesDef, "Types to be created already exist in the system");
AtlasTypesDef createdTypesDef = null;
try {
createdTypesDef = typeDefStore.createTypesDef(atlasTypesDef);
assertNotNull(createdTypesDef);
assertTrue(createdTypesDef.getEnumDefs().containsAll(atlasTypesDef.getEnumDefs()), "EnumDefs create failed");
assertTrue(createdTypesDef.getClassificationDefs().containsAll(atlasTypesDef.getClassificationDefs()), "ClassificationDef create failed");
assertTrue(createdTypesDef.getStructDefs().containsAll(atlasTypesDef.getStructDefs()), "StructDef creation failed");
Assert.assertEquals(createdTypesDef.getEntityDefs(), atlasTypesDef.getEntityDefs());
} catch (AtlasBaseException e) {
fail("Creation of Types should've been a success", e);
}
}
use of org.apache.atlas.model.SearchFilter in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testSearchFunctionality.
@Test(dependsOnMethods = "testGet")
public void testSearchFunctionality() {
SearchFilter searchFilter = new SearchFilter();
searchFilter.setParam(SearchFilter.PARAM_SUPERTYPE, "Person");
try {
AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter);
assertNotNull(typesDef);
assertNotNull(typesDef.getEntityDefs());
assertEquals(typesDef.getEntityDefs().size(), 3);
} catch (AtlasBaseException e) {
fail("Search should've succeeded", e);
}
}
Aggregations