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.sql.Date; 019 import java.util.List; 020 021 import org.apache.log4j.Logger; 022 import org.joda.time.DateTime; 023 import org.joda.time.DateTimeZone; 024 import org.junit.Assert; 025 import org.junit.Ignore; 026 import org.junit.Test; 027 import org.kuali.hr.job.Job; 028 import org.kuali.hr.test.KPMETestCase; 029 import org.kuali.hr.time.calendar.CalendarEntries; 030 import org.kuali.hr.time.service.base.TkServiceLocator; 031 import org.kuali.hr.time.timesheet.TimesheetDocument; 032 import org.kuali.hr.time.timesheet.service.TimesheetService; 033 import org.kuali.hr.time.util.TKUtils; 034 import org.kuali.rice.kew.service.KEWServiceLocator; 035 import org.kuali.rice.krad.util.GlobalVariables; 036 @Ignore 037 public class WorkflowTimesheetTest extends KPMETestCase { 038 039 private static final Logger LOG = Logger.getLogger(WorkflowTimesheetTest.class); 040 041 @Test 042 public void testRouting() throws Exception { 043 TimesheetService timesheetService = TkServiceLocator.getTimesheetService(); 044 Assert.assertNotNull("timesheet service null", timesheetService); 045 046 Date asOfDate = new Date((new DateTime(2010, 8, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis()); 047 048 List<Job> jobs = TkServiceLocator.getJobService().getJobs(GlobalVariables.getUserSession().getPrincipalId(), asOfDate); 049 Assert.assertNotNull("No jobs", jobs); 050 Assert.assertTrue("Should only be two Jobs.", jobs.size() == 2); 051 CalendarEntries pcd = TkServiceLocator.getCalendarService().getCurrentCalendarDates(GlobalVariables.getUserSession().getPrincipalId(), asOfDate); 052 Assert.assertNotNull("No PayCalendarDates", pcd); 053 054 TimesheetDocument tdoc = timesheetService.openTimesheetDocument(GlobalVariables.getUserSession().getPrincipalId(), pcd); 055 String kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId()); 056 String tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus(); 057 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus); 058 Assert.assertEquals("Document is already routed.", "I", tkSourceDocumentStatus); 059 timesheetService.routeTimesheet(GlobalVariables.getUserSession().getPrincipalId(), tdoc); 060 LOG.debug("Routing document: " + tdoc.getDocumentHeader().getDocumentId()); 061 062 kewSourceDocumentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(tdoc.getDocumentHeader().getDocumentId()); 063 tkSourceDocumentStatus = tdoc.getDocumentHeader().getDocumentStatus(); 064 065 Assert.assertEquals("Status should be equal.", kewSourceDocumentStatus, tkSourceDocumentStatus); 066 } 067 068 }