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.kpme.tklm.time.approval;
17  
18  import org.joda.time.LocalDate;
19  import org.junit.Assert;
20  import org.junit.Test;
21  import org.kuali.kpme.core.IntegrationTest;
22  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
23  import org.kuali.kpme.core.service.HrServiceLocator;
24  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
25  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
26  
27  import java.text.DateFormat;
28  import java.text.ParseException;
29  import java.text.SimpleDateFormat;
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  @IntegrationTest
34  public class TimeApproveServiceTest extends TKLMIntegrationTestCase {
35  	
36  	@Test
37  	public void testGetTimePrincipalIdsWithSearchCriteria() throws ParseException {
38  		List<String> workAreaList = new ArrayList<String>();
39  		String calendarGroup = "payCal";
40  		DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yy");
41  		LocalDate beginDate = LocalDate.fromDateFields(DATE_FORMAT.parse("03/01/2012"));
42  		LocalDate endDate = LocalDate.fromDateFields(DATE_FORMAT.parse("03/30/2012"));
43  		
44  		List<String> idList = TkServiceLocator.getTimeApproveService()
45  								.getTimePrincipalIdsWithSearchCriteria(workAreaList, calendarGroup, endDate, beginDate, endDate);		
46  		Assert.assertTrue("There should be 0 principal ids when searching with empty workarea list, not " + idList.size(), idList.isEmpty());
47  		
48  		workAreaList.add("1111");
49  		workAreaList.add("2222");
50  		idList = TkServiceLocator.getTimeApproveService()
51  					.getTimePrincipalIdsWithSearchCriteria(workAreaList, calendarGroup, endDate, beginDate, endDate);	
52  		// there's an principal id '1033' in setup that does not have jobs with flsaStatus = NE, so it should not be in the search results
53  		Assert.assertTrue("There should be 2 principal ids when searching with both workareas, not " + idList.size(), idList.size() == 2);
54  		for(String anId : idList) {
55  			if(!(anId.equals("1011") || anId.equals("1022"))) {
56  				Assert.fail("PrincipalIds searched with both workareas should be either '1011' or '1022', not " + anId);
57  			}
58  		}
59  		
60  		workAreaList = new ArrayList<String>();
61  		workAreaList.add("1111");
62  		idList = TkServiceLocator.getTimeApproveService()
63  					.getTimePrincipalIdsWithSearchCriteria(workAreaList, calendarGroup, endDate, beginDate, endDate);		
64  		Assert.assertTrue("There should be 1 principal ids for workArea '1111', not " + idList.size(), idList.size() == 1);
65  		Assert.assertTrue("Principal id for workArea '1111' should be principalA, not " + idList.get(0), idList.get(0).equals("1011"));
66  		
67  		workAreaList = new ArrayList<String>();
68  		workAreaList.add("2222");
69  		idList = TkServiceLocator.getTimeApproveService()
70  						.getTimePrincipalIdsWithSearchCriteria(workAreaList, calendarGroup, endDate, beginDate, endDate);	
71  		Assert.assertTrue("There should be 1 principal ids for workArea '2222', not " + idList.size(), idList.size() == 1);
72  		Assert.assertTrue("Principal id for workArea '2222' should be principalB, not " + idList.get(0), idList.get(0).equals("1022"));
73  	}
74  
75      @Test
76      public void testGetApprovalSummaryRows() throws Exception {
77          //DateTime payBeginDate = new DateTime();
78          //DateTime payEndDate = new DateTime();
79          String calGroup = "";
80          List<String> principalIds = new ArrayList<String>();
81          principalIds.add("admin");
82          List<String> payCalendarLabels = new ArrayList<String>();
83          CalendarEntry pce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("55");
84  
85      }
86  }