PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/server/endpoint/gwtrpc/handler/calendar/DummyCalendarHandler.java

http://sigma-h.googlecode.com/
Java | 51 lines | 33 code | 9 blank | 9 comment | 2 complexity | e5a61e540317e0645ef65417ac17a860 MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.server.endpoint.gwtrpc.handler.calendar;
 7
 8import java.io.Serializable;
 9import java.util.Arrays;
10import java.util.Date;
11import java.util.HashMap;
12import java.util.List;
13import org.sigmah.shared.domain.calendar.Calendar;
14import org.sigmah.shared.domain.calendar.CalendarType;
15import org.sigmah.shared.domain.calendar.Event;
16
17/**
18 * Creates a new dummy calendar.
19 * This class is primary used for testing purposes.
20 * @author Rapha??l Calabro (rcalabro@ideia.fr)
21 */
22public class DummyCalendarHandler implements CalendarHandler {
23
24    @Override
25    public Calendar getCalendar(Serializable identifier) {
26        final Calendar calendar = new Calendar();
27        calendar.setType(CalendarType.Dummy);
28        calendar.setIdentifier("dummy");
29
30        if(identifier != null)
31            calendar.setName(identifier.toString());
32        else
33            calendar.setName("null");
34
35        final HashMap<Date, List<Event>> events = new HashMap<Date, List<Event>>();
36        events.put(new Date(110, 7, 27), Arrays.asList(new Event[]{ new Event("Weekly meeting", "Rien", new Date(110, 7, 27, 10, 5), new Date(110, 7, 27, 11, 0), calendar)}));
37        events.put(new Date(110, 8, 1), Arrays.asList(new Event[]{new Event("Fill up the activity report", "Rien", new Date(110, 8, 1, 18, 0), null, calendar)}));
38        events.put(new Date(110, 8, 3), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 8, 3, 10, 5), new Date(110, 8, 3, 11, 0), calendar)}));
39        events.put(new Date(110, 8, 10), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 8, 10, 10, 5), new Date(110, 8, 10, 11, 0), calendar)}));
40        events.put(new Date(110, 8, 17), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 8, 17, 10, 5), new Date(110, 8, 17, 11, 0), calendar)}));
41        events.put(new Date(110, 8, 24), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 8, 24, 10, 5), new Date(110, 8, 24, 11, 0), calendar)}));
42        events.put(new Date(110, 8, 28), Arrays.asList(new Event[]{new Event("Early duty", "Rien", new Date(110, 8, 28, 7, 30), new Date(110, 8, 28, 12, 0), calendar), new Event("After noon duty", "Rien", new Date(110, 8, 28, 14, 0), null, calendar), new Event("Late duty", "Rien", new Date(110, 8, 28, 17, 45), null, calendar), new Event("Midnight duty", "Rien", new Date(110, 8, 28, 23, 45), null, calendar)}));
43        events.put(new Date(110, 9, 1), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 9, 1, 10, 5), new Date(110, 9, 1, 11, 0), calendar), new Event("Fill up the activity report", "Rien", new Date(110, 9, 1, 18, 0), null, calendar)}));
44        events.put(new Date(110, 9, 8), Arrays.asList(new Event[]{new Event("Weekly meeting", "Rien", new Date(110, 9, 8, 10, 5), new Date(110, 9, 8, 11, 0), calendar)}));
45
46        calendar.setEvents(events);
47
48        return calendar;
49    }
50
51}