Repository: incubator-atlas
Updated Branches:
  refs/heads/master de6122fa3 -> 2c881a466


ATLAS-1307: Integration test calls routing via the Client.


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/2c881a46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/2c881a46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/2c881a46

Branch: refs/heads/master
Commit: 2c881a4668de7c077c01df886158423d20d65b8a
Parents: de6122f
Author: apoorvnaik <[email protected]>
Authored: Sun Nov 20 19:58:12 2016 -0800
Committer: Suma Shivaprasad <[email protected]>
Committed: Wed Dec 7 18:45:06 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/atlas/AtlasBaseClient.java  |  72 +++---
 .../main/java/org/apache/atlas/AtlasClient.java |  48 +++-
 .../org/apache/atlas/AtlasEntitiesClientV2.java |   2 +-
 .../org/apache/atlas/AtlasTypedefClientV2.java  |   2 +-
 release-log.txt                                 |   1 +
 .../notification/EntityNotificationIT.java      |  29 +--
 .../web/resources/AdminJerseyResourceIT.java    |  19 +-
 .../atlas/web/resources/BaseResourceIT.java     |  15 +-
 .../DataSetLineageJerseyResourceIT.java         |  61 +----
 .../web/resources/EntityJerseyResourceIT.java   | 257 +++++--------------
 .../EntityLineageJerseyResourceIT.java          |  59 ++---
 .../MetadataDiscoveryJerseyResourceIT.java      |  91 +++----
 .../web/resources/TypesJerseyResourceIT.java    |  68 ++---
 13 files changed, 241 insertions(+), 483 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/client/src/main/java/org/apache/atlas/AtlasBaseClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasBaseClient.java 
b/client/src/main/java/org/apache/atlas/AtlasBaseClient.java
index 04a418a..72fd69e 100644
--- a/client/src/main/java/org/apache/atlas/AtlasBaseClient.java
+++ b/client/src/main/java/org/apache/atlas/AtlasBaseClient.java
@@ -224,8 +224,8 @@ public abstract class AtlasBaseClient {
         String activeServerAddress = null;
         for (int i = 0; i < getNumberOfRetries(); i++) {
             try {
-                WebResource service = 
client.resource(UriBuilder.fromUri(serverInstance).build());
-                String adminStatus = getAdminStatus(service);
+                service = 
client.resource(UriBuilder.fromUri(serverInstance).build());
+                String adminStatus = getAdminStatus();
                 if (StringUtils.equals(adminStatus, "ACTIVE")) {
                     activeServerAddress = serverInstance;
                     break;
@@ -315,11 +315,7 @@ public abstract class AtlasBaseClient {
 
     private WebResource getResource(WebResource service, String path, 
String... pathParams) {
         WebResource resource = service.path(path);
-        if (pathParams != null) {
-            for (String pathParam : pathParams) {
-                resource = resource.path(pathParam);
-            }
-        }
+        resource = appendPathParams(resource, pathParams);
         return resource;
     }
 
@@ -347,10 +343,6 @@ public abstract class AtlasBaseClient {
      * @throws AtlasServiceException if there is a HTTP error.
      */
     public String getAdminStatus() throws AtlasServiceException {
-        return getAdminStatus(service);
-    }
-
-    private String getAdminStatus(WebResource service) throws 
AtlasServiceException {
         String result = AtlasBaseClient.UNKNOWN_STATUS;
         WebResource resource = getResource(service, STATUS.getPath());
         JSONObject response = callAPIWithResource(STATUS, resource, null, 
JSONObject.class);
@@ -380,14 +372,6 @@ public abstract class AtlasBaseClient {
         throw che;
     }
 
-    public boolean isRetryEnabled() {
-        return retryEnabled;
-    }
-
-    public void setRetryEnabled(boolean retryEnabled) {
-        this.retryEnabled = retryEnabled;
-    }
-
     @VisibleForTesting
     JSONObject callAPIWithRetries(APIInfo api, Object requestObject, 
ResourceCreator resourceCreator)
             throws AtlasServiceException {
@@ -395,7 +379,7 @@ public abstract class AtlasBaseClient {
             WebResource resource = resourceCreator.createResource();
             try {
                 LOG.debug("Using resource {} for {} times", resource.getURI(), 
i);
-                JSONObject result = callAPIWithResource(api, resource, 
requestObject);
+                JSONObject result = callAPIWithResource(api, resource, 
requestObject, JSONObject.class);
                 return result;
             } catch (ClientHandlerException che) {
                 if (i == (getNumberOfRetries() - 1)) {
@@ -409,24 +393,15 @@ public abstract class AtlasBaseClient {
         throw new AtlasServiceException(api, new RuntimeException("Could not 
get response after retries."));
     }
 
-    protected JSONObject callAPIWithResource(APIInfo api, WebResource 
resource, Object requestObject)
-            throws AtlasServiceException {
-        return callAPIWithResource(api, resource, requestObject, 
JSONObject.class);
-    }
-
-    protected JSONObject callAPI(final APIInfo api, Object requestObject, 
final String... pathParams)
+    public <T> T callAPI(APIInfo api, Object requestObject, Class<T> 
responseType, String... params)
             throws AtlasServiceException {
-        return callAPIWithRetries(api, requestObject, new ResourceCreator() {
-            @Override
-            public WebResource createResource() {
-                return getResource(api, pathParams);
-            }
-        });
+        return callAPIWithResource(api, getResource(api, params), 
requestObject, responseType);
     }
 
-    protected <T> T callAPI(APIInfo api, Object requestObject, Class<T> 
responseType, String... params)
+    public <T> T callAPI(APIInfo api, Class<T> responseType, Map<String, 
String> queryParams, String... params)
             throws AtlasServiceException {
-        return callAPIWithResource(api, getResource(api, params), 
requestObject, responseType);
+        WebResource resource = getResource(api, queryParams, params);
+        return callAPIWithResource(api, resource, null, responseType);
     }
 
     protected WebResource getResource(APIInfo api, String... pathParams) {
@@ -436,6 +411,23 @@ public abstract class AtlasBaseClient {
     // Modify URL to include the path params
     private WebResource getResource(WebResource service, APIInfo api, 
String... pathParams) {
         WebResource resource = service.path(api.getPath());
+        resource = appendPathParams(resource, pathParams);
+        return resource;
+    }
+
+    public <T> T callAPI(APIInfo api, Class<T> responseType, Map<String, 
String> queryParams)
+            throws AtlasServiceException {
+        return callAPIWithResource(api, getResource(api, queryParams), null, 
responseType);
+    }
+
+    protected WebResource getResource(APIInfo api, Map<String, String> 
queryParams, String ... pathParams) {
+        WebResource resource = service.path(api.getPath());
+        resource = appendPathParams(resource, pathParams);
+        resource = appendQueryParams(queryParams, resource);
+        return resource;
+    }
+
+    private WebResource appendPathParams(WebResource resource, String[] 
pathParams) {
         if (pathParams != null) {
             for (String pathParam : pathParams) {
                 resource = resource.path(pathParam);
@@ -444,11 +436,6 @@ public abstract class AtlasBaseClient {
         return resource;
     }
 
-    protected <T> T callAPI(APIInfo api, Object requestObject, Class<T> 
responseType, Map<String, String> queryParams)
-            throws AtlasServiceException {
-        return callAPIWithResource(api, getResource(api, queryParams), 
requestObject, responseType);
-    }
-
     protected WebResource getResource(APIInfo api, Map<String, String> 
queryParams) {
         return getResource(service, api, queryParams);
     }
@@ -456,6 +443,11 @@ public abstract class AtlasBaseClient {
     // Modify URL to include the query params
     private WebResource getResource(WebResource service, APIInfo api, 
Map<String, String> queryParams) {
         WebResource resource = service.path(api.getPath());
+        resource = appendQueryParams(queryParams, resource);
+        return resource;
+    }
+
+    private WebResource appendQueryParams(Map<String, String> queryParams, 
WebResource resource) {
         if (null != queryParams && !queryParams.isEmpty()) {
             for (Map.Entry<String, String> entry : queryParams.entrySet()) {
                 resource = resource.queryParam(entry.getKey(), 
entry.getValue());
@@ -484,7 +476,7 @@ public abstract class AtlasBaseClient {
         private final String path;
         private final Response.Status status;
 
-        APIInfo(String path, String method, Response.Status status) {
+        public APIInfo(String path, String method, Response.Status status) {
             this.path = path;
             this.method = method;
             this.status = status;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/client/src/main/java/org/apache/atlas/AtlasClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasClient.java 
b/client/src/main/java/org/apache/atlas/AtlasClient.java
index 70e1a0d..a2fabdb 100755
--- a/client/src/main/java/org/apache/atlas/AtlasClient.java
+++ b/client/src/main/java/org/apache/atlas/AtlasClient.java
@@ -20,9 +20,7 @@ package org.apache.atlas;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
-
 import com.sun.jersey.api.client.WebResource;
-
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.typesystem.Referenceable;
 import org.apache.atlas.typesystem.Struct;
@@ -43,6 +41,8 @@ import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -50,9 +50,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.Response;
-
 /**
  * Client for metadata.
  */
@@ -208,6 +205,8 @@ public class AtlasClient extends AtlasBaseClient {
         SEARCH_DSL(BASE_URI + URI_SEARCH + "/dsl", HttpMethod.GET, 
Response.Status.OK),
         SEARCH_FULL_TEXT(BASE_URI + URI_SEARCH + "/fulltext", HttpMethod.GET, 
Response.Status.OK),
 
+        GREMLIN_SEARCH(BASE_URI + URI_SEARCH + "/gremlin", HttpMethod.GET, 
Response.Status.OK),
+
         //Lineage operations based on dataset name
         NAME_LINEAGE_INPUTS_GRAPH(BASE_URI + URI_NAME_LINEAGE, HttpMethod.GET, 
Response.Status.OK),
         NAME_LINEAGE_OUTPUTS_GRAPH(BASE_URI + URI_NAME_LINEAGE, 
HttpMethod.GET, Response.Status.OK),
@@ -566,6 +565,16 @@ public class AtlasClient extends AtlasBaseClient {
     }
 
     /**
+     * Delete a trait from the given entity
+     * @param guid guid of the entity
+     * @param traitName trait to be deleted
+     * @throws AtlasServiceException
+     */
+    public void deleteTrait(String guid, String traitName) throws 
AtlasServiceException {
+        callAPI(API.DELETE_TRAITS, null, guid, TRAITS, traitName);
+    }
+
+    /**
      * Supports Partial updates
      * Updates properties set in the definition for the entity corresponding 
to guid
      * @param entityType Type of the entity being updated
@@ -644,7 +653,7 @@ public class AtlasClient extends AtlasBaseClient {
         resource = resource.queryParam(TYPE, entityType);
         resource = resource.queryParam(ATTRIBUTE_NAME, uniqueAttributeName);
         resource = resource.queryParam(ATTRIBUTE_VALUE, uniqueAttributeValue);
-        JSONObject jsonResponse = callAPIWithResource(API.DELETE_ENTITIES, 
resource, null);
+        JSONObject jsonResponse = callAPIWithResource(API.DELETE_ENTITIES, 
resource);
         EntityResult results = extractEntityResult(jsonResponse);
         LOG.debug("Delete entities returned results: {}", results);
         return results;
@@ -814,7 +823,7 @@ public class AtlasClient extends AtlasBaseClient {
         }
         resource = resource.queryParam(NUM_RESULTS, 
String.valueOf(numResults));
 
-        JSONObject jsonResponse = callAPIWithResource(API.LIST_ENTITY_AUDIT, 
resource, null);
+        JSONObject jsonResponse = callAPIWithResource(API.LIST_ENTITY_AUDIT, 
resource);
         return extractResults(jsonResponse, AtlasClient.EVENTS, new 
ExtractOperation<EntityAuditEvent, JSONObject>() {
             @Override
             EntityAuditEvent extractElement(JSONObject element) throws 
JSONException {
@@ -945,19 +954,32 @@ public class AtlasClient extends AtlasBaseClient {
     }
 
     // Wrapper methods for compatibility
-
-    JSONObject callAPIWithResource(API api, WebResource resource, Object 
requestObject) throws AtlasServiceException {
-        return callAPIWithResource(toAPIInfo(api), resource, requestObject);
+    @VisibleForTesting
+    public JSONObject callAPIWithResource(API api, WebResource resource) 
throws AtlasServiceException {
+        return callAPIWithResource(toAPIInfo(api), resource, null, 
JSONObject.class);
     }
 
-    WebResource getResource(API api, String ... params) {
+    @VisibleForTesting
+    public WebResource getResource(API api, String ... params) {
         return getResource(toAPIInfo(api), params);
     }
 
-    JSONObject callAPI(API api, Object requestObject, String ... params) 
throws AtlasServiceException {
-        return callAPI(toAPIInfo(api), requestObject, params);
+    @VisibleForTesting
+    public JSONObject callAPI(API api, Object requestObject) throws 
AtlasServiceException {
+        return callAPI(toAPIInfo(api), requestObject, JSONObject.class, 
(String[]) null);
+    }
+
+    @VisibleForTesting
+    public JSONObject callAPI(API api, Object requestObject, String ... 
params) throws AtlasServiceException {
+        return callAPI(toAPIInfo(api), requestObject, JSONObject.class, 
params);
+    }
+
+    @VisibleForTesting
+    public JSONObject callAPI(API api, Map<String, String> queryParams) throws 
AtlasServiceException {
+        return callAPI(toAPIInfo(api), JSONObject.class, queryParams);
     }
 
+    @VisibleForTesting
     JSONObject callAPIWithRetries(API api, Object requestObject, 
ResourceCreator resourceCreator) throws AtlasServiceException {
         return super.callAPIWithRetries(toAPIInfo(api), requestObject, 
resourceCreator);
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java 
b/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
index fae4dd8..16556c8 100644
--- a/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
+++ b/client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
@@ -131,6 +131,6 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
     }
 
     public AtlasEntity.AtlasEntities searchEntities(SearchFilter searchFilter) 
throws AtlasServiceException {
-        return callAPI(GET_ENTITIES, null, AtlasEntity.AtlasEntities.class, 
searchFilter.getParams());
+        return callAPI(GET_ENTITIES, AtlasEntity.AtlasEntities.class, 
searchFilter.getParams());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java 
b/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
index cf86e7a..a193524 100644
--- a/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
+++ b/client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
@@ -73,7 +73,7 @@ public class AtlasTypedefClientV2 extends AtlasBaseClient {
      * @return A composite wrapper object with lists of all type definitions
      */
     public AtlasTypesDef getAllTypeDefs(SearchFilter searchFilter) throws 
AtlasServiceException {
-        return callAPI(GET_ALL_TYPE_DEFS, null, AtlasTypesDef.class, 
searchFilter.getParams());
+        return callAPI(GET_ALL_TYPE_DEFS, AtlasTypesDef.class, 
searchFilter.getParams());
     }
 
     public AtlasEnumDef getEnumByName(final String name) throws 
AtlasServiceException {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 5a87d9b..058377a 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ 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)
 
 ALL CHANGES:
+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-1351 HiveHook fails with NPE for hive process registration (vimalsharma 
via sumasai)
 ATLAS-1342 Titan Solrclient - Add timeouts for zookeeper connect and session 
(sumasai)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java 
b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
index 081d5ca..ec62112 100644
--- 
a/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
@@ -20,8 +20,6 @@ package org.apache.atlas.notification;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.inject.Inject;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.notification.entity.EntityNotification;
 import org.apache.atlas.typesystem.IReferenceableInstance;
@@ -35,14 +33,10 @@ import 
org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import org.apache.atlas.web.resources.BaseResourceIT;
-import org.apache.atlas.web.util.Servlets;
-import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.Response;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -144,8 +138,7 @@ public class EntityNotificationIT extends BaseResourceIT {
 
         final String guid = tableId._getId();
 
-        ClientResponse clientResponse = addTrait(guid, traitInstanceJSON);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
+        serviceClient.addTrait(guid, traitInstance);
 
         EntityNotification entityNotification = 
waitForNotification(notificationConsumer, MAX_WAIT_TIME,
                 
newNotificationPredicate(EntityNotification.OperationType.TRAIT_ADD, 
HIVE_TABLE_TYPE, guid));
@@ -170,8 +163,7 @@ public class EntityNotificationIT extends BaseResourceIT {
         traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
         LOG.debug("Trait instance = " + traitInstanceJSON);
 
-        clientResponse = addTrait(guid, traitInstanceJSON);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
+        serviceClient.addTrait(guid, traitInstance);
 
         entityNotification = waitForNotification(notificationConsumer, 
MAX_WAIT_TIME,
                 
newNotificationPredicate(EntityNotification.OperationType.TRAIT_ADD, 
HIVE_TABLE_TYPE, guid));
@@ -192,8 +184,7 @@ public class EntityNotificationIT extends BaseResourceIT {
     public void testDeleteTrait() throws Exception {
         final String guid = tableId._getId();
 
-        ClientResponse clientResponse = deleteTrait(guid, traitName);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        serviceClient.deleteTrait(guid, traitName);
 
         EntityNotification entityNotification = 
waitForNotification(notificationConsumer, MAX_WAIT_TIME,
                 
newNotificationPredicate(EntityNotification.OperationType.TRAIT_DELETE, 
HIVE_TABLE_TYPE, guid));
@@ -213,18 +204,4 @@ public class EntityNotificationIT extends BaseResourceIT {
         createType(traitDefinitionJSON);
     }
 
-    private ClientResponse addTrait(String guid, String traitInstance) {
-        WebResource resource = service.path(ENTITIES).path(guid).path(TRAITS);
-
-        return resource.accept(Servlets.JSON_MEDIA_TYPE)
-            .type(Servlets.JSON_MEDIA_TYPE)
-            .method(HttpMethod.POST, ClientResponse.class, traitInstance);
-    }
-
-    private ClientResponse deleteTrait(String guid, String traitName) {
-        WebResource resource = 
service.path(ENTITIES).path(guid).path(TRAITS).path(traitName);
-
-        return 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-            .method(HttpMethod.DELETE, ClientResponse.class);
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
index e7af0b2..110a7bb 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
@@ -18,18 +18,13 @@
 
 package org.apache.atlas.web.resources;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import org.apache.atlas.web.util.Servlets;
+import org.apache.atlas.AtlasClient;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.Response;
-
 /**
  * Integration test for Admin jersey resource.
  */
@@ -42,19 +37,11 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
 
     @Test
     public void testGetVersion() throws Exception {
-        WebResource resource = service.path("api/atlas/admin/version");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        JSONObject response = serviceClient.callAPI(AtlasClient.API.VERSION, 
null, (String[]) null);
+        Assert.assertNotNull(response);
 
         PropertiesConfiguration buildConfiguration = new 
PropertiesConfiguration("atlas-buildinfo.properties");
 
-
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertEquals(response.get("Version"), 
buildConfiguration.getString("build.version"));
         Assert.assertEquals(response.get("Name"), 
buildConfiguration.getString("project.name"));
         Assert.assertEquals(response.get("Description"), 
buildConfiguration.getString("project.description"));

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java 
b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
index 1777f75..325c25b 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
@@ -21,7 +21,6 @@ package org.apache.atlas.web.resources;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import com.sun.jersey.api.client.WebResource;
 import kafka.consumer.ConsumerTimeoutException;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasClient;
@@ -34,17 +33,7 @@ import org.apache.atlas.typesystem.TypesDef;
 import org.apache.atlas.typesystem.json.InstanceSerialization;
 import org.apache.atlas.typesystem.json.TypesSerialization;
 import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.types.AttributeDefinition;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes;
-import org.apache.atlas.typesystem.types.EnumTypeDefinition;
-import org.apache.atlas.typesystem.types.EnumValue;
-import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
-import org.apache.atlas.typesystem.types.IDataType;
-import org.apache.atlas.typesystem.types.Multiplicity;
-import org.apache.atlas.typesystem.types.StructTypeDefinition;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.TypeUtils;
+import org.apache.atlas.typesystem.types.*;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import org.apache.atlas.utils.AuthenticationUtil;
 import org.apache.atlas.utils.ParamChecker;
@@ -68,7 +57,6 @@ import java.util.Map;
 public abstract class BaseResourceIT {
 
     public static final String ATLAS_REST_ADDRESS = "atlas.rest.address";
-    protected WebResource service;
     protected AtlasClient serviceClient;
     public static final Logger LOG = 
LoggerFactory.getLogger(BaseResourceIT.class);
     protected static final int MAX_WAIT_TIME = 60000;
@@ -89,7 +77,6 @@ public abstract class BaseResourceIT {
         } else {
             serviceClient = new AtlasClient(atlasUrls);
         }
-        service = serviceClient.getResource();
     }
 
     protected void createType(TypesDef typesDef) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
index d9f14d0..011701a 100644
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
@@ -19,14 +19,12 @@
 package org.apache.atlas.web.resources;
 
 import com.google.common.collect.ImmutableList;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.atlas.AtlasClient;
+import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.typesystem.Referenceable;
 import org.apache.atlas.typesystem.Struct;
 import org.apache.atlas.typesystem.json.InstanceSerialization;
 import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.web.util.Servlets;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
@@ -37,8 +35,6 @@ import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import com.google.common.collect.ImmutableSet;
 
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.Response;
 import java.util.List;
 import java.util.Map;
 
@@ -49,7 +45,6 @@ import static org.testng.Assert.assertEquals;
  */
 public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
 
-    private static final String BASE_URI = "api/atlas/lineage/hive/table/";
     private String salesFactTable;
     private String salesMonthlyTable;
     private String salesDBName;
@@ -64,17 +59,10 @@ public class DataSetLineageJerseyResourceIT extends 
BaseResourceIT {
 
     @Test
     public void testInputsGraph() throws Exception {
-        WebResource resource = 
service.path(BASE_URI).path(salesMonthlyTable).path("inputs").path("graph");
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_INPUTS_GRAPH, null, 
salesMonthlyTable, "inputs", "graph");
+        Assert.assertNotNull(response);
+        System.out.println("inputs graph = " + response);
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("inputs graph = " + responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         JSONObject results = response.getJSONObject(AtlasClient.RESULTS);
@@ -107,17 +95,10 @@ public class DataSetLineageJerseyResourceIT extends 
BaseResourceIT {
 
     @Test
     public void testOutputsGraph() throws Exception {
-        WebResource resource = 
service.path(BASE_URI).path(salesFactTable).path("outputs").path("graph");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_OUTPUTS_GRAPH, null, 
salesFactTable, "outputs", "graph");
+        Assert.assertNotNull(response);
+        System.out.println("outputs graph= " + response);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("outputs graph= " + responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         JSONObject results = response.getJSONObject(AtlasClient.RESULTS);
@@ -150,17 +131,11 @@ public class DataSetLineageJerseyResourceIT extends 
BaseResourceIT {
 
     @Test
     public void testSchema() throws Exception {
-        WebResource resource = 
service.path(BASE_URI).path(salesFactTable).path("schema");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, 
salesFactTable, "schema");
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("schema = " + responseAsString);
+        Assert.assertNotNull(response);
+        System.out.println("schema = " + response);
 
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         JSONObject results = response.getJSONObject(AtlasClient.RESULTS);
@@ -198,22 +173,14 @@ public class DataSetLineageJerseyResourceIT extends 
BaseResourceIT {
         }
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testSchemaForInvalidTable() throws Exception {
-        WebResource resource = 
service.path(BASE_URI).path("blah").path("schema");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, "blah", 
"schema");
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testSchemaForDB() throws Exception {
-        WebResource resource = 
service.path(BASE_URI).path(salesDBName).path("schema");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-            .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesDBName, 
"schema");
     }
 
     private void setupInstances() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
index 38c823a..28b6325 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
@@ -1,4 +1,4 @@
-    /**
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -24,7 +24,6 @@ import com.google.gson.Gson;
 import com.google.gson.JsonSyntaxException;
 import com.google.inject.Inject;
 import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.EntityAuditEvent;
@@ -49,10 +48,8 @@ import 
org.apache.atlas.typesystem.types.StructTypeDefinition;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import org.apache.atlas.utils.AuthenticationUtil;
-import org.apache.atlas.web.util.Servlets;
 import org.apache.commons.lang.RandomStringUtils;
 import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.joda.time.DateTime;
 import org.slf4j.Logger;
@@ -63,7 +60,6 @@ import org.testng.annotations.DataProvider;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -172,16 +168,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
         databaseInstance.set("parameters", Collections.EMPTY_MAP);
         databaseInstance.set("location", "/tmp");
 
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class,
-                                InstanceSerialization.toJson(databaseInstance, 
true));
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = serviceClient
+                .callAPI(AtlasClient.API.CREATE_ENTITY, 
InstanceSerialization.toJson(databaseInstance, true));
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         AtlasClient.EntityResult entityResult = 
AtlasClient.EntityResult.fromString(response.toString());
@@ -333,8 +322,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         String description = "bar table - new desc";
         addProperty(guid, "description", description);
 
-        String entityRef = getEntityDefinition(getEntityDefinition(guid));
-        Assert.assertNotNull(entityRef);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, guid);
+        Assert.assertNotNull(response);
 
         tableInstance.set("description", description);
 
@@ -349,8 +338,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         String currentTime = String.valueOf(new DateTime() );
         addProperty(guid, "createTime", currentTime);
 
-        entityRef = getEntityDefinition(getEntityDefinition(guid));
-        Assert.assertNotNull(entityRef);
+        response = serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, 
guid);
+        Assert.assertNotNull(response);
 
         tableInstance.set("createTime", currentTime);
     }
@@ -401,13 +390,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
     @Test(dependsOnMethods = "testSubmitEntity")
     public void testGetEntityDefinition() throws Exception {
         final String guid = tableId._getId();
-        ClientResponse clientResponse = getEntityDefinition(guid);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, guid);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        Assert.assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final String definition = response.getString(AtlasClient.DEFINITION);
@@ -422,38 +407,13 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         assertEquals(entityResult.getUpdateEntities().get(0), guid);
     }
 
-    private ClientResponse getEntityDefinition(String guid) {
-        WebResource resource = service.path(ENTITIES).path(guid);
-        return 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-    }
-
-    private String getEntityDefinition(ClientResponse clientResponse) throws 
Exception {
-        JSONObject response = getEntity(clientResponse);
-        final String definition = response.getString(AtlasClient.DEFINITION);
-        Assert.assertNotNull(definition);
-
-        return definition;
-    }
-
-    private JSONObject getEntity(ClientResponse clientResponse) throws 
JSONException {
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-        JSONObject response = new 
JSONObject(clientResponse.getEntity(String.class));
-        return response;
-    }
-
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testGetInvalidEntityDefinition() throws Exception {
-        WebResource resource = service.path(ENTITIES).path("blah");
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, "blah");
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        Assert.assertNotNull(response);
 
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.ERROR));
         Assert.assertNotNull(response.get(AtlasClient.STACKTRACE));
     }
@@ -465,17 +425,13 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         Assert.assertTrue(entities.contains(tableId._getId()));
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testGetEntityListForBadEntityType() throws Exception {
-        ClientResponse clientResponse =
-                service.path(ENTITIES).queryParam("type", 
"blah").accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, 
ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.BAD_REQUEST.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("type", "blah");
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, queryParams);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.ERROR));
         Assert.assertNotNull(response.get(AtlasClient.STACKTRACE));
     }
@@ -485,15 +441,11 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
     public void testGetEntityListForNoInstances() throws Exception {
         String typeName = addNewType();
 
-        ClientResponse clientResponse =
-                service.path(ENTITIES).queryParam("type", 
typeName).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, 
ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("type", typeName);
 
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, queryParams);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
@@ -515,15 +467,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
     @Test(dependsOnMethods = "testSubmitEntity")
     public void testGetTraitNames() throws Exception {
         final String guid = tableId._getId();
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, 
ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
 
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.LIST_TRAITS, null, guid, TRAITS);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
@@ -544,16 +490,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
         LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
 
         final String guid = tableId._getId();
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
traitInstanceAsJSON);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, 
TRAITS);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_ADD);
@@ -573,12 +511,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
         LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
 
         final String guid = tableId._getId();
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
traitInstanceAsJSON);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
-
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, 
TRAITS);
+        assertNotNull(response);
         Struct traitDef = serviceClient.getTraitDefinition(guid, traitName);
         System.out.println(traitDef.toString());
         JSONObject responseAsJSON = new 
JSONObject(InstanceSerialization.toJson(traitDef, true));
@@ -590,7 +524,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         Assert.assertEquals(allTraitDefs.size(), 9);
     }
 
-    @Test(dependsOnMethods = "testAddTrait")
+    @Test(dependsOnMethods = "testAddTrait", expectedExceptions = 
AtlasServiceException.class)
     public void testAddExistingTrait() throws Exception {
         final String traitName = "PII_Trait" + randomString();
 
@@ -599,11 +533,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT 
{
         LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
 
         final String guid = tableId._getId();
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
traitInstanceAsJSON);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, 
TRAITS);
+        assertNotNull(response);
     }
 
     @Test(dependsOnMethods = "testGetTraitNames")
@@ -622,24 +553,12 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
 
         final String guid = tableId._getId();
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
traitInstanceAsJSON);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, 
TRAITS);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         // verify the response
-        clientResponse = getEntityDefinition(guid);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-        responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        response = new JSONObject(responseAsString);
+        response = serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, 
guid);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final String definition = response.getString(AtlasClient.DEFINITION);
@@ -650,7 +569,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         Assert.assertEquals(type, "SSN");
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testAddTraitWithNoRegistration() throws Exception {
         final String traitName = "PII_Trait" + randomString();
         HierarchicalTypeDefinition<TraitType> piiTrait =
@@ -662,53 +581,33 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         String traitInstanceAsJSON = 
InstanceSerialization$.MODULE$.toJson(traitInstance, true);
         LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
 
-        ClientResponse clientResponse =
-                
service.path(ENTITIES).path("random").path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
traitInstanceAsJSON);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.CREATE_ENTITY, traitInstanceAsJSON, 
"random", TRAITS);
     }
 
     @Test(dependsOnMethods = "testAddTrait")
     public void testDeleteTrait() throws Exception {
         final String guid = tableId._getId();
 
-        ClientResponse clientResponse = 
service.path(ENTITIES).path(guid).path(TRAITS).path(traitName)
-                
.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.DELETE, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.DELETE_TRAITS, null, guid, TRAITS, 
traitName);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
         Assert.assertNotNull(response.get("traitName"));
         assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_DELETE);
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testDeleteTraitNonExistent() throws Exception {
         final String traitName = "blah_trait";
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.DELETE_TRAITS, null, "random", TRAITS);
 
-        ClientResponse clientResponse = 
service.path(ENTITIES).path("random").path(TRAITS).path(traitName)
-                
.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.DELETE, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.ERROR));
         Assert.assertEquals(response.getString(AtlasClient.ERROR),
                 "trait=" + traitName + " should be defined in type system 
before it can be deleted");
         Assert.assertNotNull(response.get(AtlasClient.STACKTRACE));
     }
 
-    @Test(dependsOnMethods = "testSubmitEntity()")
+    @Test(dependsOnMethods = "testSubmitEntity")
     public void testDeleteExistentTraitNonExistentForEntity() throws Exception 
{
-    
+
         final String guid = tableId._getId();
         final String traitName = "PII_Trait" + randomString();
         HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil
@@ -716,22 +615,12 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
                         TypesUtil.createRequiredAttrDef("type", 
DataTypes.STRING_TYPE));
         String traitDefinitionAsJSON = 
TypesSerialization$.MODULE$.toJson(piiTrait, true);
         createType(traitDefinitionAsJSON);
-        
-        ClientResponse clientResponse = 
service.path(ENTITIES).path(guid).path(TRAITS).path(traitName)
-                
.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.DELETE, ClientResponse.class);
-        
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.DELETE_TRAITS, null, "random", TRAITS);
         Assert.assertNotNull(response.get(AtlasClient.ERROR));
         Assert.assertNotNull(response.get(AtlasClient.STACKTRACE));
-     
-        
     }
+
     private String random() {
         return RandomStringUtils.random(10);
     }
@@ -754,9 +643,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         instance.set(attrName, attrValue);
         Id guid = createInstance(instance);
 
-        ClientResponse response = getEntityDefinition(guid._getId());
-        String definition = getEntityDefinition(response);
-        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(definition, true);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, guid._getId());
+        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(response.toString(), true);
         Assert.assertEquals(getReferenceable.get(attrName), attrValue);
     }
 
@@ -786,9 +674,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         assertEquals(entityResult.getUpdateEntities().size(), 1);
         assertEquals(entityResult.getUpdateEntities().get(0), 
tableId._getId());
 
-        ClientResponse response = getEntityDefinition(tableId._getId());
-        String definition = getEntityDefinition(response);
-        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(definition, true);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, tableId._getId());
+        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(response.toString(), true);
         List<Referenceable> refs = (List<Referenceable>) 
getReferenceable.get("columns");
 
         Assert.assertTrue(refs.get(0).equalsContents(columns.get(0)));
@@ -807,9 +694,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
         assertEquals(entityResult.getUpdateEntities().size(), 2);
         assertEquals(entityResult.getUpdateEntities().get(0), 
tableId._getId());
 
-        response = getEntityDefinition(tableId._getId());
-        definition = getEntityDefinition(response);
-        getReferenceable = 
InstanceSerialization.fromJsonReferenceable(definition, true);
+        response = serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, 
tableId._getId());
+        getReferenceable = 
InstanceSerialization.fromJsonReferenceable(response.toString(), true);
         refs = (List<Referenceable>) getReferenceable.get("columns");
 
         Assert.assertTrue(refs.get(0).getValuesMap().equals(values));
@@ -849,42 +735,38 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         JSONArray entityArray = new JSONArray(1);
         entityArray.put(entityJson);
         LOG.debug("Replacing entity= " + tableInstance);
-        ClientResponse clientResponse = service.path(ENTITIES).
-            accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE).
-            method(HttpMethod.PUT, ClientResponse.class, entityArray);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.UPDATE_ENTITY, entityArray);
 
         // ATLAS-586: verify response entity can be parsed by GSON.
-        String entity = clientResponse.getEntity(String.class);
         Gson gson = new Gson();
         try {
-            UpdateEntitiesResponse updateEntitiesResponse = 
gson.fromJson(entity, UpdateEntitiesResponse.class);
+            UpdateEntitiesResponse updateEntitiesResponse = 
gson.fromJson(response.toString(), UpdateEntitiesResponse.class);
         }
         catch (JsonSyntaxException e) {
-            Assert.fail("Response entity from " + 
service.path(ENTITIES).getURI() + " not parseable by GSON", e);
+            Assert.fail("Response entity from not parse-able by GSON", e);
         }
-        
-        clientResponse = getEntityDefinition(tableId._getId());
-        String definition = getEntityDefinition(clientResponse);
-        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(definition, true);
+
+        response = serviceClient.callAPI(AtlasClient.API.GET_ENTITY, null, 
tableId._getId());
+        Referenceable getReferenceable = 
InstanceSerialization.fromJsonReferenceable(response.toString(), true);
         List<Referenceable> refs = (List<Referenceable>) 
getReferenceable.get("columns");
         Assert.assertEquals(refs.size(), 2);
 
         Assert.assertTrue(refs.get(0).getValuesMap().equals(values1));
         Assert.assertTrue(refs.get(1).getValuesMap().equals(values2));
     }
-    
+
     private static class UpdateEntitiesResponse {
         String requestId;
         AtlasClient.EntityResult entities;
         AtlasEntity definition;
     }
-    
+
     private static class AtlasEntity {
         String typeName;
         final Map<String, Object> values = new HashMap<String, Object>();
     }
-    
+
     @Test
     public void testDeleteEntitiesViaRestApi() throws Exception {
         // Create 2 database entities
@@ -911,14 +793,13 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         db2.set("parameters", Collections.EMPTY_MAP);
         db2.set("location", "/tmp");
         Id db2Id = createInstance(db2);
-        
+
         // Delete the database entities
-        ClientResponse clientResponse = service.path(ENTITIES).
-            queryParam(AtlasClient.GUID.toLowerCase(), db1Id._getId()).
-            queryParam(AtlasClient.GUID.toLowerCase(), db2Id._getId()).
-            
accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.DELETE,
 ClientResponse.class);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put(AtlasClient.GUID.toLowerCase(), db1Id._getId());
+        queryParams.put(AtlasClient.GUID.toLowerCase(), db2Id._getId());
 
-        JSONObject response = getEntity(clientResponse);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.DELETE_ENTITIES, queryParams);
         List<String> deletedGuidsList = 
AtlasClient.EntityResult.fromString(response.toString()).getDeletedEntities();
         Assert.assertTrue(deletedGuidsList.contains(db1Id._getId()));
         Assert.assertTrue(deletedGuidsList.contains(db2Id._getId()));
@@ -929,7 +810,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
             assertEquals(entity.getId().getState(), Id.EntityState.DELETED);
         }
     }
-    
+
     @Test
     public void testDeleteEntitiesViaClientApi() throws Exception {
         // Create 2 database entities
@@ -955,16 +836,16 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         db2.set("parameters", Collections.EMPTY_MAP);
         db2.set("location", "/tmp");
         Id db2Id = createInstance(db2);
-        
+
         // Delete the database entities
         List<String> deletedGuidsList =
                 serviceClient.deleteEntities(db1Id._getId(), 
db2Id._getId()).getDeletedEntities();
-        
+
         // Verify that deleteEntities() response has database entity guids 
         Assert.assertEquals(deletedGuidsList.size(), 2);
-        Assert.assertTrue(deletedGuidsList.contains(db1Id._getId()));   
+        Assert.assertTrue(deletedGuidsList.contains(db1Id._getId()));
         Assert.assertTrue(deletedGuidsList.contains(db2Id._getId()));
-        
+
         // Verify entities were deleted from the repository.
         for (String guid : deletedGuidsList) {
             Referenceable entity = serviceClient.getEntity(guid);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
index cf25814..2fb1517 100644
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
@@ -20,29 +20,30 @@ package org.apache.atlas.web.resources;
 
 import com.google.common.collect.ImmutableList;
 import com.google.gson.Gson;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.lineage.AtlasLineageInfo;
 import org.apache.atlas.typesystem.Referenceable;
 import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.web.util.Servlets;
+import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.Response;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import static org.apache.atlas.AtlasBaseClient.APIInfo;
+
 /**
  * Entity Lineage v2 Integration Tests.
  */
 public class EntityLineageJerseyResourceIT extends 
DataSetLineageJerseyResourceIT {
     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 String INPUT_DIRECTION = "INPUT";
     private static final String OUTPUT_DIRECTION = "OUTPUT";
     private static final String BOTH_DIRECTION = "BOTH";
@@ -66,18 +67,16 @@ public class EntityLineageJerseyResourceIT extends 
DataSetLineageJerseyResourceI
     public void testInputLineageInfo() throws Exception {
         String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
                 AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, 
salesMonthlyTable).getId()._getId();
-        WebResource resource = 
service.path(BASE_URI).path(tableId).queryParam(DIRECTION_PARAM, 
INPUT_DIRECTION).
-                queryParam(DEPTH_PARAM, "5");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("input lineage info = " + responseAsString);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put(DIRECTION_PARAM, INPUT_DIRECTION);
+        queryParams.put(DEPTH_PARAM, "5");
+        JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, 
JSONObject.class, queryParams);
+        Assert.assertNotNull(response);
+        System.out.println("input lineage info = " + response
+        );
 
-        AtlasLineageInfo inputLineageInfo = gson.fromJson(responseAsString, 
AtlasLineageInfo.class);
+        AtlasLineageInfo inputLineageInfo = gson.fromJson(response.toString(), 
AtlasLineageInfo.class);
 
         Map<String, AtlasEntityHeader> entities = 
inputLineageInfo.getGuidEntityMap();
         Assert.assertNotNull(entities);
@@ -96,18 +95,16 @@ public class EntityLineageJerseyResourceIT extends 
DataSetLineageJerseyResourceI
     public void testOutputLineageInfo() throws Exception {
         String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
                 AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, 
salesFactTable).getId()._getId();
-        WebResource resource = 
service.path(BASE_URI).path(tableId).queryParam(DIRECTION_PARAM, 
OUTPUT_DIRECTION).
-                queryParam(DEPTH_PARAM, "5");
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put(DIRECTION_PARAM, OUTPUT_DIRECTION);
+        queryParams.put(DEPTH_PARAM, "5");
+        JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, 
JSONObject.class, queryParams);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("output lineage info = " + responseAsString);
+        Assert.assertNotNull(response);
+        System.out.println("output lineage info = " + response);
 
-        AtlasLineageInfo outputLineageInfo = gson.fromJson(responseAsString, 
AtlasLineageInfo.class);
+        AtlasLineageInfo outputLineageInfo = 
gson.fromJson(response.toString(), AtlasLineageInfo.class);
 
         Map<String, AtlasEntityHeader> entities = 
outputLineageInfo.getGuidEntityMap();
         Assert.assertNotNull(entities);
@@ -126,18 +123,16 @@ public class EntityLineageJerseyResourceIT extends 
DataSetLineageJerseyResourceI
     public void testLineageInfo() throws Exception {
         String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
                 AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, 
salesMonthlyTable).getId()._getId();
-        WebResource resource = 
service.path(BASE_URI).path(tableId).queryParam(DIRECTION_PARAM, 
BOTH_DIRECTION).
-                queryParam(DEPTH_PARAM, "5");
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        Assert.assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put(DIRECTION_PARAM, BOTH_DIRECTION);
+        queryParams.put(DEPTH_PARAM, "5");
+        JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, 
JSONObject.class, queryParams);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-        System.out.println("both lineage info = " + responseAsString);
+        Assert.assertNotNull(response);
+        System.out.println("both lineage info = " + response);
 
-        AtlasLineageInfo bothLineageInfo = gson.fromJson(responseAsString, 
AtlasLineageInfo.class);
+        AtlasLineageInfo bothLineageInfo = gson.fromJson(response.toString(), 
AtlasLineageInfo.class);
 
         Map<String, AtlasEntityHeader> entities = 
bothLineageInfo.getGuidEntityMap();
         Assert.assertNotNull(entities);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
index 13ef503..ee6d064 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
@@ -21,8 +21,7 @@ package org.apache.atlas.web.resources;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-
+import org.apache.atlas.AtlasBaseClient;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.typesystem.Referenceable;
@@ -36,19 +35,19 @@ import 
org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
 import org.apache.atlas.typesystem.types.StructTypeDefinition;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
-import org.apache.atlas.web.util.Servlets;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.Response;
-
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.fail;
 
 /**
@@ -56,6 +55,10 @@ import static org.testng.Assert.fail;
  */
 public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
 
+    private static final String SEARCH_DSL_PATH = 
"api/atlas/discovery/search/dsl";
+
+    private static final AtlasBaseClient.APIInfo SEARCH_DSL = new 
AtlasBaseClient.APIInfo(SEARCH_DSL_PATH, "GET", Response.Status.OK);
+    public static final String GREMLIN_SEARCH = 
"api/atlas/discovery/search/gremlin";
     private String tagName;
     private String dbName;
 
@@ -70,16 +73,11 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
     @Test
     public void testSearchByDSL() throws Exception {
         String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + 
dbName + "\"";
-        WebResource resource = 
service.path("api/atlas/discovery/search/dsl").queryParam("query", dslQuery);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", dslQuery);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams);
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        Assert.assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         assertEquals(response.getString("query"), dslQuery);
@@ -98,11 +96,10 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
 
         //search without new parameters of limit and offset should work
         String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + 
dbName + "\"";
-        WebResource resource = 
service.path("api/atlas/discovery/search/dsl").queryParam("query", dslQuery);
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                                                .method(HttpMethod.GET, 
ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", dslQuery);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams);
+        assertNotNull(response);
 
         //higher limit, all results returned
         JSONArray results = serviceClient.searchByDSL(dslQuery, 10, 0);
@@ -145,29 +142,24 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
         }
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testSearchByDSLForUnknownType() throws Exception {
         String dslQuery = "from blah";
-        WebResource resource = 
service.path("api/atlas/discovery/search/dsl").queryParam("query", dslQuery);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", dslQuery);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams);
 
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.BAD_REQUEST.getStatusCode());
     }
 
     @Test
     public void testSearchUsingGremlin() throws Exception {
         String query = "g.V.has('type', 'hive_db').toList()";
-        WebResource resource = 
service.path("api/atlas/discovery/search/gremlin").queryParam("query", query);
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", query);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.GREMLIN_SEARCH, queryParams);
 
-        JSONObject response = new JSONObject(responseAsString);
+        assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         assertEquals(response.getString("query"), query);
@@ -178,16 +170,11 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
     public void testSearchUsingDSL() throws Exception {
         //String query = "from dsl_test_type";
         String query = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName 
+"\"";
-        WebResource resource = 
service.path("api/atlas/discovery/search").queryParam("query", query);
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", query);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
+        Assert.assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         assertEquals(response.getString("query"), query);
@@ -197,16 +184,11 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
     @Test
     public void testSearchFullTextOnDSLFailure() throws Exception {
         String query = "*";
-        WebResource resource = 
service.path("api/atlas/discovery/search").queryParam("query", query);
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-            .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", query);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.SEARCH_DSL, queryParams);
 
-        JSONObject response = new JSONObject(responseAsString);
+        Assert.assertNotNull(response);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         assertEquals(response.getString("query"), query);
@@ -234,11 +216,10 @@ public class MetadataDiscoveryJerseyResourceIT extends 
BaseResourceIT {
 
         //API works without limit and offset
         String query = dbName;
-        WebResource resource = 
service.path("api/atlas/discovery/search/fulltext").queryParam("query", query);
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                                                .method(HttpMethod.GET, 
ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-        results = new 
JSONObject(clientResponse.getEntity(String.class)).getJSONArray(AtlasClient.RESULTS);
+        Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("query", query);
+        response = serviceClient.callAPI(AtlasClient.API.SEARCH_FULL_TEXT, 
queryParams);
+        results = response.getJSONArray(AtlasClient.RESULTS);
         assertEquals(results.length(), 1);
 
         //verify passed in limits and offsets are used

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2c881a46/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
index fd15544..4dd65e7 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
@@ -20,9 +20,6 @@ package org.apache.atlas.web.resources;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.typesystem.TypesDef;
@@ -37,7 +34,6 @@ import org.apache.atlas.typesystem.types.Multiplicity;
 import org.apache.atlas.typesystem.types.StructTypeDefinition;
 import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
-import org.apache.atlas.web.util.Servlets;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
@@ -45,11 +41,12 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import static 
org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef;
 import static org.testng.Assert.assertEquals;
@@ -84,21 +81,14 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
                 String typesAsJSON = TypesSerialization.toJson(typeDefinition, 
false);
                 System.out.println("typesAsJSON = " + typesAsJSON);
 
-                WebResource resource = service.path("api/atlas/types");
-
-                ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                        .method(HttpMethod.POST, ClientResponse.class, 
typesAsJSON);
-                assertEquals(clientResponse.getStatus(), 
Response.Status.CREATED.getStatusCode());
+            JSONObject response = 
serviceClient.callAPI(AtlasClient.API.CREATE_TYPE, typesAsJSON);
+            Assert.assertNotNull(response);
 
-                String responseAsString = 
clientResponse.getEntity(String.class);
-                Assert.assertNotNull(responseAsString);
 
-                JSONObject response = new JSONObject(responseAsString);
-                JSONArray typesAdded = 
response.getJSONArray(AtlasClient.TYPES);
-                assertEquals(typesAdded.length(), 1);
-                assertEquals(typesAdded.getJSONObject(0).getString("name"), 
typeDefinition.typeName);
-                Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
-            }
+            JSONArray typesAdded = response.getJSONArray(AtlasClient.TYPES);
+            assertEquals(typesAdded.length(), 1);
+            assertEquals(typesAdded.getJSONObject(0).getString("name"), 
typeDefinition.typeName);
+            Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));}
         }
     }
 
@@ -152,15 +142,9 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
         for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) {
             System.out.println("typeName = " + typeDefinition.typeName);
 
-            WebResource resource = 
service.path("api/atlas/types").path(typeDefinition.typeName);
+            JSONObject response = 
serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, 
typeDefinition.typeName);
 
-            ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                    .method(HttpMethod.GET, ClientResponse.class);
-            assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
-
-            String responseAsString = clientResponse.getEntity(String.class);
-            Assert.assertNotNull(responseAsString);
-            JSONObject response = new JSONObject(responseAsString);
+            Assert.assertNotNull(response);
             Assert.assertNotNull(response.get(AtlasClient.DEFINITION));
             Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
@@ -178,27 +162,16 @@ public class TypesJerseyResourceIT extends BaseResourceIT 
{
         }
     }
 
-    @Test
+    @Test(expectedExceptions = AtlasServiceException.class)
     public void testGetDefinitionForNonexistentType() throws Exception {
-        WebResource resource = service.path("api/atlas/types").path("blah");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.NOT_FOUND.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, "blah");
     }
 
     @Test(dependsOnMethods = "testSubmit")
     public void testGetTypeNames() throws Exception {
-        WebResource resource = service.path("api/atlas/types");
-
-        ClientResponse clientResponse = 
resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                .method(HttpMethod.GET, ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.LIST_TYPES, null, (String[]) null);
+        Assert.assertNotNull(response);
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
-
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
@@ -214,17 +187,12 @@ public class TypesJerseyResourceIT extends BaseResourceIT 
{
     public void testGetTraitNames() throws Exception {
         String[] traitsAdded = addTraits();
 
-        WebResource resource = service.path("api/atlas/types");
-
-        ClientResponse clientResponse =
-                resource.queryParam("type", 
DataTypes.TypeCategory.TRAIT.name()).accept(Servlets.JSON_MEDIA_TYPE)
-                        .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, 
ClientResponse.class);
-        assertEquals(clientResponse.getStatus(), 
Response.Status.OK.getStatusCode());
+            Map<String, String> queryParams = new HashMap<>();
+        queryParams.put("type", DataTypes.TypeCategory.TRAIT.name());
 
-        String responseAsString = clientResponse.getEntity(String.class);
-        Assert.assertNotNull(responseAsString);
+        JSONObject response = 
serviceClient.callAPI(AtlasClient.API.LIST_TYPES, queryParams);
+        Assert.assertNotNull(response);
 
-        JSONObject response = new JSONObject(responseAsString);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
         final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);

Reply via email to