View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }