1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.workflow;
17
18 import java.util.List;
19
20 import org.apache.log4j.Logger;
21 import org.joda.time.DateTime;
22 import org.junit.Assert;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.kuali.hr.KPMEWebTestCase;
26 import org.kuali.kpme.core.FunctionalTest;
27 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
28 import org.kuali.kpme.core.job.Job;
29 import org.kuali.kpme.core.service.HrServiceLocator;
30 import org.kuali.kpme.core.util.TKUtils;
31 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
32 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
33 import org.kuali.kpme.tklm.time.timesheet.service.TimesheetService;
34 import org.kuali.rice.kew.service.KEWServiceLocator;
35 import org.kuali.rice.krad.util.GlobalVariables;
36 @Ignore
37 @FunctionalTest
38 public class WorkflowTimesheetTest extends KPMEWebTestCase {
39
40 private static final Logger LOG = Logger.getLogger(WorkflowTimesheetTest.class);
41
42 @Test
43 public void testRouting() throws Exception {
44 TimesheetService timesheetService = TkServiceLocator.getTimesheetService();
45 Assert.assertNotNull("timesheet service null", timesheetService);
46
47 DateTime asOfDate = new DateTime(2010, 8, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone());
48
49 List<Job> jobs = HrServiceLocator.getJobService().getJobs(GlobalVariables.getUserSession().getPrincipalId(), asOfDate.toLocalDate());
50 Assert.assertNotNull("No jobs", jobs);
51 Assert.assertTrue("Should only be two Jobs.", jobs.size() == 2);
52 CalendarEntry pcd = HrServiceLocator.getCalendarEntryService().getCurrentCalendarDates(GlobalVariables.getUserSession().getPrincipalId(), asOfDate);
53 Assert.assertNotNull("No PayCalendarDates", pcd);
54
55 TimesheetDocument tdoc = timesheetService.openTimesheetDocument(GlobalVariables.getUserSession().getPrincipalId(), pcd);
56 String kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId());
57 String tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus();
58 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus);
59 Assert.assertEquals("Document is already routed.", "I", tkSourceDocumentStatus);
60 timesheetService.routeTimesheet(GlobalVariables.getUserSession().getPrincipalId(), tdoc);
61 LOG.debug("Routing document: " + tdoc.getDocumentHeader().getDocumentId());
62
63 kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId());
64 tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus();
65
66 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus);
67 }
68
69 }