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