Commit f87072f3 by Sarath Subramanian

ATLAS-2302: Fix test failures in AtlasClientTest

parent 69330a5d
......@@ -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 @@ public class AtlasClientTest {
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);
......
......@@ -72,6 +72,7 @@ public abstract class AtlasBaseClient {
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 @@ public abstract class AtlasBaseClient {
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;
}
......
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