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
74e56544
Commit
74e56544
authored
Jan 10, 2018
by
Sarath Subramanian
Committed by
Madhan Neethiraj
Jan 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2349: Fix IT failures related to jackson serialization
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
cef91eb8
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
84 additions
and
35 deletions
+84
-35
AtlasClient.java
...client-v1/src/main/java/org/apache/atlas/AtlasClient.java
+25
-11
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+4
-1
pom.xml
webapp/pom.xml
+16
-0
QuickStart.java
...p/src/main/java/org/apache/atlas/examples/QuickStart.java
+6
-3
QuickStartIT.java
...src/test/java/org/apache/atlas/examples/QuickStartIT.java
+4
-3
BaseResourceIT.java
...java/org/apache/atlas/web/integration/BaseResourceIT.java
+2
-0
EntityDiscoveryJerseyResourceIT.java
...tlas/web/integration/EntityDiscoveryJerseyResourceIT.java
+3
-3
EntityJerseyResourceIT.java
.../apache/atlas/web/integration/EntityJerseyResourceIT.java
+18
-10
EntityV2JerseyResourceIT.java
...pache/atlas/web/integration/EntityV2JerseyResourceIT.java
+1
-1
MetadataDiscoveryJerseyResourceIT.java
...as/web/integration/MetadataDiscoveryJerseyResourceIT.java
+4
-2
TypesJerseyResourceIT.java
...g/apache/atlas/web/integration/TypesJerseyResourceIT.java
+1
-1
No files found.
client/client-v1/src/main/java/org/apache/atlas/AtlasClient.java
View file @
74e56544
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.google.common.annotations.VisibleForTesting
;
...
...
@@ -337,8 +338,8 @@ public class AtlasClient extends AtlasBaseClient {
* @throws AtlasServiceException
*/
public
List
<
String
>
listTypes
()
throws
AtlasServiceException
{
final
ObjectNode
json
Object
=
callAPIWithQueryParams
(
API_V1
.
LIST_TYPES
,
null
);
return
extract
Results
(
jsonObject
,
AtlasClient
.
RESULTS
,
new
ExtractOperation
<
String
,
String
>()
);
final
ObjectNode
json
Response
=
callAPIWithQueryParams
(
API_V1
.
LIST_TYPES
,
null
);
return
extract
StringList
(
jsonResponse
);
}
/**
...
...
@@ -385,12 +386,12 @@ public class AtlasClient extends AtlasBaseClient {
return
resource
;
}
});
return
extract
Results
(
response
,
AtlasClient
.
RESULTS
,
new
ExtractOperation
<
String
,
String
>()
);
return
extract
StringList
(
response
);
}
public
TypesDef
getType
(
String
typeName
)
throws
AtlasServiceException
{
ObjectNode
response
=
callAPIWithBodyAndParams
(
API_V1
.
GET_TYPE
,
null
,
typeName
);
String
typeJson
=
response
.
get
(
DEFINITION
).
asText
(
);
String
typeJson
=
AtlasType
.
toJson
(
response
.
get
(
DEFINITION
)
);
return
AtlasType
.
fromV1Json
(
typeJson
,
TypesDef
.
class
);
}
...
...
@@ -613,7 +614,7 @@ public class AtlasClient extends AtlasBaseClient {
*/
public
Referenceable
getEntity
(
String
guid
)
throws
AtlasServiceException
{
ObjectNode
jsonResponse
=
callAPIWithBodyAndParams
(
API_V1
.
GET_ENTITY
,
null
,
guid
);
String
entityInstanceDefinition
=
jsonResponse
.
get
(
AtlasClient
.
DEFINITION
).
asText
(
);
String
entityInstanceDefinition
=
AtlasType
.
toJson
(
jsonResponse
.
get
(
AtlasClient
.
DEFINITION
)
);
return
AtlasType
.
fromV1Json
(
entityInstanceDefinition
,
Referenceable
.
class
);
}
...
...
@@ -646,7 +647,7 @@ public class AtlasClient extends AtlasBaseClient {
return
resource
;
}
});
String
entityInstanceDefinition
=
jsonResponse
.
get
(
AtlasClient
.
DEFINITION
).
asText
(
);
String
entityInstanceDefinition
=
AtlasType
.
toJson
(
jsonResponse
.
get
(
AtlasClient
.
DEFINITION
)
);
return
AtlasType
.
fromV1Json
(
entityInstanceDefinition
,
Referenceable
.
class
);
}
...
...
@@ -665,7 +666,7 @@ public class AtlasClient extends AtlasBaseClient {
return
resource
;
}
});
return
extract
Results
(
jsonResponse
,
AtlasClient
.
RESULTS
,
new
ExtractOperation
<
String
,
String
>()
);
return
extract
StringList
(
jsonResponse
);
}
/**
...
...
@@ -676,7 +677,7 @@ public class AtlasClient extends AtlasBaseClient {
*/
public
List
<
String
>
listTraits
(
final
String
guid
)
throws
AtlasServiceException
{
ObjectNode
jsonResponse
=
callAPIWithBodyAndParams
(
API_V1
.
LIST_TRAITS
,
null
,
guid
,
URI_TRAITS
);
return
extract
Results
(
jsonResponse
,
AtlasClient
.
RESULTS
,
new
ExtractOperation
<
String
,
String
>()
);
return
extract
StringList
(
jsonResponse
);
}
/**
...
...
@@ -706,7 +707,7 @@ public class AtlasClient extends AtlasBaseClient {
public
Struct
getTraitDefinition
(
final
String
guid
,
final
String
traitName
)
throws
AtlasServiceException
{
ObjectNode
jsonResponse
=
callAPIWithBodyAndParams
(
API_V1
.
GET_TRAIT_DEFINITION
,
null
,
guid
,
TRAIT_DEFINITIONS
,
traitName
);
return
AtlasType
.
fromV1Json
(
jsonResponse
.
get
(
AtlasClient
.
RESULTS
).
asText
(
),
Struct
.
class
);
return
AtlasType
.
fromV1Json
(
AtlasType
.
toJson
(
jsonResponse
.
get
(
AtlasClient
.
RESULTS
)
),
Struct
.
class
);
}
protected
class
ExtractOperation
<
T
,
U
>
{
...
...
@@ -772,7 +773,7 @@ public class AtlasClient extends AtlasBaseClient {
* @return Query results
* @throws AtlasServiceException
*/
public
Array
Node
search
(
final
String
searchQuery
,
final
int
limit
,
final
int
offset
)
throws
AtlasServiceException
{
public
Json
Node
search
(
final
String
searchQuery
,
final
int
limit
,
final
int
offset
)
throws
AtlasServiceException
{
final
API
api
=
API_V1
.
SEARCH
;
ObjectNode
result
=
callAPIWithRetries
(
api
,
null
,
new
ResourceCreator
()
{
@Override
...
...
@@ -784,7 +785,7 @@ public class AtlasClient extends AtlasBaseClient {
return
resource
;
}
});
return
(
ArrayNode
)
result
.
get
(
RESULTS
);
return
result
.
get
(
RESULTS
);
}
/**
...
...
@@ -858,6 +859,19 @@ public class AtlasClient extends AtlasBaseClient {
return
(
ObjectNode
)
response
.
get
(
AtlasClient
.
RESULTS
);
}
private
List
<
String
>
extractStringList
(
ObjectNode
response
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
JsonNode
results
=
(
response
!=
null
)
?
response
.
get
(
AtlasClient
.
RESULTS
)
:
null
;
if
(
results
!=
null
&&
results
instanceof
ArrayNode
)
{
for
(
JsonNode
node
:
results
)
{
ret
.
add
(
node
.
asText
());
}
}
return
ret
;
}
// Wrapper methods for compatibility
@VisibleForTesting
public
ObjectNode
callAPIWithResource
(
API
api
,
WebResource
resource
)
throws
AtlasServiceException
{
...
...
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
74e56544
...
...
@@ -538,7 +538,10 @@ public class AtlasTypeUtil {
private
static
HashMap
getNestedTraitDetails
(
final
AtlasClassification
atlasClassification
)
{
return
new
HashMap
<
String
,
Object
>()
{{
put
(
"$typeName$"
,
atlasClassification
.
getTypeName
());
putAll
(
atlasClassification
.
getAttributes
());
if
(
MapUtils
.
isNotEmpty
(
atlasClassification
.
getAttributes
()))
{
putAll
(
atlasClassification
.
getAttributes
());
}
}};
}
...
...
webapp/pom.xml
View file @
74e56544
...
...
@@ -674,6 +674,22 @@
</resources>
</configuration>
</execution>
<execution>
<id>
copy-solr-resources
</id>
<phase>
validate
</phase>
<goals>
<goal>
copy-resources
</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/solr
</outputDirectory>
<resources>
<resource>
<directory>
${basedir}/../test-tools/src/main/resources/solr
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
...
...
webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
View file @
74e56544
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
examples
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.base.Preconditions
;
...
...
@@ -431,7 +432,9 @@ public class QuickStart {
return
new
String
[]{
"from DB_v1"
,
"DB_v1"
,
"DB_v1 where name=\"Reporting\""
,
"DB_v1 where DB_v1.name=\"Reporting\""
,
"DB_v1 name = \"Reporting\""
,
"DB_v1 DB_v1.name = \"Reporting\""
,
"DB_v1 where name=\"Reporting\" select name, owner"
,
"DB_v1 where DB_v1.name=\"Reporting\" select name, owner"
,
"DB_v1 has name"
,
"DB_v1 where DB_v1 has name"
,
"DB_v1, Table_v1"
,
"DB_v1 is JdbcAccess"
,
"DB_v1 has name"
,
"DB_v1 where DB_v1 has name"
,
// "DB_v1, Table_v1", TODO: Fix "DB, Table", Table, db; Table db works
"DB_v1 is JdbcAccess"
,
/*
"DB, hive_process has name",
"DB as db1, Table where db1.name = \"Reporting\"",
...
...
@@ -478,8 +481,8 @@ public class QuickStart {
private
void
search
()
throws
AtlasBaseException
{
try
{
for
(
String
dslQuery
:
getDSLQueries
())
{
Array
Node
results
=
metadataServiceClient
.
search
(
dslQuery
,
10
,
0
);
if
(
results
!=
null
)
{
Json
Node
results
=
metadataServiceClient
.
search
(
dslQuery
,
10
,
0
);
if
(
results
!=
null
&&
results
instanceof
ArrayNode
)
{
System
.
out
.
println
(
"query ["
+
dslQuery
+
"] returned ["
+
results
.
size
()
+
"] rows"
);
}
else
{
System
.
out
.
println
(
"query ["
+
dslQuery
+
"] failed, results:"
+
results
);
...
...
webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java
View file @
74e56544
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
examples
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
org.apache.atlas.AtlasClient
;
...
...
@@ -122,9 +123,9 @@ public class QuickStartIT extends BaseResourceIT {
String
timeDimTableId
=
getTableId
(
QuickStart
.
TIME_DIM_TABLE
);
String
salesFactDailyMVId
=
getTableId
(
QuickStart
.
SALES_FACT_DAILY_MV_TABLE
);
ObjectNode
inputGraph
=
atlasClientV1
.
getInputGraph
(
QuickStart
.
SALES_FACT_DAILY_MV_TABLE
);
ArrayNode
vertices
=
(
ArrayNode
)
inputGraph
.
get
(
"values"
).
get
(
"vertices"
);
ArrayNode
edges
=
(
ArrayNode
)
inputGraph
.
get
(
"values"
).
get
(
"edges"
);
ObjectNode
inputGraph
=
atlasClientV1
.
getInputGraph
ForEntity
(
salesFactDailyMVId
);
JsonNode
vertices
=
inputGraph
.
get
(
"values"
).
get
(
"vertices"
);
JsonNode
edges
=
inputGraph
.
get
(
"values"
).
get
(
"edges"
);
assertTrue
(
vertices
.
has
(
salesFactTableId
));
assertTrue
(
vertices
.
has
(
timeDimTableId
));
...
...
webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
View file @
74e56544
...
...
@@ -36,6 +36,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef
;
import
org.apache.atlas.notification.NotificationInterface
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.v1.model.instance.Id
;
import
org.apache.atlas.v1.model.instance.Referenceable
;
import
org.apache.atlas.v1.model.instance.Struct
;
...
...
@@ -56,6 +57,7 @@ import org.slf4j.LoggerFactory;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
...
...
webapp/src/test/java/org/apache/atlas/web/integration/EntityDiscoveryJerseyResourceIT.java
View file @
74e56544
...
...
@@ -19,7 +19,6 @@
package
org
.
apache
.
atlas
.
web
.
integration
;
import
com.sun.jersey.core.util.MultivaluedMapImpl
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult
;
import
org.apache.atlas.model.discovery.AtlasSearchResult.AtlasQueryType
;
...
...
@@ -110,10 +109,11 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals
(
searchResult
.
getEntities
().
size
(),
1
);
}
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
public
void
testSearchByDSLForUnknownType
()
throws
Exception
{
String
dslQuery
=
"from blah"
;
atlasClientV2
.
dslSearch
(
dslQuery
);
AtlasSearchResult
searchResult
=
atlasClientV2
.
dslSearch
(
dslQuery
);
//TODO: Should throw an exception, current v2 DSL doesn't handle search on unknown type
}
@Test
(
enabled
=
false
)
...
...
webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
View file @
74e56544
...
...
@@ -25,14 +25,12 @@ import com.sun.jersey.core.util.MultivaluedMapImpl;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.kafka.NotificationProvider
;
import
org.apache.atlas.model.legacy.EntityResult
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.v1.model.instance.Id
;
import
org.apache.atlas.v1.model.instance.Referenceable
;
import
org.apache.atlas.v1.model.instance.Struct
;
import
org.apache.atlas.v1.model.typedef.*
;
import
org.apache.atlas.notification.NotificationInterface
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.v1.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
...
...
@@ -49,6 +47,7 @@ import javax.ws.rs.core.MultivaluedMap;
import
javax.ws.rs.core.Response
;
import
java.util.*
;
import
static
com
.
sun
.
jersey
.
api
.
client
.
ClientResponse
.
Status
.
BAD_REQUEST
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
fail
;
...
...
@@ -269,7 +268,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
createInstance
(
databaseInstance
);
Assert
.
fail
(
"Expected AtlasServiceException"
);
}
catch
(
AtlasServiceException
e
)
{
Assert
.
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
);
Assert
.
assertEquals
(
e
.
getStatus
(),
BAD_REQUEST
);
}
}
...
...
@@ -293,14 +292,23 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
}
@Test
public
void
testSubmitEntityWithBadDateFormat
()
throws
Exception
{
public
void
testSubmitEntityWithBadDateFormat
()
{
String
dbName
=
"db"
+
randomString
();
String
tableName
=
"table"
+
randomString
();
Referenceable
hiveDBInstance
=
createHiveDBInstanceBuiltIn
(
dbName
);
Id
dbId
=
createInstance
(
hiveDBInstance
);
Referenceable
hiveTableInstance
=
createHiveTableInstanceBuiltIn
(
dbName
,
tableName
,
dbId
);
hiveTableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11"
);
Id
tableId
=
createInstance
(
hiveTableInstance
);
Id
dbId
=
null
;
try
{
dbId
=
createInstance
(
hiveDBInstance
);
Referenceable
hiveTableInstance
=
createHiveTableInstanceBuiltIn
(
dbName
,
tableName
,
dbId
);
hiveTableInstance
.
set
(
"lastAccessTime"
,
"2014-07-11"
);
createInstance
(
hiveTableInstance
);
}
catch
(
AtlasServiceException
e
)
{
// Should catch the exception
assertEquals
(
e
.
getStatus
().
getStatusCode
(),
BAD_REQUEST
.
getStatusCode
());
}
catch
(
Exception
e
)
{
// ignore
}
}
@Test
...
...
@@ -647,7 +655,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
atlasClientV1
.
addTrait
(
guid
,
traitInstance
);
fail
(
"Duplicate trait addition should've failed"
);
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
(),
ClientResponse
.
Status
.
BAD_REQUEST
);
assertEquals
(
e
.
getStatus
(),
BAD_REQUEST
);
}
}
...
...
@@ -828,7 +836,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Id
guid
=
createInstance
(
instance
);
ObjectNode
response
=
atlasClientV1
.
callAPIWithBodyAndParams
(
AtlasClient
.
API_V1
.
GET_ENTITY
,
null
,
guid
.
_getId
());
Referenceable
getReferenceable
=
AtlasType
.
fromV1Json
(
response
.
get
(
AtlasClient
.
DEFINITION
).
asText
(
),
Referenceable
.
class
);
Referenceable
getReferenceable
=
AtlasType
.
fromV1Json
(
AtlasType
.
toJson
(
response
.
get
(
AtlasClient
.
DEFINITION
)
),
Referenceable
.
class
);
Assert
.
assertEquals
(
getReferenceable
.
get
(
attrName
),
attrValue
);
}
...
...
webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
View file @
74e56544
...
...
@@ -298,7 +298,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
// }
//non-string property, update
Object
currentTime
=
new
Date
Time
(
);
Object
currentTime
=
new
Date
(
System
.
currentTimeMillis
()
);
addProperty
(
createHiveTable
().
getGuid
(),
"createTime"
,
currentTime
);
entityByGuid
=
getEntityByGuid
(
createHiveTable
().
getGuid
());
...
...
webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java
View file @
74e56544
...
...
@@ -133,16 +133,18 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
}
}
@Test
(
expectedExceptions
=
AtlasServiceException
.
class
)
@Test
public
void
testSearchByDSLForUnknownType
()
throws
Exception
{
String
dslQuery
=
"from blah"
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
dslQuery
);
atlasClientV1
.
callAPIWithQueryParams
(
AtlasClient
.
API_V1
.
SEARCH_DSL
,
queryParams
);
//TODO: Should throw an exception, current v2 DSL doesn't handle search on unknown type
}
@Test
@Test
(
enabled
=
false
)
public
void
testSearchUsingGremlin
()
throws
Exception
{
// Disabling this test, since search using Gremlin is no longer supported.
String
query
=
"g.V.has('type', '"
+
BaseResourceIT
.
HIVE_TABLE_TYPE
+
"').toList()"
;
MultivaluedMap
<
String
,
String
>
queryParams
=
new
MultivaluedMapImpl
();
queryParams
.
add
(
"query"
,
query
);
...
...
webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java
View file @
74e56544
...
...
@@ -149,7 +149,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
DEFINITION
));
Assert
.
assertNotNull
(
response
.
get
(
AtlasClient
.
REQUEST_ID
));
TypesDef
typesDef
=
AtlasType
.
fromV1Json
(
response
.
get
(
AtlasClient
.
DEFINITION
).
asText
(
),
TypesDef
.
class
);
TypesDef
typesDef
=
AtlasType
.
fromV1Json
(
AtlasType
.
toJson
(
response
.
get
(
AtlasClient
.
DEFINITION
)
),
TypesDef
.
class
);
List
<?
extends
HierarchicalTypeDefinition
>
hierarchicalTypeDefs
=
Collections
.
emptyList
();
...
...
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