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
c9e58e0a
Commit
c9e58e0a
authored
Nov 01, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1233 UnitTests for the TypeDefStores (apoorvnaik via sumasai)
parent
0b85d5a0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
10 deletions
+140
-10
pom.xml
intg/pom.xml
+17
-0
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+100
-0
TestUtilsV2.java
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
+0
-0
release-log.txt
release-log.txt
+1
-0
pom.xml
repository/pom.xml
+7
-0
TypeDefSorter.java
...ry/src/main/java/org/apache/atlas/util/TypeDefSorter.java
+15
-10
AtlasTypeDefGraphStoreTest.java
...as/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+0
-0
No files found.
intg/pom.xml
View file @
c9e58e0a
...
...
@@ -67,4 +67,21 @@
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<version>
2.4
</version>
<executions>
<execution>
<goals>
<goal>
test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
c9e58e0a
...
...
@@ -17,11 +17,22 @@
*/
package
org
.
apache
.
atlas
.
type
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
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.AtlasEnumDef.AtlasEnumElementDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -91,5 +102,94 @@ public class AtlasTypeUtil {
referencedTypeNames
.
add
(
typeName
);
}
}
}
public
static
AtlasAttributeDef
createOptionalAttrDef
(
String
name
,
AtlasType
dataType
)
{
return
new
AtlasAttributeDef
(
name
,
dataType
.
getTypeName
(),
true
,
Cardinality
.
SINGLE
,
0
,
1
,
true
,
false
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasAttributeDef
createOptionalAttrDef
(
String
name
,
String
dataType
)
{
return
new
AtlasAttributeDef
(
name
,
dataType
,
true
,
Cardinality
.
SINGLE
,
0
,
1
,
true
,
false
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasAttributeDef
createRequiredAttrDef
(
String
name
,
String
dataType
)
{
return
new
AtlasAttributeDef
(
name
,
dataType
,
false
,
Cardinality
.
SINGLE
,
1
,
1
,
false
,
false
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasAttributeDef
createUniqueRequiredAttrDef
(
String
name
,
AtlasType
dataType
)
{
return
new
AtlasAttributeDef
(
name
,
dataType
.
getTypeName
(),
false
,
Cardinality
.
SINGLE
,
1
,
1
,
true
,
true
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasAttributeDef
createUniqueRequiredAttrDef
(
String
name
,
String
typeName
)
{
return
new
AtlasAttributeDef
(
name
,
typeName
,
false
,
Cardinality
.
SINGLE
,
1
,
1
,
true
,
true
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasAttributeDef
createRequiredAttrDef
(
String
name
,
AtlasType
dataType
)
{
return
new
AtlasAttributeDef
(
name
,
dataType
.
getTypeName
(),
false
,
Cardinality
.
SINGLE
,
1
,
1
,
false
,
false
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
());
}
public
static
AtlasEnumDef
createEnumTypeDef
(
String
name
,
String
description
,
AtlasEnumElementDef
...
enumValues
)
{
return
new
AtlasEnumDef
(
name
,
description
,
"1.0"
,
Arrays
.
asList
(
enumValues
));
}
public
static
AtlasClassificationDef
createTraitTypeDef
(
String
name
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
createTraitTypeDef
(
name
,
null
,
superTypes
,
attrDefs
);
}
public
static
AtlasClassificationDef
createTraitTypeDef
(
String
name
,
String
description
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
createTraitTypeDef
(
name
,
description
,
"1.0"
,
superTypes
,
attrDefs
);
}
public
static
AtlasClassificationDef
createTraitTypeDef
(
String
name
,
String
description
,
String
version
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
new
AtlasClassificationDef
(
name
,
description
,
"1.0"
,
Arrays
.
asList
(
attrDefs
),
superTypes
);
}
public
static
AtlasStructDef
createStructTypeDef
(
String
name
,
AtlasAttributeDef
...
attrDefs
)
{
return
createStructTypeDef
(
name
,
null
,
attrDefs
);
}
public
static
AtlasStructDef
createStructTypeDef
(
String
name
,
String
description
,
AtlasAttributeDef
...
attrDefs
)
{
return
new
AtlasStructDef
(
name
,
description
,
"1.0"
,
Arrays
.
asList
(
attrDefs
));
}
public
static
AtlasEntityDef
createClassTypeDef
(
String
name
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
createClassTypeDef
(
name
,
null
,
"1.0"
,
superTypes
,
attrDefs
);
}
public
static
AtlasEntityDef
createClassTypeDef
(
String
name
,
String
description
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
createClassTypeDef
(
name
,
description
,
"1.0"
,
superTypes
,
attrDefs
);
}
public
static
AtlasEntityDef
createClassTypeDef
(
String
name
,
String
description
,
String
version
,
ImmutableSet
<
String
>
superTypes
,
AtlasAttributeDef
...
attrDefs
)
{
return
new
AtlasEntityDef
(
name
,
description
,
"1.0"
,
Arrays
.
asList
(
attrDefs
),
superTypes
);
}
public
static
AtlasTypesDef
getTypesDef
(
List
<
AtlasEnumDef
>
enums
,
List
<
AtlasStructDef
>
structs
,
List
<
AtlasClassificationDef
>
traits
,
List
<
AtlasEntityDef
>
classes
)
{
return
new
AtlasTypesDef
(
enums
,
structs
,
traits
,
classes
);
}
}
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
0 → 100755
View file @
c9e58e0a
This diff is collapsed.
Click to expand it.
release-log.txt
View file @
c9e58e0a
...
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1233 UnitTests for the TypeDefStores (apoorvnaik via sumasai)
ATLAS-1240 Adding Change listeners to react on changes in TypesDef (apoorvnaik via sumasai)
ATLAS-1239 when stopping Atlas on the command line it should explicitly say when it has stopped (ayubkhan via sumasai)
ATLAS-1253 Extract error codes into AtlasErrorCode Enum (apoorvnaik via sumasai)
...
...
repository/pom.xml
View file @
c9e58e0a
...
...
@@ -165,6 +165,13 @@
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-intg
</artifactId>
<type>
test-jar
</type>
<version>
${project.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
repository/src/main/java/org/apache/atlas/util/TypeDefSorter.java
View file @
c9e58e0a
...
...
@@ -57,18 +57,23 @@ public class TypeDefSorter {
}
processed
.
add
(
type
);
Set
<
String
>
superTypeNames
=
new
HashSet
<>();
try
{
AtlasClassificationDef
classificationDef
=
AtlasClassificationDef
.
class
.
cast
(
type
);
superTypeNames
.
addAll
(
classificationDef
.
getSuperTypes
());
}
catch
(
ClassCastException
ex
)
{
LOG
.
warn
(
"Casting to ClassificationDef failed"
);
if
(
type
.
getClass
().
equals
(
AtlasClassificationDef
.
class
))
{
try
{
AtlasClassificationDef
classificationDef
=
AtlasClassificationDef
.
class
.
cast
(
type
);
superTypeNames
.
addAll
(
classificationDef
.
getSuperTypes
());
}
catch
(
ClassCastException
ex
)
{
LOG
.
warn
(
"Casting to ClassificationDef failed"
);
}
}
try
{
AtlasEntityDef
entityDef
=
AtlasEntityDef
.
class
.
cast
(
type
);
superTypeNames
.
addAll
(
entityDef
.
getSuperTypes
());
}
catch
(
ClassCastException
ex
)
{
LOG
.
warn
(
"Casting to AtlasEntityDef failed"
);
if
(
type
.
getClass
().
equals
(
AtlasEntityDef
.
class
))
{
try
{
AtlasEntityDef
entityDef
=
AtlasEntityDef
.
class
.
cast
(
type
);
superTypeNames
.
addAll
(
entityDef
.
getSuperTypes
());
}
catch
(
ClassCastException
ex
)
{
LOG
.
warn
(
"Casting to AtlasEntityDef failed"
);
}
}
for
(
String
superTypeName
:
superTypeNames
)
{
// Recursively add any supertypes first to the result.
T
superType
=
typesByName
.
get
(
superTypeName
);
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
0 → 100644
View file @
c9e58e0a
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