Commit ec1b160a by apoorvnaik Committed by Madhan Neethiraj

ATLAS-1311: Integration tests for V2 Entity APIs

parent 3b1a7d09
......@@ -15,7 +15,7 @@
# limitations under the License.
# Maven
target
target*
dependency-reduced-pom.xml
core*.dmp
pom.xml.releaseBackup
......
......@@ -1337,7 +1337,7 @@ public class HiveHookIT extends HiveITBase {
* query = "alter table " + tableName + " STORED AS " + testFormat.toUpperCase();
* runCommand(query);
* tableRef = atlasClient.getEntity(tableId);
* tableRef = atlasClientV1.getEntity(tableId);
* sdRef = (Referenceable)tableRef.get(HiveMetaStoreBridge.STORAGE_DESC);
* Assert.assertEquals(sdRef.get(HiveMetaStoreBridge.STORAGE_DESC_INPUT_FMT), "org.apache.hadoop.hive.ql.io.orc.OrcInputFormat");
* Assert.assertEquals(sdRef.get(HiveMetaStoreBridge.STORAGE_DESC_OUTPUT_FMT), "org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat");
......
......@@ -27,6 +27,7 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
import org.apache.atlas.security.SecureClientUtils;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
......@@ -276,12 +277,18 @@ public abstract class AtlasBaseClient {
ClientResponse clientResponse = null;
int i = 0;
do {
if (LOG.isDebugEnabled()) {
LOG.debug("Calling API [ {} : {} ] {}", api.getMethod(), api.getPath(), requestObject != null ? "<== " + requestObject : "");
}
clientResponse = resource
.accept(JSON_MEDIA_TYPE)
.type(JSON_MEDIA_TYPE)
.method(api.getMethod(), ClientResponse.class, requestObject);
LOG.debug("API {} returned status {}", resource.getURI(), clientResponse.getStatus());
if (LOG.isDebugEnabled()) {
LOG.debug("API {} returned status {}", resource.getURI(), clientResponse.getStatus());
}
if (clientResponse.getStatus() == api.getExpectedStatus().getStatusCode()) {
if (null == responseType) {
LOG.warn("No response type specified, returning null");
......@@ -291,12 +298,16 @@ public abstract class AtlasBaseClient {
if (responseType == JSONObject.class) {
String stringEntity = clientResponse.getEntity(String.class);
try {
return (T) new JSONObject(stringEntity);
JSONObject jsonObject = new JSONObject(stringEntity);
LOG.info("Response = {}", jsonObject);
return (T) jsonObject;
} catch (JSONException e) {
throw new AtlasServiceException(api, e);
}
} else {
return clientResponse.getEntity(responseType);
T entity = clientResponse.getEntity(responseType);
LOG.info("Response = {}", AtlasType.toJson(entity));
return entity;
}
} catch (ClientHandlerException e) {
throw new AtlasServiceException(api, e);
......@@ -380,8 +391,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.class);
return result;
return callAPIWithResource(api, resource, requestObject, JSONObject.class);
} catch (ClientHandlerException che) {
if (i == (getNumberOfRetries() - 1)) {
throw che;
......@@ -399,6 +409,12 @@ public abstract class AtlasBaseClient {
return callAPIWithResource(api, getResource(api, params), requestObject, responseType);
}
public <T> T callAPI(APIInfo api, Object requestBody, Class<T> responseType,
MultivaluedMap<String, String> queryParams, String... params) throws AtlasServiceException {
WebResource resource = getResource(api, queryParams, params);
return callAPIWithResource(api, resource, requestBody, responseType);
}
public <T> T callAPI(APIInfo api, Class<T> responseType, MultivaluedMap<String, String> queryParams, String... params)
throws AtlasServiceException {
WebResource resource = getResource(api, queryParams, params);
......@@ -476,7 +492,7 @@ public abstract class AtlasBaseClient {
return resource;
}
protected APIInfo formatPath(APIInfo apiInfo, String ... params) {
protected APIInfo formatPathForPathParams(APIInfo apiInfo, String ... params) {
return new APIInfo(String.format(apiInfo.getPath(), params), apiInfo.getMethod(), apiInfo.getExpectedStatus());
}
......
......@@ -108,7 +108,8 @@ public class AtlasClient extends AtlasBaseClient {
public static final String PROCESS_ATTRIBUTE_OUTPUTS = "outputs";
public static final String REFERENCEABLE_SUPER_TYPE = "Referenceable";
public static final String REFERENCEABLE_ATTRIBUTE_NAME = "qualifiedName";
public static final String QUALIFIED_NAME = "qualifiedName";
public static final String REFERENCEABLE_ATTRIBUTE_NAME = QUALIFIED_NAME;
public static final String UNKNOWN_STATUS = "Unknown status";
......@@ -593,7 +594,7 @@ public class AtlasClient extends AtlasBaseClient {
JSONObject response = callAPIWithRetries(api, entityJson, new ResourceCreator() {
@Override
public WebResource createResource() {
WebResource resource = getResource(api, "qualifiedName");
WebResource resource = getResource(api, QUALIFIED_NAME);
resource = resource.queryParam(TYPE, entityType);
resource = resource.queryParam(ATTRIBUTE_NAME, uniqueAttributeName);
resource = resource.queryParam(ATTRIBUTE_VALUE, uniqueAttributeValue);
......
......@@ -18,21 +18,23 @@
package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import java.util.List;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.List;
import static org.apache.atlas.model.instance.AtlasEntity.AtlasEntities;
public class AtlasEntitiesClientV2 extends AtlasBaseClient {
......@@ -40,19 +42,24 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
public static final String ENTITIES_API = BASE_URI + "v2/entities/";
private static final APIInfo GET_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.GET, Response.Status.OK);
private static final APIInfo GET_ENTITY_WITH_ASSOCIATION_BY_GUID = new APIInfo(ENTITY_API + "guid/%s/associations", HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ENTITY = new APIInfo(ENTITY_API, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ENTITY = CREATE_ENTITY;
private static final APIInfo GET_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.GET, Response.Status.OK);
private static final APIInfo UPDATE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s/attribute/%s", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo UPDATE_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_GUIDS = new APIInfo(ENTITIES_API + "guids/", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo GET_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.GET, Response.Status.OK);
private static final APIInfo ADD_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_CLASSIFICATION = new APIInfo(ENTITY_API + "guid/%s/classification/%s", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo ADD_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.POST, Response.Status.NO_CONTENT);
private static final APIInfo UPDATE_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_CLASSIFICATION = new APIInfo(ENTITY_API + "guid/%s/classification/%s", HttpMethod.DELETE, Response.Status.NO_CONTENT);
private static final APIInfo GET_ENTITIES = new APIInfo(ENTITIES_API + "guids/", HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ENTITIES = new APIInfo(ENTITIES_API, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ENTITIES = CREATE_ENTITIES;
private static final APIInfo DELETE_ENTITIES = new APIInfo(ENTITIES_API + "guids/", HttpMethod.GET, Response.Status.OK);
private static final APIInfo DELETE_ENTITIES = new APIInfo(ENTITIES_API + "guids/", HttpMethod.GET, Response.Status.NO_CONTENT);
private static final APIInfo SEARCH_ENTITIES = new APIInfo(ENTITIES_API, HttpMethod.GET, Response.Status.OK);
public AtlasEntitiesClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
......@@ -80,6 +87,32 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
return callAPI(GET_ENTITY_BY_GUID, null, AtlasEntity.class, guid);
}
public AtlasEntities getEntityByGuids(List<String> guids) throws AtlasServiceException {
return callAPI(GET_ENTITY_BY_GUID, AtlasEntities.class, "guid", guids);
}
public AtlasEntityWithAssociations getEntityWithAssociationByGuid(String guid) throws AtlasServiceException {
return callAPI(formatPathForPathParams(GET_ENTITY_WITH_ASSOCIATION_BY_GUID, guid), null, AtlasEntityWithAssociations.class);
}
public AtlasEntity getEntityByAttribute(String type, String attribute, String value) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("value", value);
return callAPI(formatPathForPathParams(GET_ENTITY_BY_ATTRIBUTE, type, attribute), AtlasEntity.class, queryParams);
}
public EntityMutationResponse updateEntityByAttribute(String type, String attribute, String value, AtlasEntity entity) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("value", value);
return callAPI(formatPathForPathParams(UPDATE_ENTITY_BY_ATTRIBUTE, type, attribute), entity, EntityMutationResponse.class, queryParams);
}
public EntityMutationResponse deleteEntityByAttribute(String type, String attribute, String value) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("value", value);
return callAPI(formatPathForPathParams(DELETE_ENTITY_BY_ATTRIBUTE, type, attribute), null, EntityMutationResponse.class, queryParams);
}
public EntityMutationResponse createEntity(AtlasEntity atlasEntity) throws AtlasServiceException {
return callAPI(CREATE_ENTITY, atlasEntity, EntityMutationResponse.class);
}
......@@ -89,31 +122,35 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
}
public EntityMutationResponse updateEntity(String guid, AtlasEntity atlasEntity) throws AtlasServiceException {
return callAPI(UPDATE_ENTITY, atlasEntity, EntityMutationResponse.class, guid);
return callAPI(UPDATE_ENTITY_BY_GUID, atlasEntity, EntityMutationResponse.class, guid);
}
public AtlasEntity deleteEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(DELETE_ENTITY_BY_GUID, null, AtlasEntity.class, guid);
}
public EntityMutationResponse deleteEntityByGuid(List<String> guids) throws AtlasServiceException {
return callAPI(DELETE_ENTITY_BY_GUIDS, EntityMutationResponse.class, "guid", guids);
}
public AtlasClassifications getClassifications(String guid) throws AtlasServiceException {
return callAPI(formatPath(GET_CLASSIFICATIONS, guid), null, AtlasClassifications.class);
return callAPI(formatPathForPathParams(GET_CLASSIFICATIONS, guid), null, AtlasClassifications.class);
}
public void addClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPath(ADD_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
callAPI(formatPathForPathParams(ADD_CLASSIFICATIONS, guid), classifications, null, (String[]) null);
}
public void updateClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPath(UPDATE_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
callAPI(formatPathForPathParams(UPDATE_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
}
public void deleteClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPath(GET_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
callAPI(formatPathForPathParams(GET_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
}
public void deleteClassification(String guid, String classificationName) throws AtlasServiceException {
callAPI(formatPath(DELETE_CLASSIFICATION, guid, classificationName), null, AtlasClassifications.class);
callAPI(formatPathForPathParams(DELETE_CLASSIFICATION, guid, classificationName), null, null);
}
// Entities operations
......
......@@ -32,7 +32,7 @@ public class AtlasServiceException extends Exception {
}
public AtlasServiceException(AtlasBaseClient.APIInfo api, Exception e) {
super("Metadata service API " + api + " failed", e);
super("Metadata service API " + api.getMethod() + " : " + api.getPath() + " failed", e);
}
public AtlasServiceException(AtlasClient.API api, WebApplicationException e) throws JSONException {
......
......@@ -37,10 +37,19 @@ import javax.ws.rs.core.Response;
public class AtlasTypedefClientV2 extends AtlasBaseClient {
private static final String BASE_URI = "api/atlas/v2/types/";
private static final String ENUMDEF_URI = BASE_URI + "enumdef/";
private static final String STRUCTDEF_URI = BASE_URI + "structdef/";
private static final String ENTITYDEF_URI = BASE_URI + "entitydef/";
private static final String CLASSIFICATIONDEF_URI = BASE_URI + "classificationdef/";
private static final String TYPEDEFS_PATH = BASE_URI + "typedefs/";
private static final String GET_BY_NAME_TEMPLATE = BASE_URI + "%s/name/%s";
private static final String GET_BY_GUID_TEMPLATE = BASE_URI + "%s/guid/%s";
private static final APIInfo CREATE_ENUM_DEF = new APIInfo(ENUMDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_STRUCT_DEF = new APIInfo(STRUCTDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_ENTITY_DEF = new APIInfo(ENTITYDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_CLASSIFICATION_DEF = new APIInfo(CLASSIFICATIONDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo GET_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.PUT, Response.Status.OK);
......@@ -108,6 +117,24 @@ public class AtlasTypedefClientV2 extends AtlasBaseClient {
return getTypeDefByGuid(guid, AtlasEntityDef.class);
}
public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasServiceException {
return callAPI(CREATE_ENUM_DEF, AtlasType.toJson(enumDef), AtlasEnumDef.class);
}
public AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasServiceException {
return callAPI(CREATE_STRUCT_DEF, AtlasType.toJson(structDef), AtlasStructDef.class);
}
public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasServiceException {
return callAPI(CREATE_ENTITY_DEF, AtlasType.toJson(entityDef), AtlasEntityDef.class);
}
public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef)
throws AtlasServiceException {
return callAPI(CREATE_CLASSIFICATION_DEF, AtlasType.toJson(classificationDef), AtlasClassificationDef.class);
}
/**
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Any changes to the existing definitions will be discarded
......
......@@ -103,6 +103,15 @@ public class SearchFilter {
}
}
public void setParam(String name, List<String> values) {
if (name != null) {
if (params == null) {
params = new MultivaluedMapImpl();
}
params.put(name, values);
}
}
public long getStartIndex() {
return startIndex;
}
......
......@@ -18,7 +18,6 @@
package org.apache.atlas.model.instance;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
......
......@@ -82,7 +82,7 @@ public final class GraphToTypedInstanceMapper {
LOG.debug("Found createdBy : {} modifiedBy : {} createdTime: {} modifedTime: {}", createdBy, modifiedBy, createdTime, modifiedTime);
Id id = new Id(guid, (Integer) GraphHelper.getProperty(instanceVertex, Constants.VERSION_PROPERTY_KEY),
Id id = new Id(guid, Integer.parseInt(String.valueOf(GraphHelper.getProperty(instanceVertex, Constants.VERSION_PROPERTY_KEY))),
typeName, state);
LOG.debug("Created id {} for instance type {}", id, typeName);
......
......@@ -117,6 +117,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
@Override
public AtlasEntity.AtlasEntities searchEntities(final SearchFilter searchFilter) throws AtlasBaseException {
// TODO: Add checks here to ensure that typename and supertype are mandatory in the requests
return null;
}
}
......@@ -22,15 +22,14 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.type.AtlasArrayType;
......@@ -63,9 +62,9 @@ import java.util.Set;
import static org.apache.atlas.AtlasErrorCode.INVALID_TYPE_DEFINITION;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ON_DELETE;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_VAL_CASCADE;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_FOREIGN_KEY;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_MAPPED_FROM_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_VAL_CASCADE;
import static org.apache.atlas.type.AtlasTypeUtil.isArrayType;
......
......@@ -40,6 +40,7 @@ import org.apache.atlas.typesystem.ITypedStruct;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.exception.EntityNotFoundException;
import org.apache.atlas.typesystem.exception.TraitNotFoundException;
import org.apache.atlas.typesystem.exception.TypeNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -143,7 +144,7 @@ public class AtlasInstanceRestAdapters {
}
public static AtlasBaseException toAtlasBaseException(AtlasException e) {
if ( e instanceof EntityNotFoundException) {
if ( e instanceof EntityNotFoundException || e instanceof TraitNotFoundException) {
return new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, e);
}
......
......@@ -18,15 +18,8 @@
package org.apache.atlas.web.resources;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.Map;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.apache.atlas.catalog.JsonSerializer;
import org.apache.atlas.catalog.Request;
import org.apache.atlas.catalog.ResourceProvider;
......@@ -40,8 +33,13 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.Map;
/**
* Base class for all v1 API services.
......
......@@ -47,17 +47,7 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
......
......@@ -19,7 +19,13 @@
package org.apache.atlas.web.resources;
import org.apache.atlas.AtlasException;
import org.apache.atlas.catalog.*;
import org.apache.atlas.catalog.BaseRequest;
import org.apache.atlas.catalog.CollectionRequest;
import org.apache.atlas.catalog.DefaultTypeSystem;
import org.apache.atlas.catalog.EntityResourceProvider;
import org.apache.atlas.catalog.EntityTagResourceProvider;
import org.apache.atlas.catalog.InstanceRequest;
import org.apache.atlas.catalog.Result;
import org.apache.atlas.catalog.exception.CatalogException;
import org.apache.atlas.services.MetadataService;
import org.apache.atlas.utils.AtlasPerfTracer;
......@@ -28,9 +34,22 @@ import org.slf4j.Logger;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import java.util.*;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Service which handles API requests for v1 entity resources.
......
......@@ -20,7 +20,6 @@ package org.apache.atlas.web.resources;
import org.apache.atlas.AtlasException;
import org.apache.atlas.catalog.*;
import org.apache.atlas.catalog.Request;
import org.apache.atlas.catalog.exception.CatalogException;
import org.apache.atlas.catalog.exception.InvalidPayloadException;
import org.apache.atlas.services.MetadataService;
......@@ -30,8 +29,18 @@ import org.slf4j.Logger;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
......
......@@ -17,30 +17,24 @@
*/
package org.apache.atlas.web.rest;
import com.google.inject.Inject;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasEntityWithAssociations;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.services.MetadataService;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.web.adapters.AtlasFormatConverters;
import org.apache.atlas.web.adapters.AtlasInstanceRestAdapters;
import org.apache.atlas.web.util.Servlets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toAtlasBaseException;
import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toEntityMutationResponse;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
......@@ -53,8 +47,13 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toAtlasBaseException;
import static org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toEntityMutationResponse;
@Path("v2/entities")
......@@ -67,19 +66,16 @@ public class EntitiesREST {
@Context
private HttpServletRequest httpServletRequest;
@Inject
private MetadataService metadataService;
private AtlasTypeRegistry typeRegistry;
private final MetadataService metadataService;
@Inject
AtlasInstanceRestAdapters restAdapters;
private final AtlasInstanceRestAdapters restAdapters;
@Inject
public EntitiesREST(AtlasEntityStore entitiesStore, AtlasTypeRegistry atlasTypeRegistry) {
public EntitiesREST(AtlasEntityStore entitiesStore, MetadataService metadataService, AtlasInstanceRestAdapters restAdapters) {
LOG.info("EntitiesRest Init");
this.entitiesStore = entitiesStore;
this.typeRegistry = atlasTypeRegistry;
this.metadataService = metadataService;
this.restAdapters = restAdapters;
}
/*******
......@@ -174,9 +170,24 @@ public class EntitiesREST {
@GET
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasEntityHeader.AtlasEntityHeaders searchEntities() throws AtlasBaseException {
//SearchFilter searchFilter
//TODO: Need to handle getEntitiesByType for older API
return null;
SearchFilter searchFilter = getSearchFilter();
AtlasEntity.AtlasEntities atlasEntities = entitiesStore.searchEntities(searchFilter);
AtlasEntityHeader.AtlasEntityHeaders entityHeaders = new AtlasEntityHeader.AtlasEntityHeaders();
entityHeaders.setList(new LinkedList<AtlasEntityHeader>());
for (AtlasEntity atlasEntity : atlasEntities.getList()) {
entityHeaders.getList().add(new AtlasEntityHeader(atlasEntity.getTypeName(), atlasEntity.getAttributes()));
}
return entityHeaders;
}
private SearchFilter getSearchFilter() {
SearchFilter searchFilter = new SearchFilter();
if (null != httpServletRequest && null != httpServletRequest.getParameterMap()) {
for (Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
searchFilter.setParam(entry.getKey(), Arrays.asList(entry.getValue()));
}
}
return searchFilter;
}
}
......@@ -17,7 +17,6 @@
*/
package org.apache.atlas.web.rest;
import com.google.inject.Inject;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
......@@ -42,17 +41,9 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;
......@@ -69,14 +60,19 @@ public class EntityREST {
private static final Logger LOG = LoggerFactory.getLogger(EntityREST.class);
@Inject
AtlasTypeRegistry typeRegistry;
private final AtlasTypeRegistry typeRegistry;
@Inject
AtlasInstanceRestAdapters restAdapters;
private final AtlasInstanceRestAdapters restAdapters;
private final MetadataService metadataService;
@Inject
private MetadataService metadataService;
public EntityREST(AtlasTypeRegistry typeRegistry, AtlasInstanceRestAdapters restAdapters, MetadataService metadataService) {
this.typeRegistry = typeRegistry;
this.restAdapters = restAdapters;
this.metadataService = metadataService;
}
/**
* Create or Update an entity if it already exists
*
......@@ -323,6 +319,8 @@ public class EntityREST {
final ITypedStruct trait = restAdapters.getTrait(classification);
try {
metadataService.addTrait(guid, trait);
} catch (IllegalArgumentException e) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, e);
} catch (AtlasException e) {
throw toAtlasBaseException(e);
}
......
......@@ -14,17 +14,15 @@
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/security/oauth2
http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
......
......@@ -11,16 +11,9 @@
language governing permissions and limitations under the License. -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<import resource="classpath:/spring-security.xml" />
......
......@@ -52,7 +52,7 @@ public class QuickStartIT extends BaseResourceIT {
}
private Referenceable getDB(String dbName) throws AtlasServiceException, JSONException {
return serviceClient.getEntity(QuickStart.DATABASE_TYPE, "name", dbName);
return atlasClientV1.getEntity(QuickStart.DATABASE_TYPE, "name", dbName);
}
@Test
......@@ -68,7 +68,7 @@ public class QuickStartIT extends BaseResourceIT {
}
private Referenceable getTable(String tableName) throws AtlasServiceException {
return serviceClient.getEntity(QuickStart.TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
return atlasClientV1.getEntity(QuickStart.TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
}
private void verifyTrait(Referenceable table) throws JSONException {
......@@ -95,7 +95,7 @@ public class QuickStartIT extends BaseResourceIT {
@Test
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
Referenceable loadProcess = serviceClient.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
Referenceable loadProcess = atlasClientV1.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
QuickStart.LOAD_SALES_DAILY_PROCESS);
assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS, loadProcess.get(AtlasClient.NAME));
......@@ -123,7 +123,7 @@ public class QuickStartIT extends BaseResourceIT {
String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE);
String salesFactDailyMVId = getTableId(QuickStart.SALES_FACT_DAILY_MV_TABLE);
JSONObject inputGraph = serviceClient.getInputGraph(QuickStart.SALES_FACT_DAILY_MV_TABLE);
JSONObject inputGraph = atlasClientV1.getInputGraph(QuickStart.SALES_FACT_DAILY_MV_TABLE);
JSONObject vertices = (JSONObject) ((JSONObject) inputGraph.get("values")).get("vertices");
JSONObject edges = (JSONObject) ((JSONObject) inputGraph.get("values")).get("edges");
......@@ -142,7 +142,7 @@ public class QuickStartIT extends BaseResourceIT {
@Test
public void testViewIsAdded() throws AtlasServiceException, JSONException {
Referenceable view = serviceClient.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);
Referenceable view = atlasClientV1.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);
assertEquals(QuickStart.PRODUCT_DIM_VIEW, view.get(AtlasClient.NAME));
......
......@@ -65,8 +65,8 @@ public class EntityNotificationIT extends BaseResourceIT {
@BeforeClass
public void setUp() throws Exception {
super.setUp();
createTypeDefinitions();
Referenceable HiveDBInstance = createHiveDBInstance(DATABASE_NAME);
createTypeDefinitionsV1();
Referenceable HiveDBInstance = createHiveDBInstanceV1(DATABASE_NAME);
dbId = createInstance(HiveDBInstance);
List<NotificationConsumer<EntityNotification>> consumers =
......@@ -77,7 +77,7 @@ public class EntityNotificationIT extends BaseResourceIT {
@Test
public void testCreateEntity() throws Exception {
Referenceable tableInstance = createHiveTableInstance(DATABASE_NAME, TABLE_NAME, dbId);
Referenceable tableInstance = createHiveTableInstanceV1(DATABASE_NAME, TABLE_NAME, dbId);
tableId = createInstance(tableInstance);
final String guid = tableId._getId();
......@@ -93,7 +93,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final String guid = tableId._getId();
serviceClient.updateEntityAttribute(guid, property, newValue);
atlasClientV1.updateEntityAttribute(guid, property, newValue);
waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.ENTITY_UPDATE, HIVE_TABLE_TYPE, guid));
......@@ -103,10 +103,10 @@ public class EntityNotificationIT extends BaseResourceIT {
public void testDeleteEntity() throws Exception {
final String tableName = "table-" + randomString();
final String dbName = "db-" + randomString();
Referenceable HiveDBInstance = createHiveDBInstance(dbName);
Referenceable HiveDBInstance = createHiveDBInstanceV1(dbName);
Id dbId = createInstance(HiveDBInstance);
Referenceable tableInstance = createHiveTableInstance(dbName, tableName, dbId);
Referenceable tableInstance = createHiveTableInstanceV1(dbName, tableName, dbId);
final Id tableId = createInstance(tableInstance);
final String guid = tableId._getId();
......@@ -115,7 +115,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final String name = (String) tableInstance.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME);
serviceClient.deleteEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
atlasClientV1.deleteEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.ENTITY_DELETE, HIVE_TABLE_TYPE, guid));
......@@ -138,7 +138,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final String guid = tableId._getId();
serviceClient.addTrait(guid, traitInstance);
atlasClientV1.addTrait(guid, traitInstance);
EntityNotification entityNotification = waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.TRAIT_ADD, HIVE_TABLE_TYPE, guid));
......@@ -163,7 +163,7 @@ public class EntityNotificationIT extends BaseResourceIT {
traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("Trait instance = " + traitInstanceJSON);
serviceClient.addTrait(guid, traitInstance);
atlasClientV1.addTrait(guid, traitInstance);
entityNotification = waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.TRAIT_ADD, HIVE_TABLE_TYPE, guid));
......@@ -184,7 +184,7 @@ public class EntityNotificationIT extends BaseResourceIT {
public void testDeleteTrait() throws Exception {
final String guid = tableId._getId();
serviceClient.deleteTrait(guid, traitName);
atlasClientV1.deleteTrait(guid, traitName);
EntityNotification entityNotification = waitForNotification(notificationConsumer, MAX_WAIT_TIME,
newNotificationPredicate(EntityNotification.OperationType.TRAIT_DELETE, HIVE_TABLE_TYPE, guid));
......
......@@ -39,6 +39,9 @@ import static org.mockito.Mockito.verify;
@Guice(modules = NotificationModule.class)
public class NotificationHookConsumerKafkaTest {
public static final String NAME = "name";
public static final String DESCRIPTION = "description";
public static final String QUALIFIED_NAME = "qualifiedName";
@Inject
private NotificationInterface notificationInterface;
......@@ -128,9 +131,9 @@ public class NotificationHookConsumerKafkaTest {
Referenceable createEntity() {
final Referenceable entity = new Referenceable(AtlasClient.DATA_SET_SUPER_TYPE);
entity.set("name", "db" + randomString());
entity.set("description", randomString());
entity.set("qualifiedName", randomString());
entity.set(NAME, "db" + randomString());
entity.set(DESCRIPTION, randomString());
entity.set(QUALIFIED_NAME, randomString());
return entity;
}
......
......@@ -37,7 +37,7 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
@Test
public void testGetVersion() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.VERSION, null, (String[]) null);
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.VERSION, null, (String[]) null);
Assert.assertNotNull(response);
PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties");
......
......@@ -53,13 +53,13 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
public void setUp() throws Exception {
super.setUp();
createTypeDefinitions();
createTypeDefinitionsV1();
setupInstances();
}
@Test
public void testInputsGraph() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_INPUTS_GRAPH, null, salesMonthlyTable, "inputs", "graph");
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_INPUTS_GRAPH, null, salesMonthlyTable, "inputs", "graph");
Assert.assertNotNull(response);
System.out.println("inputs graph = " + response);
......@@ -78,9 +78,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
public void testInputsGraphForEntity() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
salesMonthlyTable).getId()._getId();
JSONObject results = serviceClient.getInputGraphForEntity(tableId);
JSONObject results = atlasClientV1.getInputGraphForEntity(tableId);
Assert.assertNotNull(results);
Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
......@@ -95,7 +95,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
public void testOutputsGraph() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_OUTPUTS_GRAPH, null, salesFactTable, "outputs", "graph");
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_OUTPUTS_GRAPH, null, salesFactTable, "outputs", "graph");
Assert.assertNotNull(response);
System.out.println("outputs graph= " + response);
......@@ -114,9 +114,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
public void testOutputsGraphForEntity() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
salesFactTable).getId()._getId();
JSONObject results = serviceClient.getOutputGraphForEntity(tableId);
JSONObject results = atlasClientV1.getOutputGraphForEntity(tableId);
Assert.assertNotNull(results);
Struct resultsInstance = InstanceSerialization.fromJsonStruct(results.toString(), true);
......@@ -131,7 +131,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
public void testSchema() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesFactTable, "schema");
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesFactTable, "schema");
Assert.assertNotNull(response);
System.out.println("schema = " + response);
......@@ -156,8 +156,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
public void testSchemaForEntity() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();
JSONObject results = serviceClient.getSchemaForEntity(tableId);
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();
JSONObject results = atlasClientV1.getSchemaForEntity(tableId);
Assert.assertNotNull(results);
JSONArray rows = results.getJSONArray("rows");
......@@ -175,12 +175,12 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test(expectedExceptions = AtlasServiceException.class)
public void testSchemaForInvalidTable() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, "blah", "schema");
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, "blah", "schema");
}
@Test(expectedExceptions = AtlasServiceException.class)
public void testSchemaForDB() throws Exception {
JSONObject response = serviceClient.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesDBName, "schema");
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.NAME_LINEAGE_SCHEMA, null, salesDBName, "schema");
}
private void setupInstances() throws Exception {
......@@ -238,9 +238,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
Id database(String name, String description, String owner, String locationUri, String... traitNames)
throws Exception {
Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("qualifiedName", name);
referenceable.set("clusterName", locationUri + name);
referenceable.set(NAME, name);
referenceable.set(QUALIFIED_NAME, name);
referenceable.set(CLUSTER_NAME, locationUri + name);
referenceable.set("description", description);
referenceable.set("owner", owner);
referenceable.set("locationUri", locationUri);
......@@ -251,8 +251,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
Referenceable column(String name, String type, String comment, String... traitNames) throws Exception {
Referenceable referenceable = new Referenceable(COLUMN_TYPE, traitNames);
referenceable.set("name", name);
referenceable.set("qualifiedName", name);
referenceable.set(NAME, name);
referenceable.set(QUALIFIED_NAME, name);
referenceable.set("type", type);
referenceable.set("comment", comment);
......
......@@ -60,19 +60,19 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
public void setUp() throws Exception {
super.setUp();
createTypeDefinitions();
createTypeDefinitionsV1();
setupInstances();
}
@Test
public void testInputLineageInfo() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(DIRECTION_PARAM, INPUT_DIRECTION);
queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response);
System.out.println("input lineage info = " + response
);
......@@ -94,13 +94,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
@Test
public void testOutputLineageInfo() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(DIRECTION_PARAM, OUTPUT_DIRECTION);
queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response);
System.out.println("output lineage info = " + response);
......@@ -122,13 +122,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
@Test
public void testLineageInfo() throws Exception {
String tableId = serviceClient.getEntity(HIVE_TABLE_TYPE,
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(DIRECTION_PARAM, BOTH_DIRECTION);
queryParams.add(DEPTH_PARAM, "5");
JSONObject response = serviceClient.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response);
System.out.println("both lineage info = " + response);
......
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