From 17a9993995cfd3434259cd8b0f729f76da36de12 Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Sat, 23 Aug 2014 12:50:35 +0300 Subject: Handle cases when start/end date is not set for Between filter (#13354). Change-Id: If75998b1bc87b0bd7d2fa83298e1f17d65a18745 --- .../util/sqlcontainer/filters/BetweenTest.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'server/tests/src/com/vaadin') diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java index 16171f67bc..6daf730e25 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java @@ -118,4 +118,65 @@ public class BetweenTest { Between b2 = new Between("bar", 0, 1); Assert.assertFalse(b1.equals(b2)); } + + @Test + public void hashCode_nullStartValue_shouldBeEqual() { + Between b1 = new Between("foo", null, 2); + Between b2 = new Between("foo", null, 2); + Assert.assertEquals(b1.hashCode(), b2.hashCode()); + } + + @Test + public void hashCode_nullEndValue_shouldBeEqual() { + Between b1 = new Between("foo", 0, null); + Between b2 = new Between("foo", 0, null); + Assert.assertEquals(b1.hashCode(), b2.hashCode()); + } + + @Test + public void hashCode_nullPropertyId_shouldBeEqual() { + Between b1 = new Between(null, 0, 2); + Between b2 = new Between(null, 0, 2); + Assert.assertEquals(b1.hashCode(), b2.hashCode()); + } + + @Test + public void passesFilter_nullValue_filterIsPassed() { + String id = "id"; + Between between = new Between(id, null, null); + Assert.assertTrue(between.passesFilter(id, + itemWithPropertyValue(id, null))); + } + + @Test + public void passesFilter_nullStartValue_filterIsPassed() { + String id = "id"; + Between between = new Between(id, null, 2); + Assert.assertTrue(between + .passesFilter(id, itemWithPropertyValue(id, 1))); + } + + @Test + public void passesFilter_nullEndValue_filterIsPassed() { + String id = "id"; + Between between = new Between(id, 0, null); + Assert.assertTrue(between + .passesFilter(id, itemWithPropertyValue(id, 1))); + } + + @Test + public void passesFilter_nullStartValueAndEndValue_filterIsPassed() { + String id = "id"; + Between between = new Between(id, null, null); + Assert.assertTrue(between + .passesFilter(id, itemWithPropertyValue(id, 1))); + } + + @Test + public void passesFilter_nullStartValueAndEndValueAndValueIsNotComparable_filterIsNotPassed() { + String id = "id"; + Between between = new Between(id, null, null); + Assert.assertFalse(between.passesFilter(id, + itemWithPropertyValue(id, new Object()))); + } } -- cgit v1.2.3