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