1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
78
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 }