コード例 #1
0
 /** Event properties should be immutable. */
 @Test
 public void testEventImmutable() {
   DateSelectionReport report = new DateSelectionReport(model);
   Date date = new Date();
   model.setSelectionInterval(date, date);
   assertEquals(1, report.getEventCount());
   DateSelectionEvent event = report.getLastEvent();
   // sanity
   assertEquals(date, event.getSelection().first());
   Date next = new Date();
   model.setSelectionInterval(next, next);
   assertSame(date, event.getSelection().first());
 }
コード例 #2
0
 /** @param model */
 private void assertUnselectableDatesSelectedWhileHasValidSelection(DateSelectionModel model) {
   SortedSet<Date> unselectableDates = new TreeSet<Date>();
   unselectableDates.add(tomorrow);
   model.setUnselectableDates(unselectableDates);
   // valid selection
   model.setSelectionInterval(today, today);
   DateSelectionReport report = new DateSelectionReport(model);
   model.setSelectionInterval(tomorrow, tomorrow);
   if (model.isSelectionEmpty()) {
     assertEquals(
         "implementation clears old selection, must fire clear event",
         1,
         report.getEventCount(DateSelectionEvent.EventType.SELECTION_CLEARED));
   } else {
     assertEquals(
         "implementation does not clear old selection, old must be unchanged",
         today,
         model.getSelection().first());
   }
 }