use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class CompactCalendarHelper method getDayEventWithMultipleEventsPerDay.
public static List<Events> getDayEventWithMultipleEventsPerDay(int start, int days, long timeStamp) {
Calendar currentCalender = Calendar.getInstance(Locale.getDefault());
List<Events> events = new ArrayList<>();
for (int i = start; i < days; i++) {
setDateTime(timeStamp, currentCalender, i);
List<Event> eventsList = Arrays.asList(new Event(Color.BLUE, currentCalender.getTimeInMillis()), new Event(Color.RED, currentCalender.getTimeInMillis() + 3600 * 1000), new Event(Color.RED, currentCalender.getTimeInMillis() + (3600 * 2) * 1000), new Event(Color.RED, currentCalender.getTimeInMillis() + (3600 * 3) * 1000));
Events eventsObject = new Events(currentCalender.getTimeInMillis(), eventsList);
events.add(eventsObject);
}
return events;
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItRemovesEvents.
@Test
public void testItRemovesEvents() {
//Sun, 01 Feb 2015 00:00:00 GMT
List<Event> events = getSingleEvents(0, 30, 1422748800000L);
for (Event event : events) {
underTest.addEvent(event);
}
underTest.removeEvent(events.get(0));
underTest.removeEvent(events.get(1));
underTest.removeEvent(events.get(5));
underTest.removeEvent(events.get(20));
List<Event> expectedEvents = getSingleEvents(0, 28, 1422748800000L);
expectedEvents.remove(events.get(0));
expectedEvents.remove(events.get(1));
expectedEvents.remove(events.get(5));
expectedEvents.remove(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 testItAddsAndGetsEvents.
@Test
public void testItAddsAndGetsEvents() {
//Sun, 01 Feb 2015 00:00:00 GMT
List<Event> events = getSingleEvents(0, 30, 1422748800000L);
for (Event event : events) {
underTest.addEvent(event);
}
events = getSingleEvents(0, 28, 1422748800000L);
List<Event> actualEvents = underTest.getEventsFor(1422748800000L);
Assert.assertEquals(events.get(0), actualEvents.get(0));
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItGetsEventsForMonth.
@Test
public void testItGetsEventsForMonth() {
//Sun, 07 Jun 2015 18:20:51 GMT
//get 30 events in total
List<Event> events = getSingleEvents(0, 30, 1433701251000L);
//Wed, 06 Jul 2016 13:37:32 GMT
List<Event> events2 = getSingleEvents(0, 30, 1467812256000L);
//give a random ordering to elements
Collections.shuffle(events, new Random());
Collections.shuffle(events2, new Random());
for (Event event : events) {
underTest.addEvent(event);
}
for (Event event : events2) {
underTest.addEvent(event);
}
//Sun, 07 Jun 2015 18:20:51 GMT
List<Event> calendarDayEvents = underTest.getEventsForMonth(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
assertNotNull(calendarDayEvents);
//Assert 6th item since it will represent Sun, 07 Jun 2015 which is the day that we queried for
//Check that events are sorted as expected
assertEquals(getSingleEvents(0, 30, 1433701251000L), calendarDayEvents);
}
use of com.github.sundeepk.compactcalendarview.domain.Event in project CompactCalendarView by SundeepK.
the class EventsContainerTest method testItUpdatesEvents.
@Test
public void testItUpdatesEvents() {
//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);
}
//Sun, 07 Jun 2015 18:20:51 GMT
List<Event> calendarDayEvents = underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
assertNotNull(calendarDayEvents);
//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 a random event Sun, 07 Jun 2015 21:24:21 GMT
Event updateItem = new Event(Color.GREEN, 1433712261000L);
calendarDayEvents.add(updateItem);
//Query again Sun, 07 Jun 2015 18:20:51 GMT to make sure list is updated
List<Event> calendarDayEvents2 = underTest.getEventsFor(setTimeToMidnightAndGet(Calendar.getInstance(), 1433701251000L));
assertTrue(calendarDayEvents2.contains(updateItem));
}
Aggregations