use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItAddsEventsToExistingList.
@Test
public void testItAddsEventsToExistingList() {
//Sun, 07 Jun 2015 18:20:51 GMT
//get 30 events in total
List<Event> events = getSingleEvents(0, 30, 1433701251000L);
underTest.addEvents(events);
//Sun, 07 Jun 2015 18:20:51 GMT
List<Event> calendarDayEvents = underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
//Assert 6th item since it will represent Sun, 07 Jun 2015 which is the day that we queried for
assertEquals(events.get(6), calendarDayEvents.get(0));
//add event in Sun, 07 Jun 2015 18:20:51 GMT for same day, making total 2 events for same day now
Event extraEventAdded = new Event(Color.GREEN, 1433701251000L);
underTest.addEvent(extraEventAdded);
//Sun, 07 Jun 2015 18:20:51 GMT
List<Event> calendarDayEvents2 = underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
assertNotNull(calendarDayEvents2);
//Assert 6th item since it will represent Sun, 07 Jun 2015 which is the day that we queried for
assertEquals(2, calendarDayEvents2.size());
assertEquals(events.get(6), calendarDayEvents2.get(0));
assertEquals(extraEventAdded, calendarDayEvents2.get(1));
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItGetsMultipleEventsThatWereAddedForADay.
@Test
public void testItGetsMultipleEventsThatWereAddedForADay() {
//Add 3 events per a day for Feb starting from Sun, 01 Feb 2015 00:00:00 GMT
Map<Long, List<Event>> events = getMultipleEventsForEachDayAsMap(0, 30, 1422748800000L);
for (Map.Entry<Long, List<Event>> entry : events.entrySet()) {
for (Event event : entry.getValue()) {
underTest.addEvent(event);
}
}
//if multiple events were added for every day, then check that all events are present by day
for (Map.Entry<Long, List<Event>> entry : events.entrySet()) {
List<Event> actualEvents = underTest.getEventsFor(entry.getKey());
Assert.assertEquals(entry.getValue(), actualEvents);
}
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItRemovesEventByDate.
@Test
public void testItRemovesEventByDate() {
//Sun, 07 Jun 2015 18:20:51 GMT
//get 30 events in total
List<Event> events = getSingleEvents(0, 30, 1433701251000L);
for (Event event : events) {
underTest.addEvent(event);
}
assertEquals(1, underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L)).size());
assertEquals(events.get(6), underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L)).get(0));
//Sun, 07 Jun 2015 18:20:51 GMT
underTest.removeEventByEpochMillis(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
//Remove 6th item since it will represent Sun, 07 Jun 2015 which is the day that was removed
events.remove(6);
assertEquals(0, underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L)).size());
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItRemovesEventsUsingList.
@Test
public void testItRemovesEventsUsingList() {
//Sun, 01 Feb 2015 00:00:00 GMT
List<Event> events = getSingleEvents(0, 30, 1422748800000L);
for (Event event : events) {
underTest.addEvent(event);
}
underTest.removeEvents(Arrays.asList(events.get(0), events.get(1), events.get(5), events.get(20)));
List<Event> expectedEvents = getSingleEvents(0, 28, 1422748800000L);
expectedEvents.removeAll(Arrays.asList(events.get(0), events.get(1), events.get(5), events.get(20)));
for (Event e : expectedEvents) {
List<Event> actualEvents = underTest.getEventsFor(e.getTimeInMillis());
Assert.assertEquals(1, actualEvents.size());
Assert.assertEquals(e, actualEvents.get(0));
}
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItRemovesAllEvents.
@Test
public void testItRemovesAllEvents() {
//Sun, 01 Feb 2015 00:00:00 GMT
List<Event> events = getSingleEvents(0, 30, 1422748800000L);
for (Event event : events) {
underTest.addEvent(event);
}
underTest.removeAllEvents();
List<Event> actualEvents = underTest.getEventsFor(1422748800000L);
Assert.assertEquals(new ArrayList<Event>(), actualEvents);
}
Aggregations