Commit 28410df5 by apoorvnaik Committed by Suma Shivaprasad

ATLAS-1357: Fixes for test failures from ATLAS-1307

parent 2c881a46
...@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; ...@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import java.io.IOException; import java.io.IOException;
...@@ -398,7 +399,7 @@ public abstract class AtlasBaseClient { ...@@ -398,7 +399,7 @@ public abstract class AtlasBaseClient {
return callAPIWithResource(api, getResource(api, params), requestObject, responseType); return callAPIWithResource(api, getResource(api, params), requestObject, responseType);
} }
public <T> T callAPI(APIInfo api, Class<T> responseType, Map<String, String> queryParams, String... params) public <T> T callAPI(APIInfo api, Class<T> responseType, MultivaluedMap<String, String> queryParams, String... params)
throws AtlasServiceException { throws AtlasServiceException {
WebResource resource = getResource(api, queryParams, params); WebResource resource = getResource(api, queryParams, params);
return callAPIWithResource(api, resource, null, responseType); return callAPIWithResource(api, resource, null, responseType);
...@@ -415,12 +416,27 @@ public abstract class AtlasBaseClient { ...@@ -415,12 +416,27 @@ public abstract class AtlasBaseClient {
return resource; return resource;
} }
public <T> T callAPI(APIInfo api, Class<T> responseType, Map<String, String> queryParams) public <T> T callAPI(APIInfo api, Class<T> responseType, MultivaluedMap<String, String> queryParams)
throws AtlasServiceException { throws AtlasServiceException {
return callAPIWithResource(api, getResource(api, queryParams), null, responseType); return callAPIWithResource(api, getResource(api, queryParams), null, responseType);
} }
protected WebResource getResource(APIInfo api, Map<String, String> queryParams, String ... pathParams) { public <T> T callAPI(APIInfo api, Class<T> responseType, String queryParamKey, List<String> queryParamValues)
throws AtlasServiceException {
return callAPIWithResource(api, getResource(api, queryParamKey, queryParamValues), null, responseType);
}
private WebResource getResource(APIInfo api, String queryParamKey, List<String> queryParamValues) {
WebResource resource = service.path(api.getPath());
for (String queryParamValue : queryParamValues) {
if (StringUtils.isNotBlank(queryParamKey) && StringUtils.isNotBlank(queryParamValue)) {
resource = resource.queryParam(queryParamKey, queryParamValue);
}
}
return resource;
}
protected WebResource getResource(APIInfo api, MultivaluedMap<String, String> queryParams, String ... pathParams) {
WebResource resource = service.path(api.getPath()); WebResource resource = service.path(api.getPath());
resource = appendPathParams(resource, pathParams); resource = appendPathParams(resource, pathParams);
resource = appendQueryParams(queryParams, resource); resource = appendQueryParams(queryParams, resource);
...@@ -436,21 +452,25 @@ public abstract class AtlasBaseClient { ...@@ -436,21 +452,25 @@ public abstract class AtlasBaseClient {
return resource; return resource;
} }
protected WebResource getResource(APIInfo api, Map<String, String> queryParams) { protected WebResource getResource(APIInfo api, MultivaluedMap<String, String> queryParams) {
return getResource(service, api, queryParams); return getResource(service, api, queryParams);
} }
// Modify URL to include the query params // Modify URL to include the query params
private WebResource getResource(WebResource service, APIInfo api, Map<String, String> queryParams) { private WebResource getResource(WebResource service, APIInfo api, MultivaluedMap<String, String> queryParams) {
WebResource resource = service.path(api.getPath()); WebResource resource = service.path(api.getPath());
resource = appendQueryParams(queryParams, resource); resource = appendQueryParams(queryParams, resource);
return resource; return resource;
} }
private WebResource appendQueryParams(Map<String, String> queryParams, WebResource resource) { private WebResource appendQueryParams(MultivaluedMap<String, String> queryParams, WebResource resource) {
if (null != queryParams && !queryParams.isEmpty()) { if (null != queryParams && !queryParams.isEmpty()) {
for (Map.Entry<String, String> entry : queryParams.entrySet()) { for (Map.Entry<String, List<String>> entry : queryParams.entrySet()) {
resource = resource.queryParam(entry.getKey(), entry.getValue()); for (String value : entry.getValue()) {
if (StringUtils.isNotBlank(value)) {
resource = resource.queryParam(entry.getKey(), value);
}
}
} }
} }
return resource; return resource;
......
...@@ -17,18 +17,19 @@ ...@@ -17,18 +17,19 @@
*/ */
package org.apache.atlas.model; package org.apache.atlas.model;
import java.util.HashMap; import com.sun.jersey.core.util.MultivaluedMapImpl;
import java.util.Map;
import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonAutoDetect;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize; import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.ws.rs.core.MultivaluedMap;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/** /**
* Generic filter, to specify search criteria using name/value pairs. * Generic filter, to specify search criteria using name/value pairs.
...@@ -48,7 +49,7 @@ public class SearchFilter { ...@@ -48,7 +49,7 @@ public class SearchFilter {
*/ */
public enum SortType { NONE, ASC, DESC }; public enum SortType { NONE, ASC, DESC };
private Map<String, String> params = null; private MultivaluedMap<String, String> params = null;
private long startIndex = 0; private long startIndex = 0;
private long maxRows = Long.MAX_VALUE; private long maxRows = Long.MAX_VALUE;
private boolean getCount = true; private boolean getCount = true;
...@@ -59,20 +60,24 @@ public class SearchFilter { ...@@ -59,20 +60,24 @@ public class SearchFilter {
setParams(null); setParams(null);
} }
public SearchFilter(Map<String, String> params) { public SearchFilter(MultivaluedMap<String, String> params) {
setParams(params); setParams(params);
} }
public Map<String, String> getParams() { public MultivaluedMap<String, String> getParams() {
return params; return params;
} }
public void setParams(Map<String, String> params) { public void setParams(MultivaluedMap<String, String> params) {
this.params = params; this.params = params;
} }
public String getParam(String name) { public String getParam(String name) {
String ret = null; return getParams(name).get(0);
}
public List<String> getParams(String name) {
List<String> ret = null;
if (name != null && params != null) { if (name != null && params != null) {
ret = params.get(name); ret = params.get(name);
...@@ -84,10 +89,10 @@ public class SearchFilter { ...@@ -84,10 +89,10 @@ public class SearchFilter {
public void setParam(String name, String value) { public void setParam(String name, String value) {
if (name != null) { if (name != null) {
if (params == null) { if (params == null) {
params = new HashMap<String, String>(); params = new MultivaluedMapImpl();
} }
params.put(name, value); params.add(name, value);
} }
} }
......
...@@ -9,7 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -9,7 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: ALL CHANGES:
ATLAS-1307: Integration test calls routing via the Client. ((apoorvnaik via sumasai) ATLAS-1357: Fixes for test failures from ATLAS-1307 (apoorvnaik via sumasai)
ATLAS-1307: Integration test calls routing via the Client. (apoorvnaik via sumasai)
ATLAS-1355: Fix for bad error translation from V2 API (apoorvnaik via sumasai) ATLAS-1355: Fix for bad error translation from V2 API (apoorvnaik via sumasai)
ATLAS-1351 HiveHook fails with NPE for hive process registration (vimalsharma via sumasai) ATLAS-1351 HiveHook fails with NPE for hive process registration (vimalsharma via sumasai)
ATLAS-1342 Titan Solrclient - Add timeouts for zookeeper connect and session (sumasai) ATLAS-1342 Titan Solrclient - Add timeouts for zookeeper connect and session (sumasai)
......
...@@ -37,7 +37,7 @@ public class AdminJerseyResourceIT extends BaseResourceIT { ...@@ -37,7 +37,7 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testGetVersion() throws Exception { public void testGetVersion() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.VERSION, null, (String[]) null); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.VERSION, null, (String[]) null);
Assert.assertNotNull(response); Assert.assertNotNull(response);
PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties"); PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties");
......
...@@ -59,7 +59,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT { ...@@ -59,7 +59,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testInputsGraph() throws Exception { public void testInputsGraph() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_INPUTS_GRAPH, null, salesMonthlyTable, "inputs", "graph"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_INPUTS_GRAPH, null, salesMonthlyTable, "inputs", "graph");
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("inputs graph = " + response); System.out.println("inputs graph = " + response);
...@@ -95,7 +95,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT { ...@@ -95,7 +95,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testOutputsGraph() throws Exception { public void testOutputsGraph() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_OUTPUTS_GRAPH, null, salesFactTable, "outputs", "graph"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_OUTPUTS_GRAPH, null, salesFactTable, "outputs", "graph");
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("outputs graph= " + response); System.out.println("outputs graph= " + response);
...@@ -131,7 +131,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT { ...@@ -131,7 +131,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testSchema() throws Exception { public void testSchema() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesFactTable, "schema"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesFactTable, "schema");
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("schema = " + response); System.out.println("schema = " + response);
...@@ -175,12 +175,12 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT { ...@@ -175,12 +175,12 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class) @Test(expectedExceptions = AtlasServiceException.class)
public void testSchemaForInvalidTable() throws Exception { public void testSchemaForInvalidTable() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, "blah", "schema"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, "blah", "schema");
} }
@Test(expectedExceptions = AtlasServiceException.class) @Test(expectedExceptions = AtlasServiceException.class)
public void testSchemaForDB() throws Exception { public void testSchemaForDB() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesDBName, "schema"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesDBName, "schema");
} }
private void setupInstances() throws Exception { private void setupInstances() throws Exception {
......
...@@ -20,6 +20,7 @@ package org.apache.atlas.web.resources; ...@@ -20,6 +20,7 @@ package org.apache.atlas.web.resources;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.lineage.AtlasLineageInfo; import org.apache.atlas.model.lineage.AtlasLineageInfo;
...@@ -30,8 +31,8 @@ import org.testng.Assert; ...@@ -30,8 +31,8 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -42,7 +43,7 @@ import static org.apache.atlas.AtlasBaseClient.APIInfo; ...@@ -42,7 +43,7 @@ import static org.apache.atlas.AtlasBaseClient.APIInfo;
* Entity Lineage v2 Integration Tests. * Entity Lineage v2 Integration Tests.
*/ */
public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceIT { public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceIT {
private static final String BASE_URI = "api/atlas/v2/lineage/"; private static final String BASE_URI = "api/atlas/v2/lineage";
private static final APIInfo LINEAGE_V2_API = new APIInfo(BASE_URI, "GET", Response.Status.OK); private static final APIInfo LINEAGE_V2_API = new APIInfo(BASE_URI, "GET", Response.Status.OK);
private static final String INPUT_DIRECTION = "INPUT"; private static final String INPUT_DIRECTION = "INPUT";
private static final String OUTPUT_DIRECTION = "OUTPUT"; private static final String OUTPUT_DIRECTION = "OUTPUT";
...@@ -68,10 +69,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI ...@@ -68,10 +69,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId(); AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put(DIRECTION_PARAM, INPUT_DIRECTION); queryParams.add(DIRECTION_PARAM, INPUT_DIRECTION);
queryParams.put(DEPTH_PARAM, "5"); queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams); JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("input lineage info = " + response System.out.println("input lineage info = " + response
); );
...@@ -96,10 +97,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI ...@@ -96,10 +97,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId(); AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put(DIRECTION_PARAM, OUTPUT_DIRECTION); queryParams.add(DIRECTION_PARAM, OUTPUT_DIRECTION);
queryParams.put(DEPTH_PARAM, "5"); queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams); JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("output lineage info = " + response); System.out.println("output lineage info = " + response);
...@@ -124,10 +125,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI ...@@ -124,10 +125,10 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId(); AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put(DIRECTION_PARAM, BOTH_DIRECTION); queryParams.add(DIRECTION_PARAM, BOTH_DIRECTION);
queryParams.put(DEPTH_PARAM, "5"); queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams); JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response); Assert.assertNotNull(response);
System.out.println("both lineage info = " + response); System.out.println("both lineage info = " + response);
......
...@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources; ...@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasBaseClient; import org.apache.atlas.AtlasBaseClient;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
...@@ -41,10 +42,9 @@ import org.testng.Assert; ...@@ -41,10 +42,9 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
...@@ -73,9 +73,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -73,9 +73,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testSearchByDSL() throws Exception { public void testSearchByDSL() throws Exception {
String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\""; String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\"";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", dslQuery); queryParams.add("query", dslQuery);
JSONObject response = serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
...@@ -96,9 +96,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -96,9 +96,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
//search without new parameters of limit and offset should work //search without new parameters of limit and offset should work
String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\""; String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\"";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", dslQuery); queryParams.add("query", dslQuery);
JSONObject response = serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
assertNotNull(response); assertNotNull(response);
//higher limit, all results returned //higher limit, all results returned
...@@ -145,19 +145,19 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -145,19 +145,19 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class) @Test(expectedExceptions = AtlasServiceException.class)
public void testSearchByDSLForUnknownType() throws Exception { public void testSearchByDSLForUnknownType() throws Exception {
String dslQuery = "from blah"; String dslQuery = "from blah";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", dslQuery); queryParams.add("query", dslQuery);
JSONObject response = serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
} }
@Test @Test
public void testSearchUsingGremlin() throws Exception { public void testSearchUsingGremlin() throws Exception {
String query = "g.V.has('type', 'hive_db').toList()"; String query = "g.V.has('type', 'hive_db').toList()";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", query); queryParams.add("query", query);
JSONObject response = serviceClient.callAPI(AtlasClient.API.GREMLIN_SEARCH, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.GREMLIN_SEARCH, queryParams);
assertNotNull(response); assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
...@@ -170,9 +170,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -170,9 +170,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
public void testSearchUsingDSL() throws Exception { public void testSearchUsingDSL() throws Exception {
//String query = "from dsl_test_type"; //String query = "from dsl_test_type";
String query = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName +"\""; String query = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName +"\"";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", query); queryParams.add("query", query);
JSONObject response = serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH, queryParams);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
...@@ -184,9 +184,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -184,9 +184,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testSearchFullTextOnDSLFailure() throws Exception { public void testSearchFullTextOnDSLFailure() throws Exception {
String query = "*"; String query = "*";
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", query); queryParams.add("query", query);
JSONObject response = serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams); JSONObject response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH, queryParams);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
...@@ -216,9 +216,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -216,9 +216,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
//API works without limit and offset //API works without limit and offset
String query = dbName; String query = dbName;
Map<String, String> queryParams = new HashMap<>(); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("query", query); queryParams.add("query", query);
response = serviceClient.callAPI(AtlasClient.API.SEARCH_FULL_TEXT, queryParams); response = serviceClient.callAPIWithQueryParams(AtlasClient.API.SEARCH_FULL_TEXT, queryParams);
results = response.getJSONArray(AtlasClient.RESULTS); results = response.getJSONArray(AtlasClient.RESULTS);
assertEquals(results.length(), 1); assertEquals(results.length(), 1);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.apache.atlas.web.resources; package org.apache.atlas.web.resources;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.AtlasTypedefClientV2; import org.apache.atlas.AtlasTypedefClientV2;
import org.apache.atlas.model.SearchFilter; import org.apache.atlas.model.SearchFilter;
...@@ -41,19 +41,13 @@ import org.testng.annotations.AfterClass; ...@@ -41,19 +41,13 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Collections; import javax.ws.rs.core.MultivaluedMap;
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Collections;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality; import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality;
import static org.apache.atlas.type.AtlasTypeUtil.createClassTypeDef; import static org.apache.atlas.type.AtlasTypeUtil.createClassTypeDef;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.*;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
/** /**
* Integration test for types jersey resource. * Integration test for types jersey resource.
...@@ -136,8 +130,8 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT { ...@@ -136,8 +130,8 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
assertEquals(updatedTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); assertEquals(updatedTypeDefs.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName()); assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName());
Map<String, String> filterParams = new HashMap<>(); MultivaluedMap<String, String> filterParams = new MultivaluedMapImpl();
filterParams.put(SearchFilter.PARAM_TYPE, "ENTITY"); filterParams.add(SearchFilter.PARAM_TYPE, "ENTITY");
AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams)); AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams));
assertNotNull(allTypeDefs); assertNotNull(allTypeDefs);
Boolean entityDefFound = false; Boolean entityDefFound = false;
...@@ -265,15 +259,15 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT { ...@@ -265,15 +259,15 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
assertNotNull(created); assertNotNull(created);
assertEquals(created.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size()); assertEquals(created.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size());
Map<String, String> searchParams = new HashMap<>(); MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();
searchParams.put(SearchFilter.PARAM_TYPE, "CLASS"); searchParams.add(SearchFilter.PARAM_TYPE, "CLASS");
searchParams.put(SearchFilter.PARAM_SUPERTYPE, classDefA.getName()); searchParams.add(SearchFilter.PARAM_SUPERTYPE, classDefA.getName());
SearchFilter searchFilter = new SearchFilter(searchParams); SearchFilter searchFilter = new SearchFilter(searchParams);
AtlasTypesDef searchDefs = clientV2.getAllTypeDefs(searchFilter); AtlasTypesDef searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs); assertNotNull(searchDefs);
assertEquals(searchDefs.getEntityDefs().size(), 2); assertEquals(searchDefs.getEntityDefs().size(), 2);
searchParams.put(SearchFilter.PARAM_NOT_SUPERTYPE, classDefB.getName()); searchParams.add(SearchFilter.PARAM_NOT_SUPERTYPE, classDefB.getName());
searchFilter = new SearchFilter(searchParams); searchFilter = new SearchFilter(searchParams);
searchDefs = clientV2.getAllTypeDefs(searchFilter); searchDefs = clientV2.getAllTypeDefs(searchFilter);
assertNotNull(searchDefs); assertNotNull(searchDefs);
......
...@@ -81,7 +81,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -81,7 +81,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
String typesAsJSON = TypesSerialization.toJson(typeDefinition, false); String typesAsJSON = TypesSerialization.toJson(typeDefinition, false);
System.out.println("typesAsJSON = " + typesAsJSON); System.out.println("typesAsJSON = " + typesAsJSON);
JSONObject response = serviceClient.callAPI(AtlasClient.API.CREATE_TYPE, typesAsJSON); JSONObject response = serviceClient.callAPIWithBody(AtlasClient.API.CREATE_TYPE, typesAsJSON);
Assert.assertNotNull(response); Assert.assertNotNull(response);
...@@ -142,7 +142,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -142,7 +142,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) { for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) {
System.out.println("typeName = " + typeDefinition.typeName); System.out.println("typeName = " + typeDefinition.typeName);
JSONObject response = serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, typeDefinition.typeName); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.LIST_TYPES, null, typeDefinition.typeName);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.DEFINITION)); Assert.assertNotNull(response.get(AtlasClient.DEFINITION));
...@@ -164,12 +164,12 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -164,12 +164,12 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class) @Test(expectedExceptions = AtlasServiceException.class)
public void testGetDefinitionForNonexistentType() throws Exception { public void testGetDefinitionForNonexistentType() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, "blah"); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.LIST_TYPES, null, "blah");
} }
@Test(dependsOnMethods = "testSubmit") @Test(dependsOnMethods = "testSubmit")
public void testGetTypeNames() throws Exception { public void testGetTypeNames() throws Exception {
JSONObject response = serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, (String[]) null); JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.LIST_TYPES, null, (String[]) null);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
...@@ -190,7 +190,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -190,7 +190,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
Map<String, String> queryParams = new HashMap<>(); Map<String, String> queryParams = new HashMap<>();
queryParams.put("type", DataTypes.TypeCategory.TRAIT.name()); queryParams.put("type", DataTypes.TypeCategory.TRAIT.name());
JSONObject response = serviceClient.callAPI(AtlasClient.API.LIST_TYPES, queryParams); JSONObject response = serviceClient.callAPIWithBody(AtlasClient.API.LIST_TYPES, queryParams);
Assert.assertNotNull(response); Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment