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
11e22022
Commit
11e22022
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1613: fix for bigdecimal value handling to avoid casting to long (#2 - fix…
ATLAS-1613: fix for bigdecimal value handling to avoid casting to long (#2 - fix for unittest failures)
parent
48b05f36
master
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
AtlasBuiltInTypes.java
...rc/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
+1
-1
TestAtlasBigDecimalType.java
...t/java/org/apache/atlas/type/TestAtlasBigDecimalType.java
+11
-2
No files found.
intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
View file @
11e22022
...
@@ -414,7 +414,7 @@ public class AtlasBuiltInTypes {
...
@@ -414,7 +414,7 @@ public class AtlasBuiltInTypes {
}
else
if
(
obj
instanceof
BigInteger
)
{
}
else
if
(
obj
instanceof
BigInteger
)
{
return
new
BigDecimal
((
BigInteger
)
obj
);
return
new
BigDecimal
((
BigInteger
)
obj
);
}
else
if
(
obj
instanceof
Number
)
{
}
else
if
(
obj
instanceof
Number
)
{
return
BigDecimal
.
valueOf
(((
Number
)
obj
).
doubleValue
());
return
obj
.
equals
(
0
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(((
Number
)
obj
).
doubleValue
());
}
else
{
}
else
{
try
{
try
{
return
new
BigDecimal
(
obj
.
toString
());
return
new
BigDecimal
(
obj
.
toString
());
...
...
This diff is collapsed.
Click to expand it.
intg/src/test/java/org/apache/atlas/type/TestAtlasBigDecimalType.java
View file @
11e22022
...
@@ -32,12 +32,12 @@ public class TestAtlasBigDecimalType {
...
@@ -32,12 +32,12 @@ public class TestAtlasBigDecimalType {
private
final
AtlasBigDecimalType
bigDecimalType
=
new
AtlasBigDecimalType
();
private
final
AtlasBigDecimalType
bigDecimalType
=
new
AtlasBigDecimalType
();
private
final
Object
[]
validValues
=
{
private
final
Object
[]
validValues
=
{
null
,
Byte
.
valueOf
((
byte
)
1
),
Short
.
valueOf
((
short
)
1
),
Integer
.
valueOf
(
1
),
Long
.
valueOf
(
1L
),
Float
.
valueOf
(
1
),
null
,
Byte
.
valueOf
((
byte
)
1
),
Short
.
valueOf
((
short
)
1
),
Integer
.
valueOf
(
1
),
Long
.
valueOf
(
1L
),
Float
.
valueOf
(
1
),
Double
.
valueOf
(
1
),
BigInteger
.
valueOf
(
1
),
BigDecimal
.
valueOf
(
1
),
"1
"
,
Double
.
valueOf
(
1
),
BigInteger
.
valueOf
(
1
),
BigDecimal
.
valueOf
(
1
.0
),
"1.0
"
,
};
};
private
final
Object
[]
negativeValues
=
{
private
final
Object
[]
negativeValues
=
{
Byte
.
valueOf
((
byte
)-
1
),
Short
.
valueOf
((
short
)-
1
),
Integer
.
valueOf
(-
1
),
Long
.
valueOf
(-
1L
),
Float
.
valueOf
(-
1
),
Byte
.
valueOf
((
byte
)-
1
),
Short
.
valueOf
((
short
)-
1
),
Integer
.
valueOf
(-
1
),
Long
.
valueOf
(-
1L
),
Float
.
valueOf
(-
1
),
Double
.
valueOf
(-
1
),
BigInteger
.
valueOf
(-
1
),
BigDecimal
.
valueOf
(-
1
),
"-1
"
,
Double
.
valueOf
(-
1
),
BigInteger
.
valueOf
(-
1
),
BigDecimal
.
valueOf
(-
1
.0
),
"-1.0
"
,
};
};
private
final
Object
[]
invalidValues
=
{
""
,
"12ab"
,
"abcd"
,
"-12ab"
};
private
final
Object
[]
invalidValues
=
{
""
,
"12ab"
,
"abcd"
,
"-12ab"
};
...
@@ -77,14 +77,23 @@ public class TestAtlasBigDecimalType {
...
@@ -77,14 +77,23 @@ public class TestAtlasBigDecimalType {
BigDecimal
normalizedValue
=
bigDecimalType
.
getNormalizedValue
(
value
);
BigDecimal
normalizedValue
=
bigDecimalType
.
getNormalizedValue
(
value
);
assertNotNull
(
normalizedValue
,
"value="
+
value
);
assertNotNull
(
normalizedValue
,
"value="
+
value
);
if
(
value
instanceof
BigInteger
)
{
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(
1
),
"value="
+
value
);
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(
1
),
"value="
+
value
);
}
else
{
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(
1.0
),
"value="
+
value
);
}
}
}
for
(
Object
value
:
negativeValues
)
{
for
(
Object
value
:
negativeValues
)
{
BigDecimal
normalizedValue
=
bigDecimalType
.
getNormalizedValue
(
value
);
BigDecimal
normalizedValue
=
bigDecimalType
.
getNormalizedValue
(
value
);
assertNotNull
(
normalizedValue
,
"value="
+
value
);
assertNotNull
(
normalizedValue
,
"value="
+
value
);
if
(
value
instanceof
BigInteger
)
{
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(-
1
),
"value="
+
value
);
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(-
1
),
"value="
+
value
);
}
else
{
assertEquals
(
normalizedValue
,
BigDecimal
.
valueOf
(-
1.0
),
"value="
+
value
);
}
}
}
for
(
Object
value
:
invalidValues
)
{
for
(
Object
value
:
invalidValues
)
{
...
...
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