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
b28ab21e
Commit
b28ab21e
authored
Jul 15, 2016
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1010 Atlas allows recreation of tags with same name (shwethags)
parent
8f229628
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
28 deletions
+63
-28
HiveHookIT.java
.../src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
+2
-2
release-log.txt
release-log.txt
+1
-0
StoreBackedTypeCacheTest.java
.../atlas/repository/typestore/StoreBackedTypeCacheTest.java
+11
-15
StoreBackedTypeCacheMetadataServiceTest.java
...tlas/service/StoreBackedTypeCacheMetadataServiceTest.java
+1
-1
TypeSystem.java
...in/java/org/apache/atlas/typesystem/types/TypeSystem.java
+9
-8
EnumTest.java
...test/java/org/apache/atlas/typesystem/types/EnumTest.java
+2
-2
TypeSystemTest.java
...ava/org/apache/atlas/typesystem/types/TypeSystemTest.java
+18
-0
TypesJerseyResourceIT.java
...org/apache/atlas/web/resources/TypesJerseyResourceIT.java
+19
-0
No files found.
addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
View file @
b28ab21e
...
@@ -1426,7 +1426,7 @@ public class HiveHookIT {
...
@@ -1426,7 +1426,7 @@ public class HiveHookIT {
assertColumnIsRegistered
(
HiveMetaStoreBridge
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
tableName
),
NAME
));
assertColumnIsRegistered
(
HiveMetaStoreBridge
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
tableName
),
NAME
));
final
String
query
=
String
.
format
(
"drop table %s "
,
tableName
);
final
String
query
=
String
.
format
(
"drop table %s "
,
tableName
);
runCommand
(
query
);
runCommand
WithDelay
(
query
,
1000
);
assertColumnIsNotRegistered
(
HiveMetaStoreBridge
assertColumnIsNotRegistered
(
HiveMetaStoreBridge
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
tableName
),
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
tableName
),
"id"
));
"id"
));
...
@@ -1537,7 +1537,7 @@ public class HiveHookIT {
...
@@ -1537,7 +1537,7 @@ public class HiveHookIT {
query
=
String
.
format
(
"drop view %s "
,
viewName
);
query
=
String
.
format
(
"drop view %s "
,
viewName
);
runCommand
(
query
);
runCommand
WithDelay
(
query
,
1000
);
assertColumnIsNotRegistered
(
HiveMetaStoreBridge
assertColumnIsNotRegistered
(
HiveMetaStoreBridge
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
viewName
),
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
viewName
),
"id"
));
"id"
));
...
...
release-log.txt
View file @
b28ab21e
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES:
ALL CHANGES:
ATLAS-1010 Atlas allows recreation of tags with same name (shwethags)
ATLAS-990 Hive Import metadata script fails with auth exception (nixonrodrigues via shwethags)
ATLAS-990 Hive Import metadata script fails with auth exception (nixonrodrigues via shwethags)
ATLAS-998 determine HA mode from property atlas.server.ids, instead of atlas.server.ha.enabled (madhan.neethiraj via shwethags)
ATLAS-998 determine HA mode from property atlas.server.ids, instead of atlas.server.ha.enabled (madhan.neethiraj via shwethags)
ATLAS-986 Ability to differentiate business catalog terms from traits (sumasai,svimal2106 via shwethags)
ATLAS-986 Ability to differentiate business catalog terms from traits (sumasai,svimal2106 via shwethags)
...
...
repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java
View file @
b28ab21e
...
@@ -17,11 +17,10 @@
...
@@ -17,11 +17,10 @@
*/
*/
package
org
.
apache
.
atlas
.
repository
.
typestore
;
package
org
.
apache
.
atlas
.
repository
.
typestore
;
import
java.util.HashMap
;
import
com.google.common.collect.ImmutableList
;
import
java.util.Map
;
import
com.google.common.collect.ImmutableSet
;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
javax.inject.Inject
;
import
com.thinkaurelius.titan.core.util.TitanCleanup
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.RepositoryMetadataModule
;
import
org.apache.atlas.RepositoryMetadataModule
;
import
org.apache.atlas.TestUtils
;
import
org.apache.atlas.TestUtils
;
...
@@ -41,16 +40,16 @@ import org.testng.annotations.BeforeMethod;
...
@@ -41,16 +40,16 @@ import org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
com.google.common.collect.ImmutableList
;
import
javax.inject.Inject
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.HashMap
;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
java.util.Map
;
import
com.thinkaurelius.titan.core.util.TitanCleanup
;
/**
/**
* Unit test for {@link StoreBackedTypeCache}
* Unit test for {@link StoreBackedTypeCache}
*/
*/
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
@Test
(
enabled
=
false
)
public
class
StoreBackedTypeCacheTest
{
public
class
StoreBackedTypeCacheTest
{
@Inject
@Inject
...
@@ -70,6 +69,7 @@ public class StoreBackedTypeCacheTest {
...
@@ -70,6 +69,7 @@ public class StoreBackedTypeCacheTest {
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
ts
=
TypeSystem
.
getInstance
();
ts
=
TypeSystem
.
getInstance
();
ts
.
reset
();
ts
.
reset
();
ts
.
setTypeCache
(
typeCache
);
// Populate the type store for testing.
// Populate the type store for testing.
TestUtils
.
defineDeptEmployeeTypes
(
ts
);
TestUtils
.
defineDeptEmployeeTypes
(
ts
);
...
@@ -103,16 +103,15 @@ public class StoreBackedTypeCacheTest {
...
@@ -103,16 +103,15 @@ public class StoreBackedTypeCacheTest {
@BeforeMethod
@BeforeMethod
public
void
setupTestMethod
()
throws
Exception
{
public
void
setupTestMethod
()
throws
Exception
{
t
ypeCache
.
clear
();
t
s
.
reset
();
}
}
@Test
public
void
testGetClassType
()
throws
Exception
{
public
void
testGetClassType
()
throws
Exception
{
for
(
Map
.
Entry
<
String
,
ClassType
>
typeEntry
:
classTypesToTest
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
ClassType
>
typeEntry
:
classTypesToTest
.
entrySet
())
{
// Not cached yet
// Not cached yet
Assert
.
assertFalse
(
typeCache
.
isCachedInMemory
(
typeEntry
.
getKey
()));
Assert
.
assertFalse
(
typeCache
.
isCachedInMemory
(
typeEntry
.
getKey
()));
IDataType
dataType
=
t
ypeCache
.
get
(
typeEntry
.
getKey
());
IDataType
dataType
=
t
s
.
getDataType
(
IDataType
.
class
,
typeEntry
.
getKey
());
// Verify the type is now cached.
// Verify the type is now cached.
Assert
.
assertTrue
(
typeCache
.
isCachedInMemory
(
typeEntry
.
getKey
()));
Assert
.
assertTrue
(
typeCache
.
isCachedInMemory
(
typeEntry
.
getKey
()));
...
@@ -123,7 +122,6 @@ public class StoreBackedTypeCacheTest {
...
@@ -123,7 +122,6 @@ public class StoreBackedTypeCacheTest {
}
}
}
}
@Test
public
void
testHasClassType
()
throws
Exception
{
public
void
testHasClassType
()
throws
Exception
{
for
(
Map
.
Entry
<
String
,
ClassType
>
typeEntry
:
classTypesToTest
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
ClassType
>
typeEntry
:
classTypesToTest
.
entrySet
())
{
// Not cached yet
// Not cached yet
...
@@ -138,7 +136,6 @@ public class StoreBackedTypeCacheTest {
...
@@ -138,7 +136,6 @@ public class StoreBackedTypeCacheTest {
}
}
}
}
@Test
public
void
testGetTraitType
()
throws
Exception
{
public
void
testGetTraitType
()
throws
Exception
{
ImmutableList
<
String
>
traitNames
=
ts
.
getTypeNamesByCategory
(
TypeCategory
.
TRAIT
);
ImmutableList
<
String
>
traitNames
=
ts
.
getTypeNamesByCategory
(
TypeCategory
.
TRAIT
);
for
(
String
traitTypeName
:
traitNames
)
{
for
(
String
traitTypeName
:
traitNames
)
{
...
@@ -156,7 +153,6 @@ public class StoreBackedTypeCacheTest {
...
@@ -156,7 +153,6 @@ public class StoreBackedTypeCacheTest {
}
}
}
}
@Test
public
void
testHasTraitType
()
throws
Exception
{
public
void
testHasTraitType
()
throws
Exception
{
ImmutableList
<
String
>
traitNames
=
ts
.
getTypeNamesByCategory
(
TypeCategory
.
TRAIT
);
ImmutableList
<
String
>
traitNames
=
ts
.
getTypeNamesByCategory
(
TypeCategory
.
TRAIT
);
for
(
String
traitTypeName
:
traitNames
)
{
for
(
String
traitTypeName
:
traitNames
)
{
...
...
repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java
View file @
b28ab21e
...
@@ -43,6 +43,7 @@ import com.thinkaurelius.titan.core.util.TitanCleanup;
...
@@ -43,6 +43,7 @@ import com.thinkaurelius.titan.core.util.TitanCleanup;
* which has type cache implementation class set to {@link StoreBackedTypeCache}.
* which has type cache implementation class set to {@link StoreBackedTypeCache}.
*/
*/
@Guice
(
modules
=
StoreBackedTypeCacheTestModule
.
class
)
@Guice
(
modules
=
StoreBackedTypeCacheTestModule
.
class
)
@Test
(
enabled
=
false
)
public
class
StoreBackedTypeCacheMetadataServiceTest
public
class
StoreBackedTypeCacheMetadataServiceTest
{
{
@Inject
@Inject
...
@@ -90,7 +91,6 @@ public class StoreBackedTypeCacheMetadataServiceTest
...
@@ -90,7 +91,6 @@ public class StoreBackedTypeCacheMetadataServiceTest
}
}
}
}
@Test
public
void
testIt
()
throws
Exception
{
public
void
testIt
()
throws
Exception
{
Assert
.
assertTrue
(
typeCache
instanceof
StoreBackedTypeCache
);
Assert
.
assertTrue
(
typeCache
instanceof
StoreBackedTypeCache
);
StoreBackedTypeCache
storeBackedCache
=
(
StoreBackedTypeCache
)
typeCache
;
StoreBackedTypeCache
storeBackedCache
=
(
StoreBackedTypeCache
)
typeCache
;
...
...
typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
View file @
b28ab21e
...
@@ -342,7 +342,6 @@ public class TypeSystem {
...
@@ -342,7 +342,6 @@ public class TypeSystem {
*/
*/
public
void
commitTypes
(
Map
<
String
,
IDataType
>
typesAdded
)
throws
AtlasException
{
public
void
commitTypes
(
Map
<
String
,
IDataType
>
typesAdded
)
throws
AtlasException
{
for
(
Map
.
Entry
<
String
,
IDataType
>
typeEntry
:
typesAdded
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
IDataType
>
typeEntry
:
typesAdded
.
entrySet
())
{
String
typeName
=
typeEntry
.
getKey
();
IDataType
type
=
typeEntry
.
getValue
();
IDataType
type
=
typeEntry
.
getValue
();
//Add/replace the new type in the typesystem
//Add/replace the new type in the typesystem
typeCache
.
put
(
type
);
typeCache
.
put
(
type
);
...
@@ -378,7 +377,6 @@ public class TypeSystem {
...
@@ -378,7 +377,6 @@ public class TypeSystem {
}
}
private
IDataType
dataType
(
String
name
)
throws
AtlasException
{
private
IDataType
dataType
(
String
name
)
throws
AtlasException
{
if
(
transientTypes
.
containsKey
(
name
))
{
if
(
transientTypes
.
containsKey
(
name
))
{
return
transientTypes
.
get
(
name
);
return
transientTypes
.
get
(
name
);
}
}
...
@@ -394,7 +392,7 @@ public class TypeSystem {
...
@@ -394,7 +392,7 @@ public class TypeSystem {
private
void
validateAndSetupShallowTypes
(
boolean
update
)
throws
AtlasException
{
private
void
validateAndSetupShallowTypes
(
boolean
update
)
throws
AtlasException
{
for
(
EnumTypeDefinition
eDef
:
enumDefs
)
{
for
(
EnumTypeDefinition
eDef
:
enumDefs
)
{
assert
eDef
.
name
!=
null
;
assert
eDef
.
name
!=
null
;
if
(!
update
&&
(
transientTypes
.
containsKey
(
eDef
.
name
)
||
isRegistered
(
eDef
.
name
)
))
{
if
(!
update
&&
isRegistered
(
eDef
.
name
))
{
throw
new
AtlasException
(
String
.
format
(
"Redefinition of type %s not supported"
,
eDef
.
name
));
throw
new
AtlasException
(
String
.
format
(
"Redefinition of type %s not supported"
,
eDef
.
name
));
}
}
...
@@ -404,7 +402,7 @@ public class TypeSystem {
...
@@ -404,7 +402,7 @@ public class TypeSystem {
for
(
StructTypeDefinition
sDef
:
structDefs
)
{
for
(
StructTypeDefinition
sDef
:
structDefs
)
{
assert
sDef
.
typeName
!=
null
;
assert
sDef
.
typeName
!=
null
;
if
(!
update
&&
(
transientTypes
.
containsKey
(
sDef
.
typeName
)
||
isRegistered
(
sDef
.
typeName
)
))
{
if
(!
update
&&
isRegistered
(
sDef
.
typeName
))
{
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
sDef
.
typeName
));
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
sDef
.
typeName
));
}
}
StructType
sT
=
new
StructType
(
this
,
sDef
.
typeName
,
sDef
.
typeDescription
,
sDef
.
attributeDefinitions
.
length
);
StructType
sT
=
new
StructType
(
this
,
sDef
.
typeName
,
sDef
.
typeDescription
,
sDef
.
attributeDefinitions
.
length
);
...
@@ -414,8 +412,7 @@ public class TypeSystem {
...
@@ -414,8 +412,7 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
TraitType
>
traitDef
:
traitDefs
)
{
for
(
HierarchicalTypeDefinition
<
TraitType
>
traitDef
:
traitDefs
)
{
assert
traitDef
.
typeName
!=
null
;
assert
traitDef
.
typeName
!=
null
;
if
(!
update
&&
if
(!
update
&&
isRegistered
(
traitDef
.
typeName
))
{
(
transientTypes
.
containsKey
(
traitDef
.
typeName
)
||
isRegistered
(
traitDef
.
typeName
)))
{
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
traitDef
.
typeName
));
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
traitDef
.
typeName
));
}
}
TraitType
tT
=
new
TraitType
(
this
,
traitDef
.
typeName
,
traitDef
.
typeDescription
,
traitDef
.
superTypes
,
TraitType
tT
=
new
TraitType
(
this
,
traitDef
.
typeName
,
traitDef
.
typeDescription
,
traitDef
.
superTypes
,
...
@@ -426,8 +423,7 @@ public class TypeSystem {
...
@@ -426,8 +423,7 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
ClassType
>
classDef
:
classDefs
)
{
for
(
HierarchicalTypeDefinition
<
ClassType
>
classDef
:
classDefs
)
{
assert
classDef
.
typeName
!=
null
;
assert
classDef
.
typeName
!=
null
;
if
(!
update
&&
if
(!
update
&&
isRegistered
(
classDef
.
typeName
))
{
(
transientTypes
.
containsKey
(
classDef
.
typeName
)
||
isRegistered
(
classDef
.
typeName
)))
{
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
classDef
.
typeName
));
throw
new
TypeExistsException
(
String
.
format
(
"Cannot redefine type %s"
,
classDef
.
typeName
));
}
}
...
@@ -438,6 +434,11 @@ public class TypeSystem {
...
@@ -438,6 +434,11 @@ public class TypeSystem {
}
}
}
}
@Override
public
boolean
isRegistered
(
String
typeName
)
throws
AtlasException
{
return
transientTypes
.
containsKey
(
typeName
)
||
TypeSystem
.
this
.
isRegistered
(
typeName
);
}
private
<
U
extends
HierarchicalType
>
void
validateSuperTypes
(
Class
<
U
>
cls
,
HierarchicalTypeDefinition
<
U
>
def
)
private
<
U
extends
HierarchicalType
>
void
validateSuperTypes
(
Class
<
U
>
cls
,
HierarchicalTypeDefinition
<
U
>
def
)
throws
AtlasException
{
throws
AtlasException
{
for
(
String
superTypeName
:
def
.
superTypes
)
{
for
(
String
superTypeName
:
def
.
superTypes
)
{
...
...
typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java
View file @
b28ab21e
...
@@ -169,7 +169,7 @@ public class EnumTest extends BaseTest {
...
@@ -169,7 +169,7 @@ public class EnumTest extends BaseTest {
public
void
testStruct
()
throws
AtlasException
{
public
void
testStruct
()
throws
AtlasException
{
TypeSystem
ts
=
getTypeSystem
();
TypeSystem
ts
=
getTypeSystem
();
defineEnums
(
ts
);
defineEnums
(
ts
);
StructType
structType
=
ts
.
defineStructType
(
"t
3
"
,
true
,
createRequiredAttrDef
(
"a"
,
DataTypes
.
INT_TYPE
),
StructType
structType
=
ts
.
defineStructType
(
"t
s
"
,
true
,
createRequiredAttrDef
(
"a"
,
DataTypes
.
INT_TYPE
),
createOptionalAttrDef
(
"b"
,
DataTypes
.
BOOLEAN_TYPE
),
createOptionalAttrDef
(
"c"
,
DataTypes
.
BYTE_TYPE
),
createOptionalAttrDef
(
"b"
,
DataTypes
.
BOOLEAN_TYPE
),
createOptionalAttrDef
(
"c"
,
DataTypes
.
BYTE_TYPE
),
createOptionalAttrDef
(
"d"
,
DataTypes
.
SHORT_TYPE
),
createOptionalAttrDef
(
"d"
,
DataTypes
.
SHORT_TYPE
),
createOptionalAttrDef
(
"enum1"
,
ts
.
getDataType
(
EnumType
.
class
,
"HiveObjectType"
)),
createOptionalAttrDef
(
"enum1"
,
ts
.
getDataType
(
EnumType
.
class
,
"HiveObjectType"
)),
...
@@ -186,7 +186,7 @@ public class EnumTest extends BaseTest {
...
@@ -186,7 +186,7 @@ public class EnumTest extends BaseTest {
createOptionalAttrDef
(
"o"
,
ts
.
defineMapType
(
DataTypes
.
STRING_TYPE
,
DataTypes
.
DOUBLE_TYPE
)),
createOptionalAttrDef
(
"o"
,
ts
.
defineMapType
(
DataTypes
.
STRING_TYPE
,
DataTypes
.
DOUBLE_TYPE
)),
createOptionalAttrDef
(
"enum4"
,
ts
.
getDataType
(
EnumType
.
class
,
"LockLevel"
)));
createOptionalAttrDef
(
"enum4"
,
ts
.
getDataType
(
EnumType
.
class
,
"LockLevel"
)));
Struct
s
=
createStructWithEnum
(
"t
3
"
);
Struct
s
=
createStructWithEnum
(
"t
s
"
);
ITypedStruct
typedS
=
structType
.
convert
(
s
,
Multiplicity
.
REQUIRED
);
ITypedStruct
typedS
=
structType
.
convert
(
s
,
Multiplicity
.
REQUIRED
);
Assert
.
assertEquals
(
typedS
.
toString
(),
"{\n"
+
Assert
.
assertEquals
(
typedS
.
toString
(),
"{\n"
+
"\ta : \t1\n"
+
"\ta : \t1\n"
+
...
...
typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
View file @
b28ab21e
...
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList;
...
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.typesystem.exception.TypeExistsException
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.testng.Assert
;
import
org.testng.Assert
;
...
@@ -41,6 +42,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAt
...
@@ -41,6 +42,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAt
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createTraitTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createTraitTypeDef
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
public
class
TypeSystemTest
extends
BaseTest
{
public
class
TypeSystemTest
extends
BaseTest
{
...
@@ -266,4 +268,20 @@ public class TypeSystemTest extends BaseTest {
...
@@ -266,4 +268,20 @@ public class TypeSystemTest extends BaseTest {
ClassType
dataType
=
getTypeSystem
().
getDataType
(
ClassType
.
class
,
"MyNewAnnotation"
);
ClassType
dataType
=
getTypeSystem
().
getDataType
(
ClassType
.
class
,
"MyNewAnnotation"
);
Assert
.
assertTrue
(
dataType
.
fieldMapping
.
fields
.
containsKey
(
"inheritedAttribute"
));
Assert
.
assertTrue
(
dataType
.
fieldMapping
.
fields
.
containsKey
(
"inheritedAttribute"
));
}
}
@Test
public
void
testDuplicateTypenames
()
throws
Exception
{
TypeSystem
typeSystem
=
getTypeSystem
();
HierarchicalTypeDefinition
<
TraitType
>
trait
=
TypesUtil
.
createTraitTypeDef
(
random
(),
"description"
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createRequiredAttrDef
(
"type"
,
DataTypes
.
STRING_TYPE
));
typeSystem
.
defineTraitType
(
trait
);
try
{
typeSystem
.
defineTraitType
(
trait
);
fail
(
"Expected TypeExistsException"
);
}
catch
(
TypeExistsException
e
)
{
//expected
}
}
}
}
webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
View file @
b28ab21e
...
@@ -24,6 +24,7 @@ import com.sun.jersey.api.client.ClientResponse;
...
@@ -24,6 +24,7 @@ import com.sun.jersey.api.client.ClientResponse;
import
com.sun.jersey.api.client.WebResource
;
import
com.sun.jersey.api.client.WebResource
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.typesystem.TypesDef
;
import
org.apache.atlas.typesystem.TypesDef
;
import
org.apache.atlas.typesystem.json.TypesSerialization
;
import
org.apache.atlas.typesystem.json.TypesSerialization
;
import
org.apache.atlas.typesystem.json.TypesSerialization
$
;
import
org.apache.atlas.typesystem.json.TypesSerialization
$
;
...
@@ -51,6 +52,7 @@ import java.util.ArrayList;
...
@@ -51,6 +52,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
fail
;
/**
/**
* Integration test for types jersey resource.
* Integration test for types jersey resource.
...
@@ -95,6 +97,23 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
...
@@ -95,6 +97,23 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
}
}
@Test
@Test
public
void
testDuplicateSubmit
()
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
type
=
TypesUtil
.
createClassTypeDef
(
randomString
(),
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
TypesDef
typesDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(),
ImmutableList
.
of
(
type
));
serviceClient
.
createType
(
typesDef
);
try
{
serviceClient
.
createType
(
typesDef
);
fail
(
"Expected 409"
);
}
catch
(
AtlasServiceException
e
)
{
assertEquals
(
e
.
getStatus
().
getStatusCode
(),
Response
.
Status
.
CONFLICT
.
getStatusCode
());
}
}
@Test
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
(),
...
...
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