Commit b1717f2e by Sarath Subramanian Committed by Madhan Neethiraj

ATLAS-1602: fixed IT failures in QuickStart and issues identified in coverity scan

parent 8bb31fdf
...@@ -32,7 +32,6 @@ import javax.ws.rs.core.UriBuilder; ...@@ -32,7 +32,6 @@ import javax.ws.rs.core.UriBuilder;
import org.apache.atlas.model.metrics.AtlasMetrics; import org.apache.atlas.model.metrics.AtlasMetrics;
import org.apache.atlas.security.SecureClientUtils; import org.apache.atlas.security.SecureClientUtils;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -319,7 +318,6 @@ public abstract class AtlasBaseClient { ...@@ -319,7 +318,6 @@ public abstract class AtlasBaseClient {
} }
} else { } else {
T entity = clientResponse.getEntity(responseType); T entity = clientResponse.getEntity(responseType);
LOG.info("Response = {}", AtlasType.toJson(entity));
return entity; return entity;
} }
} catch (ClientHandlerException e) { } catch (ClientHandlerException e) {
......
...@@ -20,8 +20,9 @@ package org.apache.atlas; ...@@ -20,8 +20,9 @@ package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct; import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.TypesDef;
...@@ -259,6 +260,8 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -259,6 +260,8 @@ public class AtlasClient extends AtlasBaseClient {
@XmlRootElement @XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY) @XmlAccessorType(XmlAccessType.PROPERTY)
public static class EntityResult { public static class EntityResult {
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public static final String OP_CREATED = "created"; public static final String OP_CREATED = "created";
public static final String OP_UPDATED = "updated"; public static final String OP_UPDATED = "updated";
public static final String OP_DELETED = "deleted"; public static final String OP_DELETED = "deleted";
...@@ -314,12 +317,10 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -314,12 +317,10 @@ public class AtlasClient extends AtlasBaseClient {
} }
@Override @Override
public String toString() { public String toString() { return gson.toJson(this); }
return AtlasType.toJson(this);
}
public static EntityResult fromString(String json) throws AtlasServiceException { public static EntityResult fromString(String json) throws AtlasServiceException {
return AtlasType.fromJson(json, EntityResult.class); return gson.fromJson(json, EntityResult.class);
} }
} }
......
...@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory; ...@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -281,24 +282,28 @@ public class AtlasInstanceConverter { ...@@ -281,24 +282,28 @@ public class AtlasInstanceConverter {
case CREATE: case CREATE:
List<AtlasEntityHeader> createdEntities = mutatedEntities.get(EntityOperation.CREATE); List<AtlasEntityHeader> createdEntities = mutatedEntities.get(EntityOperation.CREATE);
if (CollectionUtils.isNotEmpty(createdEntities)) { if (CollectionUtils.isNotEmpty(createdEntities)) {
Collections.reverse(createdEntities);
entityResult.set(EntityResult.OP_CREATED, getGuids(createdEntities)); entityResult.set(EntityResult.OP_CREATED, getGuids(createdEntities));
} }
break; break;
case UPDATE: case UPDATE:
List<AtlasEntityHeader> updatedEntities = mutatedEntities.get(EntityOperation.UPDATE); List<AtlasEntityHeader> updatedEntities = mutatedEntities.get(EntityOperation.UPDATE);
if (CollectionUtils.isNotEmpty(updatedEntities)) { if (CollectionUtils.isNotEmpty(updatedEntities)) {
Collections.reverse(updatedEntities);
entityResult.set(EntityResult.OP_UPDATED, getGuids(updatedEntities)); entityResult.set(EntityResult.OP_UPDATED, getGuids(updatedEntities));
} }
break; break;
case PARTIAL_UPDATE: case PARTIAL_UPDATE:
List<AtlasEntityHeader> partialUpdatedEntities = mutatedEntities.get(EntityOperation.PARTIAL_UPDATE); List<AtlasEntityHeader> partialUpdatedEntities = mutatedEntities.get(EntityOperation.PARTIAL_UPDATE);
if (CollectionUtils.isNotEmpty(partialUpdatedEntities)) { if (CollectionUtils.isNotEmpty(partialUpdatedEntities)) {
Collections.reverse(partialUpdatedEntities);
entityResult.set(EntityResult.OP_UPDATED, getGuids(partialUpdatedEntities)); entityResult.set(EntityResult.OP_UPDATED, getGuids(partialUpdatedEntities));
} }
break; break;
case DELETE: case DELETE:
List<AtlasEntityHeader> deletedEntities = mutatedEntities.get(EntityOperation.DELETE); List<AtlasEntityHeader> deletedEntities = mutatedEntities.get(EntityOperation.DELETE);
if (CollectionUtils.isNotEmpty(deletedEntities)) { if (CollectionUtils.isNotEmpty(deletedEntities)) {
Collections.reverse(deletedEntities);
entityResult.set(EntityResult.OP_DELETED, getGuids(deletedEntities)); entityResult.set(EntityResult.OP_DELETED, getGuids(deletedEntities));
} }
break; break;
......
...@@ -350,10 +350,6 @@ public class QuickStartV2 { ...@@ -350,10 +350,6 @@ public class QuickStartV2 {
System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid()); System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid());
} }
if (ArrayUtils.isNotEmpty(traitNames)) {
entitiesClient.addClassifications(ret.getGuid(), toAtlasClassifications(traitNames));
}
return ret; return ret;
} }
......
...@@ -98,6 +98,9 @@ public class DataSetLineageResource { ...@@ -98,6 +98,9 @@ public class DataSetLineageResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get lineage inputs graph for table {}", tableName, e); LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get lineage inputs graph for table {}", tableName, e); LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -141,6 +144,9 @@ public class DataSetLineageResource { ...@@ -141,6 +144,9 @@ public class DataSetLineageResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get lineage outputs graph for table {}", tableName, e); LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get lineage outputs graph for table {}", tableName, e); LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -184,6 +190,9 @@ public class DataSetLineageResource { ...@@ -184,6 +190,9 @@ public class DataSetLineageResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get schema for table {}", tableName, e); LOG.error("Unable to get schema for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get schema for table {}", tableName, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get schema for table {}", tableName, e); LOG.error("Unable to get schema for table {}", tableName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
......
...@@ -99,7 +99,10 @@ public class LineageResource { ...@@ -99,7 +99,10 @@ public class LineageResource {
return Response.ok(response).build(); return Response.ok(response).build();
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e); LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (WebApplicationException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw e;
} catch (JSONException e) { } catch (JSONException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e); LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -143,7 +146,10 @@ public class LineageResource { ...@@ -143,7 +146,10 @@ public class LineageResource {
return Response.ok(response).build(); return Response.ok(response).build();
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e); LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (WebApplicationException e) {
LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
throw e;
} catch (JSONException e) { } catch (JSONException e) {
LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e); LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -192,6 +198,9 @@ public class LineageResource { ...@@ -192,6 +198,9 @@ public class LineageResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get schema for entity guid={}", guid, e); LOG.error("Unable to get schema for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get schema for entity guid={}", guid, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get schema for entity={}", guid, e); LOG.error("Unable to get schema for entity={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
......
...@@ -150,6 +150,9 @@ public class MetadataDiscoveryResource { ...@@ -150,6 +150,9 @@ public class MetadataDiscoveryResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e); LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e); LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -225,6 +228,9 @@ public class MetadataDiscoveryResource { ...@@ -225,6 +228,9 @@ public class MetadataDiscoveryResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e); LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e); LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -272,6 +278,9 @@ public class MetadataDiscoveryResource { ...@@ -272,6 +278,9 @@ public class MetadataDiscoveryResource {
} catch (DiscoveryException | IllegalArgumentException e) { } catch (DiscoveryException | IllegalArgumentException e) {
LOG.error("Unable to get entity list for query {}", query, e); LOG.error("Unable to get entity list for query {}", query, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get entity list for query {}", query, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get entity list for query {}", query, e); LOG.error("Unable to get entity list for query {}", query, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
......
...@@ -121,12 +121,12 @@ public class TypesResource { ...@@ -121,12 +121,12 @@ public class TypesResource {
return Response.status(ClientResponse.Status.CREATED).entity(response).build(); return Response.status(ClientResponse.Status.CREATED).entity(response).build();
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.error("Type creation failed", e); LOG.error("Type creation failed", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) { } catch (WebApplicationException e) {
LOG.error("Unable to persist types due to V2 API error", e); LOG.error("Unable to persist types", e);
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
...@@ -187,11 +187,14 @@ public class TypesResource { ...@@ -187,11 +187,14 @@ public class TypesResource {
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId()); response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
response.put(AtlasClient.TYPES, typesResponse); response.put(AtlasClient.TYPES, typesResponse);
return Response.ok().entity(response).build(); return Response.ok().entity(response).build();
} catch (AtlasBaseException | IllegalArgumentException e) { } catch (AtlasBaseException e) {
LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (IllegalArgumentException e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) { } catch (WebApplicationException e) {
LOG.error("Unable to persist types due to V2 API error", e); LOG.error("Unable to persist types", e);
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
...@@ -237,10 +240,13 @@ public class TypesResource { ...@@ -237,10 +240,13 @@ public class TypesResource {
return Response.ok(response).build(); return Response.ok(response).build();
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.error("Unable to get type definition for type {}", typeName, e); LOG.error("Unable to get type definition for type {}", typeName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (JSONException | IllegalArgumentException e) { } catch (JSONException | IllegalArgumentException e) {
LOG.error("Unable to get type definition for type {}", typeName, e); LOG.error("Unable to get type definition for type {}", typeName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) {
LOG.error("Unable to get type definition for type {}", typeName, e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get type definition for type {}", typeName, e); LOG.error("Unable to get type definition for type {}", typeName, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
...@@ -292,7 +298,10 @@ public class TypesResource { ...@@ -292,7 +298,10 @@ public class TypesResource {
return Response.ok(response).build(); return Response.ok(response).build();
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.warn("TypesREST exception: {} {}", e.getClass().getSimpleName(), e.getMessage()); LOG.warn("TypesREST exception: {} {}", e.getClass().getSimpleName(), e.getMessage());
throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (WebApplicationException e) {
LOG.error("Unable to get types list", e);
throw e;
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Unable to get types list", e); LOG.error("Unable to get types list", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
......
...@@ -20,6 +20,7 @@ package org.apache.atlas.web.util; ...@@ -20,6 +20,7 @@ package org.apache.atlas.web.util;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.LocalServletRequest; import org.apache.atlas.LocalServletRequest;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -137,6 +138,13 @@ public final class Servlets { ...@@ -137,6 +138,13 @@ public final class Servlets {
return url.toString(); return url.toString();
} }
public static Response getErrorResponse(AtlasBaseException e) {
String message = e.getMessage() == null ? "Failed with " + e.getClass().getName() : e.getMessage();
Response response = getErrorResponse(message, e.getAtlasErrorCode().getHttpCode());
return response;
}
public static Response getErrorResponse(Throwable e, Response.Status status) { public static Response getErrorResponse(Throwable e, Response.Status status) {
String message = e.getMessage() == null ? "Failed with " + e.getClass().getName() : e.getMessage(); String message = e.getMessage() == null ? "Failed with " + e.getClass().getName() : e.getMessage();
Response response = getErrorResponse(message, status); Response response = getErrorResponse(message, status);
......
...@@ -28,6 +28,7 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection; ...@@ -28,6 +28,7 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation; import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation;
import org.apache.atlas.web.resources.BaseResourceIT; import org.apache.atlas.web.resources.BaseResourceIT;
import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONException;
import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
...@@ -35,6 +36,7 @@ import java.util.ArrayList; ...@@ -35,6 +36,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
...@@ -98,13 +100,13 @@ public class QuickStartV2IT extends BaseResourceIT { ...@@ -98,13 +100,13 @@ public class QuickStartV2IT extends BaseResourceIT {
private void verifyColumnsAreAddedToTable(AtlasEntity table) throws JSONException { private void verifyColumnsAreAddedToTable(AtlasEntity table) throws JSONException {
Map<String, Object> tableAttributes = table.getAttributes(); Map<String, Object> tableAttributes = table.getAttributes();
List<AtlasEntity> columns = (List<AtlasEntity>) tableAttributes.get("columns"); List<Map> columns = (List<Map>) tableAttributes.get("columns");
assertEquals(4, columns.size()); assertEquals(4, columns.size());
Map<String, Object> column = (Map) columns.get(0); for (Map colMap : columns) {
Map<String, Object> columnAttributes = (Map) column.get("attributes"); String colGuid = (String) colMap.get("guid");
assertEquals(QuickStartV2.TIME_ID_COLUMN, columnAttributes.get("name")); assertNotNull(UUID.fromString(colGuid));
assertEquals("int", columnAttributes.get("dataType")); }
} }
private void verifyDBIsLinkedToTable(AtlasEntity table) throws AtlasServiceException, JSONException { private void verifyDBIsLinkedToTable(AtlasEntity table) throws AtlasServiceException, JSONException {
......
...@@ -69,9 +69,11 @@ public class EntityResourceTest { ...@@ -69,9 +69,11 @@ public class EntityResourceTest {
EntityMutationResponse resp = new EntityMutationResponse(); EntityMutationResponse resp = new EntityMutationResponse();
List<AtlasEntityHeader> headers = toAtlasEntityHeaders(guids); List<AtlasEntityHeader> headers = toAtlasEntityHeaders(guids);
if (CollectionUtils.isNotEmpty(headers)) {
for (AtlasEntityHeader entity : headers) { for (AtlasEntityHeader entity : headers) {
resp.addEntity(EntityMutations.EntityOperation.DELETE, entity); resp.addEntity(EntityMutations.EntityOperation.DELETE, entity);
} }
}
when(entitiesStore.deleteByIds(guids)).thenReturn(resp); when(entitiesStore.deleteByIds(guids)).thenReturn(resp);
......
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