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.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  }