From efe8342965c333b2a1a47903f8b5779f94cb3e08 Mon Sep 17 00:00:00 2001 From: girirajsharma Date: Thu, 28 May 2015 18:05:31 +0530 Subject: [PATCH] [KEYCLOAK-1200]- From and To filter fields in Event viewer in admin app --- .../java/org/keycloak/events/EventQuery.java | 5 ++- .../events/admin/AdminEventQuery.java | 9 ++-- .../events/jpa/JpaAdminEventQuery.java | 23 +++------- .../keycloak/events/jpa/JpaEventQuery.java | 25 +++-------- .../events/mongo/MongoAdminEventQuery.java | 23 +++------- .../events/mongo/MongoEventQuery.java | 25 +++-------- .../providers/events/MemAdminEventQuery.java | 25 +++-------- .../providers/events/MemEventQuery.java | 25 +++-------- .../resources/admin/RealmAdminResource.java | 43 +++++++++++++++++-- .../events/AdminEventStoreProviderTest.java | 35 +++++++++------ .../events/EventStoreProviderTest.java | 35 +++++++++------ 11 files changed, 124 insertions(+), 149 deletions(-) diff --git a/events/api/src/main/java/org/keycloak/events/EventQuery.java b/events/api/src/main/java/org/keycloak/events/EventQuery.java index 9a555caad5..8b4885d34a 100644 --- a/events/api/src/main/java/org/keycloak/events/EventQuery.java +++ b/events/api/src/main/java/org/keycloak/events/EventQuery.java @@ -1,5 +1,6 @@ package org.keycloak.events; +import java.util.Date; import java.util.List; /** @@ -15,9 +16,9 @@ public interface EventQuery { public EventQuery user(String userId); - public EventQuery fromDate(String fromDate); + public EventQuery fromDate(Date fromDate); - public EventQuery toDate(String toDate); + public EventQuery toDate(Date toDate); public EventQuery ipAddress(String ipAddress); diff --git a/events/api/src/main/java/org/keycloak/events/admin/AdminEventQuery.java b/events/api/src/main/java/org/keycloak/events/admin/AdminEventQuery.java index d7b5fe4ed0..50b4e63ce7 100644 --- a/events/api/src/main/java/org/keycloak/events/admin/AdminEventQuery.java +++ b/events/api/src/main/java/org/keycloak/events/admin/AdminEventQuery.java @@ -1,5 +1,6 @@ package org.keycloak.events.admin; +import java.util.Date; import java.util.List; /** @@ -71,18 +72,18 @@ public interface AdminEventQuery { /** * Search by events after the specified time * - * @param fromTime time in millis + * @param fromTime from date * @return this for method chaining */ - AdminEventQuery fromTime(String fromTime); + AdminEventQuery fromTime(Date fromTime); /** * Search by events before the specified time * - * @param toTime time in millis + * @param toTime to date * @return this for method chaining */ - AdminEventQuery toTime(String toTime); + AdminEventQuery toTime(Date toTime); /** * Used for pagination diff --git a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaAdminEventQuery.java b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaAdminEventQuery.java index f9ea14d432..94906ee40c 100644 --- a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaAdminEventQuery.java +++ b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaAdminEventQuery.java @@ -3,6 +3,7 @@ package org.keycloak.events.jpa; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -88,28 +89,14 @@ public class JpaAdminEventQuery implements AdminEventQuery { } @Override - public AdminEventQuery fromTime(String fromTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - predicates.add(cb.greaterThanOrEqualTo(root.get("time"), from)); + public AdminEventQuery fromTime(Date fromTime) { + predicates.add(cb.greaterThanOrEqualTo(root.get("time"), fromTime.getTime())); return this; } @Override - public AdminEventQuery toTime(String toTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - predicates.add(cb.lessThanOrEqualTo(root.get("time"), to)); + public AdminEventQuery toTime(Date toTime) { + predicates.add(cb.lessThanOrEqualTo(root.get("time"), toTime.getTime())); return this; } diff --git a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventQuery.java b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventQuery.java index ffbf619526..0210c1e8f5 100644 --- a/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventQuery.java +++ b/events/jpa/src/main/java/org/keycloak/events/jpa/JpaEventQuery.java @@ -11,9 +11,8 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -68,28 +67,14 @@ public class JpaEventQuery implements EventQuery { } @Override - public EventQuery fromDate(String fromDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - predicates.add(cb.greaterThanOrEqualTo(root.get("time"), from)); + public EventQuery fromDate(Date fromDate) { + predicates.add(cb.greaterThanOrEqualTo(root.get("time"), fromDate.getTime())); return this; } @Override - public EventQuery toDate(String toDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - predicates.add(cb.lessThanOrEqualTo(root.get("time"), to)); + public EventQuery toDate(Date toDate) { + predicates.add(cb.lessThanOrEqualTo(root.get("time"), toDate.getTime())); return this; } diff --git a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoAdminEventQuery.java b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoAdminEventQuery.java index c614d76f08..4fdb9221ed 100644 --- a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoAdminEventQuery.java +++ b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoAdminEventQuery.java @@ -2,6 +2,7 @@ package org.keycloak.events.mongo; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; @@ -74,28 +75,14 @@ public class MongoAdminEventQuery implements AdminEventQuery{ } @Override - public AdminEventQuery fromTime(String fromTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - query.put("time", BasicDBObjectBuilder.start("$gte", from).get()); + public AdminEventQuery fromTime(Date fromTime) { + query.put("time", BasicDBObjectBuilder.start("$gte", fromTime.getTime()).get()); return this; } @Override - public AdminEventQuery toTime(String toTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - query.put("time", BasicDBObjectBuilder.start("$lte", to).get()); + public AdminEventQuery toTime(Date toTime) { + query.put("time", BasicDBObjectBuilder.start("$lte", toTime.getTime()).get()); return this; } diff --git a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventQuery.java b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventQuery.java index 75165c751d..47efa6ae69 100755 --- a/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventQuery.java +++ b/events/mongo/src/main/java/org/keycloak/events/mongo/MongoEventQuery.java @@ -4,14 +4,15 @@ import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObjectBuilder; import com.mongodb.DBCollection; import com.mongodb.DBCursor; - import com.mongodb.DBObject; + import org.keycloak.events.Event; import org.keycloak.events.EventQuery; import org.keycloak.events.EventType; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -59,31 +60,17 @@ public class MongoEventQuery implements EventQuery { } @Override - public EventQuery fromDate(String fromDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } + public EventQuery fromDate(Date fromDate) { BasicDBObject time = query.containsField("time") ? (BasicDBObject) query.get("time") : new BasicDBObject(); - time.append("$gte", from); + time.append("$gte", fromDate.getTime()); query.put("time", time); return this; } @Override - public EventQuery toDate(String toDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } + public EventQuery toDate(Date toDate) { BasicDBObject time = query.containsField("time") ? (BasicDBObject) query.get("time") : new BasicDBObject(); - time.append("$lte", to); + time.append("$lte", toDate.getTime()); query.put("time", time); return this; } diff --git a/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemAdminEventQuery.java b/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemAdminEventQuery.java index 6b3a5da6c7..c636534812 100644 --- a/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemAdminEventQuery.java +++ b/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemAdminEventQuery.java @@ -3,6 +3,7 @@ package org.keycloak.examples.providers.events; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.regex.Pattern; @@ -112,18 +113,10 @@ public class MemAdminEventQuery implements AdminEventQuery { } @Override - public AdminEventQuery fromTime(String fromTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - + public AdminEventQuery fromTime(Date fromTime) { Iterator itr = this.adminEvents.iterator(); while (itr.hasNext()) { - if (!(itr.next().getTime() >= from)) { + if (!(itr.next().getTime() >= fromTime.getTime())) { itr.remove(); } } @@ -131,18 +124,10 @@ public class MemAdminEventQuery implements AdminEventQuery { } @Override - public AdminEventQuery toTime(String toTime) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toTime).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - + public AdminEventQuery toTime(Date toTime) { Iterator itr = this.adminEvents.iterator(); while (itr.hasNext()) { - if (!(itr.next().getTime() <= to)) { + if (!(itr.next().getTime() <= toTime.getTime())) { itr.remove(); } } diff --git a/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemEventQuery.java b/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemEventQuery.java index e60b0555e8..eccd62dba5 100644 --- a/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemEventQuery.java +++ b/examples/providers/event-store-mem/src/main/java/org/keycloak/examples/providers/events/MemEventQuery.java @@ -7,6 +7,7 @@ import org.keycloak.events.EventType; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.List; @@ -77,18 +78,10 @@ public class MemEventQuery implements EventQuery { } @Override - public EventQuery fromDate(String fromDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long from = null; - try { - from = df.parse(fromDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - + public EventQuery fromDate(Date fromDate) { Iterator itr = this.events.iterator(); while (itr.hasNext()) { - if (!(itr.next().getTime() >= from)) { + if (!(itr.next().getTime() >= fromDate.getTime())) { itr.remove(); } } @@ -96,18 +89,10 @@ public class MemEventQuery implements EventQuery { } @Override - public EventQuery toDate(String toDate) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - Long to = null; - try { - to = df.parse(toDate).getTime(); - } catch (ParseException e) { - e.printStackTrace(); - } - + public EventQuery toDate(Date toDate) { Iterator itr = this.events.iterator(); while (itr.hasNext()) { - if (!(itr.next().getTime() <= to)) { + if (!(itr.next().getTime() <= toDate.getTime())) { itr.remove(); } } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index e2899fe0ea..2208718c82 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -35,6 +35,7 @@ import org.keycloak.services.managers.UsersSyncManager; import org.keycloak.services.ErrorResponse; import org.keycloak.timer.TimerProvider; +import javax.ws.rs.BadRequestException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -50,6 +51,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -416,10 +421,25 @@ public class RealmAdminResource { } if(dateFrom != null) { - query.fromDate(dateFrom); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Date from = null; + try { + from = df.parse(dateFrom); + } catch (ParseException e) { + throw new BadRequestException("Invalid value for 'Date(From)', excepted format is yyyy-MM-dd"); + } + query.fromDate(from); } + if(dateTo != null) { - query.toDate(dateTo); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Date to = null; + try { + to = df.parse(dateTo); + } catch (ParseException e) { + throw new BadRequestException("Invalid value for 'Date(To)', excepted format is yyyy-MM-dd"); + } + query.toDate(to); } if (ipAddress != null) { @@ -494,10 +514,25 @@ public class RealmAdminResource { } if(dateFrom != null) { - query.fromTime(dateFrom); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Date from = null; + try { + from = df.parse(dateFrom); + } catch (ParseException e) { + throw new BadRequestException("Invalid value for 'Date(From)', excepted format is yyyy-MM-dd"); + } + query.fromTime(from); } + if(dateTo != null) { - query.toTime(dateTo); + SimpleDateFormat df = new SimpleDateFormat("Invalid value for 'Date(To)', excepted format is yyyy-MM-dd"); + Date to = null; + try { + to = df.parse(dateTo); + } catch (ParseException e) { + throw new BadRequestException("An unexpected server error has occurred"); + } + query.toTime(to); } if (firstResult != null) { diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/events/AdminEventStoreProviderTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/events/AdminEventStoreProviderTest.java index 58c569899e..534f056ae3 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/events/AdminEventStoreProviderTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/events/AdminEventStoreProviderTest.java @@ -83,14 +83,25 @@ public class AdminEventStoreProviderTest { String d3 = new String("2015-03-06"); String d4 = new String("2015-03-07"); + String d5 = new String("2015-03-01"); + String d6 = new String("2015-03-03"); + String d7 = new String("2015-03-08"); + String d8 = new String("2015-03-10"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = null, date2 = null, date3 = null, date4 = null; + Date date5 = null, date6 = null, date7 = null, date8 = null; try { date1 = formatter.parse(d1); date2 = formatter.parse(d2); date3 = formatter.parse(d3); date4 = formatter.parse(d4); + + date5 = formatter.parse(d5); + date6 = formatter.parse(d6); + date7 = formatter.parse(d7); + date8 = formatter.parse(d8); } catch (ParseException e) { e.printStackTrace(); } @@ -121,22 +132,22 @@ public class AdminEventStoreProviderTest { Assert.assertEquals(1, eventStore.createAdminQuery().operation(OperationType.DELETE).getResultList().size()); Assert.assertEquals(4, eventStore.createAdminQuery().operation(OperationType.CREATE).getResultList().size()); - Assert.assertEquals(8, eventStore.createAdminQuery().fromTime("2015-03-04").getResultList().size()); - Assert.assertEquals(8, eventStore.createAdminQuery().toTime("2015-03-07").getResultList().size()); + Assert.assertEquals(8, eventStore.createAdminQuery().fromTime(date1).getResultList().size()); + Assert.assertEquals(8, eventStore.createAdminQuery().toTime(date4).getResultList().size()); - Assert.assertEquals(4, eventStore.createAdminQuery().fromTime("2015-03-06").getResultList().size()); - Assert.assertEquals(4, eventStore.createAdminQuery().toTime("2015-03-05").getResultList().size()); + Assert.assertEquals(4, eventStore.createAdminQuery().fromTime(date3).getResultList().size()); + Assert.assertEquals(4, eventStore.createAdminQuery().toTime(date2).getResultList().size()); - Assert.assertEquals(0, eventStore.createAdminQuery().fromTime("2015-03-08").getResultList().size()); - Assert.assertEquals(0, eventStore.createAdminQuery().toTime("2015-03-03").getResultList().size()); + Assert.assertEquals(0, eventStore.createAdminQuery().fromTime(date7).getResultList().size()); + Assert.assertEquals(0, eventStore.createAdminQuery().toTime(date6).getResultList().size()); - Assert.assertEquals(8, eventStore.createAdminQuery().fromTime("2015-03-04").toTime("2015-03-07").getResultList().size()); - Assert.assertEquals(6, eventStore.createAdminQuery().fromTime("2015-03-05").toTime("2015-03-07").getResultList().size()); - Assert.assertEquals(4, eventStore.createAdminQuery().fromTime("2015-03-04").toTime("2015-03-05").getResultList().size()); - Assert.assertEquals(4, eventStore.createAdminQuery().fromTime("2015-03-06").toTime("2015-03-07").getResultList().size()); + Assert.assertEquals(8, eventStore.createAdminQuery().fromTime(date1).toTime(date4).getResultList().size()); + Assert.assertEquals(6, eventStore.createAdminQuery().fromTime(date2).toTime(date4).getResultList().size()); + Assert.assertEquals(4, eventStore.createAdminQuery().fromTime(date1).toTime(date2).getResultList().size()); + Assert.assertEquals(4, eventStore.createAdminQuery().fromTime(date3).toTime(date4).getResultList().size()); - Assert.assertEquals(0, eventStore.createAdminQuery().fromTime("2015-03-01").toTime("2015-03-03").getResultList().size()); - Assert.assertEquals(0, eventStore.createAdminQuery().fromTime("2015-03-08").toTime("2015-03-10").getResultList().size()); + Assert.assertEquals(0, eventStore.createAdminQuery().fromTime(date5).toTime(date6).getResultList().size()); + Assert.assertEquals(0, eventStore.createAdminQuery().fromTime(date7).toTime(date8).getResultList().size()); } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/events/EventStoreProviderTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/events/EventStoreProviderTest.java index f5f81ffc36..7a378aad6c 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/events/EventStoreProviderTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/events/EventStoreProviderTest.java @@ -84,14 +84,25 @@ public class EventStoreProviderTest { String d3 = new String("2015-03-06"); String d4 = new String("2015-03-07"); + String d5 = new String("2015-03-01"); + String d6 = new String("2015-03-03"); + String d7 = new String("2015-03-08"); + String d8 = new String("2015-03-10"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = null, date2 = null, date3 = null, date4 = null; + Date date5 = null, date6 = null, date7 = null, date8 = null; try { date1 = formatter.parse(d1); date2 = formatter.parse(d2); date3 = formatter.parse(d3); date4 = formatter.parse(d4); + + date5 = formatter.parse(d5); + date6 = formatter.parse(d6); + date7 = formatter.parse(d7); + date8 = formatter.parse(d8); } catch (ParseException e) { e.printStackTrace(); } @@ -124,22 +135,22 @@ public class EventStoreProviderTest { Assert.assertEquals(1, eventStore.createQuery().type(EventType.UPDATE_PROFILE).getResultList().size()); Assert.assertEquals(1, eventStore.createQuery().type(EventType.UPDATE_EMAIL).getResultList().size()); - Assert.assertEquals(8, eventStore.createQuery().fromDate("2015-03-04").getResultList().size()); - Assert.assertEquals(8, eventStore.createQuery().toDate("2015-03-07").getResultList().size()); + Assert.assertEquals(8, eventStore.createQuery().fromDate(date1).getResultList().size()); + Assert.assertEquals(8, eventStore.createQuery().toDate(date4).getResultList().size()); - Assert.assertEquals(4, eventStore.createQuery().fromDate("2015-03-06").getResultList().size()); - Assert.assertEquals(4, eventStore.createQuery().toDate("2015-03-05").getResultList().size()); + Assert.assertEquals(4, eventStore.createQuery().fromDate(date3).getResultList().size()); + Assert.assertEquals(4, eventStore.createQuery().toDate(date2).getResultList().size()); - Assert.assertEquals(0, eventStore.createQuery().fromDate("2015-03-08").getResultList().size()); - Assert.assertEquals(0, eventStore.createQuery().toDate("2015-03-03").getResultList().size()); + Assert.assertEquals(0, eventStore.createQuery().fromDate(date7).getResultList().size()); + Assert.assertEquals(0, eventStore.createQuery().toDate(date6).getResultList().size()); - Assert.assertEquals(8, eventStore.createQuery().fromDate("2015-03-04").toDate("2015-03-07").getResultList().size()); - Assert.assertEquals(6, eventStore.createQuery().fromDate("2015-03-05").toDate("2015-03-07").getResultList().size()); - Assert.assertEquals(4, eventStore.createQuery().fromDate("2015-03-04").toDate("2015-03-05").getResultList().size()); - Assert.assertEquals(4, eventStore.createQuery().fromDate("2015-03-06").toDate("2015-03-07").getResultList().size()); + Assert.assertEquals(8, eventStore.createQuery().fromDate(date1).toDate(date4).getResultList().size()); + Assert.assertEquals(6, eventStore.createQuery().fromDate(date2).toDate(date4).getResultList().size()); + Assert.assertEquals(4, eventStore.createQuery().fromDate(date1).toDate(date2).getResultList().size()); + Assert.assertEquals(4, eventStore.createQuery().fromDate(date3).toDate(date4).getResultList().size()); - Assert.assertEquals(0, eventStore.createQuery().fromDate("2015-03-01").toDate("2015-03-03").getResultList().size()); - Assert.assertEquals(0, eventStore.createQuery().fromDate("2015-03-08").toDate("2015-03-10").getResultList().size()); + Assert.assertEquals(0, eventStore.createQuery().fromDate(date5).toDate(date6).getResultList().size()); + Assert.assertEquals(0, eventStore.createQuery().fromDate(date7).toDate(date8).getResultList().size()); }