use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method testSearchUsingDSL.
@Test
public void testSearchUsingDSL() throws Exception {
// String query = "from dsl_test_type";
String query = "from " + DATABASE_TYPE + " name=\"" + dbName + "\"";
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", query);
JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH, queryParams);
Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
assertEquals(response.getString("query"), query);
assertEquals(response.getString("queryType"), "dsl");
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method testSearchByDSL.
@Test
public void testSearchByDSL() throws Exception {
String dslQuery = "from " + DATABASE_TYPE + " name=\"" + dbName + "\"";
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", dslQuery);
JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
assertEquals(response.getString("query"), dslQuery);
assertEquals(response.getString("queryType"), "dsl");
JSONArray results = response.getJSONArray(AtlasClient.RESULTS);
assertNotNull(results);
assertEquals(results.length(), 1);
int numRows = response.getInt(AtlasClient.COUNT);
assertEquals(numRows, 1);
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-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(), ImmutableSet.<String>of(), attr);
AtlasEntityDef classDefA1 = AtlasTypeUtil.createClassTypeDef("A1" + randomString(), ImmutableSet.of(classDefA.getName()), attr);
AtlasEntityDef classDefB = AtlasTypeUtil.createClassTypeDef("B" + randomString(), ImmutableSet.<String>of(), attr);
AtlasEntityDef classDefC = AtlasTypeUtil.createClassTypeDef("C" + randomString(), ImmutableSet.of(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 com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method testSearchDSLLimits.
@Test
public void testSearchDSLLimits() throws Exception {
// search without new parameters of limit and offset should work
String dslQuery = "from " + DATABASE_TYPE + " name=\"" + dbName + "\"";
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", dslQuery);
JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
assertNotNull(response);
// higher limit, all results returned
JSONArray results = atlasClientV1.searchByDSL(dslQuery, 10, 0);
assertEquals(results.length(), 1);
// default limit and offset -1, all results returned
results = atlasClientV1.searchByDSL(dslQuery, -1, -1);
assertEquals(results.length(), 1);
// uses the limit parameter passed
results = atlasClientV1.searchByDSL(dslQuery, 1, 0);
assertEquals(results.length(), 1);
// uses the offset parameter passed
results = atlasClientV1.searchByDSL(dslQuery, 10, 1);
assertEquals(results.length(), 0);
// limit > 0
try {
atlasClientV1.searchByDSL(dslQuery, 0, 10);
fail("Expected BAD_REQUEST");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus(), ClientResponse.Status.BAD_REQUEST, "Got " + e.getStatus());
}
// limit > maxlimit
try {
atlasClientV1.searchByDSL(dslQuery, Integer.MAX_VALUE, 10);
fail("Expected BAD_REQUEST");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus(), ClientResponse.Status.BAD_REQUEST, "Got " + e.getStatus());
}
// offset >= 0
try {
atlasClientV1.searchByDSL(dslQuery, 10, -2);
fail("Expected BAD_REQUEST");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus(), ClientResponse.Status.BAD_REQUEST, "Got " + e.getStatus());
}
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method testSearchUsingGremlin.
@Test
public void testSearchUsingGremlin() throws Exception {
String query = "g.V.has('type', '" + BaseResourceIT.HIVE_TABLE_TYPE + "').toList()";
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", query);
JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.GREMLIN_SEARCH, queryParams);
assertNotNull(response);
assertNotNull(response.get(AtlasClient.REQUEST_ID));
assertEquals(response.getString("query"), query);
assertEquals(response.getString("queryType"), "gremlin");
}
Aggregations