@Test public void shouldReturnEntriesForTimeInterval() throws Exception { Entry<?> entry1 = new Entry<>(); Entry<?> entry2 = new Entry<>(); Entry<?> entry3 = new Entry<>(); Entry<?> entryA = new Entry<>(); Entry<?> entryB = new Entry<>(); Entry<?> entryC = new Entry<>(); entry1.changeStartDate(LocalDate.now()); entry1.changeEndDate(LocalDate.now().plusDays(10)); entry2.changeStartDate(LocalDate.now().plusDays(7)); entry2.changeEndDate(LocalDate.now().plusDays(9)); entry3.changeStartDate(LocalDate.now().plusDays(4)); entry3.changeEndDate(LocalDate.now().plusDays(6)); entryA.changeStartDate(LocalDate.now().minusDays(7)); entryA.changeEndDate(LocalDate.now().minusDays(10)); entryB.changeStartDate(LocalDate.now().minusDays(7)); entryB.changeEndDate(LocalDate.now().minusDays(9)); entryC.changeStartDate(LocalDate.now().plusDays(40)); entryC.changeEndDate(LocalDate.now().plusDays(60)); entry1.setCalendar(calendar); entryA.setCalendar(calendar); entry2.setCalendar(calendar); entryB.setCalendar(calendar); entry3.setCalendar(calendar); entryC.setCalendar(calendar); Map<LocalDate, List<Entry<?>>> entries = calendar.findEntries( LocalDate.now(), LocalDate.now().plusDays(10), ZoneId.systemDefault()); assertThat(entries.keySet().size(), is(equalTo(11))); for (int i = 0; i <= 10; i++) { assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entry1), is(true)); assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entryA), is(false)); assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entryB), is(false)); assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entryC), is(false)); } for (int i = 7; i <= 9; i++) { assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entry2), is(true)); } for (int i = 4; i <= 6; i++) { assertThat( entries.get(LocalDate.now().plusDays(i)).contains(entry3), is(true)); } }
public final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId) { fireEvents = false; Map<LocalDate, List<Entry<?>>> result; try { result = doGetEntries(startDate, endDate, zoneId); } finally { fireEvents = true; } return result; }
Calendar implements EventTarget { public final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId) { fireEvents = false; Map<LocalDate, List<Entry<?>>> result; try { result = doGetEntries(startDate, endDate, zoneId); } finally { fireEvents = true; } return result; } }
Calendar implements EventTarget { public final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId) { fireEvents = false; Map<LocalDate, List<Entry<?>>> result; try { result = doGetEntries(startDate, endDate, zoneId); } finally { fireEvents = true; } return result; } Calendar();  Calendar(String name); }
Calendar implements EventTarget { public final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId) { fireEvents = false; Map<LocalDate, List<Entry<?>>> result; try { result = doGetEntries(startDate, endDate, zoneId); } finally { fireEvents = true; } return result; } Calendar();  Calendar(String name); final Instant getEarliestTimeUsed(); final Instant getLatestTimeUsed(); final void startBatchUpdates(); final void stopBatchUpdates(); final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId); final ObjectProperty<Duration> lookAheadDurationProperty(); final void setLookAheadDuration(Duration duration); final Duration getLookAheadDuration(); final ObjectProperty<Duration> lookBackDurationProperty(); final void setLookBackDuration(Duration duration); final Duration getLookBackDuration(); List<Entry<?>> findEntries(String searchText); final void clear(); final void addEntry(Entry<?> entry); final void addEntries(Entry<?>... entries); final void addEntries(Collection<Entry<?>> entries); final void addEntries(Iterator<Entry<?>> entries); final void addEntries(Iterable<Entry<?>> entries); final void removeEntry(Entry<?> entry); final void removeEntries(Entry<?>... entries); final void removeEntries(Collection<Entry<?>> entries); final void removeEntries(Iterator<Entry<?>> entries); final void removeEntries(Iterable<Entry<?>> entries); final StringProperty nameProperty(); final void setName(String name); final String getName(); final StringProperty shortNameProperty(); final void setShortName(String name); final String getShortName(); final StringProperty styleProperty(); final void setStyle(Style style); final void setStyle(String stylePrefix); final String getStyle(); final BooleanProperty readOnlyProperty(); final boolean isReadOnly(); final void setReadOnly(boolean readOnly); final void addEventHandler(EventHandler<CalendarEvent> l); final void removeEventHandler(EventHandler<CalendarEvent> l); final void fireEvent(CalendarEvent evt); @Override final EventDispatchChain buildEventDispatchChain(EventDispatchChain givenTail); @Override String toString(); }
Calendar implements EventTarget { public final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId) { fireEvents = false; Map<LocalDate, List<Entry<?>>> result; try { result = doGetEntries(startDate, endDate, zoneId); } finally { fireEvents = true; } return result; } Calendar();  Calendar(String name); final Instant getEarliestTimeUsed(); final Instant getLatestTimeUsed(); final void startBatchUpdates(); final void stopBatchUpdates(); final Map<LocalDate, List<Entry<?>>> findEntries(LocalDate startDate, LocalDate endDate, ZoneId zoneId); final ObjectProperty<Duration> lookAheadDurationProperty(); final void setLookAheadDuration(Duration duration); final Duration getLookAheadDuration(); final ObjectProperty<Duration> lookBackDurationProperty(); final void setLookBackDuration(Duration duration); final Duration getLookBackDuration(); List<Entry<?>> findEntries(String searchText); final void clear(); final void addEntry(Entry<?> entry); final void addEntries(Entry<?>... entries); final void addEntries(Collection<Entry<?>> entries); final void addEntries(Iterator<Entry<?>> entries); final void addEntries(Iterable<Entry<?>> entries); final void removeEntry(Entry<?> entry); final void removeEntries(Entry<?>... entries); final void removeEntries(Collection<Entry<?>> entries); final void removeEntries(Iterator<Entry<?>> entries); final void removeEntries(Iterable<Entry<?>> entries); final StringProperty nameProperty(); final void setName(String name); final String getName(); final StringProperty shortNameProperty(); final void setShortName(String name); final String getShortName(); final StringProperty styleProperty(); final void setStyle(Style style); final void setStyle(String stylePrefix); final String getStyle(); final BooleanProperty readOnlyProperty(); final boolean isReadOnly(); final void setReadOnly(boolean readOnly); final void addEventHandler(EventHandler<CalendarEvent> l); final void removeEventHandler(EventHandler<CalendarEvent> l); final void fireEvent(CalendarEvent evt); @Override final EventDispatchChain buildEventDispatchChain(EventDispatchChain givenTail); @Override String toString();  }