Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
ec1b160a
Commit
ec1b160a
authored
Nov 20, 2016
by
apoorvnaik
Committed by
Madhan Neethiraj
Dec 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1311: Integration tests for V2 Entity APIs
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
3b1a7d09
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1376 additions
and
389 deletions
+1376
-389
.gitignore
.gitignore
+1
-1
HiveHookIT.java
.../src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
+1
-1
AtlasBaseClient.java
client/src/main/java/org/apache/atlas/AtlasBaseClient.java
+22
-6
AtlasClient.java
client/src/main/java/org/apache/atlas/AtlasClient.java
+3
-2
AtlasEntitiesClientV2.java
...src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
+51
-14
AtlasServiceException.java
...src/main/java/org/apache/atlas/AtlasServiceException.java
+1
-1
AtlasTypedefClientV2.java
.../src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
+27
-0
SearchFilter.java
intg/src/main/java/org/apache/atlas/model/SearchFilter.java
+9
-0
EntityMutationResponse.java
...g/apache/atlas/model/instance/EntityMutationResponse.java
+0
-1
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+1
-1
AtlasEntityStoreV1.java
...e/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
+1
-0
RestUtils.java
webapp/src/main/java/org/apache/atlas/util/RestUtils.java
+2
-3
AtlasInstanceRestAdapters.java
.../apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
+2
-1
BaseService.java
...main/java/org/apache/atlas/web/resources/BaseService.java
+9
-11
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+1
-11
EntityService.java
...in/java/org/apache/atlas/web/resources/EntityService.java
+23
-4
TaxonomyService.java
.../java/org/apache/atlas/web/resources/TaxonomyService.java
+12
-3
EntitiesREST.java
...src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
+31
-20
EntityREST.java
...p/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+14
-16
spring-security.xml
webapp/src/main/resources/spring-security.xml
+4
-6
applicationContext.xml
webapp/src/main/webapp/WEB-INF/applicationContext.xml
+3
-10
QuickStartIT.java
...src/test/java/org/apache/atlas/examples/QuickStartIT.java
+5
-5
EntityNotificationIT.java
...a/org/apache/atlas/notification/EntityNotificationIT.java
+10
-10
NotificationHookConsumerIT.java
...apache/atlas/notification/NotificationHookConsumerIT.java
+52
-48
NotificationHookConsumerKafkaTest.java
...atlas/notification/NotificationHookConsumerKafkaTest.java
+6
-3
AdminJerseyResourceIT.java
...org/apache/atlas/web/resources/AdminJerseyResourceIT.java
+1
-1
BaseResourceIT.java
...t/java/org/apache/atlas/web/resources/BaseResourceIT.java
+252
-38
DataSetLineageJerseyResourceIT.java
...e/atlas/web/resources/DataSetLineageJerseyResourceIT.java
+17
-17
EntityJerseyResourceIT.java
...rg/apache/atlas/web/resources/EntityJerseyResourceIT.java
+83
-85
EntityLineageJerseyResourceIT.java
...he/atlas/web/resources/EntityLineageJerseyResourceIT.java
+7
-7
EntityV2JerseyResourceIT.java
.../apache/atlas/web/resources/EntityV2JerseyResourceIT.java
+669
-0
MetadataDiscoveryJerseyResourceIT.java
...tlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
+26
-33
TypesJerseyResourceIT.java
...org/apache/atlas/web/resources/TypesJerseyResourceIT.java
+30
-30
No files found.
.gitignore
View file @
ec1b160a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
# limitations under the License.
# limitations under the License.
# Maven
# Maven
target
target
*
dependency-reduced-pom.xml
dependency-reduced-pom.xml
core*.dmp
core*.dmp
pom.xml.releaseBackup
pom.xml.releaseBackup
...
...
addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
View file @
ec1b160a
...
@@ -1337,7 +1337,7 @@ public class HiveHookIT extends HiveITBase {
...
@@ -1337,7 +1337,7 @@ public class HiveHookIT extends HiveITBase {
* query = "alter table " + tableName + " STORED AS " + testFormat.toUpperCase();
* query = "alter table " + tableName + " STORED AS " + testFormat.toUpperCase();
* runCommand(query);
* runCommand(query);
* tableRef = atlasClient.getEntity(tableId);
* tableRef = atlasClient
V1
.getEntity(tableId);
* sdRef = (Referenceable)tableRef.get(HiveMetaStoreBridge.STORAGE_DESC);
* 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_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");
* Assert.assertEquals(sdRef.get(HiveMetaStoreBridge.STORAGE_DESC_OUTPUT_FMT), "org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat");
...
...
client/src/main/java/org/apache/atlas/AtlasBaseClient.java
View file @
ec1b160a
...
@@ -27,6 +27,7 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
...
@@ -27,6 +27,7 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import
com.sun.jersey.api.json.JSONConfiguration
;
import
com.sun.jersey.api.json.JSONConfiguration
;
import
com.sun.jersey.client.urlconnection.URLConnectionClientHandler
;
import
com.sun.jersey.client.urlconnection.URLConnectionClientHandler
;
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
;
...
@@ -276,12 +277,18 @@ public abstract class AtlasBaseClient {
...
@@ -276,12 +277,18 @@ public abstract class AtlasBaseClient {
ClientResponse
clientResponse
=
null
;
ClientResponse
clientResponse
=
null
;
int
i
=
0
;
int
i
=
0
;
do
{
do
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Calling API [ {} : {} ] {}"
,
api
.
getMethod
(),
api
.
getPath
(),
requestObject
!=
null
?
"<== "
+
requestObject
:
""
);
}
clientResponse
=
resource
clientResponse
=
resource
.
accept
(
JSON_MEDIA_TYPE
)
.
accept
(
JSON_MEDIA_TYPE
)
.
type
(
JSON_MEDIA_TYPE
)
.
type
(
JSON_MEDIA_TYPE
)
.
method
(
api
.
getMethod
(),
ClientResponse
.
class
,
requestObject
);
.
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
(
clientResponse
.
getStatus
()
==
api
.
getExpectedStatus
().
getStatusCode
())
{
if
(
null
==
responseType
)
{
if
(
null
==
responseType
)
{
LOG
.
warn
(
"No response type specified, returning null"
);
LOG
.
warn
(
"No response type specified, returning null"
);
...
@@ -291,12 +298,16 @@ public abstract class AtlasBaseClient {
...
@@ -291,12 +298,16 @@ public abstract class AtlasBaseClient {
if
(
responseType
==
JSONObject
.
class
)
{
if
(
responseType
==
JSONObject
.
class
)
{
String
stringEntity
=
clientResponse
.
getEntity
(
String
.
class
);
String
stringEntity
=
clientResponse
.
getEntity
(
String
.
class
);
try
{
try
{
return
(
T
)
new
JSONObject
(
stringEntity
);
JSONObject
jsonObject
=
new
JSONObject
(
stringEntity
);
LOG
.
info
(
"Response = {}"
,
jsonObject
);
return
(
T
)
jsonObject
;
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
throw
new
AtlasServiceException
(
api
,
e
);
throw
new
AtlasServiceException
(
api
,
e
);
}
}
}
else
{
}
else
{
return
clientResponse
.
getEntity
(
responseType
);
T
entity
=
clientResponse
.
getEntity
(
responseType
);
LOG
.
info
(
"Response = {}"
,
AtlasType
.
toJson
(
entity
));
return
entity
;
}
}
}
catch
(
ClientHandlerException
e
)
{
}
catch
(
ClientHandlerException
e
)
{
throw
new
AtlasServiceException
(
api
,
e
);
throw
new
AtlasServiceException
(
api
,
e
);
...
@@ -380,8 +391,7 @@ public abstract class AtlasBaseClient {
...
@@ -380,8 +391,7 @@ public abstract class AtlasBaseClient {
WebResource
resource
=
resourceCreator
.
createResource
();
WebResource
resource
=
resourceCreator
.
createResource
();
try
{
try
{
LOG
.
debug
(
"Using resource {} for {} times"
,
resource
.
getURI
(),
i
);
LOG
.
debug
(
"Using resource {} for {} times"
,
resource
.
getURI
(),
i
);
JSONObject
result
=
callAPIWithResource
(
api
,
resource
,
requestObject
,
JSONObject
.
class
);
return
callAPIWithResource
(
api
,
resource
,
requestObject
,
JSONObject
.
class
);
return
result
;
}
catch
(
ClientHandlerException
che
)
{
}
catch
(
ClientHandlerException
che
)
{
if
(
i
==
(
getNumberOfRetries
()
-
1
))
{
if
(
i
==
(
getNumberOfRetries
()
-
1
))
{
throw
che
;
throw
che
;
...
@@ -399,6 +409,12 @@ public abstract class AtlasBaseClient {
...
@@ -399,6 +409,12 @@ public abstract class AtlasBaseClient {
return
callAPIWithResource
(
api
,
getResource
(
api
,
params
),
requestObject
,
responseType
);
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
)
public
<
T
>
T
callAPI
(
APIInfo
api
,
Class
<
T
>
responseType
,
MultivaluedMap
<
String
,
String
>
queryParams
,
String
...
params
)
throws
AtlasServiceException
{
throws
AtlasServiceException
{
WebResource
resource
=
getResource
(
api
,
queryParams
,
params
);
WebResource
resource
=
getResource
(
api
,
queryParams
,
params
);
...
@@ -476,7 +492,7 @@ public abstract class AtlasBaseClient {
...
@@ -476,7 +492,7 @@ public abstract class AtlasBaseClient {
return
resource
;
return
resource
;
}
}
protected
APIInfo
formatPath
(
APIInfo
apiInfo
,
String
...
params
)
{
protected
APIInfo
formatPath
ForPathParams
(
APIInfo
apiInfo
,
String
...
params
)
{
return
new
APIInfo
(
String
.
format
(
apiInfo
.
getPath
(),
params
),
apiInfo
.
getMethod
(),
apiInfo
.
getExpectedStatus
());
return
new
APIInfo
(
String
.
format
(
apiInfo
.
getPath
(),
params
),
apiInfo
.
getMethod
(),
apiInfo
.
getExpectedStatus
());
}
}
...
...
client/src/main/java/org/apache/atlas/AtlasClient.java
View file @
ec1b160a
...
@@ -108,7 +108,8 @@ public class AtlasClient extends AtlasBaseClient {
...
@@ -108,7 +108,8 @@ public class AtlasClient extends AtlasBaseClient {
public
static
final
String
PROCESS_ATTRIBUTE_OUTPUTS
=
"outputs"
;
public
static
final
String
PROCESS_ATTRIBUTE_OUTPUTS
=
"outputs"
;
public
static
final
String
REFERENCEABLE_SUPER_TYPE
=
"Referenceable"
;
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"
;
public
static
final
String
UNKNOWN_STATUS
=
"Unknown status"
;
...
@@ -593,7 +594,7 @@ public class AtlasClient extends AtlasBaseClient {
...
@@ -593,7 +594,7 @@ public class AtlasClient extends AtlasBaseClient {
JSONObject
response
=
callAPIWithRetries
(
api
,
entityJson
,
new
ResourceCreator
()
{
JSONObject
response
=
callAPIWithRetries
(
api
,
entityJson
,
new
ResourceCreator
()
{
@Override
@Override
public
WebResource
createResource
()
{
public
WebResource
createResource
()
{
WebResource
resource
=
getResource
(
api
,
"qualifiedName"
);
WebResource
resource
=
getResource
(
api
,
QUALIFIED_NAME
);
resource
=
resource
.
queryParam
(
TYPE
,
entityType
);
resource
=
resource
.
queryParam
(
TYPE
,
entityType
);
resource
=
resource
.
queryParam
(
ATTRIBUTE_NAME
,
uniqueAttributeName
);
resource
=
resource
.
queryParam
(
ATTRIBUTE_NAME
,
uniqueAttributeName
);
resource
=
resource
.
queryParam
(
ATTRIBUTE_VALUE
,
uniqueAttributeValue
);
resource
=
resource
.
queryParam
(
ATTRIBUTE_VALUE
,
uniqueAttributeValue
);
...
...
client/src/main/java/org/apache/atlas/AtlasEntitiesClientV2.java
View file @
ec1b160a
...
@@ -18,21 +18,23 @@
...
@@ -18,21 +18,23 @@
package
org
.
apache
.
atlas
;
package
org
.
apache
.
atlas
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.sun.jersey.api.client.WebResource
;
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.SearchFilter
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications
;
import
org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntityWithAssociations
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
java.util.List
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
AtlasEntities
;
public
class
AtlasEntitiesClientV2
extends
AtlasBaseClient
{
public
class
AtlasEntitiesClientV2
extends
AtlasBaseClient
{
...
@@ -40,19 +42,24 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
...
@@ -40,19 +42,24 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
public
static
final
String
ENTITIES_API
=
BASE_URI
+
"v2/entities/"
;
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_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
CREATE_ENTITY
=
new
APIInfo
(
ENTITY_API
,
HttpMethod
.
POST
,
Response
.
Status
.
OK
);
private
static
final
APIInfo
UPDATE_ENTITY
=
CREATE_ENTITY
;
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
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_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
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
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
.
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
.
NO_CONTENT
);
private
static
final
APIInfo
GET_ENTITIES
=
new
APIInfo
(
ENTITIES_API
+
"guids/"
,
HttpMethod
.
GET
,
Response
.
Status
.
OK
);
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
CREATE_ENTITIES
=
new
APIInfo
(
ENTITIES_API
,
HttpMethod
.
POST
,
Response
.
Status
.
OK
);
private
static
final
APIInfo
UPDATE_ENTITIES
=
CREATE_ENTITIES
;
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
);
private
static
final
APIInfo
SEARCH_ENTITIES
=
new
APIInfo
(
ENTITIES_API
,
HttpMethod
.
GET
,
Response
.
Status
.
OK
);
public
AtlasEntitiesClientV2
(
String
[]
baseUrl
,
String
[]
basicAuthUserNamePassword
)
{
public
AtlasEntitiesClientV2
(
String
[]
baseUrl
,
String
[]
basicAuthUserNamePassword
)
{
...
@@ -80,6 +87,32 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
...
@@ -80,6 +87,32 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
return
callAPI
(
GET_ENTITY_BY_GUID
,
null
,
AtlasEntity
.
class
,
guid
);
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
{
public
EntityMutationResponse
createEntity
(
AtlasEntity
atlasEntity
)
throws
AtlasServiceException
{
return
callAPI
(
CREATE_ENTITY
,
atlasEntity
,
EntityMutationResponse
.
class
);
return
callAPI
(
CREATE_ENTITY
,
atlasEntity
,
EntityMutationResponse
.
class
);
}
}
...
@@ -89,31 +122,35 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
...
@@ -89,31 +122,35 @@ public class AtlasEntitiesClientV2 extends AtlasBaseClient {
}
}
public
EntityMutationResponse
updateEntity
(
String
guid
,
AtlasEntity
atlasEntity
)
throws
AtlasServiceException
{
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
{
public
AtlasEntity
deleteEntityByGuid
(
String
guid
)
throws
AtlasServiceException
{
return
callAPI
(
DELETE_ENTITY_BY_GUID
,
null
,
AtlasEntity
.
class
,
guid
);
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
{
public
AtlasClassifications
getClassifications
(
String
guid
)
throws
AtlasServiceException
{
return
callAPI
(
formatPath
(
GET_CLASSIFICATIONS
,
guid
),
null
,
AtlasClassifications
.
class
);
return
callAPI
(
formatPath
ForPathParams
(
GET_CLASSIFICATIONS
,
guid
),
null
,
AtlasClassifications
.
class
);
}
}
public
void
addClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
public
void
addClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
callAPI
(
formatPath
(
ADD_CLASSIFICATIONS
,
guid
),
classifications
,
AtlasClassifications
.
class
);
callAPI
(
formatPath
ForPathParams
(
ADD_CLASSIFICATIONS
,
guid
),
classifications
,
null
,
(
String
[])
null
);
}
}
public
void
updateClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
public
void
updateClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
callAPI
(
formatPath
(
UPDATE_CLASSIFICATIONS
,
guid
),
classifications
,
AtlasClassifications
.
class
);
callAPI
(
formatPath
ForPathParams
(
UPDATE_CLASSIFICATIONS
,
guid
),
classifications
,
AtlasClassifications
.
class
);
}
}
public
void
deleteClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
public
void
deleteClassifications
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasServiceException
{
callAPI
(
formatPath
(
GET_CLASSIFICATIONS
,
guid
),
classifications
,
AtlasClassifications
.
class
);
callAPI
(
formatPath
ForPathParams
(
GET_CLASSIFICATIONS
,
guid
),
classifications
,
AtlasClassifications
.
class
);
}
}
public
void
deleteClassification
(
String
guid
,
String
classificationName
)
throws
AtlasServiceException
{
public
void
deleteClassification
(
String
guid
,
String
classificationName
)
throws
AtlasServiceException
{
callAPI
(
formatPath
(
DELETE_CLASSIFICATION
,
guid
,
classificationName
),
null
,
AtlasClassifications
.
class
);
callAPI
(
formatPath
ForPathParams
(
DELETE_CLASSIFICATION
,
guid
,
classificationName
),
null
,
null
);
}
}
// Entities operations
// Entities operations
...
...
client/src/main/java/org/apache/atlas/AtlasServiceException.java
View file @
ec1b160a
...
@@ -32,7 +32,7 @@ public class AtlasServiceException extends Exception {
...
@@ -32,7 +32,7 @@ public class AtlasServiceException extends Exception {
}
}
public
AtlasServiceException
(
AtlasBaseClient
.
APIInfo
api
,
Exception
e
)
{
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
{
public
AtlasServiceException
(
AtlasClient
.
API
api
,
WebApplicationException
e
)
throws
JSONException
{
...
...
client/src/main/java/org/apache/atlas/AtlasTypedefClientV2.java
View file @
ec1b160a
...
@@ -37,10 +37,19 @@ import javax.ws.rs.core.Response;
...
@@ -37,10 +37,19 @@ import javax.ws.rs.core.Response;
public
class
AtlasTypedefClientV2
extends
AtlasBaseClient
{
public
class
AtlasTypedefClientV2
extends
AtlasBaseClient
{
private
static
final
String
BASE_URI
=
"api/atlas/v2/types/"
;
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
TYPEDEFS_PATH
=
BASE_URI
+
"typedefs/"
;
private
static
final
String
GET_BY_NAME_TEMPLATE
=
BASE_URI
+
"%s/name/%s"
;
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
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
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
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
);
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 {
...
@@ -108,6 +117,24 @@ public class AtlasTypedefClientV2 extends AtlasBaseClient {
return
getTypeDefByGuid
(
guid
,
AtlasEntityDef
.
class
);
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.
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Any changes to the existing definitions will be discarded
* Any changes to the existing definitions will be discarded
...
...
intg/src/main/java/org/apache/atlas/model/SearchFilter.java
View file @
ec1b160a
...
@@ -103,6 +103,15 @@ public class SearchFilter {
...
@@ -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
()
{
public
long
getStartIndex
()
{
return
startIndex
;
return
startIndex
;
}
}
...
...
intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java
View file @
ec1b160a
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
package
org
.
apache
.
atlas
.
model
.
instance
;
package
org
.
apache
.
atlas
.
model
.
instance
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.codehaus.jackson.annotate.JsonAutoDetect
;
import
org.codehaus.jackson.annotate.JsonAutoDetect
;
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
ec1b160a
...
@@ -82,7 +82,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -82,7 +82,7 @@ public final class GraphToTypedInstanceMapper {
LOG
.
debug
(
"Found createdBy : {} modifiedBy : {} createdTime: {} modifedTime: {}"
,
createdBy
,
modifiedBy
,
createdTime
,
modifiedTime
);
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
);
typeName
,
state
);
LOG
.
debug
(
"Created id {} for instance type {}"
,
id
,
typeName
);
LOG
.
debug
(
"Created id {} for instance type {}"
,
id
,
typeName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
View file @
ec1b160a
...
@@ -117,6 +117,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
...
@@ -117,6 +117,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
@Override
@Override
public
AtlasEntity
.
AtlasEntities
searchEntities
(
final
SearchFilter
searchFilter
)
throws
AtlasBaseException
{
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
;
return
null
;
}
}
}
}
webapp/src/main/java/org/apache/atlas/util/RestUtils.java
View file @
ec1b160a
...
@@ -22,15 +22,14 @@ import com.google.common.collect.ImmutableList;
...
@@ -22,15 +22,14 @@ import com.google.common.collect.ImmutableList;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
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.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
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
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality
;
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.AtlasTypeDefHeader
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.type.AtlasArrayType
;
import
org.apache.atlas.type.AtlasArrayType
;
...
@@ -63,9 +62,9 @@ import java.util.Set;
...
@@ -63,9 +62,9 @@ import java.util.Set;
import
static
org
.
apache
.
atlas
.
AtlasErrorCode
.
INVALID_TYPE_DEFINITION
;
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_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_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_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
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasTypeUtil
.
isArrayType
;
...
...
webapp/src/main/java/org/apache/atlas/web/adapters/AtlasInstanceRestAdapters.java
View file @
ec1b160a
...
@@ -40,6 +40,7 @@ import org.apache.atlas.typesystem.ITypedStruct;
...
@@ -40,6 +40,7 @@ import org.apache.atlas.typesystem.ITypedStruct;
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.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.TraitNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -143,7 +144,7 @@ public class AtlasInstanceRestAdapters {
...
@@ -143,7 +144,7 @@ public class AtlasInstanceRestAdapters {
}
}
public
static
AtlasBaseException
toAtlasBaseException
(
AtlasException
e
)
{
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
);
return
new
AtlasBaseException
(
AtlasErrorCode
.
INSTANCE_GUID_NOT_FOUND
,
e
);
}
}
...
...
webapp/src/main/java/org/apache/atlas/web/resources/BaseService.java
View file @
ec1b160a
...
@@ -18,15 +18,8 @@
...
@@ -18,15 +18,8 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
package
org
.
apache
.
atlas
.
web
.
resources
;
import
java.io.UnsupportedEncodingException
;
import
com.google.gson.Gson
;
import
java.net.URLDecoder
;
import
com.google.gson.JsonSyntaxException
;
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
org.apache.atlas.catalog.JsonSerializer
;
import
org.apache.atlas.catalog.JsonSerializer
;
import
org.apache.atlas.catalog.Request
;
import
org.apache.atlas.catalog.Request
;
import
org.apache.atlas.catalog.ResourceProvider
;
import
org.apache.atlas.catalog.ResourceProvider
;
...
@@ -40,8 +33,13 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider;
...
@@ -40,8 +33,13 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.google.gson.Gson
;
import
javax.ws.rs.core.Context
;
import
com.google.gson.JsonSyntaxException
;
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.
* Base class for all v1 API services.
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
ec1b160a
...
@@ -47,17 +47,7 @@ import org.slf4j.LoggerFactory;
...
@@ -47,17 +47,7 @@ import org.slf4j.LoggerFactory;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.*
;
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.core.Context
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
View file @
ec1b160a
...
@@ -19,7 +19,13 @@
...
@@ -19,7 +19,13 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasException
;
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.catalog.exception.CatalogException
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
...
@@ -28,9 +34,22 @@ import org.slf4j.Logger;
...
@@ -28,9 +34,22 @@ import org.slf4j.Logger;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.ws.rs.*
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.core.*
;
import
javax.ws.rs.GET
;
import
java.util.*
;
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.
* Service which handles API requests for v1 entity resources.
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
View file @
ec1b160a
...
@@ -20,7 +20,6 @@ package org.apache.atlas.web.resources;
...
@@ -20,7 +20,6 @@ package org.apache.atlas.web.resources;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.Request
;
import
org.apache.atlas.catalog.exception.CatalogException
;
import
org.apache.atlas.catalog.exception.CatalogException
;
import
org.apache.atlas.catalog.exception.InvalidPayloadException
;
import
org.apache.atlas.catalog.exception.InvalidPayloadException
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
...
@@ -30,8 +29,18 @@ import org.slf4j.Logger;
...
@@ -30,8 +29,18 @@ import org.slf4j.Logger;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.ws.rs.*
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.core.*
;
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.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
...
webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
View file @
ec1b160a
...
@@ -17,30 +17,24 @@
...
@@ -17,30 +17,24 @@
*/
*/
package
org
.
apache
.
atlas
.
web
.
rest
;
package
org
.
apache
.
atlas
.
web
.
rest
;
import
com.google.inject.Inject
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.exception.AtlasBaseException
;
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.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
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.model.instance.EntityMutationResponse
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
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.adapters.AtlasInstanceRestAdapters
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toAtlasBaseException
;
import
javax.inject.Inject
;
import
static
org
.
apache
.
atlas
.
web
.
adapters
.
AtlasInstanceRestAdapters
.
toEntityMutationResponse
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Consumes
;
...
@@ -53,8 +47,13 @@ import javax.ws.rs.Produces;
...
@@ -53,8 +47,13 @@ import javax.ws.rs.Produces;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Context
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.List
;
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"
)
@Path
(
"v2/entities"
)
...
@@ -67,19 +66,16 @@ public class EntitiesREST {
...
@@ -67,19 +66,16 @@ public class EntitiesREST {
@Context
@Context
private
HttpServletRequest
httpServletRequest
;
private
HttpServletRequest
httpServletRequest
;
@Inject
private
final
MetadataService
metadataService
;
private
MetadataService
metadataService
;
private
AtlasTypeRegistry
typeRegistry
;
@Inject
private
final
AtlasInstanceRestAdapters
restAdapters
;
AtlasInstanceRestAdapters
restAdapters
;
@Inject
@Inject
public
EntitiesREST
(
AtlasEntityStore
entitiesStore
,
AtlasTypeRegistry
atlasTypeRegistry
)
{
public
EntitiesREST
(
AtlasEntityStore
entitiesStore
,
MetadataService
metadataService
,
AtlasInstanceRestAdapters
restAdapters
)
{
LOG
.
info
(
"EntitiesRest Init"
);
LOG
.
info
(
"EntitiesRest Init"
);
this
.
entitiesStore
=
entitiesStore
;
this
.
entitiesStore
=
entitiesStore
;
this
.
typeRegistry
=
atlasTypeRegistry
;
this
.
metadataService
=
metadataService
;
this
.
restAdapters
=
restAdapters
;
}
}
/*******
/*******
...
@@ -174,9 +170,24 @@ public class EntitiesREST {
...
@@ -174,9 +170,24 @@ public class EntitiesREST {
@GET
@GET
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasEntityHeader
.
AtlasEntityHeaders
searchEntities
()
throws
AtlasBaseException
{
public
AtlasEntityHeader
.
AtlasEntityHeaders
searchEntities
()
throws
AtlasBaseException
{
//SearchFilter searchFilter
SearchFilter
searchFilter
=
getSearchFilter
();
//TODO: Need to handle getEntitiesByType for older API
AtlasEntity
.
AtlasEntities
atlasEntities
=
entitiesStore
.
searchEntities
(
searchFilter
);
return
null
;
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
;
}
}
}
}
webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
View file @
ec1b160a
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
*/
*/
package
org
.
apache
.
atlas
.
web
.
rest
;
package
org
.
apache
.
atlas
.
web
.
rest
;
import
com.google.inject.Inject
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
...
@@ -42,17 +41,9 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -42,17 +41,9 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.*
;
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.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -69,14 +60,19 @@ public class EntityREST {
...
@@ -69,14 +60,19 @@ public class EntityREST {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityREST
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityREST
.
class
);
@Inject
private
final
AtlasTypeRegistry
typeRegistry
;
AtlasTypeRegistry
typeRegistry
;
@Inject
private
final
AtlasInstanceRestAdapters
restAdapters
;
AtlasInstanceRestAdapters
restAdapters
;
private
final
MetadataService
metadataService
;
@Inject
@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
* Create or Update an entity if it already exists
*
*
...
@@ -323,6 +319,8 @@ public class EntityREST {
...
@@ -323,6 +319,8 @@ public class EntityREST {
final
ITypedStruct
trait
=
restAdapters
.
getTrait
(
classification
);
final
ITypedStruct
trait
=
restAdapters
.
getTrait
(
classification
);
try
{
try
{
metadataService
.
addTrait
(
guid
,
trait
);
metadataService
.
addTrait
(
guid
,
trait
);
}
catch
(
IllegalArgumentException
e
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
,
e
);
}
catch
(
AtlasException
e
)
{
}
catch
(
AtlasException
e
)
{
throw
toAtlasBaseException
(
e
);
throw
toAtlasBaseException
(
e
);
}
}
...
...
webapp/src/main/resources/spring-security.xml
View file @
ec1b160a
...
@@ -14,17 +14,15 @@
...
@@ -14,17 +14,15 @@
xmlns:beans=
"http://www.springframework.org/schema/beans"
xmlns:beans=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:security=
"http://www.springframework.org/schema/security"
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"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
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
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>
...
...
webapp/src/main/webapp/WEB-INF/applicationContext.xml
View file @
ec1b160a
...
@@ -11,16 +11,9 @@
...
@@ -11,16 +11,9 @@
language governing permissions and limitations under the License. -->
language governing permissions and limitations under the License. -->
<beans
xmlns=
"http://www.springframework.org/schema/beans"
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xmlns:context=
"http://www.springframework.org/schema/context"
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
>
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"
>
<import
resource=
"classpath:/spring-security.xml"
/>
<import
resource=
"classpath:/spring-security.xml"
/>
...
...
webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java
View file @
ec1b160a
...
@@ -52,7 +52,7 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -52,7 +52,7 @@ public class QuickStartIT extends BaseResourceIT {
}
}
private
Referenceable
getDB
(
String
dbName
)
throws
AtlasServiceException
,
JSONException
{
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
@Test
...
@@ -68,7 +68,7 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -68,7 +68,7 @@ public class QuickStartIT extends BaseResourceIT {
}
}
private
Referenceable
getTable
(
String
tableName
)
throws
AtlasServiceException
{
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
{
private
void
verifyTrait
(
Referenceable
table
)
throws
JSONException
{
...
@@ -95,7 +95,7 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -95,7 +95,7 @@ public class QuickStartIT extends BaseResourceIT {
@Test
@Test
public
void
testProcessIsAdded
()
throws
AtlasServiceException
,
JSONException
{
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
);
QuickStart
.
LOAD_SALES_DAILY_PROCESS
);
assertEquals
(
QuickStart
.
LOAD_SALES_DAILY_PROCESS
,
loadProcess
.
get
(
AtlasClient
.
NAME
));
assertEquals
(
QuickStart
.
LOAD_SALES_DAILY_PROCESS
,
loadProcess
.
get
(
AtlasClient
.
NAME
));
...
@@ -123,7 +123,7 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -123,7 +123,7 @@ public class QuickStartIT extends BaseResourceIT {
String
timeDimTableId
=
getTableId
(
QuickStart
.
TIME_DIM_TABLE
);
String
timeDimTableId
=
getTableId
(
QuickStart
.
TIME_DIM_TABLE
);
String
salesFactDailyMVId
=
getTableId
(
QuickStart
.
SALES_FACT_DAILY_MV_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
vertices
=
(
JSONObject
)
((
JSONObject
)
inputGraph
.
get
(
"values"
)).
get
(
"vertices"
);
JSONObject
edges
=
(
JSONObject
)
((
JSONObject
)
inputGraph
.
get
(
"values"
)).
get
(
"edges"
);
JSONObject
edges
=
(
JSONObject
)
((
JSONObject
)
inputGraph
.
get
(
"values"
)).
get
(
"edges"
);
...
@@ -142,7 +142,7 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -142,7 +142,7 @@ public class QuickStartIT extends BaseResourceIT {
@Test
@Test
public
void
testViewIsAdded
()
throws
AtlasServiceException
,
JSONException
{
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
));
assertEquals
(
QuickStart
.
PRODUCT_DIM_VIEW
,
view
.
get
(
AtlasClient
.
NAME
));
...
...
webapp/src/test/java/org/apache/atlas/notification/EntityNotificationIT.java
View file @
ec1b160a
...
@@ -65,8 +65,8 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -65,8 +65,8 @@ public class EntityNotificationIT extends BaseResourceIT {
@BeforeClass
@BeforeClass
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
createTypeDefinitions
();
createTypeDefinitions
V1
();
Referenceable
HiveDBInstance
=
createHiveDBInstance
(
DATABASE_NAME
);
Referenceable
HiveDBInstance
=
createHiveDBInstance
V1
(
DATABASE_NAME
);
dbId
=
createInstance
(
HiveDBInstance
);
dbId
=
createInstance
(
HiveDBInstance
);
List
<
NotificationConsumer
<
EntityNotification
>>
consumers
=
List
<
NotificationConsumer
<
EntityNotification
>>
consumers
=
...
@@ -77,7 +77,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -77,7 +77,7 @@ public class EntityNotificationIT extends BaseResourceIT {
@Test
@Test
public
void
testCreateEntity
()
throws
Exception
{
public
void
testCreateEntity
()
throws
Exception
{
Referenceable
tableInstance
=
createHiveTableInstance
(
DATABASE_NAME
,
TABLE_NAME
,
dbId
);
Referenceable
tableInstance
=
createHiveTableInstance
V1
(
DATABASE_NAME
,
TABLE_NAME
,
dbId
);
tableId
=
createInstance
(
tableInstance
);
tableId
=
createInstance
(
tableInstance
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
...
@@ -93,7 +93,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -93,7 +93,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
serviceClient
.
updateEntityAttribute
(
guid
,
property
,
newValue
);
atlasClientV1
.
updateEntityAttribute
(
guid
,
property
,
newValue
);
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
newNotificationPredicate
(
EntityNotification
.
OperationType
.
ENTITY_UPDATE
,
HIVE_TABLE_TYPE
,
guid
));
newNotificationPredicate
(
EntityNotification
.
OperationType
.
ENTITY_UPDATE
,
HIVE_TABLE_TYPE
,
guid
));
...
@@ -103,10 +103,10 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -103,10 +103,10 @@ public class EntityNotificationIT extends BaseResourceIT {
public
void
testDeleteEntity
()
throws
Exception
{
public
void
testDeleteEntity
()
throws
Exception
{
final
String
tableName
=
"table-"
+
randomString
();
final
String
tableName
=
"table-"
+
randomString
();
final
String
dbName
=
"db-"
+
randomString
();
final
String
dbName
=
"db-"
+
randomString
();
Referenceable
HiveDBInstance
=
createHiveDBInstance
(
dbName
);
Referenceable
HiveDBInstance
=
createHiveDBInstance
V1
(
dbName
);
Id
dbId
=
createInstance
(
HiveDBInstance
);
Id
dbId
=
createInstance
(
HiveDBInstance
);
Referenceable
tableInstance
=
createHiveTableInstance
(
dbName
,
tableName
,
dbId
);
Referenceable
tableInstance
=
createHiveTableInstance
V1
(
dbName
,
tableName
,
dbId
);
final
Id
tableId
=
createInstance
(
tableInstance
);
final
Id
tableId
=
createInstance
(
tableInstance
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
...
@@ -115,7 +115,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -115,7 +115,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final
String
name
=
(
String
)
tableInstance
.
get
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
);
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
,
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
newNotificationPredicate
(
EntityNotification
.
OperationType
.
ENTITY_DELETE
,
HIVE_TABLE_TYPE
,
guid
));
newNotificationPredicate
(
EntityNotification
.
OperationType
.
ENTITY_DELETE
,
HIVE_TABLE_TYPE
,
guid
));
...
@@ -138,7 +138,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -138,7 +138,7 @@ public class EntityNotificationIT extends BaseResourceIT {
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
serviceClient
.
addTrait
(
guid
,
traitInstance
);
atlasClientV1
.
addTrait
(
guid
,
traitInstance
);
EntityNotification
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
EntityNotification
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_ADD
,
HIVE_TABLE_TYPE
,
guid
));
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_ADD
,
HIVE_TABLE_TYPE
,
guid
));
...
@@ -163,7 +163,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -163,7 +163,7 @@ public class EntityNotificationIT extends BaseResourceIT {
traitInstanceJSON
=
InstanceSerialization
.
toJson
(
traitInstance
,
true
);
traitInstanceJSON
=
InstanceSerialization
.
toJson
(
traitInstance
,
true
);
LOG
.
debug
(
"Trait instance = "
+
traitInstanceJSON
);
LOG
.
debug
(
"Trait instance = "
+
traitInstanceJSON
);
serviceClient
.
addTrait
(
guid
,
traitInstance
);
atlasClientV1
.
addTrait
(
guid
,
traitInstance
);
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_ADD
,
HIVE_TABLE_TYPE
,
guid
));
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_ADD
,
HIVE_TABLE_TYPE
,
guid
));
...
@@ -184,7 +184,7 @@ public class EntityNotificationIT extends BaseResourceIT {
...
@@ -184,7 +184,7 @@ public class EntityNotificationIT extends BaseResourceIT {
public
void
testDeleteTrait
()
throws
Exception
{
public
void
testDeleteTrait
()
throws
Exception
{
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
serviceClient
.
deleteTrait
(
guid
,
traitName
);
atlasClientV1
.
deleteTrait
(
guid
,
traitName
);
EntityNotification
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
EntityNotification
entityNotification
=
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_DELETE
,
HIVE_TABLE_TYPE
,
guid
));
newNotificationPredicate
(
EntityNotification
.
OperationType
.
TRAIT_DELETE
,
HIVE_TABLE_TYPE
,
guid
));
...
...
webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerIT.java
View file @
ec1b160a
...
@@ -38,6 +38,10 @@ import static org.testng.Assert.assertEquals;
...
@@ -38,6 +38,10 @@ import static org.testng.Assert.assertEquals;
public
class
NotificationHookConsumerIT
extends
BaseResourceIT
{
public
class
NotificationHookConsumerIT
extends
BaseResourceIT
{
private
static
final
String
TEST_USER
=
"testuser"
;
private
static
final
String
TEST_USER
=
"testuser"
;
public
static
final
String
NAME
=
"name"
;
public
static
final
String
DESCRIPTION
=
"description"
;
public
static
final
String
QUALIFIED_NAME
=
"qualifiedName"
;
public
static
final
String
CLUSTER_NAME
=
"clusterName"
;
@Inject
@Inject
private
NotificationInterface
kafka
;
private
NotificationInterface
kafka
;
...
@@ -45,7 +49,7 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -45,7 +49,7 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
@BeforeClass
@BeforeClass
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
createTypeDefinitions
();
createTypeDefinitions
V1
();
}
}
@AfterClass
@AfterClass
...
@@ -66,16 +70,16 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -66,16 +70,16 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
//send valid message
//send valid message
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
"db"
+
randomString
();
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
sendHookMessage
(
new
HookNotification
.
EntityCreateRequest
(
TEST_USER
,
entity
));
sendHookMessage
(
new
HookNotification
.
EntityCreateRequest
(
TEST_USER
,
entity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where name='%s'"
,
DATABASE_TYPE
,
entity
.
get
(
"name"
)));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where name='%s'"
,
DATABASE_TYPE
,
entity
.
get
(
NAME
)));
return
results
.
length
()
==
1
;
return
results
.
length
()
==
1
;
}
}
});
});
...
@@ -85,25 +89,25 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -85,25 +89,25 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
public
void
testCreateEntity
()
throws
Exception
{
public
void
testCreateEntity
()
throws
Exception
{
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
"db"
+
randomString
();
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
sendHookMessage
(
new
HookNotification
.
EntityCreateRequest
(
TEST_USER
,
entity
));
sendHookMessage
(
new
HookNotification
.
EntityCreateRequest
(
TEST_USER
,
entity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
entity
.
get
(
"qualifiedName"
)));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
entity
.
get
(
QUALIFIED_NAME
)));
return
results
.
length
()
==
1
;
return
results
.
length
()
==
1
;
}
}
});
});
//Assert that user passed in hook message is used in audit
//Assert that user passed in hook message is used in audit
Referenceable
instance
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
(
String
)
entity
.
get
(
"qualifiedName"
));
Referenceable
instance
=
atlasClientV1
.
getEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
(
String
)
entity
.
get
(
QUALIFIED_NAME
));
List
<
EntityAuditEvent
>
events
=
List
<
EntityAuditEvent
>
events
=
serviceClient
.
getEntityAuditEvents
(
instance
.
getId
().
_getId
(),
(
short
)
1
);
atlasClientV1
.
getEntityAuditEvents
(
instance
.
getId
().
_getId
(),
(
short
)
1
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
get
(
0
).
getUser
(),
TEST_USER
);
assertEquals
(
events
.
get
(
0
).
getUser
(),
TEST_USER
);
}
}
...
@@ -112,47 +116,47 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -112,47 +116,47 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
public
void
testUpdateEntityPartial
()
throws
Exception
{
public
void
testUpdateEntityPartial
()
throws
Exception
{
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
dbName
=
"db"
+
randomString
();
final
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
serviceClient
.
createEntity
(
entity
);
atlasClientV1
.
createEntity
(
entity
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
newEntity
.
set
(
"owner"
,
randomString
());
newEntity
.
set
(
"owner"
,
randomString
());
sendHookMessage
(
sendHookMessage
(
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
"qualifiedName"
,
dbName
,
newEntity
));
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
,
newEntity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
Referenceable
localEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
dbName
);
Referenceable
localEntity
=
atlasClientV1
.
getEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
);
return
(
localEntity
.
get
(
"owner"
)
!=
null
&&
localEntity
.
get
(
"owner"
).
equals
(
newEntity
.
get
(
"owner"
)));
return
(
localEntity
.
get
(
"owner"
)
!=
null
&&
localEntity
.
get
(
"owner"
).
equals
(
newEntity
.
get
(
"owner"
)));
}
}
});
});
//Its partial update and un-set fields are not updated
//Its partial update and un-set fields are not updated
Referenceable
actualEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
dbName
);
Referenceable
actualEntity
=
atlasClientV1
.
getEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
);
assertEquals
(
actualEntity
.
get
(
"description"
),
entity
.
get
(
"description"
));
assertEquals
(
actualEntity
.
get
(
DESCRIPTION
),
entity
.
get
(
DESCRIPTION
));
}
}
@Test
@Test
public
void
testUpdatePartialUpdatingQualifiedName
()
throws
Exception
{
public
void
testUpdatePartialUpdatingQualifiedName
()
throws
Exception
{
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
dbName
=
"db"
+
randomString
();
final
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
serviceClient
.
createEntity
(
entity
);
atlasClientV1
.
createEntity
(
entity
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
newName
=
"db"
+
randomString
();
final
String
newName
=
"db"
+
randomString
();
newEntity
.
set
(
"qualifiedName"
,
newName
);
newEntity
.
set
(
QUALIFIED_NAME
,
newName
);
sendHookMessage
(
sendHookMessage
(
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
"qualifiedName"
,
dbName
,
newEntity
));
new
HookNotification
.
EntityPartialUpdateRequest
(
TEST_USER
,
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
,
newEntity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
...
@@ -171,19 +175,19 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -171,19 +175,19 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
public
void
testDeleteByQualifiedName
()
throws
Exception
{
public
void
testDeleteByQualifiedName
()
throws
Exception
{
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
dbName
=
"db"
+
randomString
();
final
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
final
String
dbId
=
serviceClient
.
createEntity
(
entity
).
get
(
0
);
final
String
dbId
=
atlasClientV1
.
createEntity
(
entity
).
get
(
0
);
sendHookMessage
(
sendHookMessage
(
new
HookNotification
.
EntityDeleteRequest
(
TEST_USER
,
DATABASE_TYPE
,
"qualifiedName"
,
dbName
));
new
HookNotification
.
EntityDeleteRequest
(
TEST_USER
,
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
Referenceable
getEntity
=
serviceClient
.
getEntity
(
dbId
);
Referenceable
getEntity
=
atlasClientV1
.
getEntity
(
dbId
);
return
getEntity
.
getId
().
getState
()
==
Id
.
EntityState
.
DELETED
;
return
getEntity
.
getId
().
getState
()
==
Id
.
EntityState
.
DELETED
;
}
}
});
});
...
@@ -193,32 +197,32 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
...
@@ -193,32 +197,32 @@ public class NotificationHookConsumerIT extends BaseResourceIT {
public
void
testUpdateEntityFullUpdate
()
throws
Exception
{
public
void
testUpdateEntityFullUpdate
()
throws
Exception
{
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
dbName
=
"db"
+
randomString
();
final
String
dbName
=
"db"
+
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
NAME
,
dbName
);
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
CLUSTER_NAME
,
randomString
());
serviceClient
.
createEntity
(
entity
);
atlasClientV1
.
createEntity
(
entity
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
newEntity
=
new
Referenceable
(
DATABASE_TYPE
);
newEntity
.
set
(
"name"
,
randomString
());
newEntity
.
set
(
NAME
,
randomString
());
newEntity
.
set
(
"description"
,
randomString
());
newEntity
.
set
(
DESCRIPTION
,
randomString
());
newEntity
.
set
(
"owner"
,
randomString
());
newEntity
.
set
(
"owner"
,
randomString
());
newEntity
.
set
(
"qualifiedName"
,
dbName
);
newEntity
.
set
(
QUALIFIED_NAME
,
dbName
);
newEntity
.
set
(
"clusterName"
,
randomString
());
newEntity
.
set
(
CLUSTER_NAME
,
randomString
());
//updating unique attribute
//updating unique attribute
sendHookMessage
(
new
HookNotification
.
EntityUpdateRequest
(
TEST_USER
,
newEntity
));
sendHookMessage
(
new
HookNotification
.
EntityUpdateRequest
(
TEST_USER
,
newEntity
));
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
waitFor
(
MAX_WAIT_TIME
,
new
Predicate
()
{
@Override
@Override
public
boolean
evaluate
()
throws
Exception
{
public
boolean
evaluate
()
throws
Exception
{
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
newEntity
.
get
(
"qualifiedName"
)));
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
newEntity
.
get
(
QUALIFIED_NAME
)));
return
results
.
length
()
==
1
;
return
results
.
length
()
==
1
;
}
}
});
});
Referenceable
actualEntity
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
dbName
);
Referenceable
actualEntity
=
atlasClientV1
.
getEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
);
assertEquals
(
actualEntity
.
get
(
"description"
),
newEntity
.
get
(
"description"
));
assertEquals
(
actualEntity
.
get
(
DESCRIPTION
),
newEntity
.
get
(
DESCRIPTION
));
assertEquals
(
actualEntity
.
get
(
"owner"
),
newEntity
.
get
(
"owner"
));
assertEquals
(
actualEntity
.
get
(
"owner"
),
newEntity
.
get
(
"owner"
));
}
}
...
...
webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
View file @
ec1b160a
...
@@ -39,6 +39,9 @@ import static org.mockito.Mockito.verify;
...
@@ -39,6 +39,9 @@ import static org.mockito.Mockito.verify;
@Guice
(
modules
=
NotificationModule
.
class
)
@Guice
(
modules
=
NotificationModule
.
class
)
public
class
NotificationHookConsumerKafkaTest
{
public
class
NotificationHookConsumerKafkaTest
{
public
static
final
String
NAME
=
"name"
;
public
static
final
String
DESCRIPTION
=
"description"
;
public
static
final
String
QUALIFIED_NAME
=
"qualifiedName"
;
@Inject
@Inject
private
NotificationInterface
notificationInterface
;
private
NotificationInterface
notificationInterface
;
...
@@ -128,9 +131,9 @@ public class NotificationHookConsumerKafkaTest {
...
@@ -128,9 +131,9 @@ public class NotificationHookConsumerKafkaTest {
Referenceable
createEntity
()
{
Referenceable
createEntity
()
{
final
Referenceable
entity
=
new
Referenceable
(
AtlasClient
.
DATA_SET_SUPER_TYPE
);
final
Referenceable
entity
=
new
Referenceable
(
AtlasClient
.
DATA_SET_SUPER_TYPE
);
entity
.
set
(
"name"
,
"db"
+
randomString
());
entity
.
set
(
NAME
,
"db"
+
randomString
());
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
DESCRIPTION
,
randomString
());
entity
.
set
(
"qualifiedName"
,
randomString
());
entity
.
set
(
QUALIFIED_NAME
,
randomString
());
return
entity
;
return
entity
;
}
}
...
...
webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java
View file @
ec1b160a
...
@@ -37,7 +37,7 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
...
@@ -37,7 +37,7 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testGetVersion
()
throws
Exception
{
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
);
Assert
.
assertNotNull
(
response
);
PropertiesConfiguration
buildConfiguration
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
PropertiesConfiguration
buildConfiguration
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
View file @
ec1b160a
...
@@ -24,9 +24,24 @@ import com.google.common.collect.ImmutableSet;
...
@@ -24,9 +24,24 @@ import com.google.common.collect.ImmutableSet;
import
kafka.consumer.ConsumerTimeoutException
;
import
kafka.consumer.ConsumerTimeoutException
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasEntitiesClientV2
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.AtlasTypedefClientV2
;
import
org.apache.atlas.model.instance.AtlasClassification
;
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.AtlasStruct
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutations
;
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.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.notification.NotificationConsumer
;
import
org.apache.atlas.notification.NotificationConsumer
;
import
org.apache.atlas.notification.entity.EntityNotification
;
import
org.apache.atlas.notification.entity.EntityNotification
;
import
org.apache.atlas.type.AtlasTypeUtil
;
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
;
...
@@ -45,11 +60,15 @@ import org.slf4j.LoggerFactory;
...
@@ -45,11 +60,15 @@ import org.slf4j.LoggerFactory;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeClass
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
/**
/**
* Base class for integration tests.
* Base class for integration tests.
* Sets up the web resource and has helper methods to create type and entity.
* Sets up the web resource and has helper methods to create type and entity.
...
@@ -57,7 +76,16 @@ import java.util.Map;
...
@@ -57,7 +76,16 @@ import java.util.Map;
public
abstract
class
BaseResourceIT
{
public
abstract
class
BaseResourceIT
{
public
static
final
String
ATLAS_REST_ADDRESS
=
"atlas.rest.address"
;
public
static
final
String
ATLAS_REST_ADDRESS
=
"atlas.rest.address"
;
protected
AtlasClient
serviceClient
;
public
static
final
String
NAME
=
"name"
;
public
static
final
String
QUALIFIED_NAME
=
"qualifiedName"
;
public
static
final
String
CLUSTER_NAME
=
"clusterName"
;
public
static
final
String
DESCRIPTION
=
"description"
;
// All service clients
protected
AtlasClient
atlasClientV1
;
protected
AtlasTypedefClientV2
typedefClientV2
;
protected
AtlasEntitiesClientV2
entitiesClientV2
;
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BaseResourceIT
.
class
);
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BaseResourceIT
.
class
);
protected
static
final
int
MAX_WAIT_TIME
=
60000
;
protected
static
final
int
MAX_WAIT_TIME
=
60000
;
protected
String
[]
atlasUrls
;
protected
String
[]
atlasUrls
;
...
@@ -73,32 +101,69 @@ public abstract class BaseResourceIT {
...
@@ -73,32 +101,69 @@ public abstract class BaseResourceIT {
}
}
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
serviceClient
=
new
AtlasClient
(
atlasUrls
,
new
String
[]{
"admin"
,
"admin"
});
atlasClientV1
=
new
AtlasClient
(
atlasUrls
,
new
String
[]{
"admin"
,
"admin"
});
typedefClientV2
=
new
AtlasTypedefClientV2
(
atlasUrls
,
new
String
[]{
"admin"
,
"admin"
});
entitiesClientV2
=
new
AtlasEntitiesClientV2
(
atlasUrls
,
new
String
[]{
"admin"
,
"admin"
});
}
else
{
}
else
{
serviceClient
=
new
AtlasClient
(
atlasUrls
);
atlasClientV1
=
new
AtlasClient
(
atlasUrls
);
typedefClientV2
=
new
AtlasTypedefClientV2
(
atlasUrls
);
entitiesClientV2
=
new
AtlasEntitiesClientV2
(
atlasUrls
);
}
}
protected
void
createType
(
AtlasTypesDef
typesDef
)
{
// Since the bulk create bails out on a single failure, this has to be done as a workaround
for
(
AtlasEnumDef
enumDef
:
typesDef
.
getEnumDefs
())
{
try
{
typedefClientV2
.
createEnumDef
(
enumDef
);
}
catch
(
AtlasServiceException
ex
)
{
LOG
.
warn
(
"EnumDef creation failed for {}"
,
enumDef
.
getName
());
}
}
}
for
(
AtlasStructDef
structDef
:
typesDef
.
getStructDefs
())
{
try
{
typedefClientV2
.
createStructDef
(
structDef
);
}
catch
(
AtlasServiceException
ex
)
{
LOG
.
warn
(
"StructDef creation failed for {}"
,
structDef
.
getName
());
}
}
for
(
AtlasEntityDef
entityDef
:
typesDef
.
getEntityDefs
())
{
try
{
typedefClientV2
.
createEntityDef
(
entityDef
);
}
catch
(
AtlasServiceException
ex
)
{
LOG
.
warn
(
"EntityDef creation failed for {}"
,
entityDef
.
getName
());
}
}
for
(
AtlasClassificationDef
classificationDef
:
typesDef
.
getClassificationDefs
())
{
try
{
typedefClientV2
.
createClassificationDef
(
classificationDef
);
}
catch
(
AtlasServiceException
ex
)
{
LOG
.
warn
(
"ClassificationDef creation failed for {}"
,
classificationDef
.
getName
());
}
}
}
}
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
try
{
try
{
if
(
!
typesDef
.
enumTypes
().
isEmpty
()
){
if
(
!
typesDef
.
enumTypes
().
isEmpty
()
){
String
sampleType
=
typesDef
.
enumTypesAsJavaList
().
get
(
0
).
name
;
String
sampleType
=
typesDef
.
enumTypesAsJavaList
().
get
(
0
).
name
;
serviceClient
.
getType
(
sampleType
);
atlasClientV1
.
getType
(
sampleType
);
LOG
.
info
(
"Checking enum type existence"
);
LOG
.
info
(
"Checking enum type existence"
);
}
}
else
if
(
!
typesDef
.
structTypes
().
isEmpty
()){
else
if
(
!
typesDef
.
structTypes
().
isEmpty
()){
StructTypeDefinition
sampleType
=
typesDef
.
structTypesAsJavaList
().
get
(
0
);
StructTypeDefinition
sampleType
=
typesDef
.
structTypesAsJavaList
().
get
(
0
);
serviceClient
.
getType
(
sampleType
.
typeName
);
atlasClientV1
.
getType
(
sampleType
.
typeName
);
LOG
.
info
(
"Checking struct type existence"
);
LOG
.
info
(
"Checking struct type existence"
);
}
}
else
if
(
!
typesDef
.
traitTypes
().
isEmpty
()){
else
if
(
!
typesDef
.
traitTypes
().
isEmpty
()){
HierarchicalTypeDefinition
<
TraitType
>
sampleType
=
typesDef
.
traitTypesAsJavaList
().
get
(
0
);
HierarchicalTypeDefinition
<
TraitType
>
sampleType
=
typesDef
.
traitTypesAsJavaList
().
get
(
0
);
serviceClient
.
getType
(
sampleType
.
typeName
);
atlasClientV1
.
getType
(
sampleType
.
typeName
);
LOG
.
info
(
"Checking trait type existence"
);
LOG
.
info
(
"Checking trait type existence"
);
}
}
else
{
else
{
HierarchicalTypeDefinition
<
ClassType
>
sampleType
=
typesDef
.
classTypesAsJavaList
().
get
(
0
);
HierarchicalTypeDefinition
<
ClassType
>
sampleType
=
typesDef
.
classTypesAsJavaList
().
get
(
0
);
serviceClient
.
getType
(
sampleType
.
typeName
);
atlasClientV1
.
getType
(
sampleType
.
typeName
);
LOG
.
info
(
"Checking class type existence"
);
LOG
.
info
(
"Checking class type existence"
);
}
}
LOG
.
info
(
"Types already exist. Skipping type creation"
);
LOG
.
info
(
"Types already exist. Skipping type creation"
);
...
@@ -110,7 +175,7 @@ public abstract class BaseResourceIT {
...
@@ -110,7 +175,7 @@ public abstract class BaseResourceIT {
}
}
protected
List
<
String
>
createType
(
String
typesAsJSON
)
throws
Exception
{
protected
List
<
String
>
createType
(
String
typesAsJSON
)
throws
Exception
{
return
serviceClient
.
createType
(
TypesSerialization
.
fromJson
(
typesAsJSON
));
return
atlasClientV1
.
createType
(
TypesSerialization
.
fromJson
(
typesAsJSON
));
}
}
protected
Id
createInstance
(
Referenceable
referenceable
)
throws
Exception
{
protected
Id
createInstance
(
Referenceable
referenceable
)
throws
Exception
{
...
@@ -119,7 +184,7 @@ public abstract class BaseResourceIT {
...
@@ -119,7 +184,7 @@ public abstract class BaseResourceIT {
String
entityJSON
=
InstanceSerialization
.
toJson
(
referenceable
,
true
);
String
entityJSON
=
InstanceSerialization
.
toJson
(
referenceable
,
true
);
System
.
out
.
println
(
"Submitting new entity= "
+
entityJSON
);
System
.
out
.
println
(
"Submitting new entity= "
+
entityJSON
);
List
<
String
>
guids
=
serviceClient
.
createEntity
(
entityJSON
);
List
<
String
>
guids
=
atlasClientV1
.
createEntity
(
entityJSON
);
System
.
out
.
println
(
"created instance for type "
+
typeName
+
", guid: "
+
guids
);
System
.
out
.
println
(
"created instance for type "
+
typeName
+
", guid: "
+
guids
);
// return the reference to created instance with guid
// return the reference to created instance with guid
...
@@ -147,25 +212,51 @@ public abstract class BaseResourceIT {
...
@@ -147,25 +212,51 @@ public abstract class BaseResourceIT {
}
}
protected
AtlasEntityHeader
modifyEntity
(
AtlasEntity
atlasEntity
,
boolean
update
)
{
EntityMutationResponse
entity
=
null
;
try
{
if
(!
update
)
{
entity
=
entitiesClientV2
.
createEntity
(
atlasEntity
);
}
else
{
entity
=
entitiesClientV2
.
updateEntity
(
atlasEntity
);
}
assertNotNull
(
entity
);
assertNotNull
(
entity
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
assertTrue
(
entity
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
size
()
>
0
);
return
entity
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
get
(
0
);
}
catch
(
AtlasServiceException
e
)
{
LOG
.
error
(
"Entity {} failed"
,
update
?
"update"
:
"creation"
,
entity
);
}
return
null
;
}
protected
AtlasEntityHeader
createEntity
(
AtlasEntity
atlasEntity
)
{
return
modifyEntity
(
atlasEntity
,
false
);
}
protected
AtlasEntityHeader
updateEntity
(
AtlasEntity
atlasEntity
)
{
return
modifyEntity
(
atlasEntity
,
true
);
}
protected
static
final
String
DATABASE_TYPE
=
"hive_db"
;
protected
static
final
String
DATABASE_TYPE
=
"hive_db"
;
protected
static
final
String
HIVE_TABLE_TYPE
=
"hive_table"
;
protected
static
final
String
HIVE_TABLE_TYPE
=
"hive_table"
;
protected
static
final
String
COLUMN_TYPE
=
"hive_column"
;
protected
static
final
String
COLUMN_TYPE
=
"hive_column"
;
protected
static
final
String
HIVE_PROCESS_TYPE
=
"hive_process"
;
protected
static
final
String
HIVE_PROCESS_TYPE
=
"hive_process"
;
protected
void
createTypeDefinitions
()
throws
Exception
{
protected
void
createTypeDefinitions
V1
()
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
dbClsDef
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
dbClsDef
=
TypesUtil
.
createClassTypeDef
(
DATABASE_TYPE
,
null
,
.
createClassTypeDef
(
DATABASE_TYPE
,
null
,
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
DESCRIPTION
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"locationUri"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"locationUri"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"owner"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"createTime"
,
DataTypes
.
INT_TYPE
));
attrDef
(
"owner"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"createTime"
,
DataTypes
.
INT_TYPE
));
HierarchicalTypeDefinition
<
ClassType
>
columnClsDef
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
columnClsDef
=
TypesUtil
.
createClassTypeDef
(
COLUMN_TYPE
,
null
,
attrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
.
createClassTypeDef
(
COLUMN_TYPE
,
null
,
attrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"dataType"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"comment"
,
DataTypes
.
STRING_TYPE
));
attrDef
(
"dataType"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"comment"
,
DataTypes
.
STRING_TYPE
));
StructTypeDefinition
structTypeDefinition
=
new
StructTypeDefinition
(
"serdeType"
,
StructTypeDefinition
structTypeDefinition
=
new
StructTypeDefinition
(
"serdeType"
,
new
AttributeDefinition
[]{
TypesUtil
.
createRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
new
AttributeDefinition
[]{
TypesUtil
.
createRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"serde"
,
DataTypes
.
STRING_TYPE
)});
TypesUtil
.
createRequiredAttrDef
(
"serde"
,
DataTypes
.
STRING_TYPE
)});
EnumValue
values
[]
=
{
new
EnumValue
(
"MANAGED"
,
1
),
new
EnumValue
(
"EXTERNAL"
,
2
),};
EnumValue
values
[]
=
{
new
EnumValue
(
"MANAGED"
,
1
),
new
EnumValue
(
"EXTERNAL"
,
2
),};
...
@@ -180,9 +271,9 @@ public abstract class BaseResourceIT {
...
@@ -180,9 +271,9 @@ public abstract class BaseResourceIT {
new
AttributeDefinition
(
"db"
,
DATABASE_TYPE
,
Multiplicity
.
REQUIRED
,
true
,
null
),
new
AttributeDefinition
(
"db"
,
DATABASE_TYPE
,
Multiplicity
.
REQUIRED
,
true
,
null
),
new
AttributeDefinition
(
"columns"
,
DataTypes
.
arrayTypeName
(
COLUMN_TYPE
),
new
AttributeDefinition
(
"columns"
,
DataTypes
.
arrayTypeName
(
COLUMN_TYPE
),
Multiplicity
.
OPTIONAL
,
true
,
null
),
Multiplicity
.
OPTIONAL
,
true
,
null
),
new
AttributeDefinition
(
"tableType"
,
"tableType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
),
new
AttributeDefinition
(
"tableType"
,
"tableType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
),
new
AttributeDefinition
(
"serde1"
,
"serdeType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
),
new
AttributeDefinition
(
"serde1"
,
"serdeType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
),
new
AttributeDefinition
(
"serde2"
,
"serdeType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
));
new
AttributeDefinition
(
"serde2"
,
"serdeType"
,
Multiplicity
.
OPTIONAL
,
false
,
null
));
HierarchicalTypeDefinition
<
ClassType
>
loadProcessClsDef
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
loadProcessClsDef
=
TypesUtil
.
createClassTypeDef
(
HIVE_PROCESS_TYPE
,
ImmutableSet
.
of
(
"Process"
),
.
createClassTypeDef
(
HIVE_PROCESS_TYPE
,
ImmutableSet
.
of
(
"Process"
),
...
@@ -226,6 +317,80 @@ public abstract class BaseResourceIT {
...
@@ -226,6 +317,80 @@ public abstract class BaseResourceIT {
ImmutableList
.
of
(
dbClsDef
,
columnClsDef
,
tblClsDef
,
loadProcessClsDef
)));
ImmutableList
.
of
(
dbClsDef
,
columnClsDef
,
tblClsDef
,
loadProcessClsDef
)));
}
}
protected
void
createTypeDefinitionsV2
()
throws
Exception
{
AtlasEntityDef
dbClsTypeDef
=
AtlasTypeUtil
.
createClassTypeDef
(
DATABASE_TYPE
,
null
,
AtlasTypeUtil
.
createUniqueRequiredAttrDef
(
NAME
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
DESCRIPTION
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"locationUri"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"owner"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"createTime"
,
"int"
));
AtlasEntityDef
columnClsDef
=
AtlasTypeUtil
.
createClassTypeDef
(
COLUMN_TYPE
,
null
,
AtlasTypeUtil
.
createOptionalAttrDef
(
NAME
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"dataType"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"comment"
,
"string"
));
AtlasStructDef
structTypeDef
=
AtlasTypeUtil
.
createStructTypeDef
(
"serdeType"
,
AtlasTypeUtil
.
createRequiredAttrDef
(
NAME
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"serde"
,
"string"
)
);
AtlasEnumDef
enumDef
=
new
AtlasEnumDef
(
"tableType"
,
DESCRIPTION
,
Arrays
.
asList
(
new
AtlasEnumDef
.
AtlasEnumElementDef
(
"MANAGED"
,
null
,
1
),
new
AtlasEnumDef
.
AtlasEnumElementDef
(
"EXTERNAL"
,
null
,
2
)
));
AtlasEntityDef
tblClsDef
=
AtlasTypeUtil
.
createClassTypeDef
(
HIVE_TABLE_TYPE
,
ImmutableSet
.
of
(
"DataSet"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"owner"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"createTime"
,
"long"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"lastAccessTime"
,
"date"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"temporary"
,
"boolean"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"db"
,
DATABASE_TYPE
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"columns"
,
DataTypes
.
arrayTypeName
(
COLUMN_TYPE
)),
AtlasTypeUtil
.
createOptionalAttrDef
(
"tableType"
,
"tableType"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"serde1"
,
"serdeType"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"serde2"
,
"serdeType"
));
AtlasEntityDef
loadProcessClsDef
=
AtlasTypeUtil
.
createClassTypeDef
(
HIVE_PROCESS_TYPE
,
ImmutableSet
.
of
(
"Process"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"userName"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"startTime"
,
"int"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"endTime"
,
"long"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"queryText"
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"queryPlan"
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"queryId"
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"queryGraph"
,
"string"
));
AtlasClassificationDef
classificationTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"classification"
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"tag"
,
"string"
));
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"pii"
,
ImmutableSet
.<
String
>
of
());
AtlasClassificationDef
phiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"phi"
,
ImmutableSet
.<
String
>
of
());
AtlasClassificationDef
pciTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"pci"
,
ImmutableSet
.<
String
>
of
());
AtlasClassificationDef
soxTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"sox"
,
ImmutableSet
.<
String
>
of
());
AtlasClassificationDef
secTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"sec"
,
ImmutableSet
.<
String
>
of
());
AtlasClassificationDef
financeTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
"finance"
,
ImmutableSet
.<
String
>
of
());
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
(
ImmutableList
.
of
(
enumDef
),
ImmutableList
.
of
(
structTypeDef
),
ImmutableList
.
of
(
classificationTrait
,
piiTrait
,
phiTrait
,
pciTrait
,
soxTrait
,
secTrait
,
financeTrait
),
ImmutableList
.
of
(
dbClsTypeDef
,
columnClsDef
,
tblClsDef
,
loadProcessClsDef
));
createType
(
typesDef
);
}
AttributeDefinition
attrDef
(
String
name
,
IDataType
dT
)
{
AttributeDefinition
attrDef
(
String
name
,
IDataType
dT
)
{
return
attrDef
(
name
,
dT
,
Multiplicity
.
OPTIONAL
,
false
,
null
);
return
attrDef
(
name
,
dT
,
Multiplicity
.
OPTIONAL
,
false
,
null
);
}
}
...
@@ -245,23 +410,22 @@ public abstract class BaseResourceIT {
...
@@ -245,23 +410,22 @@ public abstract class BaseResourceIT {
return
RandomStringUtils
.
randomAlphanumeric
(
10
);
return
RandomStringUtils
.
randomAlphanumeric
(
10
);
}
}
protected
Referenceable
createHiveTableInstance
(
String
dbName
,
String
tableName
,
Id
dbId
)
throws
Exception
{
protected
Referenceable
createHiveTableInstance
V1
(
String
dbName
,
String
tableName
,
Id
dbId
)
throws
Exception
{
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
values
.
put
(
"name"
,
dbName
);
values
.
put
(
NAME
,
dbName
);
values
.
put
(
"description"
,
"foo database"
);
values
.
put
(
DESCRIPTION
,
"foo database"
);
values
.
put
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
values
.
put
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
values
.
put
(
"owner"
,
"user1"
);
values
.
put
(
"owner"
,
"user1"
);
values
.
put
(
"clusterName"
,
"cl1"
);
values
.
put
(
CLUSTER_NAME
,
"cl1"
);
values
.
put
(
"parameters"
,
Collections
.
EMPTY_MAP
);
values
.
put
(
"parameters"
,
Collections
.
EMPTY_MAP
);
values
.
put
(
"location"
,
"/tmp"
);
values
.
put
(
"location"
,
"/tmp"
);
Referenceable
databaseInstance
=
new
Referenceable
(
dbId
.
_getId
(),
dbId
.
getTypeName
(),
values
);
Referenceable
databaseInstance
=
new
Referenceable
(
dbId
.
_getId
(),
dbId
.
getTypeName
(),
values
);
Referenceable
tableInstance
=
Referenceable
tableInstance
=
new
Referenceable
(
HIVE_TABLE_TYPE
,
"classification"
,
"pii"
,
"phi"
,
"pci"
,
"sox"
,
"sec"
,
"finance"
);
new
Referenceable
(
HIVE_TABLE_TYPE
,
"classification"
,
"pii"
,
"phi"
,
"pci"
,
"sox"
,
"sec"
,
"finance"
);
tableInstance
.
set
(
"name"
,
tableName
);
tableInstance
.
set
(
NAME
,
tableName
);
tableInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
tableName
);
tableInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
tableName
);
tableInstance
.
set
(
"db"
,
databaseInstance
);
tableInstance
.
set
(
"db"
,
databaseInstance
);
tableInstance
.
set
(
"description"
,
"bar table"
);
tableInstance
.
set
(
DESCRIPTION
,
"bar table"
);
tableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11T08:00:00.000Z"
);
tableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11T08:00:00.000Z"
);
tableInstance
.
set
(
"type"
,
"managed"
);
tableInstance
.
set
(
"type"
,
"managed"
);
tableInstance
.
set
(
"level"
,
2
);
tableInstance
.
set
(
"level"
,
2
);
...
@@ -272,12 +436,12 @@ public abstract class BaseResourceIT {
...
@@ -272,12 +436,12 @@ public abstract class BaseResourceIT {
traitInstance
.
set
(
"tag"
,
"foundation_etl"
);
traitInstance
.
set
(
"tag"
,
"foundation_etl"
);
Struct
serde1Instance
=
new
Struct
(
"serdeType"
);
Struct
serde1Instance
=
new
Struct
(
"serdeType"
);
serde1Instance
.
set
(
"name"
,
"serde1"
);
serde1Instance
.
set
(
NAME
,
"serde1"
);
serde1Instance
.
set
(
"serde"
,
"serde1"
);
serde1Instance
.
set
(
"serde"
,
"serde1"
);
tableInstance
.
set
(
"serde1"
,
serde1Instance
);
tableInstance
.
set
(
"serde1"
,
serde1Instance
);
Struct
serde2Instance
=
new
Struct
(
"serdeType"
);
Struct
serde2Instance
=
new
Struct
(
"serdeType"
);
serde2Instance
.
set
(
"name"
,
"serde2"
);
serde2Instance
.
set
(
NAME
,
"serde2"
);
serde2Instance
.
set
(
"serde"
,
"serde2"
);
serde2Instance
.
set
(
"serde"
,
"serde2"
);
tableInstance
.
set
(
"serde2"
,
serde2Instance
);
tableInstance
.
set
(
"serde2"
,
serde2Instance
);
...
@@ -287,20 +451,70 @@ public abstract class BaseResourceIT {
...
@@ -287,20 +451,70 @@ public abstract class BaseResourceIT {
return
tableInstance
;
return
tableInstance
;
}
}
protected
Referenceable
createHiveDBInstance
(
String
dbName
)
{
protected
AtlasEntityWithAssociations
createHiveTableInstanceV2
(
AtlasEntity
databaseInstance
,
String
tableName
)
throws
Exception
{
AtlasEntityWithAssociations
tableInstance
=
new
AtlasEntityWithAssociations
(
HIVE_TABLE_TYPE
);
tableInstance
.
setClassifications
(
Arrays
.
asList
(
new
AtlasClassification
(
"classification"
),
new
AtlasClassification
(
"pii"
),
new
AtlasClassification
(
"phi"
),
new
AtlasClassification
(
"pci"
),
new
AtlasClassification
(
"sox"
),
new
AtlasClassification
(
"sec"
),
new
AtlasClassification
(
"finance"
))
);
tableInstance
.
setAttribute
(
NAME
,
tableName
);
tableInstance
.
setAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
tableName
);
tableInstance
.
setAttribute
(
"db"
,
databaseInstance
);
tableInstance
.
setAttribute
(
DESCRIPTION
,
"bar table"
);
tableInstance
.
setAttribute
(
"lastAccessTime"
,
"2014-07-11T08:00:00.000Z"
);
tableInstance
.
setAttribute
(
"type"
,
"managed"
);
tableInstance
.
setAttribute
(
"level"
,
2
);
tableInstance
.
setAttribute
(
"tableType"
,
1
);
// enum
tableInstance
.
setAttribute
(
"compressed"
,
false
);
AtlasClassification
classification
=
tableInstance
.
getClassifications
().
get
(
0
);
classification
.
setAttribute
(
"tag"
,
"foundation_etl"
);
AtlasStruct
serde1Instance
=
new
AtlasStruct
(
"serdeType"
);
serde1Instance
.
setAttribute
(
NAME
,
"serde1"
);
serde1Instance
.
setAttribute
(
"serde"
,
"serde1"
);
tableInstance
.
setAttribute
(
"serde1"
,
serde1Instance
);
AtlasStruct
serde2Instance
=
new
AtlasStruct
(
"serdeType"
);
serde2Instance
.
setAttribute
(
NAME
,
"serde2"
);
serde2Instance
.
setAttribute
(
"serde"
,
"serde2"
);
tableInstance
.
setAttribute
(
"serde2"
,
serde2Instance
);
List
<
AtlasClassification
>
traits
=
tableInstance
.
getClassifications
();
Assert
.
assertEquals
(
traits
.
size
(),
7
);
return
tableInstance
;
}
protected
Referenceable
createHiveDBInstanceV1
(
String
dbName
)
{
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
databaseInstance
.
set
(
"name"
,
dbName
);
databaseInstance
.
set
(
NAME
,
dbName
);
databaseInstance
.
set
(
"qualifiedName"
,
dbName
);
databaseInstance
.
set
(
QUALIFIED_NAME
,
dbName
);
databaseInstance
.
set
(
"clusterName"
,
randomString
());
databaseInstance
.
set
(
CLUSTER_NAME
,
randomString
());
databaseInstance
.
set
(
"description"
,
"foo database"
);
databaseInstance
.
set
(
DESCRIPTION
,
"foo database"
);
databaseInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
databaseInstance
.
set
(
"owner"
,
"user1"
);
databaseInstance
.
set
(
"clusterName"
,
"cl1"
);
databaseInstance
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
databaseInstance
.
set
(
"location"
,
"/tmp"
);
return
databaseInstance
;
return
databaseInstance
;
}
}
protected
AtlasEntity
createHiveDBInstanceV2
(
String
dbName
)
{
AtlasEntity
atlasEntity
=
new
AtlasEntity
(
DATABASE_TYPE
);
atlasEntity
.
setAttribute
(
NAME
,
dbName
);
atlasEntity
.
setAttribute
(
QUALIFIED_NAME
,
dbName
);
atlasEntity
.
setAttribute
(
DESCRIPTION
,
"foo database"
);
atlasEntity
.
setAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
atlasEntity
.
setAttribute
(
"owner"
,
"user1"
);
atlasEntity
.
setAttribute
(
CLUSTER_NAME
,
"cl1"
);
atlasEntity
.
setAttribute
(
"parameters"
,
Collections
.
EMPTY_MAP
);
atlasEntity
.
setAttribute
(
"location"
,
"/tmp"
);
return
atlasEntity
;
}
public
interface
Predicate
{
public
interface
Predicate
{
/**
/**
...
@@ -381,6 +595,6 @@ public abstract class BaseResourceIT {
...
@@ -381,6 +595,6 @@ public abstract class BaseResourceIT {
}
}
protected
JSONArray
searchByDSL
(
String
dslQuery
)
throws
AtlasServiceException
{
protected
JSONArray
searchByDSL
(
String
dslQuery
)
throws
AtlasServiceException
{
return
serviceClient
.
searchByDSL
(
dslQuery
,
10
,
0
);
return
atlasClientV1
.
searchByDSL
(
dslQuery
,
10
,
0
);
}
}
}
}
webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
View file @
ec1b160a
...
@@ -53,13 +53,13 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -53,13 +53,13 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
createTypeDefinitions
();
createTypeDefinitions
V1
();
setupInstances
();
setupInstances
();
}
}
@Test
@Test
public
void
testInputsGraph
()
throws
Exception
{
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"inputs graph = "
+
response
);
System
.
out
.
println
(
"inputs graph = "
+
response
);
...
@@ -78,9 +78,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -78,9 +78,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testInputsGraphForEntity
()
throws
Exception
{
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
();
salesMonthlyTable
).
getId
().
_getId
();
JSONObject
results
=
serviceClient
.
getInputGraphForEntity
(
tableId
);
JSONObject
results
=
atlasClientV1
.
getInputGraphForEntity
(
tableId
);
Assert
.
assertNotNull
(
results
);
Assert
.
assertNotNull
(
results
);
Struct
resultsInstance
=
InstanceSerialization
.
fromJsonStruct
(
results
.
toString
(),
true
);
Struct
resultsInstance
=
InstanceSerialization
.
fromJsonStruct
(
results
.
toString
(),
true
);
...
@@ -95,7 +95,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -95,7 +95,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testOutputsGraph
()
throws
Exception
{
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"outputs graph= "
+
response
);
System
.
out
.
println
(
"outputs graph= "
+
response
);
...
@@ -114,9 +114,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -114,9 +114,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testOutputsGraphForEntity
()
throws
Exception
{
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
();
salesFactTable
).
getId
().
_getId
();
JSONObject
results
=
serviceClient
.
getOutputGraphForEntity
(
tableId
);
JSONObject
results
=
atlasClientV1
.
getOutputGraphForEntity
(
tableId
);
Assert
.
assertNotNull
(
results
);
Assert
.
assertNotNull
(
results
);
Struct
resultsInstance
=
InstanceSerialization
.
fromJsonStruct
(
results
.
toString
(),
true
);
Struct
resultsInstance
=
InstanceSerialization
.
fromJsonStruct
(
results
.
toString
(),
true
);
...
@@ -131,7 +131,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -131,7 +131,7 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testSchema
()
throws
Exception
{
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"schema = "
+
response
);
System
.
out
.
println
(
"schema = "
+
response
);
...
@@ -156,8 +156,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -156,8 +156,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testSchemaForEntity
()
throws
Exception
{
public
void
testSchemaForEntity
()
throws
Exception
{
String
tableId
=
serviceClient
.
getEntity
(
HIVE_TABLE_TYPE
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
salesFactTable
).
getId
().
_getId
();
String
tableId
=
atlasClientV1
.
getEntity
(
HIVE_TABLE_TYPE
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
salesFactTable
).
getId
().
_getId
();
JSONObject
results
=
serviceClient
.
getSchemaForEntity
(
tableId
);
JSONObject
results
=
atlasClientV1
.
getSchemaForEntity
(
tableId
);
Assert
.
assertNotNull
(
results
);
Assert
.
assertNotNull
(
results
);
JSONArray
rows
=
results
.
getJSONArray
(
"rows"
);
JSONArray
rows
=
results
.
getJSONArray
(
"rows"
);
...
@@ -175,12 +175,12 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -175,12 +175,12 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testSchemaForInvalidTable
()
throws
Exception
{
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
)
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testSchemaForDB
()
throws
Exception
{
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
{
private
void
setupInstances
()
throws
Exception
{
...
@@ -238,9 +238,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -238,9 +238,9 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
Id
database
(
String
name
,
String
description
,
String
owner
,
String
locationUri
,
String
...
traitNames
)
Id
database
(
String
name
,
String
description
,
String
owner
,
String
locationUri
,
String
...
traitNames
)
throws
Exception
{
throws
Exception
{
Referenceable
referenceable
=
new
Referenceable
(
DATABASE_TYPE
,
traitNames
);
Referenceable
referenceable
=
new
Referenceable
(
DATABASE_TYPE
,
traitNames
);
referenceable
.
set
(
"name"
,
name
);
referenceable
.
set
(
NAME
,
name
);
referenceable
.
set
(
"qualifiedName"
,
name
);
referenceable
.
set
(
QUALIFIED_NAME
,
name
);
referenceable
.
set
(
"clusterName"
,
locationUri
+
name
);
referenceable
.
set
(
CLUSTER_NAME
,
locationUri
+
name
);
referenceable
.
set
(
"description"
,
description
);
referenceable
.
set
(
"description"
,
description
);
referenceable
.
set
(
"owner"
,
owner
);
referenceable
.
set
(
"owner"
,
owner
);
referenceable
.
set
(
"locationUri"
,
locationUri
);
referenceable
.
set
(
"locationUri"
,
locationUri
);
...
@@ -251,8 +251,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
...
@@ -251,8 +251,8 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
Referenceable
column
(
String
name
,
String
type
,
String
comment
,
String
...
traitNames
)
throws
Exception
{
Referenceable
column
(
String
name
,
String
type
,
String
comment
,
String
...
traitNames
)
throws
Exception
{
Referenceable
referenceable
=
new
Referenceable
(
COLUMN_TYPE
,
traitNames
);
Referenceable
referenceable
=
new
Referenceable
(
COLUMN_TYPE
,
traitNames
);
referenceable
.
set
(
"name"
,
name
);
referenceable
.
set
(
NAME
,
name
);
referenceable
.
set
(
"qualifiedName"
,
name
);
referenceable
.
set
(
QUALIFIED_NAME
,
name
);
referenceable
.
set
(
"type"
,
type
);
referenceable
.
set
(
"type"
,
type
);
referenceable
.
set
(
"comment"
,
comment
);
referenceable
.
set
(
"comment"
,
comment
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java
View file @
ec1b160a
...
@@ -64,13 +64,12 @@ import org.testng.annotations.Test;
...
@@ -64,13 +64,12 @@ import org.testng.annotations.Test;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
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
java.util.UUID
;
import
java.util.Collections
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
fail
;
import
static
org
.
testng
.
Assert
.
fail
;
...
@@ -103,8 +102,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -103,8 +102,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
createTypeDefinitions
();
createTypeDefinitions
V1
();
Referenceable
HiveDBInstance
=
createHiveDBInstance
(
DATABASE_NAME
);
Referenceable
HiveDBInstance
=
createHiveDBInstance
V1
(
DATABASE_NAME
);
dbId
=
createInstance
(
HiveDBInstance
);
dbId
=
createInstance
(
HiveDBInstance
);
List
<
NotificationConsumer
<
EntityNotification
>>
consumers
=
List
<
NotificationConsumer
<
EntityNotification
>>
consumers
=
...
@@ -115,7 +114,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -115,7 +114,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
@Test
public
void
testSubmitEntity
()
throws
Exception
{
public
void
testSubmitEntity
()
throws
Exception
{
tableInstance
=
createHiveTableInstance
(
DATABASE_NAME
,
TABLE_NAME
,
dbId
);
tableInstance
=
createHiveTableInstance
V1
(
DATABASE_NAME
,
TABLE_NAME
,
dbId
);
tableId
=
createInstance
(
tableInstance
);
tableId
=
createInstance
(
tableInstance
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
...
@@ -131,7 +130,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -131,7 +130,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
entity
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
"name"
,
dbName
);
entity
.
set
(
"qualifiedName"
,
dbName
);
entity
.
set
(
QUALIFIED_NAME
,
dbName
);
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
"clusterName"
,
randomString
());
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
"description"
,
randomString
());
entity
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
entity
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
...
@@ -150,7 +149,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -150,7 +149,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
}
String
entityId
=
localClient
.
createEntity
(
entity
).
get
(
0
);
String
entityId
=
localClient
.
createEntity
(
entity
).
get
(
0
);
List
<
EntityAuditEvent
>
events
=
serviceClient
.
getEntityAuditEvents
(
entityId
,
(
short
)
10
);
List
<
EntityAuditEvent
>
events
=
atlasClientV1
.
getEntityAuditEvents
(
entityId
,
(
short
)
10
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
size
(),
1
);
assertEquals
(
events
.
get
(
0
).
getUser
(),
user
);
assertEquals
(
events
.
get
(
0
).
getUser
(),
user
);
}
}
...
@@ -161,7 +160,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -161,7 +160,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
databaseInstance
.
set
(
"name"
,
dbName
);
databaseInstance
.
set
(
"name"
,
dbName
);
databaseInstance
.
set
(
"qualifiedName"
,
dbName
);
databaseInstance
.
set
(
QUALIFIED_NAME
,
dbName
);
databaseInstance
.
set
(
"clusterName"
,
randomString
());
databaseInstance
.
set
(
"clusterName"
,
randomString
());
databaseInstance
.
set
(
"description"
,
randomString
());
databaseInstance
.
set
(
"description"
,
randomString
());
databaseInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
databaseInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
...
@@ -170,7 +169,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -170,7 +169,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
databaseInstance
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
databaseInstance
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
databaseInstance
.
set
(
"location"
,
"/tmp"
);
databaseInstance
.
set
(
"location"
,
"/tmp"
);
JSONObject
response
=
serviceClient
JSONObject
response
=
atlasClientV1
.
callAPIWithBody
(
AtlasClient
.
API
.
CREATE_ENTITY
,
InstanceSerialization
.
toJson
(
databaseInstance
,
true
));
.
callAPIWithBody
(
AtlasClient
.
API
.
CREATE_ENTITY
,
InstanceSerialization
.
toJson
(
databaseInstance
,
true
));
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -184,7 +183,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -184,7 +183,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
public
void
testEntityDeduping
()
throws
Exception
{
public
void
testEntityDeduping
()
throws
Exception
{
final
Referenceable
db
=
new
Referenceable
(
DATABASE_TYPE
);
final
Referenceable
db
=
new
Referenceable
(
DATABASE_TYPE
);
final
String
dbName
=
"db"
+
randomString
();
final
String
dbName
=
"db"
+
randomString
();
Referenceable
HiveDBInstance
=
createHiveDBInstance
(
dbName
);
Referenceable
HiveDBInstance
=
createHiveDBInstance
V1
(
dbName
);
Id
dbIdReference
=
createInstance
(
HiveDBInstance
);
Id
dbIdReference
=
createInstance
(
HiveDBInstance
);
final
String
dbId
=
dbIdReference
.
_getId
();
final
String
dbId
=
dbIdReference
.
_getId
();
...
@@ -201,7 +200,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -201,7 +200,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//create entity again shouldn't create another instance with same unique attribute value
//create entity again shouldn't create another instance with same unique attribute value
List
<
String
>
entityResults
=
serviceClient
.
createEntity
(
HiveDBInstance
);
List
<
String
>
entityResults
=
atlasClientV1
.
createEntity
(
HiveDBInstance
);
assertEquals
(
entityResults
.
size
(),
0
);
assertEquals
(
entityResults
.
size
(),
0
);
try
{
try
{
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
new
NotificationPredicate
()
{
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
new
NotificationPredicate
()
{
...
@@ -221,15 +220,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -221,15 +220,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
//Test the same across references
//Test the same across references
Referenceable
table
=
new
Referenceable
(
HIVE_TABLE_TYPE
);
Referenceable
table
=
new
Referenceable
(
HIVE_TABLE_TYPE
);
final
String
tableName
=
randomString
();
final
String
tableName
=
randomString
();
Referenceable
tableInstance
=
createHiveTableInstance
(
DATABASE_NAME
,
tableName
,
dbIdReference
);
Referenceable
tableInstance
=
createHiveTableInstance
V1
(
DATABASE_NAME
,
tableName
,
dbIdReference
);
serviceClient
.
createEntity
(
tableInstance
);
atlasClientV1
.
createEntity
(
tableInstance
);
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
dbName
));
results
=
searchByDSL
(
String
.
format
(
"%s where qualifiedName='%s'"
,
DATABASE_TYPE
,
dbName
));
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
}
}
private
void
assertEntityAudit
(
String
dbid
,
EntityAuditEvent
.
EntityAuditAction
auditAction
)
private
void
assertEntityAudit
(
String
dbid
,
EntityAuditEvent
.
EntityAuditAction
auditAction
)
throws
Exception
{
throws
Exception
{
List
<
EntityAuditEvent
>
events
=
serviceClient
.
getEntityAuditEvents
(
dbid
,
(
short
)
100
);
List
<
EntityAuditEvent
>
events
=
atlasClientV1
.
getEntityAuditEvents
(
dbid
,
(
short
)
100
);
for
(
EntityAuditEvent
event
:
events
)
{
for
(
EntityAuditEvent
event
:
events
)
{
if
(
event
.
getAction
()
==
auditAction
)
{
if
(
event
.
getAction
()
==
auditAction
)
{
return
;
return
;
...
@@ -244,12 +243,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -244,12 +243,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
HierarchicalTypeDefinition
<
ClassType
>
typeDefinition
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
serviceClient
.
createType
(
TypesSerialization
.
toJson
(
typeDefinition
,
false
));
atlasClientV1
.
createType
(
TypesSerialization
.
toJson
(
typeDefinition
,
false
));
//create entity for the type
//create entity for the type
Referenceable
instance
=
new
Referenceable
(
typeDefinition
.
typeName
);
Referenceable
instance
=
new
Referenceable
(
typeDefinition
.
typeName
);
instance
.
set
(
"name"
,
randomString
());
instance
.
set
(
"name"
,
randomString
());
String
guid
=
serviceClient
.
createEntity
(
instance
).
get
(
0
);
String
guid
=
atlasClientV1
.
createEntity
(
instance
).
get
(
0
);
//update type - add attribute
//update type - add attribute
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
typeDefinition
.
typeName
,
ImmutableSet
.<
String
>
of
(),
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
typeDefinition
.
typeName
,
ImmutableSet
.<
String
>
of
(),
...
@@ -258,10 +257,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -258,10 +257,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
TypesDef
typeDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
TypesDef
typeDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.
of
(
typeDefinition
));
ImmutableList
.
of
(
typeDefinition
));
serviceClient
.
updateType
(
typeDef
);
atlasClientV1
.
updateType
(
typeDef
);
//Get definition after type update - new attributes should be null
//Get definition after type update - new attributes should be null
Referenceable
entity
=
serviceClient
.
getEntity
(
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
Assert
.
assertNull
(
entity
.
get
(
"description"
));
Assert
.
assertNull
(
entity
.
get
(
"description"
));
Assert
.
assertEquals
(
entity
.
get
(
"name"
),
instance
.
get
(
"name"
));
Assert
.
assertEquals
(
entity
.
get
(
"name"
),
instance
.
get
(
"name"
));
}
}
...
@@ -289,25 +288,25 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -289,25 +288,25 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
public
void
testGetEntityByAttribute
()
throws
Exception
{
public
void
testGetEntityByAttribute
()
throws
Exception
{
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
db1
.
set
(
"name"
,
dbName
);
db1
.
set
(
NAME
,
dbName
);
db1
.
set
(
"description"
,
randomString
());
db1
.
set
(
DESCRIPTION
,
randomString
());
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"clusterName"
,
"cl1"
);
db1
.
set
(
CLUSTER_NAME
,
"cl1"
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"location"
,
"/tmp"
);
db1
.
set
(
"location"
,
"/tmp"
);
createInstance
(
db1
);
createInstance
(
db1
);
//get entity by attribute
//get entity by attribute
Referenceable
referenceable
=
serviceClient
.
getEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
dbName
);
Referenceable
referenceable
=
atlasClientV1
.
getEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
);
Assert
.
assertEquals
(
referenceable
.
getTypeName
(),
DATABASE_TYPE
);
Assert
.
assertEquals
(
referenceable
.
getTypeName
(),
DATABASE_TYPE
);
Assert
.
assertEquals
(
referenceable
.
get
(
"qualifiedName"
),
dbName
);
Assert
.
assertEquals
(
referenceable
.
get
(
QUALIFIED_NAME
),
dbName
);
}
}
@Test
@Test
public
void
testSubmitEntityWithBadDateFormat
()
throws
Exception
{
public
void
testSubmitEntityWithBadDateFormat
()
throws
Exception
{
try
{
try
{
Referenceable
tableInstance
=
createHiveTableInstance
(
"db"
+
randomString
(),
"table"
+
randomString
(),
dbId
);
Referenceable
tableInstance
=
createHiveTableInstance
V1
(
"db"
+
randomString
(),
"table"
+
randomString
(),
dbId
);
tableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11"
);
tableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11"
);
tableId
=
createInstance
(
tableInstance
);
tableId
=
createInstance
(
tableInstance
);
Assert
.
fail
(
"Was expecting an exception here "
);
Assert
.
fail
(
"Was expecting an exception here "
);
...
@@ -324,7 +323,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -324,7 +323,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String
description
=
"bar table - new desc"
;
String
description
=
"bar table - new desc"
;
addProperty
(
guid
,
"description"
,
description
);
addProperty
(
guid
,
"description"
,
description
);
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
tableInstance
.
set
(
"description"
,
description
);
tableInstance
.
set
(
"description"
,
description
);
...
@@ -340,7 +339,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -340,7 +339,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String
currentTime
=
String
.
valueOf
(
new
DateTime
()
);
String
currentTime
=
String
.
valueOf
(
new
DateTime
()
);
addProperty
(
guid
,
"createTime"
,
currentTime
);
addProperty
(
guid
,
"createTime"
,
currentTime
);
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
tableInstance
.
set
(
"createTime"
,
currentTime
);
tableInstance
.
set
(
"createTime"
,
currentTime
);
...
@@ -371,13 +370,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -371,13 +370,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
//Create new db instance
//Create new db instance
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
databaseInstance
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
databaseInstance
.
set
(
"name"
,
dbName
);
databaseInstance
.
set
(
NAME
,
dbName
);
databaseInstance
.
set
(
"qualifiedName"
,
dbName
);
databaseInstance
.
set
(
QUALIFIED_NAME
,
dbName
);
databaseInstance
.
set
(
"clusterName"
,
randomString
());
databaseInstance
.
set
(
CLUSTER_NAME
,
randomString
());
databaseInstance
.
set
(
"description"
,
"new database"
);
databaseInstance
.
set
(
"description"
,
"new database"
);
databaseInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
databaseInstance
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
databaseInstance
.
set
(
"owner"
,
"user1"
);
databaseInstance
.
set
(
"owner"
,
"user1"
);
databaseInstance
.
set
(
"clusterName"
,
"cl1"
);
databaseInstance
.
set
(
CLUSTER_NAME
,
"cl1"
);
databaseInstance
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
databaseInstance
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
databaseInstance
.
set
(
"location"
,
"/tmp"
);
databaseInstance
.
set
(
"location"
,
"/tmp"
);
...
@@ -392,7 +391,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -392,7 +391,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetEntityDefinition
()
throws
Exception
{
public
void
testGetEntityDefinition
()
throws
Exception
{
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -404,7 +403,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -404,7 +403,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
}
private
void
addProperty
(
String
guid
,
String
property
,
String
value
)
throws
AtlasServiceException
{
private
void
addProperty
(
String
guid
,
String
property
,
String
value
)
throws
AtlasServiceException
{
AtlasClient
.
EntityResult
entityResult
=
serviceClient
.
updateEntityAttribute
(
guid
,
property
,
value
);
AtlasClient
.
EntityResult
entityResult
=
atlasClientV1
.
updateEntityAttribute
(
guid
,
property
,
value
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
guid
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
guid
);
}
}
...
@@ -412,7 +411,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -412,7 +411,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testGetInvalidEntityDefinition
()
throws
Exception
{
public
void
testGetInvalidEntityDefinition
()
throws
Exception
{
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
"blah"
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
"blah"
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
...
@@ -422,7 +421,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -422,7 +421,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetEntityList
()
throws
Exception
{
public
void
testGetEntityList
()
throws
Exception
{
List
<
String
>
entities
=
serviceClient
.
listEntities
(
HIVE_TABLE_TYPE
);
List
<
String
>
entities
=
atlasClientV1
.
listEntities
(
HIVE_TABLE_TYPE
);
Assert
.
assertNotNull
(
entities
);
Assert
.
assertNotNull
(
entities
);
Assert
.
assertTrue
(
entities
.
contains
(
tableId
.
_getId
()));
Assert
.
assertTrue
(
entities
.
contains
(
tableId
.
_getId
()));
}
}
...
@@ -432,7 +431,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -432,7 +431,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"type"
,
"blah"
);
queryParams
.
add
(
"type"
,
"blah"
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GET_ENTITY
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GET_ENTITY
,
queryParams
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
ERROR
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
ERROR
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
STACKTRACE
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
STACKTRACE
));
...
@@ -446,7 +445,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -446,7 +445,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"type"
,
typeName
);
queryParams
.
add
(
"type"
,
typeName
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GET_ENTITY
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GET_ENTITY
,
queryParams
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -470,7 +469,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -470,7 +469,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
public
void
testGetTraitNames
()
throws
Exception
{
public
void
testGetTraitNames
()
throws
Exception
{
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TRAITS
,
null
,
guid
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TRAITS
,
null
,
guid
,
TRAITS
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -492,7 +491,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -492,7 +491,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -513,15 +512,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -513,15 +512,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Struct
traitDef
=
serviceClient
.
getTraitDefinition
(
guid
,
traitName
);
Struct
traitDef
=
atlasClientV1
.
getTraitDefinition
(
guid
,
traitName
);
System
.
out
.
println
(
traitDef
.
toString
());
System
.
out
.
println
(
traitDef
.
toString
());
JSONObject
responseAsJSON
=
new
JSONObject
(
InstanceSerialization
.
toJson
(
traitDef
,
true
));
JSONObject
responseAsJSON
=
new
JSONObject
(
InstanceSerialization
.
toJson
(
traitDef
,
true
));
Assert
.
assertEquals
(
responseAsJSON
.
get
(
"typeName"
),
traitName
);
Assert
.
assertEquals
(
responseAsJSON
.
get
(
"typeName"
),
traitName
);
List
<
Struct
>
allTraitDefs
=
serviceClient
.
listTraitDefinitions
(
guid
);
List
<
Struct
>
allTraitDefs
=
atlasClientV1
.
listTraitDefinitions
(
guid
);
System
.
out
.
println
(
allTraitDefs
.
toString
());
System
.
out
.
println
(
allTraitDefs
.
toString
());
Assert
.
assertEquals
(
allTraitDefs
.
size
(),
9
);
Assert
.
assertEquals
(
allTraitDefs
.
size
(),
9
);
}
}
...
@@ -535,7 +534,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -535,7 +534,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
assertNotNull
(
response
);
assertNotNull
(
response
);
}
}
...
@@ -555,12 +554,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -555,12 +554,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
ADD_TRAITS
,
traitInstanceAsJSON
,
guid
,
TRAITS
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
// verify the response
// verify the response
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
final
String
definition
=
response
.
getString
(
AtlasClient
.
DEFINITION
);
final
String
definition
=
response
.
getString
(
AtlasClient
.
DEFINITION
);
...
@@ -583,14 +582,14 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -583,14 +582,14 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String
traitInstanceAsJSON
=
InstanceSerialization
$
.
MODULE
$
.
toJson
(
traitInstance
,
true
);
String
traitInstanceAsJSON
=
InstanceSerialization
$
.
MODULE
$
.
toJson
(
traitInstance
,
true
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
LOG
.
debug
(
"traitInstanceAsJSON = "
+
traitInstanceAsJSON
);
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
CREATE_ENTITY
,
traitInstanceAsJSON
,
"random"
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
CREATE_ENTITY
,
traitInstanceAsJSON
,
"random"
,
TRAITS
);
}
}
@Test
(
dependsOnMethods
=
"testAddTrait"
)
@Test
(
dependsOnMethods
=
"testAddTrait"
)
public
void
testDeleteTrait
()
throws
Exception
{
public
void
testDeleteTrait
()
throws
Exception
{
final
String
guid
=
tableId
.
_getId
();
final
String
guid
=
tableId
.
_getId
();
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
guid
,
TRAITS
,
traitName
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
guid
,
TRAITS
,
traitName
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
"traitName"
));
Assert
.
assertNotNull
(
response
.
get
(
"traitName"
));
assertEntityAudit
(
guid
,
EntityAuditEvent
.
EntityAuditAction
.
TAG_DELETE
);
assertEntityAudit
(
guid
,
EntityAuditEvent
.
EntityAuditAction
.
TAG_DELETE
);
...
@@ -599,7 +598,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -599,7 +598,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testDeleteTraitNonExistent
()
throws
Exception
{
public
void
testDeleteTraitNonExistent
()
throws
Exception
{
final
String
traitName
=
"blah_trait"
;
final
String
traitName
=
"blah_trait"
;
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
"random"
,
TRAITS
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
"random"
,
TRAITS
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
ERROR
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
ERROR
));
Assert
.
assertEquals
(
response
.
getString
(
AtlasClient
.
ERROR
),
Assert
.
assertEquals
(
response
.
getString
(
AtlasClient
.
ERROR
),
...
@@ -619,7 +618,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -619,7 +618,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
createType
(
traitDefinitionAsJSON
);
createType
(
traitDefinitionAsJSON
);
try
{
try
{
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
guid
,
TRAITS
,
traitName
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
DELETE_TRAITS
,
null
,
guid
,
TRAITS
,
traitName
);
fail
(
"Call should've failed for deletion of invalid trait"
);
fail
(
"Call should've failed for deletion of invalid trait"
);
}
catch
(
AtlasServiceException
e
)
{
}
catch
(
AtlasServiceException
e
)
{
assertNotNull
(
e
);
assertNotNull
(
e
);
...
@@ -650,7 +649,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -650,7 +649,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
instance
.
set
(
attrName
,
attrValue
);
instance
.
set
(
attrName
,
attrValue
);
Id
guid
=
createInstance
(
instance
);
Id
guid
=
createInstance
(
instance
);
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
.
_getId
());
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
guid
.
_getId
());
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
Assert
.
assertEquals
(
getReferenceable
.
get
(
attrName
),
attrValue
);
Assert
.
assertEquals
(
getReferenceable
.
get
(
attrName
),
attrValue
);
}
}
...
@@ -660,9 +659,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -660,9 +659,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String
colName
=
"col1"
+
randomString
();
String
colName
=
"col1"
+
randomString
();
final
List
<
Referenceable
>
columns
=
new
ArrayList
<>();
final
List
<
Referenceable
>
columns
=
new
ArrayList
<>();
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
values
.
put
(
"name"
,
colName
);
values
.
put
(
NAME
,
colName
);
values
.
put
(
"comment"
,
"col1 comment"
);
values
.
put
(
"comment"
,
"col1 comment"
);
values
.
put
(
"qualifiedName"
,
"default.table.col1@"
+
colName
);
values
.
put
(
QUALIFIED_NAME
,
"default.table.col1@"
+
colName
);
values
.
put
(
"comment"
,
"col1 comment"
);
values
.
put
(
"comment"
,
"col1 comment"
);
values
.
put
(
"type"
,
"string"
);
values
.
put
(
"type"
,
"string"
);
values
.
put
(
"owner"
,
"user1"
);
values
.
put
(
"owner"
,
"user1"
);
...
@@ -677,11 +676,11 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -677,11 +676,11 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}});
}});
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
AtlasClient
.
EntityResult
entityResult
=
serviceClient
.
updateEntity
(
tableId
.
_getId
(),
tableUpdated
);
AtlasClient
.
EntityResult
entityResult
=
atlasClientV1
.
updateEntity
(
tableId
.
_getId
(),
tableUpdated
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
tableId
.
_getId
());
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
tableId
.
_getId
());
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
...
@@ -696,12 +695,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -696,12 +695,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}});
}});
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
entityResult
=
serviceClient
.
updateEntity
(
BaseResourceIT
.
HIVE_TABLE_TYPE
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
entityResult
=
atlasClientV1
.
updateEntity
(
BaseResourceIT
.
HIVE_TABLE_TYPE
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
(
String
)
tableInstance
.
get
(
"qualifiedName"
),
tableUpdated
);
(
String
)
tableInstance
.
get
(
QUALIFIED_NAME
),
tableUpdated
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
2
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
2
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
tableId
.
_getId
());
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
tableId
.
_getId
());
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
...
@@ -713,8 +712,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -713,8 +712,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
public
void
testCompleteUpdate
()
throws
Exception
{
public
void
testCompleteUpdate
()
throws
Exception
{
final
List
<
Referenceable
>
columns
=
new
ArrayList
<>();
final
List
<
Referenceable
>
columns
=
new
ArrayList
<>();
Map
<
String
,
Object
>
values1
=
new
HashMap
<>();
Map
<
String
,
Object
>
values1
=
new
HashMap
<>();
values1
.
put
(
"name"
,
"col3"
);
values1
.
put
(
NAME
,
"col3"
);
values1
.
put
(
"qualifiedName"
,
"default.table.col3@cl1"
);
values1
.
put
(
QUALIFIED_NAME
,
"default.table.col3@cl1"
);
values1
.
put
(
"comment"
,
"col3 comment"
);
values1
.
put
(
"comment"
,
"col3 comment"
);
values1
.
put
(
"type"
,
"string"
);
values1
.
put
(
"type"
,
"string"
);
values1
.
put
(
"owner"
,
"user1"
);
values1
.
put
(
"owner"
,
"user1"
);
...
@@ -724,8 +723,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -724,8 +723,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Map
<
String
,
Object
>
values2
=
new
HashMap
<>();
Map
<
String
,
Object
>
values2
=
new
HashMap
<>();
values2
.
put
(
"name"
,
"col4"
);
values2
.
put
(
NAME
,
"col4"
);
values2
.
put
(
"qualifiedName"
,
"default.table.col4@cl1"
);
values2
.
put
(
QUALIFIED_NAME
,
"default.table.col4@cl1"
);
values2
.
put
(
"comment"
,
"col4 comment"
);
values2
.
put
(
"comment"
,
"col4 comment"
);
values2
.
put
(
"type"
,
"string"
);
values2
.
put
(
"type"
,
"string"
);
values2
.
put
(
"owner"
,
"user2"
);
values2
.
put
(
"owner"
,
"user2"
);
...
@@ -743,7 +742,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -743,7 +742,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
entityArray
.
put
(
entityJson
);
entityArray
.
put
(
entityJson
);
LOG
.
debug
(
"Replacing entity= "
+
tableInstance
);
LOG
.
debug
(
"Replacing entity= "
+
tableInstance
);
JSONObject
response
=
serviceClient
.
callAPIWithBody
(
AtlasClient
.
API
.
UPDATE_ENTITY
,
entityArray
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBody
(
AtlasClient
.
API
.
UPDATE_ENTITY
,
entityArray
);
// ATLAS-586: verify response entity can be parsed by GSON.
// ATLAS-586: verify response entity can be parsed by GSON.
Gson
gson
=
new
Gson
();
Gson
gson
=
new
Gson
();
...
@@ -754,7 +753,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -754,7 +753,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Assert
.
fail
(
"Response entity from not parse-able by GSON"
,
e
);
Assert
.
fail
(
"Response entity from not parse-able by GSON"
,
e
);
}
}
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
GET_ENTITY
,
null
,
tableId
.
_getId
());
LOG
.
info
(
"Response = {}"
,
response
.
toString
());
LOG
.
info
(
"Response = {}"
,
response
.
toString
());
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
Referenceable
getReferenceable
=
InstanceSerialization
.
fromJsonReferenceable
(
response
.
getString
(
AtlasClient
.
DEFINITION
),
true
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
getReferenceable
.
get
(
"columns"
);
...
@@ -780,24 +779,24 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -780,24 +779,24 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
// Create 2 database entities
// Create 2 database entities
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
db1
.
set
(
"name"
,
dbName
);
db1
.
set
(
NAME
,
dbName
);
db1
.
set
(
"description"
,
randomString
());
db1
.
set
(
DESCRIPTION
,
randomString
());
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"clusterName"
,
"cl1"
);
db1
.
set
(
CLUSTER_NAME
,
"cl1"
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"location"
,
"/tmp"
);
db1
.
set
(
"location"
,
"/tmp"
);
Id
db1Id
=
createInstance
(
db1
);
Id
db1Id
=
createInstance
(
db1
);
Referenceable
db2
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
db2
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName2
=
randomString
();
String
dbName2
=
randomString
();
db2
.
set
(
"name"
,
dbName2
);
db2
.
set
(
NAME
,
dbName2
);
db2
.
set
(
"qualifiedName"
,
dbName2
);
db2
.
set
(
QUALIFIED_NAME
,
dbName2
);
db2
.
set
(
"clusterName"
,
randomString
());
db2
.
set
(
CLUSTER_NAME
,
randomString
());
db2
.
set
(
"description"
,
randomString
());
db2
.
set
(
DESCRIPTION
,
randomString
());
db2
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName2
);
db2
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName2
);
db2
.
set
(
"owner"
,
"user2"
);
db2
.
set
(
"owner"
,
"user2"
);
db2
.
set
(
"clusterName"
,
"cl1"
);
db2
.
set
(
CLUSTER_NAME
,
"cl1"
);
db2
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db2
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db2
.
set
(
"location"
,
"/tmp"
);
db2
.
set
(
"location"
,
"/tmp"
);
Id
db2Id
=
createInstance
(
db2
);
Id
db2Id
=
createInstance
(
db2
);
...
@@ -807,14 +806,14 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -807,14 +806,14 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
queryParams
.
add
(
AtlasClient
.
GUID
.
toLowerCase
(),
db1Id
.
_getId
());
queryParams
.
add
(
AtlasClient
.
GUID
.
toLowerCase
(),
db1Id
.
_getId
());
queryParams
.
add
(
AtlasClient
.
GUID
.
toLowerCase
(),
db2Id
.
_getId
());
queryParams
.
add
(
AtlasClient
.
GUID
.
toLowerCase
(),
db2Id
.
_getId
());
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
DELETE_ENTITIES
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
DELETE_ENTITIES
,
queryParams
);
List
<
String
>
deletedGuidsList
=
AtlasClient
.
EntityResult
.
fromString
(
response
.
toString
()).
getDeletedEntities
();
List
<
String
>
deletedGuidsList
=
AtlasClient
.
EntityResult
.
fromString
(
response
.
toString
()).
getDeletedEntities
();
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db1Id
.
_getId
()));
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db1Id
.
_getId
()));
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db2Id
.
_getId
()));
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db2Id
.
_getId
()));
// Verify entities were deleted from the repository.
// Verify entities were deleted from the repository.
for
(
String
guid
:
deletedGuidsList
)
{
for
(
String
guid
:
deletedGuidsList
)
{
Referenceable
entity
=
serviceClient
.
getEntity
(
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
}
}
}
}
...
@@ -828,15 +827,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -828,15 +827,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
db1
.
set
(
"description"
,
randomString
());
db1
.
set
(
"description"
,
randomString
());
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"clusterName"
,
"cl1"
);
db1
.
set
(
CLUSTER_NAME
,
"cl1"
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"location"
,
"/tmp"
);
db1
.
set
(
"location"
,
"/tmp"
);
Id
db1Id
=
createInstance
(
db1
);
Id
db1Id
=
createInstance
(
db1
);
Referenceable
db2
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
db2
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName2
=
randomString
();
String
dbName2
=
randomString
();
db2
.
set
(
"name"
,
dbName2
);
db2
.
set
(
"name"
,
dbName2
);
db2
.
set
(
"qualifiedName"
,
dbName2
);
db2
.
set
(
QUALIFIED_NAME
,
dbName2
);
db2
.
set
(
"clusterName"
,
randomString
());
db2
.
set
(
CLUSTER_NAME
,
randomString
());
db2
.
set
(
"description"
,
randomString
());
db2
.
set
(
"description"
,
randomString
());
db2
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName2
);
db2
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName2
);
db2
.
set
(
"owner"
,
"user2"
);
db2
.
set
(
"owner"
,
"user2"
);
...
@@ -847,8 +846,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -847,8 +846,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
// Delete the database entities
// Delete the database entities
List
<
String
>
deletedGuidsList
=
List
<
String
>
deletedGuidsList
=
serviceClient
.
deleteEntities
(
db1Id
.
_getId
(),
db2Id
.
_getId
()).
getDeletedEntities
();
atlasClientV1
.
deleteEntities
(
db1Id
.
_getId
(),
db2Id
.
_getId
()).
getDeletedEntities
();
// Verify that deleteEntities() response has database entity guids
// Verify that deleteEntities() response has database entity guids
Assert
.
assertEquals
(
deletedGuidsList
.
size
(),
2
);
Assert
.
assertEquals
(
deletedGuidsList
.
size
(),
2
);
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db1Id
.
_getId
()));
Assert
.
assertTrue
(
deletedGuidsList
.
contains
(
db1Id
.
_getId
()));
...
@@ -856,7 +854,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -856,7 +854,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
// Verify entities were deleted from the repository.
// Verify entities were deleted from the repository.
for
(
String
guid
:
deletedGuidsList
)
{
for
(
String
guid
:
deletedGuidsList
)
{
Referenceable
entity
=
serviceClient
.
getEntity
(
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
}
}
}
}
...
@@ -866,19 +864,19 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -866,19 +864,19 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
// Create database entity
// Create database entity
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
Referenceable
db1
=
new
Referenceable
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
String
dbName
=
randomString
();
db1
.
set
(
"name"
,
dbName
);
db1
.
set
(
NAME
,
dbName
);
db1
.
set
(
"qualifiedName"
,
dbName
);
db1
.
set
(
QUALIFIED_NAME
,
dbName
);
db1
.
set
(
"clusterName"
,
randomString
());
db1
.
set
(
CLUSTER_NAME
,
randomString
());
db1
.
set
(
"description"
,
randomString
());
db1
.
set
(
DESCRIPTION
,
randomString
());
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
dbName
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"owner"
,
"user1"
);
db1
.
set
(
"clusterName"
,
"cl1"
);
db1
.
set
(
CLUSTER_NAME
,
"cl1"
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"parameters"
,
Collections
.
EMPTY_MAP
);
db1
.
set
(
"location"
,
"/tmp"
);
db1
.
set
(
"location"
,
"/tmp"
);
Id
db1Id
=
createInstance
(
db1
);
Id
db1Id
=
createInstance
(
db1
);
// Delete the database entity
// Delete the database entity
List
<
String
>
deletedGuidsList
=
serviceClient
.
deleteEntity
(
DATABASE_TYPE
,
"qualifiedName"
,
dbName
).
getDeletedEntities
();
List
<
String
>
deletedGuidsList
=
atlasClientV1
.
deleteEntity
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
dbName
).
getDeletedEntities
();
// Verify that deleteEntities() response has database entity guids
// Verify that deleteEntities() response has database entity guids
Assert
.
assertEquals
(
deletedGuidsList
.
size
(),
1
);
Assert
.
assertEquals
(
deletedGuidsList
.
size
(),
1
);
...
@@ -886,7 +884,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -886,7 +884,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
// Verify entities were deleted from the repository.
// Verify entities were deleted from the repository.
for
(
String
guid
:
deletedGuidsList
)
{
for
(
String
guid
:
deletedGuidsList
)
{
Referenceable
entity
=
serviceClient
.
getEntity
(
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
assertEquals
(
entity
.
getId
().
getState
(),
Id
.
EntityState
.
DELETED
);
}
}
}
}
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityLineageJerseyResourceIT.java
View file @
ec1b160a
...
@@ -60,19 +60,19 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
...
@@ -60,19 +60,19 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
createTypeDefinitions
();
createTypeDefinitions
V1
();
setupInstances
();
setupInstances
();
}
}
@Test
@Test
public
void
testInputLineageInfo
()
throws
Exception
{
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
();
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
salesMonthlyTable
).
getId
().
_getId
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
DIRECTION_PARAM
,
INPUT_DIRECTION
);
queryParams
.
add
(
DIRECTION_PARAM
,
INPUT_DIRECTION
);
queryParams
.
add
(
DEPTH_PARAM
,
"5"
);
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"input lineage info = "
+
response
System
.
out
.
println
(
"input lineage info = "
+
response
);
);
...
@@ -94,13 +94,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
...
@@ -94,13 +94,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
@Test
@Test
public
void
testOutputLineageInfo
()
throws
Exception
{
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
();
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
salesFactTable
).
getId
().
_getId
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
DIRECTION_PARAM
,
OUTPUT_DIRECTION
);
queryParams
.
add
(
DIRECTION_PARAM
,
OUTPUT_DIRECTION
);
queryParams
.
add
(
DEPTH_PARAM
,
"5"
);
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"output lineage info = "
+
response
);
System
.
out
.
println
(
"output lineage info = "
+
response
);
...
@@ -122,13 +122,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
...
@@ -122,13 +122,13 @@ public class EntityLineageJerseyResourceIT extends DataSetLineageJerseyResourceI
@Test
@Test
public
void
testLineageInfo
()
throws
Exception
{
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
();
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
salesMonthlyTable
).
getId
().
_getId
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
DIRECTION_PARAM
,
BOTH_DIRECTION
);
queryParams
.
add
(
DIRECTION_PARAM
,
BOTH_DIRECTION
);
queryParams
.
add
(
DEPTH_PARAM
,
"5"
);
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
);
Assert
.
assertNotNull
(
response
);
System
.
out
.
println
(
"both lineage info = "
+
response
);
System
.
out
.
println
(
"both lineage info = "
+
response
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
0 → 100755
View file @
ec1b160a
/**
* 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
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Lists
;
import
com.google.inject.Inject
;
import
com.sun.jersey.api.client.ClientResponse
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.EntityAuditEvent
;
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.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasEntityWithAssociations
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutations
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.notification.NotificationConsumer
;
import
org.apache.atlas.notification.NotificationInterface
;
import
org.apache.atlas.notification.NotificationModule
;
import
org.apache.atlas.notification.entity.EntityNotification
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.typesystem.types.TypeUtils
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.joda.time.DateTime
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
testng
.
Assert
.*;
/**
* Integration tests for Entity Jersey Resource.
*/
@Guice
(
modules
=
{
NotificationModule
.
class
})
public
class
EntityV2JerseyResourceIT
extends
BaseResourceIT
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityV2JerseyResourceIT
.
class
);
private
final
String
DATABASE_NAME
=
"db"
+
randomString
();
private
final
String
TABLE_NAME
=
"table"
+
randomString
();
private
static
final
String
TRAITS
=
"traits"
;
private
static
final
String
TRAIT_DEFINITION
=
"traitDefinitions"
;
private
String
traitName
;
private
AtlasEntity
dbEntity
;
private
AtlasEntityHeader
dbEntityHeader
;
private
AtlasEntityWithAssociations
tableEntity
;
private
AtlasEntityHeader
tableEntityHeader
;
@Inject
private
NotificationInterface
notificationInterface
;
private
NotificationConsumer
<
EntityNotification
>
notificationConsumer
;
@BeforeClass
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
createTypeDefinitionsV2
();
List
<
NotificationConsumer
<
EntityNotification
>>
consumers
=
notificationInterface
.
createConsumers
(
NotificationInterface
.
NotificationType
.
ENTITIES
,
1
);
notificationConsumer
=
consumers
.
iterator
().
next
();
}
@Test
public
void
testSubmitEntity
()
throws
Exception
{
TypeUtils
.
Pair
dbAndTable
=
createDBAndTable
(
DATABASE_NAME
,
TABLE_NAME
);
assertNotNull
(
dbAndTable
);
assertNotNull
(
dbAndTable
.
left
);
assertNotNull
(
dbAndTable
.
right
);
}
@Test
public
void
testRequestUser
()
throws
Exception
{
AtlasEntity
hiveDBInstanceV2
=
createHiveDB
(
DATABASE_NAME
);
List
<
EntityAuditEvent
>
events
=
atlasClientV1
.
getEntityAuditEvents
(
hiveDBInstanceV2
.
getGuid
(),
(
short
)
10
);
assertTrue
(
events
.
size
()
>
1
);
assertEquals
(
events
.
get
(
0
).
getUser
(),
"admin"
);
}
@Test
public
void
testEntityDeduping
()
throws
Exception
{
JSONArray
results
=
searchByDSL
(
String
.
format
(
"%s where name='%s'"
,
DATABASE_TYPE
,
DATABASE_NAME
));
assertEquals
(
results
.
length
(),
1
);
final
AtlasEntity
hiveDBInstanceV2
=
createHiveDB
(
DATABASE_NAME
);
// Do the notification thing here
waitForNotification
(
notificationConsumer
,
MAX_WAIT_TIME
,
new
NotificationPredicate
()
{
@Override
public
boolean
evaluate
(
EntityNotification
notification
)
throws
Exception
{
return
notification
!=
null
&&
notification
.
getEntity
().
getId
().
_getId
().
equals
(
hiveDBInstanceV2
.
getGuid
());
}
});
results
=
searchByDSL
(
String
.
format
(
"%s where name='%s'"
,
DATABASE_TYPE
,
DATABASE_NAME
));
assertEquals
(
results
.
length
(),
1
);
//Test the same across references
final
String
tableName
=
randomString
();
AtlasEntityWithAssociations
hiveTableInstanceV2
=
createHiveTableInstanceV2
(
hiveDBInstanceV2
,
tableName
);
hiveTableInstanceV2
.
setAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
tableName
);
EntityMutationResponse
entity
=
entitiesClientV2
.
createEntity
(
hiveTableInstanceV2
);
assertNotNull
(
entity
);
assertNotNull
(
entity
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
results
=
searchByDSL
(
String
.
format
(
"%s where name='%s'"
,
DATABASE_TYPE
,
DATABASE_NAME
));
assertEquals
(
results
.
length
(),
1
);
}
private
void
assertEntityAudit
(
String
dbid
,
EntityAuditEvent
.
EntityAuditAction
auditAction
)
throws
Exception
{
List
<
EntityAuditEvent
>
events
=
atlasClientV1
.
getEntityAuditEvents
(
dbid
,
(
short
)
100
);
for
(
EntityAuditEvent
event
:
events
)
{
if
(
event
.
getAction
()
==
auditAction
)
{
return
;
}
}
fail
(
"Expected audit event with action = "
+
auditAction
);
}
@Test
public
void
testEntityDefinitionAcrossTypeUpdate
()
throws
Exception
{
//create type
AtlasEntityDef
entityDef
=
AtlasTypeUtil
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createUniqueRequiredAttrDef
(
"name"
,
"string"
)
);
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getEntityDefs
().
add
(
entityDef
);
AtlasTypesDef
created
=
typedefClientV2
.
createAtlasTypeDefs
(
typesDef
);
assertNotNull
(
created
);
assertNotNull
(
created
.
getEntityDefs
());
assertEquals
(
created
.
getEntityDefs
().
size
(),
1
);
//create entity for the type
AtlasEntity
instance
=
new
AtlasEntity
(
entityDef
.
getName
());
instance
.
setAttribute
(
"name"
,
randomString
());
EntityMutationResponse
mutationResponse
=
entitiesClientV2
.
createEntity
(
instance
);
assertNotNull
(
mutationResponse
);
assertNotNull
(
mutationResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
assertEquals
(
mutationResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
size
(),
1
);
String
guid
=
mutationResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
get
(
0
).
getGuid
();
//update type - add attribute
entityDef
=
AtlasTypeUtil
.
createClassTypeDef
(
entityDef
.
getName
(),
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createUniqueRequiredAttrDef
(
"name"
,
"string"
),
AtlasTypeUtil
.
createOptionalAttrDef
(
"description"
,
"string"
));
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getEntityDefs
().
add
(
entityDef
);
AtlasTypesDef
updated
=
typedefClientV2
.
updateAtlasTypeDefs
(
typesDef
);
assertNotNull
(
updated
);
assertNotNull
(
updated
.
getEntityDefs
());
assertEquals
(
updated
.
getEntityDefs
().
size
(),
1
);
//Get definition after type update - new attributes should be null
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
guid
);
assertNull
(
entityByGuid
.
getAttribute
(
"description"
));
assertEquals
(
entityByGuid
.
getAttribute
(
"name"
),
instance
.
getAttribute
(
"name"
));
}
@DataProvider
public
Object
[][]
invalidAttrValues
()
{
return
new
Object
[][]{{
null
},
{
""
}};
}
@Test
(
dataProvider
=
"invalidAttrValues"
)
public
void
testEntityInvalidValue
(
String
value
)
throws
Exception
{
AtlasEntity
databaseInstance
=
new
AtlasEntity
(
DATABASE_TYPE
);
String
dbName
=
randomString
();
databaseInstance
.
setAttribute
(
"name"
,
dbName
);
databaseInstance
.
setAttribute
(
"description"
,
value
);
AtlasEntityHeader
created
=
createEntity
(
databaseInstance
);
assertNull
(
created
);
}
@Test
public
void
testGetEntityByAttribute
()
throws
Exception
{
AtlasEntity
hiveDB
=
createHiveDB
(
DATABASE_NAME
);
String
qualifiedName
=
(
String
)
hiveDB
.
getAttribute
(
QUALIFIED_NAME
);
//get entity by attribute
AtlasEntity
byAttribute
=
entitiesClientV2
.
getEntityByAttribute
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
qualifiedName
);
assertEquals
(
byAttribute
.
getTypeName
(),
DATABASE_TYPE
);
assertEquals
(
byAttribute
.
getAttribute
(
QUALIFIED_NAME
),
qualifiedName
);
}
@Test
public
void
testSubmitEntityWithBadDateFormat
()
throws
Exception
{
AtlasEntity
hiveDBInstance
=
createHiveDBInstanceV2
(
"db"
+
randomString
());
AtlasEntityHeader
entity
=
createEntity
(
hiveDBInstance
);
AtlasEntity
tableInstance
=
createHiveTableInstanceV2
(
hiveDBInstance
,
"table"
+
randomString
());
tableInstance
.
setAttribute
(
"lastAccessTime"
,
"2014-07-11"
);
AtlasEntityHeader
tableEntityHeader
=
createEntity
(
tableInstance
);
assertNull
(
tableEntityHeader
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testAddProperty
()
throws
Exception
{
//add property
String
description
=
"bar table - new desc"
;
addProperty
(
tableEntity
.
getGuid
(),
"description"
,
description
);
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
Assert
.
assertNotNull
(
entityByGuid
);
entityByGuid
.
setAttribute
(
"description"
,
description
);
// TODO: This behavior should've been consistent across APIs
// //invalid property for the type
// try {
// addProperty(table.getGuid(), "invalid_property", "bar table");
// Assert.fail("Expected AtlasServiceException");
// } catch (AtlasServiceException e) {
// assertNotNull(e.getStatus());
// assertEquals(e.getStatus(), ClientResponse.Status.BAD_REQUEST);
// }
//non-string property, update
String
currentTime
=
String
.
valueOf
(
new
DateTime
());
addProperty
(
tableEntity
.
getGuid
(),
"createTime"
,
currentTime
);
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
Assert
.
assertNotNull
(
entityByGuid
);
}
@Test
public
void
testAddNullPropertyValue
()
throws
Exception
{
// FIXME: Behavior has changed between v1 and v2
//add property
// try {
addProperty
(
tableEntity
.
getGuid
(),
"description"
,
null
);
// Assert.fail("Expected AtlasServiceException");
// } catch(AtlasServiceException e) {
// Assert.assertEquals(e.getStatus().getStatusCode(), Response.Status.BAD_REQUEST.getStatusCode());
// }
}
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testGetInvalidEntityDefinition
()
throws
Exception
{
entitiesClientV2
.
getEntityByGuid
(
"blah"
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
,
enabled
=
false
)
public
void
testGetEntityList
()
throws
Exception
{
// TODO: Can only be done when there's a search API exposed from entity REST
}
@Test
(
enabled
=
false
)
public
void
testGetEntityListForBadEntityType
()
throws
Exception
{
// FIXME: Complete test when search interface is in place
}
@Test
(
enabled
=
false
)
public
void
testGetEntityListForNoInstances
()
throws
Exception
{
// FIXME: Complete test when search interface is in place
/*
String typeName = "";
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);
JSONObject response = new JSONObject(responseAsString);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
Assert.assertEquals(list.length(), 0);
*/
}
private
String
addNewType
()
throws
Exception
{
String
typeName
=
"test"
+
randomString
();
AtlasEntityDef
classTypeDef
=
AtlasTypeUtil
.
createClassTypeDef
(
typeName
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"name"
,
"string"
),
AtlasTypeUtil
.
createRequiredAttrDef
(
"description"
,
"string"
));
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getEntityDefs
().
add
(
classTypeDef
);
createType
(
typesDef
);
return
typeName
;
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetTraitNames
()
throws
Exception
{
AtlasClassifications
classifications
=
entitiesClientV2
.
getClassifications
(
tableEntity
.
getGuid
());
assertNotNull
(
classifications
);
assertTrue
(
classifications
.
getList
().
size
()
>
0
);
assertEquals
(
classifications
.
getList
().
size
(),
8
);
}
private
void
addProperty
(
String
guid
,
String
property
,
String
value
)
throws
AtlasServiceException
{
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
guid
);
entityByGuid
.
setAttribute
(
property
,
value
);
EntityMutationResponse
response
=
entitiesClientV2
.
updateEntity
(
entityByGuid
);
assertNotNull
(
response
);
assertNotNull
(
response
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
}
private
AtlasEntity
createHiveDB
()
{
if
(
dbEntity
!=
null
)
{
return
dbEntity
;
}
else
{
return
createHiveDB
(
DATABASE_NAME
);
}
}
private
AtlasEntity
createHiveDB
(
String
dbName
)
{
AtlasEntity
hiveDBInstanceV2
=
createHiveDBInstanceV2
(
dbName
);
AtlasEntityHeader
entityHeader
=
createEntity
(
hiveDBInstanceV2
);
assertNotNull
(
entityHeader
);
assertNotNull
(
entityHeader
.
getGuid
());
hiveDBInstanceV2
.
setGuid
(
entityHeader
.
getGuid
());
dbEntity
=
hiveDBInstanceV2
;
dbEntityHeader
=
entityHeader
;
return
hiveDBInstanceV2
;
}
private
TypeUtils
.
Pair
<
AtlasEntity
,
AtlasEntityWithAssociations
>
createDBAndTable
(
String
dbName
,
String
tableName
)
throws
Exception
{
AtlasEntity
dbInstanceV2
=
createHiveDB
(
dbName
);
AtlasEntityWithAssociations
hiveTableInstanceV2
=
createHiveTable
(
dbInstanceV2
,
tableName
);
return
TypeUtils
.
Pair
.
of
(
dbInstanceV2
,
hiveTableInstanceV2
);
}
private
AtlasEntityWithAssociations
createHiveTable
()
throws
Exception
{
if
(
tableEntity
!=
null
)
{
return
tableEntity
;
}
else
{
return
createHiveTable
(
createHiveDB
(),
TABLE_NAME
);
}
}
private
AtlasEntityWithAssociations
createHiveTable
(
AtlasEntity
dbInstanceV2
,
String
tableName
)
throws
Exception
{
AtlasEntityWithAssociations
hiveTableInstanceV2
=
createHiveTableInstanceV2
(
dbInstanceV2
,
tableName
);
AtlasEntityHeader
createdHeader
=
createEntity
(
hiveTableInstanceV2
);
assertNotNull
(
createdHeader
);
assertNotNull
(
createdHeader
.
getGuid
());
hiveTableInstanceV2
.
setGuid
(
createdHeader
.
getGuid
());
entitiesClientV2
.
addClassifications
(
createdHeader
.
getGuid
(),
hiveTableInstanceV2
.
getClassifications
());
tableEntity
=
hiveTableInstanceV2
;
tableEntityHeader
=
createdHeader
;
return
hiveTableInstanceV2
;
}
@Test
(
dependsOnMethods
=
"testGetTraitNames"
)
public
void
testAddTrait
()
throws
Exception
{
traitName
=
"PII_Trait"
+
randomString
();
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
traitName
,
ImmutableSet
.<
String
>
of
());
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
piiTrait
);
createType
(
typesDef
);
entitiesClientV2
.
addClassifications
(
tableEntity
.
getGuid
(),
ImmutableList
.
of
(
new
AtlasClassification
(
piiTrait
.
getName
())));
assertEntityAudit
(
tableEntity
.
getGuid
(),
EntityAuditEvent
.
EntityAuditAction
.
TAG_ADD
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetTraitDefinitionForEntity
()
throws
Exception
{
traitName
=
"PII_Trait"
+
randomString
();
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
traitName
,
ImmutableSet
.<
String
>
of
());
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
piiTrait
);
createType
(
typesDef
);
AtlasClassificationDef
classificationByName
=
typedefClientV2
.
getClassificationByName
(
traitName
);
assertNotNull
(
classificationByName
);
assertEquals
(
tableEntity
.
getClassifications
().
size
(),
7
);
AtlasClassification
piiClassification
=
new
AtlasClassification
(
piiTrait
.
getName
());
entitiesClientV2
.
addClassifications
(
tableEntity
.
getGuid
(),
Lists
.
newArrayList
(
piiClassification
));
AtlasClassifications
classifications
=
entitiesClientV2
.
getClassifications
(
tableEntity
.
getGuid
());
assertNotNull
(
classifications
);
assertTrue
(
classifications
.
getList
().
size
()
>
0
);
assertEquals
(
classifications
.
getList
().
size
(),
8
);
}
@Test
(
dependsOnMethods
=
"testGetTraitNames"
)
public
void
testAddTraitWithAttribute
()
throws
Exception
{
final
String
traitName
=
"PII_Trait"
+
randomString
();
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
traitName
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"type"
,
"string"
));
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
piiTrait
);
createType
(
typesDef
);
AtlasClassification
traitInstance
=
new
AtlasClassification
(
traitName
);
traitInstance
.
setAttribute
(
"type"
,
"SSN"
);
final
String
guid
=
tableEntity
.
getGuid
();
entitiesClientV2
.
addClassifications
(
guid
,
ImmutableList
.
of
(
traitInstance
));
// verify the response
AtlasEntityWithAssociations
withAssociationByGuid
=
entitiesClientV2
.
getEntityWithAssociationByGuid
(
guid
);
assertNotNull
(
withAssociationByGuid
);
assertFalse
(
withAssociationByGuid
.
getClassifications
().
isEmpty
());
boolean
found
=
false
;
for
(
AtlasClassification
atlasClassification
:
withAssociationByGuid
.
getClassifications
())
{
String
attribute
=
(
String
)
atlasClassification
.
getAttribute
(
"type"
);
if
(
attribute
!=
null
&&
attribute
.
equals
(
"SSN"
))
{
found
=
true
;
break
;
}
}
assertTrue
(
found
);
}
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testAddTraitWithNoRegistration
()
throws
Exception
{
final
String
traitName
=
"PII_Trait"
+
randomString
();
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
traitName
,
ImmutableSet
.<
String
>
of
());
AtlasClassification
traitInstance
=
new
AtlasClassification
(
traitName
);
entitiesClientV2
.
addClassifications
(
"random"
,
ImmutableList
.
of
(
traitInstance
));
}
@Test
(
dependsOnMethods
=
"testAddTrait"
)
public
void
testDeleteTrait
()
throws
Exception
{
final
String
guid
=
tableEntity
.
getGuid
();
try
{
entitiesClientV2
.
deleteClassification
(
guid
,
traitName
);
}
catch
(
AtlasServiceException
ex
)
{
fail
(
"Deletion should've succeeded"
);
}
assertEntityAudit
(
guid
,
EntityAuditEvent
.
EntityAuditAction
.
TAG_DELETE
);
}
@Test
public
void
testDeleteTraitNonExistent
()
throws
Exception
{
final
String
traitName
=
"blah_trait"
;
try
{
entitiesClientV2
.
deleteClassification
(
"random"
,
traitName
);
fail
(
"Deletion for bogus names shouldn't have succeeded"
);
}
catch
(
AtlasServiceException
ex
)
{
assertNotNull
(
ex
.
getStatus
());
// assertEquals(ex.getStatus(), ClientResponse.Status.NOT_FOUND);
assertEquals
(
ex
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
);
// Should it be a 400 or 404
}
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testDeleteExistentTraitNonExistentForEntity
()
throws
Exception
{
final
String
guid
=
tableEntity
.
getGuid
();
final
String
traitName
=
"PII_Trait"
+
randomString
();
AtlasClassificationDef
piiTrait
=
AtlasTypeUtil
.
createTraitTypeDef
(
traitName
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createRequiredAttrDef
(
"type"
,
"string"
));
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
piiTrait
);
createType
(
typesDef
);
try
{
entitiesClientV2
.
deleteClassification
(
guid
,
traitName
);
fail
(
"Deletion should've failed for non-existent trait association"
);
}
catch
(
AtlasServiceException
ex
)
{
Assert
.
assertNotNull
(
ex
.
getStatus
());
assertEquals
(
ex
.
getStatus
(),
ClientResponse
.
Status
.
NOT_FOUND
);
}
}
private
String
random
()
{
return
RandomStringUtils
.
random
(
10
);
}
@Test
public
void
testUTF8
()
throws
Exception
{
String
classType
=
random
();
String
attrName
=
random
();
String
attrValue
=
random
();
AtlasEntityDef
classTypeDef
=
AtlasTypeUtil
.
createClassTypeDef
(
classType
,
ImmutableSet
.<
String
>
of
(),
AtlasTypeUtil
.
createUniqueRequiredAttrDef
(
attrName
,
"string"
));
AtlasTypesDef
atlasTypesDef
=
new
AtlasTypesDef
();
atlasTypesDef
.
getEntityDefs
().
add
(
classTypeDef
);
createType
(
atlasTypesDef
);
AtlasEntity
instance
=
new
AtlasEntity
(
classType
);
instance
.
setAttribute
(
attrName
,
attrValue
);
AtlasEntityHeader
entity
=
createEntity
(
instance
);
assertNotNull
(
entity
);
assertNotNull
(
entity
.
getGuid
());
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
entity
.
getGuid
());
assertEquals
(
entityByGuid
.
getAttribute
(
attrName
),
attrValue
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testPartialUpdate
()
throws
Exception
{
final
List
<
AtlasEntity
>
columns
=
new
ArrayList
<>();
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
values
.
put
(
"name"
,
"col1"
);
values
.
put
(
QUALIFIED_NAME
,
"qualifiedName.col1"
);
values
.
put
(
"type"
,
"string"
);
values
.
put
(
"comment"
,
"col1 comment"
);
AtlasEntity
ref
=
new
AtlasEntity
(
BaseResourceIT
.
COLUMN_TYPE
,
values
);
columns
.
add
(
ref
);
AtlasEntityWithAssociations
tableUpdated
=
tableEntity
;
tableEntity
.
setAttribute
(
"columns"
,
columns
);
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
EntityMutationResponse
updateResult
=
entitiesClientV2
.
updateEntity
(
tableEntity
.
getGuid
(),
tableUpdated
);
assertNotNull
(
updateResult
);
assertNotNull
(
updateResult
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
assertTrue
(
updateResult
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
size
()
>
0
);
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
assertNotNull
(
entityByGuid
);
List
<
AtlasEntity
>
columns1
=
(
List
<
AtlasEntity
>)
entityByGuid
.
getAttribute
(
"columns"
);
//Update by unique attribute
values
.
put
(
"type"
,
"int"
);
ref
=
new
AtlasEntity
(
BaseResourceIT
.
COLUMN_TYPE
,
values
);
columns
.
set
(
0
,
ref
);
tableUpdated
=
tableEntity
;
tableUpdated
.
setAttribute
(
"columns"
,
columns
);
LOG
.
debug
(
"Updating entity= "
+
tableUpdated
);
EntityMutationResponse
updateResponse
=
entitiesClientV2
.
updateEntityByAttribute
(
BaseResourceIT
.
HIVE_TABLE_TYPE
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
(
String
)
tableEntity
.
getAttribute
(
"name"
),
tableUpdated
);
assertNotNull
(
updateResponse
);
assertNotNull
(
updateResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
assertTrue
(
updateResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
size
()
>
0
);
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
assertNotNull
(
entityByGuid
);
columns1
=
(
List
<
AtlasEntity
>)
entityByGuid
.
getAttribute
(
"columns"
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testCompleteUpdate
()
throws
Exception
{
final
List
<
AtlasEntity
>
columns
=
new
ArrayList
<>();
Map
<
String
,
Object
>
values1
=
new
HashMap
<>();
values1
.
put
(
"name"
,
"col3"
);
values1
.
put
(
QUALIFIED_NAME
,
"qualifiedName.col3"
);
values1
.
put
(
"type"
,
"string"
);
values1
.
put
(
"comment"
,
"col3 comment"
);
Map
<
String
,
Object
>
values2
=
new
HashMap
<>();
values2
.
put
(
"name"
,
"col4"
);
values2
.
put
(
QUALIFIED_NAME
,
"qualifiedName.col4"
);
values2
.
put
(
"type"
,
"string"
);
values2
.
put
(
"comment"
,
"col4 comment"
);
AtlasEntity
ref1
=
new
AtlasEntity
(
BaseResourceIT
.
COLUMN_TYPE
,
values1
);
AtlasEntity
ref2
=
new
AtlasEntity
(
BaseResourceIT
.
COLUMN_TYPE
,
values2
);
columns
.
add
(
ref1
);
columns
.
add
(
ref2
);
tableEntity
.
setAttribute
(
"columns"
,
columns
);
EntityMutationResponse
updateEntityResult
=
entitiesClientV2
.
updateEntity
(
tableEntity
);
assertNotNull
(
updateEntityResult
);
assertNotNull
(
updateEntityResult
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
));
assertEquals
(
updateEntityResult
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
CREATE_OR_UPDATE
).
size
(),
3
);
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
List
<
AtlasEntity
>
refs
=
(
List
<
AtlasEntity
>)
entityByGuid
.
getAttribute
(
"columns"
);
assertEquals
(
refs
.
size
(),
2
);
}
@Test
public
void
testDeleteEntities
()
throws
Exception
{
// Create 2 database entities
AtlasEntity
db1
=
new
AtlasEntity
(
DATABASE_TYPE
);
String
dbName1
=
randomString
();
db1
.
setAttribute
(
"name"
,
dbName1
);
db1
.
setAttribute
(
QUALIFIED_NAME
,
dbName1
);
db1
.
setAttribute
(
"clusterName"
,
randomString
());
db1
.
setAttribute
(
"description"
,
randomString
());
AtlasEntityHeader
entity1Header
=
createEntity
(
db1
);
AtlasEntity
db2
=
new
AtlasEntity
(
DATABASE_TYPE
);
String
dbName2
=
randomString
();
db2
.
setAttribute
(
"name"
,
dbName2
);
db2
.
setAttribute
(
QUALIFIED_NAME
,
dbName2
);
db2
.
setAttribute
(
"clusterName"
,
randomString
());
db2
.
setAttribute
(
"description"
,
randomString
());
AtlasEntityHeader
entity2Header
=
createEntity
(
db2
);
// Delete the database entities
EntityMutationResponse
deleteResponse
=
entitiesClientV2
.
deleteEntityByGuid
(
ImmutableList
.
of
(
entity1Header
.
getGuid
(),
entity2Header
.
getGuid
()));
// Verify that deleteEntities() response has database entity guids
assertNotNull
(
deleteResponse
);
assertNotNull
(
deleteResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
));
assertEquals
(
deleteResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
).
size
(),
2
);
// Verify entities were deleted from the repository.
}
@Test
public
void
testDeleteEntityByUniqAttribute
()
throws
Exception
{
// Create database entity
AtlasEntity
hiveDB
=
createHiveDB
(
DATABASE_NAME
+
random
());
String
qualifiedName
=
(
String
)
hiveDB
.
getAttribute
(
QUALIFIED_NAME
);
// Delete the database entity
EntityMutationResponse
deleteResponse
=
entitiesClientV2
.
deleteEntityByAttribute
(
DATABASE_TYPE
,
QUALIFIED_NAME
,
qualifiedName
);
// Verify that deleteEntities() response has database entity guids
assertNotNull
(
deleteResponse
);
assertNotNull
(
deleteResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
));
assertEquals
(
deleteResponse
.
getEntitiesByOperation
(
EntityMutations
.
EntityOperation
.
DELETE
).
size
(),
1
);
// Verify entities were deleted from the repository.
}
}
webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
View file @
ec1b160a
...
@@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList;
...
@@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.ImmutableSet
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.core.util.MultivaluedMapImpl
;
import
com.sun.jersey.core.util.MultivaluedMapImpl
;
import
org.apache.atlas.AtlasBaseClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Referenceable
;
...
@@ -43,7 +42,6 @@ import org.testng.annotations.BeforeClass;
...
@@ -43,7 +42,6 @@ import org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
...
@@ -55,10 +53,6 @@ import static org.testng.Assert.fail;
...
@@ -55,10 +53,6 @@ import static org.testng.Assert.fail;
*/
*/
public
class
MetadataDiscoveryJerseyResourceIT
extends
BaseResourceIT
{
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
tagName
;
private
String
dbName
;
private
String
dbName
;
...
@@ -66,8 +60,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -66,8 +60,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
dbName
=
"db"
+
randomString
();
dbName
=
"db"
+
randomString
();
createTypes
();
createInstance
(
createHiveDBInstance
(
dbName
)
);
createInstance
(
createHiveDBInstance
V1
(
dbName
)
);
}
}
@Test
@Test
...
@@ -75,7 +69,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -75,7 +69,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
dslQuery
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
String
dslQuery
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
dslQuery
);
queryParams
.
add
(
"query"
,
dslQuery
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -84,7 +78,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -84,7 +78,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals
(
response
.
getString
(
"queryType"
),
"dsl"
);
assertEquals
(
response
.
getString
(
"queryType"
),
"dsl"
);
JSONArray
results
=
response
.
getJSONArray
(
AtlasClient
.
RESULTS
);
JSONArray
results
=
response
.
getJSONArray
(
AtlasClient
.
RESULTS
);
Assert
.
assertNotNull
(
results
);
assertNotNull
(
results
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
int
numRows
=
response
.
getInt
(
AtlasClient
.
COUNT
);
int
numRows
=
response
.
getInt
(
AtlasClient
.
COUNT
);
...
@@ -98,28 +92,28 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -98,28 +92,28 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
dslQuery
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
String
dslQuery
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
dslQuery
);
queryParams
.
add
(
"query"
,
dslQuery
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
assertNotNull
(
response
);
assertNotNull
(
response
);
//higher limit, all results returned
//higher limit, all results returned
JSONArray
results
=
serviceClient
.
searchByDSL
(
dslQuery
,
10
,
0
);
JSONArray
results
=
atlasClientV1
.
searchByDSL
(
dslQuery
,
10
,
0
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//default limit and offset -1, all results returned
//default limit and offset -1, all results returned
results
=
serviceClient
.
searchByDSL
(
dslQuery
,
-
1
,
-
1
);
results
=
atlasClientV1
.
searchByDSL
(
dslQuery
,
-
1
,
-
1
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//uses the limit parameter passed
//uses the limit parameter passed
results
=
serviceClient
.
searchByDSL
(
dslQuery
,
1
,
0
);
results
=
atlasClientV1
.
searchByDSL
(
dslQuery
,
1
,
0
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//uses the offset parameter passed
//uses the offset parameter passed
results
=
serviceClient
.
searchByDSL
(
dslQuery
,
10
,
1
);
results
=
atlasClientV1
.
searchByDSL
(
dslQuery
,
10
,
1
);
assertEquals
(
results
.
length
(),
0
);
assertEquals
(
results
.
length
(),
0
);
//limit > 0
//limit > 0
try
{
try
{
serviceClient
.
searchByDSL
(
dslQuery
,
0
,
10
);
atlasClientV1
.
searchByDSL
(
dslQuery
,
0
,
10
);
fail
(
"Expected BAD_REQUEST"
);
fail
(
"Expected BAD_REQUEST"
);
}
catch
(
AtlasServiceException
e
)
{
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
...
@@ -127,7 +121,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -127,7 +121,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
//limit > maxlimit
//limit > maxlimit
try
{
try
{
serviceClient
.
searchByDSL
(
dslQuery
,
Integer
.
MAX_VALUE
,
10
);
atlasClientV1
.
searchByDSL
(
dslQuery
,
Integer
.
MAX_VALUE
,
10
);
fail
(
"Expected BAD_REQUEST"
);
fail
(
"Expected BAD_REQUEST"
);
}
catch
(
AtlasServiceException
e
)
{
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
...
@@ -135,7 +129,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -135,7 +129,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
//offset >= 0
//offset >= 0
try
{
try
{
serviceClient
.
searchByDSL
(
dslQuery
,
10
,
-
2
);
atlasClientV1
.
searchByDSL
(
dslQuery
,
10
,
-
2
);
fail
(
"Expected BAD_REQUEST"
);
fail
(
"Expected BAD_REQUEST"
);
}
catch
(
AtlasServiceException
e
)
{
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
,
"Got "
+
e
.
getStatus
());
...
@@ -147,8 +141,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -147,8 +141,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
dslQuery
=
"from blah"
;
String
dslQuery
=
"from blah"
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
dslQuery
);
queryParams
.
add
(
"query"
,
dslQuery
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_DSL
,
queryParams
);
}
}
@Test
@Test
...
@@ -157,10 +150,10 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -157,10 +150,10 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
query
);
queryParams
.
add
(
"query"
,
query
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GREMLIN_SEARCH
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
GREMLIN_SEARCH
,
queryParams
);
assertNotNull
(
response
);
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
assertEquals
(
response
.
getString
(
"query"
),
query
);
assertEquals
(
response
.
getString
(
"query"
),
query
);
assertEquals
(
response
.
getString
(
"queryType"
),
"gremlin"
);
assertEquals
(
response
.
getString
(
"queryType"
),
"gremlin"
);
...
@@ -172,7 +165,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -172,7 +165,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
query
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
String
query
=
"from "
+
DATABASE_TYPE
+
" qualifiedName=\""
+
dbName
+
"\""
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
query
);
queryParams
.
add
(
"query"
,
query
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH
,
queryParams
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -186,7 +179,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -186,7 +179,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
query
=
"*"
;
String
query
=
"*"
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
query
);
queryParams
.
add
(
"query"
,
query
);
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH
,
queryParams
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -197,8 +190,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -197,8 +190,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testSearchDSLLimits"
)
@Test
(
dependsOnMethods
=
"testSearchDSLLimits"
)
public
void
testSearchUsingFullText
()
throws
Exception
{
public
void
testSearchUsingFullText
()
throws
Exception
{
JSONObject
response
=
serviceClient
.
searchByFullText
(
dbName
,
10
,
0
);
JSONObject
response
=
atlasClientV1
.
searchByFullText
(
dbName
,
10
,
0
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
assertEquals
(
response
.
getString
(
"query"
),
dbName
);
assertEquals
(
response
.
getString
(
"query"
),
dbName
);
assertEquals
(
response
.
getString
(
"queryType"
),
"full-text"
);
assertEquals
(
response
.
getString
(
"queryType"
),
"full-text"
);
...
@@ -207,9 +200,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -207,9 +200,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals
(
results
.
length
(),
1
,
"Results: "
+
results
);
assertEquals
(
results
.
length
(),
1
,
"Results: "
+
results
);
JSONObject
row
=
results
.
getJSONObject
(
0
);
JSONObject
row
=
results
.
getJSONObject
(
0
);
Assert
.
assertNotNull
(
row
.
get
(
"guid"
));
assertNotNull
(
row
.
get
(
"guid"
));
assertEquals
(
row
.
getString
(
"typeName"
),
DATABASE_TYPE
);
assertEquals
(
row
.
getString
(
"typeName"
),
DATABASE_TYPE
);
Assert
.
assertNotNull
(
row
.
get
(
"score"
));
assertNotNull
(
row
.
get
(
"score"
));
int
numRows
=
response
.
getInt
(
AtlasClient
.
COUNT
);
int
numRows
=
response
.
getInt
(
AtlasClient
.
COUNT
);
assertEquals
(
numRows
,
1
);
assertEquals
(
numRows
,
1
);
...
@@ -218,25 +211,25 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
...
@@ -218,25 +211,25 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
String
query
=
dbName
;
String
query
=
dbName
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
query
);
queryParams
.
add
(
"query"
,
query
);
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_FULL_TEXT
,
queryParams
);
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
SEARCH_FULL_TEXT
,
queryParams
);
results
=
response
.
getJSONArray
(
AtlasClient
.
RESULTS
);
results
=
response
.
getJSONArray
(
AtlasClient
.
RESULTS
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//verify passed in limits and offsets are used
//verify passed in limits and offsets are used
//higher limit and 0 offset returns all results
//higher limit and 0 offset returns all results
results
=
serviceClient
.
searchByFullText
(
query
,
10
,
0
).
getJSONArray
(
AtlasClient
.
RESULTS
);
results
=
atlasClientV1
.
searchByFullText
(
query
,
10
,
0
).
getJSONArray
(
AtlasClient
.
RESULTS
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//offset is used
//offset is used
results
=
serviceClient
.
searchByFullText
(
query
,
10
,
1
).
getJSONArray
(
AtlasClient
.
RESULTS
);
results
=
atlasClientV1
.
searchByFullText
(
query
,
10
,
1
).
getJSONArray
(
AtlasClient
.
RESULTS
);
assertEquals
(
results
.
length
(),
0
);
assertEquals
(
results
.
length
(),
0
);
//limit is used
//limit is used
results
=
serviceClient
.
searchByFullText
(
query
,
1
,
0
).
getJSONArray
(
AtlasClient
.
RESULTS
);
results
=
atlasClientV1
.
searchByFullText
(
query
,
1
,
0
).
getJSONArray
(
AtlasClient
.
RESULTS
);
assertEquals
(
results
.
length
(),
1
);
assertEquals
(
results
.
length
(),
1
);
//higher offset returns 0 results
//higher offset returns 0 results
results
=
serviceClient
.
searchByFullText
(
query
,
1
,
2
).
getJSONArray
(
AtlasClient
.
RESULTS
);
results
=
atlasClientV1
.
searchByFullText
(
query
,
1
,
2
).
getJSONArray
(
AtlasClient
.
RESULTS
);
assertEquals
(
results
.
length
(),
0
);
assertEquals
(
results
.
length
(),
0
);
}
}
...
...
webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
View file @
ec1b160a
...
@@ -76,33 +76,33 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -76,33 +76,33 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
public
void
testSubmit
()
throws
Exception
{
public
void
testSubmit
()
throws
Exception
{
for
(
HierarchicalTypeDefinition
typeDefinition
:
typeDefinitions
)
{
for
(
HierarchicalTypeDefinition
typeDefinition
:
typeDefinitions
)
{
try
{
try
{
serviceClient
.
getType
(
typeDefinition
.
typeName
);
atlasClientV1
.
getType
(
typeDefinition
.
typeName
);
}
catch
(
AtlasServiceException
ase
){
}
catch
(
AtlasServiceException
ase
){
String
typesAsJSON
=
TypesSerialization
.
toJson
(
typeDefinition
,
false
);
String
typesAsJSON
=
TypesSerialization
.
toJson
(
typeDefinition
,
false
);
System
.
out
.
println
(
"typesAsJSON = "
+
typesAsJSON
);
System
.
out
.
println
(
"typesAsJSON = "
+
typesAsJSON
);
JSONObject
response
=
serviceClient
.
callAPIWithBody
(
AtlasClient
.
API
.
CREATE_TYPE
,
typesAsJSON
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBody
(
AtlasClient
.
API
.
CREATE_TYPE
,
typesAsJSON
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
JSONArray
typesAdded
=
response
.
getJSONArray
(
AtlasClient
.
TYPES
);
JSONArray
typesAdded
=
response
.
getJSONArray
(
AtlasClient
.
TYPES
);
assertEquals
(
typesAdded
.
length
(),
1
);
assertEquals
(
typesAdded
.
length
(),
1
);
assertEquals
(
typesAdded
.
getJSONObject
(
0
).
getString
(
"name"
),
typeDefinition
.
typeName
);
assertEquals
(
typesAdded
.
getJSONObject
(
0
).
getString
(
NAME
),
typeDefinition
.
typeName
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));}
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));}
}
}
}
}
@Test
@Test
public
void
testDuplicateSubmit
()
throws
Exception
{
public
void
testDuplicateSubmit
()
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
type
=
TypesUtil
.
createClassTypeDef
(
randomString
(),
HierarchicalTypeDefinition
<
ClassType
>
type
=
TypesUtil
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
));
TypesDef
typesDef
=
TypesDef
typesDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.
of
(
type
));
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.
of
(
type
));
serviceClient
.
createType
(
typesDef
);
atlasClientV1
.
createType
(
typesDef
);
try
{
try
{
serviceClient
.
createType
(
typesDef
);
atlasClientV1
.
createType
(
typesDef
);
fail
(
"Expected 409"
);
fail
(
"Expected 409"
);
}
catch
(
AtlasServiceException
e
)
{
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
().
getStatusCode
(),
Response
.
Status
.
CONFLICT
.
getStatusCode
());
assertEquals
(
e
.
getStatus
().
getStatusCode
(),
Response
.
Status
.
CONFLICT
.
getStatusCode
());
...
@@ -113,24 +113,24 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -113,24 +113,24 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
public
void
testUpdate
()
throws
Exception
{
public
void
testUpdate
()
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
typeDefinition
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
));
List
<
String
>
typesCreated
=
serviceClient
.
createType
(
TypesSerialization
.
toJson
(
typeDefinition
,
false
));
List
<
String
>
typesCreated
=
atlasClientV1
.
createType
(
TypesSerialization
.
toJson
(
typeDefinition
,
false
));
assertEquals
(
typesCreated
.
size
(),
1
);
assertEquals
(
typesCreated
.
size
(),
1
);
assertEquals
(
typesCreated
.
get
(
0
),
typeDefinition
.
typeName
);
assertEquals
(
typesCreated
.
get
(
0
),
typeDefinition
.
typeName
);
//Add attribute description
//Add attribute description
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
typeDefinition
.
typeName
,
typeDefinition
=
TypesUtil
.
createClassTypeDef
(
typeDefinition
.
typeName
,
ImmutableSet
.<
String
>
of
(),
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
createOptionalAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
));
createOptionalAttrDef
(
DESCRIPTION
,
DataTypes
.
STRING_TYPE
));
TypesDef
typeDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
TypesDef
typeDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.
of
(
typeDefinition
));
ImmutableList
.
of
(
typeDefinition
));
List
<
String
>
typesUpdated
=
serviceClient
.
updateType
(
typeDef
);
List
<
String
>
typesUpdated
=
atlasClientV1
.
updateType
(
typeDef
);
assertEquals
(
typesUpdated
.
size
(),
1
);
assertEquals
(
typesUpdated
.
size
(),
1
);
Assert
.
assertTrue
(
typesUpdated
.
contains
(
typeDefinition
.
typeName
));
Assert
.
assertTrue
(
typesUpdated
.
contains
(
typeDefinition
.
typeName
));
TypesDef
updatedTypeDef
=
serviceClient
.
getType
(
typeDefinition
.
typeName
);
TypesDef
updatedTypeDef
=
atlasClientV1
.
getType
(
typeDefinition
.
typeName
);
assertNotNull
(
updatedTypeDef
);
assertNotNull
(
updatedTypeDef
);
HierarchicalTypeDefinition
<
ClassType
>
updatedType
=
updatedTypeDef
.
classTypesAsJavaList
().
get
(
0
);
HierarchicalTypeDefinition
<
ClassType
>
updatedType
=
updatedTypeDef
.
classTypesAsJavaList
().
get
(
0
);
...
@@ -142,7 +142,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -142,7 +142,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
for
(
HierarchicalTypeDefinition
typeDefinition
:
typeDefinitions
)
{
for
(
HierarchicalTypeDefinition
typeDefinition
:
typeDefinitions
)
{
System
.
out
.
println
(
"typeName = "
+
typeDefinition
.
typeName
);
System
.
out
.
println
(
"typeName = "
+
typeDefinition
.
typeName
);
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
typeDefinition
.
typeName
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
typeDefinition
.
typeName
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
DEFINITION
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
DEFINITION
));
...
@@ -153,7 +153,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -153,7 +153,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
List
<
HierarchicalTypeDefinition
<
ClassType
>>
hierarchicalTypeDefinitions
=
typesDef
.
classTypesAsJavaList
();
List
<
HierarchicalTypeDefinition
<
ClassType
>>
hierarchicalTypeDefinitions
=
typesDef
.
classTypesAsJavaList
();
for
(
HierarchicalTypeDefinition
<
ClassType
>
classType
:
hierarchicalTypeDefinitions
)
{
for
(
HierarchicalTypeDefinition
<
ClassType
>
classType
:
hierarchicalTypeDefinitions
)
{
for
(
AttributeDefinition
attrDef
:
classType
.
attributeDefinitions
)
{
for
(
AttributeDefinition
attrDef
:
classType
.
attributeDefinitions
)
{
if
(
"name"
.
equals
(
attrDef
.
name
))
{
if
(
NAME
.
equals
(
attrDef
.
name
))
{
assertEquals
(
attrDef
.
isIndexable
,
true
);
assertEquals
(
attrDef
.
isIndexable
,
true
);
assertEquals
(
attrDef
.
isUnique
,
true
);
assertEquals
(
attrDef
.
isUnique
,
true
);
}
}
...
@@ -164,12 +164,12 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -164,12 +164,12 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
public
void
testGetDefinitionForNonexistentType
()
throws
Exception
{
public
void
testGetDefinitionForNonexistentType
()
throws
Exception
{
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
"blah"
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
"blah"
);
}
}
@Test
(
dependsOnMethods
=
"testSubmit"
)
@Test
(
dependsOnMethods
=
"testSubmit"
)
public
void
testGetTypeNames
()
throws
Exception
{
public
void
testGetTypeNames
()
throws
Exception
{
JSONObject
response
=
serviceClient
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
(
String
[])
null
);
JSONObject
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API
.
LIST_TYPES
,
null
,
(
String
[])
null
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -190,7 +190,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -190,7 +190,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"type"
,
DataTypes
.
TypeCategory
.
TRAIT
.
name
());
queryParams
.
add
(
"type"
,
DataTypes
.
TypeCategory
.
TRAIT
.
name
());
JSONObject
response
=
serviceClient
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
LIST_TYPES
,
queryParams
);
JSONObject
response
=
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API
.
LIST_TYPES
,
queryParams
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
);
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
...
@@ -212,7 +212,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -212,7 +212,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
String
c
=
createType
(
TypesSerialization
.
toJson
(
String
c
=
createType
(
TypesSerialization
.
toJson
(
TypesUtil
.
createClassTypeDef
(
"C"
+
randomString
(),
ImmutableSet
.
of
(
a
,
b
),
attr
),
false
)).
get
(
0
);
TypesUtil
.
createClassTypeDef
(
"C"
+
randomString
(),
ImmutableSet
.
of
(
a
,
b
),
attr
),
false
)).
get
(
0
);
List
<
String
>
results
=
serviceClient
.
listTypes
(
DataTypes
.
TypeCategory
.
CLASS
,
a
,
b
);
List
<
String
>
results
=
atlasClientV1
.
listTypes
(
DataTypes
.
TypeCategory
.
CLASS
,
a
,
b
);
assertEquals
(
results
,
Arrays
.
asList
(
a1
),
"Results: "
+
results
);
assertEquals
(
results
,
Arrays
.
asList
(
a1
),
"Results: "
+
results
);
}
}
...
@@ -234,20 +234,20 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -234,20 +234,20 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
HierarchicalTypeDefinition
<
ClassType
>
databaseTypeDefinition
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
databaseTypeDefinition
=
TypesUtil
.
createClassTypeDef
(
"database"
,
ImmutableSet
.<
String
>
of
(),
.
createClassTypeDef
(
"database"
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
DESCRIPTION
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"qualifiedName"
,
DataTypes
.
STRING_TYPE
));
TypesUtil
.
createRequiredAttrDef
(
QUALIFIED_NAME
,
DataTypes
.
STRING_TYPE
));
typeDefinitions
.
add
(
databaseTypeDefinition
);
typeDefinitions
.
add
(
databaseTypeDefinition
);
HierarchicalTypeDefinition
<
ClassType
>
tableTypeDefinition
=
TypesUtil
HierarchicalTypeDefinition
<
ClassType
>
tableTypeDefinition
=
TypesUtil
.
createClassTypeDef
(
"table"
,
ImmutableSet
.<
String
>
of
(),
.
createClassTypeDef
(
"table"
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createUniqueRequiredAttrDef
(
NAME
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
DESCRIPTION
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"qualifiedName"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
QUALIFIED_NAME
,
DataTypes
.
STRING_TYPE
),
createOptionalAttrDef
(
"columnNames"
,
DataTypes
.
arrayTypeName
(
DataTypes
.
STRING_TYPE
)),
createOptionalAttrDef
(
"columnNames"
,
DataTypes
.
arrayTypeName
(
DataTypes
.
STRING_TYPE
)),
createOptionalAttrDef
(
"created"
,
DataTypes
.
DATE_TYPE
),
createOptionalAttrDef
(
"created"
,
DataTypes
.
DATE_TYPE
),
createOptionalAttrDef
(
"parameters"
,
createOptionalAttrDef
(
"parameters"
,
DataTypes
.
mapTypeName
(
DataTypes
.
STRING_TYPE
,
DataTypes
.
STRING_TYPE
)),
DataTypes
.
mapTypeName
(
DataTypes
.
STRING_TYPE
,
DataTypes
.
STRING_TYPE
)),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
),
new
AttributeDefinition
(
"database"
,
"database"
,
Multiplicity
.
REQUIRED
,
false
,
"database"
));
new
AttributeDefinition
(
"database"
,
"database"
,
Multiplicity
.
REQUIRED
,
false
,
"database"
));
typeDefinitions
.
add
(
tableTypeDefinition
);
typeDefinitions
.
add
(
tableTypeDefinition
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment