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
666d92e9
Commit
666d92e9
authored
Jun 05, 2015
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed add trait check
parent
ec046d19
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
DefaultMetadataService.java
...ache/hadoop/metadata/services/DefaultMetadataService.java
+1
-1
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+11
-7
No files found.
repository/src/main/java/org/apache/hadoop/metadata/services/DefaultMetadataService.java
View file @
666d92e9
...
...
@@ -332,7 +332,7 @@ public class DefaultMetadataService implements MetadataService {
Preconditions
.
checkArgument
(
typeSystem
.
isRegistered
(
traitName
),
"trait=%s should be defined in type system before it can be added"
,
traitName
);
// ensure trait is not already defined
Preconditions
.
checkArgument
(
getTraitNames
(
guid
).
contains
(
traitName
),
Preconditions
.
checkArgument
(
!
getTraitNames
(
guid
).
contains
(
traitName
),
"trait=%s is already defined for entity=%s"
,
traitName
,
guid
);
repository
.
addTrait
(
guid
,
traitInstance
);
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/EntityJerseyResourceIT.java
View file @
666d92e9
...
...
@@ -64,6 +64,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
private
Referenceable
tableInstance
;
private
Id
tableId
;
private
String
traitName
;
@BeforeClass
public
void
setUp
()
throws
Exception
{
...
...
@@ -120,8 +121,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
tableId
=
createInstance
(
tableInstance
);
Assert
.
fail
(
"Was expecting an exception here "
);
}
catch
(
MetadataServiceException
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
()
.
contains
(
"\"error\":\"Cannot convert value '2014-07-11' to datatype date\""
));
Assert
.
assertTrue
(
e
.
getMessage
()
.
contains
(
"\"error\":\"Cannot convert value '2014-07-11' to datatype date\""
));
}
}
...
...
@@ -315,8 +316,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
private
void
addNewType
()
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
testTypeDefinition
=
TypesUtil
.
createClassTypeDef
(
"test"
,
ImmutableList
.<
String
>
of
(),
TypesUtil
.
createClassTypeDef
(
"test"
,
ImmutableList
.<
String
>
of
(),
TypesUtil
.
createRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
TypesUtil
.
createRequiredAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
));
...
...
@@ -349,7 +349,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testGetTraitNames"
)
public
void
testAddTrait
()
throws
Exception
{
final
String
traitName
=
"PII_Trait"
;
traitName
=
"PII_Trait"
+
randomString
()
;
HierarchicalTypeDefinition
<
TraitType
>
piiTrait
=
TypesUtil
.
createTraitTypeDef
(
traitName
,
ImmutableList
.<
String
>
of
());
String
traitDefinitionAsJSON
=
TypesSerialization
$
.
MODULE
$
.
toJson
(
piiTrait
,
true
);
...
...
@@ -469,7 +469,6 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
@Test
(
dependsOnMethods
=
"testAddTrait"
)
public
void
testDeleteTrait
()
throws
Exception
{
final
String
traitName
=
"PII_Trait"
;
final
String
guid
=
tableId
.
_getId
();
ClientResponse
clientResponse
=
service
...
...
@@ -510,7 +509,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
JSONObject
response
=
new
JSONObject
(
responseAsString
);
Assert
.
assertNotNull
(
response
.
get
(
MetadataServiceClient
.
ERROR
));
Assert
.
assertEquals
(
response
.
getString
(
MetadataServiceClient
.
ERROR
),
"trait="
+
traitName
+
" should be defined in type system before it can be deleted"
);
Assert
.
assertEquals
(
response
.
getString
(
MetadataServiceClient
.
ERROR
),
"trait="
+
traitName
+
" should be defined in type system before it can be deleted"
);
Assert
.
assertNotNull
(
response
.
get
(
MetadataServiceClient
.
STACKTRACE
));
}
...
...
@@ -518,6 +518,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
return
RandomStringUtils
.
random
(
10
);
}
private
String
randomString
()
{
return
RandomStringUtils
.
randomAlphanumeric
(
10
);
}
@Test
public
void
testUTF8
()
throws
Exception
{
String
classType
=
random
();
...
...
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