ATLAS-2302: Fix test failures in AtlasClientTest
diff --git a/client/client-v1/src/test/java/org/apache/atlas/AtlasClientTest.java b/client/client-v1/src/test/java/org/apache/atlas/AtlasClientTest.java
index 0bd66fe..067bfdf 100644
--- a/client/client-v1/src/test/java/org/apache/atlas/AtlasClientTest.java
+++ b/client/client-v1/src/test/java/org/apache/atlas/AtlasClientTest.java
@@ -17,15 +17,13 @@
package org.apache.atlas;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import org.apache.atlas.model.legacy.EntityResult;
-import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.mockito.Matchers;
@@ -97,6 +95,10 @@
ClientResponse response = mock(ClientResponse.class);
when(response.getStatus()).thenReturn(Response.Status.CREATED.getStatusCode());
+ String jsonResponse = AtlasType.toV1Json(new EntityResult(Arrays.asList("id"), null, null));
+ when(response.getEntity(String.class)).thenReturn(jsonResponse.toString());
+ when(response.getLength()).thenReturn(jsonResponse.length());
+
String entityJson = AtlasType.toV1Json(new Referenceable("type"));
when(builder.method(anyString(), Matchers.<Class>any(), anyString())).thenReturn(response);
diff --git a/client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java b/client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
index 4da66bb..05b6cc6 100644
--- a/client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
+++ b/client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
@@ -72,6 +72,7 @@
public static final String QUERY = "query";
public static final String LIMIT = "limit";
public static final String OFFSET = "offset";
+ public static final String STATUS = "Status";
public static final API API_STATUS = new API(BASE_URI + ADMIN_STATUS, HttpMethod.GET, Response.Status.OK);;
public static final API API_VERSION = new API(BASE_URI + ADMIN_VERSION, HttpMethod.GET, Response.Status.OK);;
@@ -189,7 +190,9 @@
WebResource resource = getResource(service, API_STATUS.getNormalizedPath());
ObjectNode response = callAPIWithResource(API_STATUS, resource, null, ObjectNode.class);
- result = response.get("Status").asText();
+ if (response.has(STATUS)) {
+ result = response.get(STATUS).asText();
+ }
return result;
}