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
938af9ee
Commit
938af9ee
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1550: fix for unit test failure in TypeSystemTest.testDuplicateTypenames()
parent
3b4ccb7f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
TypeSystem.java
...in/java/org/apache/atlas/typesystem/types/TypeSystem.java
+22
-4
TypeSystemTest.java
...ava/org/apache/atlas/typesystem/types/TypeSystemTest.java
+20
-1
No files found.
typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
View file @
938af9ee
...
...
@@ -412,10 +412,14 @@ public class TypeSystem {
private
void
validateAndSetupShallowTypes
(
boolean
update
)
throws
AtlasException
{
for
(
EnumTypeDefinition
eDef
:
enumDefs
)
{
assert
eDef
.
name
!=
null
;
if
(!
update
&&
isRegistered
(
eDef
.
name
))
{
if
(!
update
)
{
if
(
TypeSystem
.
this
.
isRegistered
(
eDef
.
name
))
{
throw
new
TypeExistsException
(
String
.
format
(
"Redefinition of type %s is not supported"
,
eDef
.
name
));
}
else
if
(
transientTypes
.
containsKey
(
eDef
.
name
))
{
LOG
.
warn
(
"Found duplicate definition of type {}. Ignoring.."
,
eDef
.
name
);
continue
;
}
}
EnumType
eT
=
new
EnumType
(
this
,
eDef
.
name
,
eDef
.
description
,
eDef
.
version
,
eDef
.
enumValues
);
transientTypes
.
put
(
eDef
.
name
,
eT
);
...
...
@@ -423,10 +427,15 @@ public class TypeSystem {
for
(
StructTypeDefinition
sDef
:
structDefs
)
{
assert
sDef
.
typeName
!=
null
;
if
(!
update
&&
isRegistered
(
sDef
.
typeName
))
{
if
(!
update
)
{
if
(
TypeSystem
.
this
.
isRegistered
(
sDef
.
typeName
))
{
throw
new
TypeExistsException
(
String
.
format
(
"Redefinition of type %s is not supported"
,
sDef
.
typeName
));
}
else
if
(
transientTypes
.
containsKey
(
sDef
.
typeName
))
{
LOG
.
warn
(
"Found duplicate definition of type {}. Ignoring.."
,
sDef
.
typeName
);
continue
;
}
}
StructType
sT
=
new
StructType
(
this
,
sDef
.
typeName
,
sDef
.
typeDescription
,
sDef
.
typeVersion
,
sDef
.
attributeDefinitions
.
length
);
structNameToDefMap
.
put
(
sDef
.
typeName
,
sDef
);
transientTypes
.
put
(
sDef
.
typeName
,
sT
);
...
...
@@ -434,10 +443,15 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
TraitType
>
traitDef
:
traitDefs
)
{
assert
traitDef
.
typeName
!=
null
;
if
(!
update
&&
isRegistered
(
traitDef
.
typeName
))
{
if
(!
update
)
{
if
(
TypeSystem
.
this
.
isRegistered
(
traitDef
.
typeName
))
{
throw
new
TypeExistsException
(
String
.
format
(
"Redefinition of type %s is not supported"
,
traitDef
.
typeName
));
}
else
if
(
transientTypes
.
containsKey
(
traitDef
.
typeName
))
{
LOG
.
warn
(
"Found duplicate definition of type {}. Ignoring.."
,
traitDef
.
typeName
);
continue
;
}
}
TraitType
tT
=
new
TraitType
(
this
,
traitDef
.
typeName
,
traitDef
.
typeDescription
,
traitDef
.
typeVersion
,
traitDef
.
superTypes
,
traitDef
.
attributeDefinitions
.
length
);
traitNameToDefMap
.
put
(
traitDef
.
typeName
,
traitDef
);
...
...
@@ -446,10 +460,14 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
ClassType
>
classDef
:
classDefs
)
{
assert
classDef
.
typeName
!=
null
;
if
(!
update
&&
isRegistered
(
classDef
.
typeName
))
{
if
(!
update
)
{
if
(
TypeSystem
.
this
.
isRegistered
(
classDef
.
typeName
))
{
throw
new
TypeExistsException
(
String
.
format
(
"Redefinition of type %s is not supported"
,
classDef
.
typeName
));
}
else
if
(
transientTypes
.
containsKey
(
classDef
.
typeName
))
{
LOG
.
warn
(
"Found duplicate definition of type {}. Ignoring.."
,
classDef
.
typeName
);
continue
;
}
}
ClassType
cT
=
new
ClassType
(
this
,
classDef
.
typeName
,
classDef
.
typeDescription
,
classDef
.
typeVersion
,
classDef
.
superTypes
,
classDef
.
attributeDefinitions
.
length
);
...
...
This diff is collapsed.
Click to expand it.
typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
View file @
938af9ee
...
...
@@ -275,7 +275,7 @@ public class TypeSystemTest extends BaseTest {
}
@Test
public
void
test
DuplicateTypenames
()
throws
Exception
{
public
void
test
RedefineExistingType
()
throws
Exception
{
TypeSystem
typeSystem
=
getTypeSystem
();
HierarchicalTypeDefinition
<
TraitType
>
trait
=
TypesUtil
.
createTraitTypeDef
(
random
(),
"description"
,
ImmutableSet
.<
String
>
of
(),
...
...
@@ -290,6 +290,25 @@ public class TypeSystemTest extends BaseTest {
}
}
@Test
public
void
testDuplicateNewTypenames
()
throws
Exception
{
TypeSystem
typeSystem
=
getTypeSystem
();
HierarchicalTypeDefinition
<
TraitType
>
trait1
=
TypesUtil
.
createTraitTypeDef
(
random
(),
"description"
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
));
// create another trait with the same name
HierarchicalTypeDefinition
<
TraitType
>
trait2
=
TypesUtil
.
createTraitTypeDef
(
trait1
.
typeName
,
"description"
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
));
try
{
typeSystem
.
defineTypes
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.
of
(
trait1
,
trait2
),
ImmutableList
.<
HierarchicalTypeDefinition
<
ClassType
>>
of
());
}
catch
(
AtlasException
e
)
{
fail
(
"Exception unexpected"
);
}
}
@Test
(
expectedExceptions
=
ValueConversionException
.
class
)
public
void
testConvertInvalidDate
()
throws
Exception
{
DataTypes
.
DATE_TYPE
.
convert
(
""
,
Multiplicity
.
OPTIONAL
);
...
...
This diff is collapsed.
Click to expand it.
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