[OLINGO-1556]Fix scale handling of BigDecimals in EdmAssistedJsonSerializer
This commit is contained in:
parent
7c2b5f748b
commit
72d5e9195c
|
@ -310,7 +310,7 @@ public class EdmAssistedJsonSerializer implements EdmAssistedSerializer {
|
|||
try {
|
||||
Integer scale = null;
|
||||
if (value instanceof BigDecimal) {
|
||||
scale = ((BigDecimal) value).scale();
|
||||
scale = Math.max(0, ((BigDecimal) value).scale());
|
||||
} else {
|
||||
scale = Constants.DEFAULT_SCALE;
|
||||
}
|
||||
|
|
|
@ -678,4 +678,26 @@ public class EdmAssistedJsonSerializerTest {
|
|||
serialize(serializerMin, metadata, null, entityCollection, null)
|
||||
.contains("1.6666666666666667406815349750104360282421112060546875"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityCollectionWithBigDecimalPropertyIntegerInScientificNotation() throws Exception {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
BigDecimal b = new BigDecimal("1.52E+4");
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, b)));
|
||||
Assert.assertTrue(
|
||||
serialize(serializerMin, metadata, null, entityCollection, null)
|
||||
.contains("15200"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityCollectionWithBigDecimalPropertyInScientificNotation() throws Exception {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
BigDecimal b = new BigDecimal("1.52123123E+4");
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, b)));
|
||||
Assert.assertTrue(
|
||||
serialize(serializerMin, metadata, null, entityCollection, null)
|
||||
.contains("15212.3123"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue