summaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-20 18:06:57 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-22 11:41:13 +0000
commit8e7e4fddec6cc26c67abf8dc10adad2af6eb988a (patch)
tree5a9e8f0d4dcda9214fd467f26231c9f3d1ee4bd9 /server/tests/src/com/vaadin
parent595a3254a983c989c6fce1eb10a620202ec4d969 (diff)
downloadvaadin-framework-8e7e4fddec6cc26c67abf8dc10adad2af6eb988a.tar.gz
vaadin-framework-8e7e4fddec6cc26c67abf8dc10adad2af6eb988a.zip
Use compare for Comparable when determining equals for filtering (#10310)
Change-Id: Ie6e12b1d606d6ed06ae94527427049621b515eed
Diffstat (limited to 'server/tests/src/com/vaadin')
-rw-r--r--server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java
index 99e8429a51..b7ccd68429 100644
--- a/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java
+++ b/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java
@@ -1,5 +1,6 @@
package com.vaadin.data.util.filter;
+import java.math.BigDecimal;
import java.util.Date;
import junit.framework.Assert;
@@ -153,6 +154,59 @@ public class CompareFilterTest extends AbstractFilterTest<Compare> {
Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive));
}
+ public void testCompareBigDecimal() {
+ BigDecimal negative = new BigDecimal(-1);
+ BigDecimal zero = new BigDecimal(0);
+ BigDecimal positive = new BigDecimal(1);
+ positive.setScale(1);
+ BigDecimal positiveScaleTwo = new BigDecimal(1).setScale(2);
+
+ Item itemNegative = new PropertysetItem();
+ itemNegative.addItemProperty(PROPERTY1, new ObjectProperty<BigDecimal>(
+ negative, BigDecimal.class));
+ Item itemZero = new PropertysetItem();
+ itemZero.addItemProperty(PROPERTY1, new ObjectProperty<BigDecimal>(
+ zero, BigDecimal.class));
+ Item itemPositive = new PropertysetItem();
+ itemPositive.addItemProperty(PROPERTY1, new ObjectProperty<BigDecimal>(
+ positive, BigDecimal.class));
+ Item itemPositiveScaleTwo = new PropertysetItem();
+ itemPositiveScaleTwo.addItemProperty(PROPERTY1,
+ new ObjectProperty<BigDecimal>(positiveScaleTwo,
+ BigDecimal.class));
+
+ Filter equalZero = new Equal(PROPERTY1, zero);
+ Assert.assertFalse(equalZero.passesFilter(null, itemNegative));
+ Assert.assertTrue(equalZero.passesFilter(null, itemZero));
+ Assert.assertFalse(equalZero.passesFilter(null, itemPositive));
+
+ Filter isPositive = new Greater(PROPERTY1, zero);
+ Assert.assertFalse(isPositive.passesFilter(null, itemNegative));
+ Assert.assertFalse(isPositive.passesFilter(null, itemZero));
+ Assert.assertTrue(isPositive.passesFilter(null, itemPositive));
+
+ Filter isNegative = new Less(PROPERTY1, zero);
+ Assert.assertTrue(isNegative.passesFilter(null, itemNegative));
+ Assert.assertFalse(isNegative.passesFilter(null, itemZero));
+ Assert.assertFalse(isNegative.passesFilter(null, itemPositive));
+
+ Filter isNonNegative = new GreaterOrEqual(PROPERTY1, zero);
+ Assert.assertFalse(isNonNegative.passesFilter(null, itemNegative));
+ Assert.assertTrue(isNonNegative.passesFilter(null, itemZero));
+ Assert.assertTrue(isNonNegative.passesFilter(null, itemPositive));
+
+ Filter isNonPositive = new LessOrEqual(PROPERTY1, zero);
+ Assert.assertTrue(isNonPositive.passesFilter(null, itemNegative));
+ Assert.assertTrue(isNonPositive.passesFilter(null, itemZero));
+ Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive));
+
+ Filter isPositiveScaleTwo = new Equal(PROPERTY1, positiveScaleTwo);
+ Assert.assertTrue(isPositiveScaleTwo.passesFilter(null,
+ itemPositiveScaleTwo));
+ Assert.assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositive));
+
+ }
+
public void testCompareDate() {
Date now = new Date();
// new Date() is only accurate to the millisecond, so repeating it gives