001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.workflow;
017
018 import java.util.List;
019
020 import org.apache.log4j.Logger;
021 import org.joda.time.DateTime;
022 import org.junit.Assert;
023 import org.junit.Ignore;
024 import org.junit.Test;
025 import org.kuali.hr.KPMEWebTestCase;
026 import org.kuali.kpme.core.FunctionalTest;
027 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
028 import org.kuali.kpme.core.job.Job;
029 import org.kuali.kpme.core.service.HrServiceLocator;
030 import org.kuali.kpme.core.util.TKUtils;
031 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
032 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
033 import org.kuali.kpme.tklm.time.timesheet.service.TimesheetService;
034 import org.kuali.rice.kew.service.KEWServiceLocator;
035 import org.kuali.rice.krad.util.GlobalVariables;
036 @Ignore
037 @FunctionalTest
038 public class WorkflowTimesheetTest extends KPMEWebTestCase {
039
040 private static final Logger LOG = Logger.getLogger(WorkflowTimesheetTest.class);
041
042 @Test
043 public void testRouting() throws Exception {
044 TimesheetService timesheetService = TkServiceLocator.getTimesheetService();
045 Assert.assertNotNull("timesheet service null", timesheetService);
046
047 DateTime asOfDate = new DateTime(2010, 8, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone());
048
049 List<Job> jobs = HrServiceLocator.getJobService().getJobs(GlobalVariables.getUserSession().getPrincipalId(), asOfDate.toLocalDate());
050 Assert.assertNotNull("No jobs", jobs);
051 Assert.assertTrue("Should only be two Jobs.", jobs.size() == 2);
052 CalendarEntry pcd = HrServiceLocator.getCalendarEntryService().getCurrentCalendarDates(GlobalVariables.getUserSession().getPrincipalId(), asOfDate);
053 Assert.assertNotNull("No PayCalendarDates", pcd);
054
055 TimesheetDocument tdoc = timesheetService.openTimesheetDocument(GlobalVariables.getUserSession().getPrincipalId(), pcd);
056 String kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId());
057 String tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus();
058 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus);
059 Assert.assertEquals("Document is already routed.", "I", tkSourceDocumentStatus);
060 timesheetService.routeTimesheet(GlobalVariables.getUserSession().getPrincipalId(), tdoc);
061 LOG.debug("Routing document: " + tdoc.getDocumentHeader().getDocumentId());
062
063 kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId());
064 tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus();
065
066 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus);
067 }
068
069 }