1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.document.header;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.joda.time.DateTime;
20 import org.joda.time.LocalDate;
21 import org.junit.Assert;
22 import org.junit.Ignore;
23 import org.junit.Test;
24 import org.kuali.hr.KPMEWebTestCase;
25 import org.kuali.hr.util.HtmlUnitUtil;
26 import org.kuali.kpme.core.FunctionalTest;
27 import org.kuali.kpme.core.IntegrationTest;
28 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
29 import org.kuali.kpme.tklm.time.workflow.TimesheetDocumentHeader;
30 import org.kuali.kpme.tklm.utils.TkTestConstants;
31 import org.kuali.rice.krad.service.KRADServiceLocator;
32
33 import com.gargoylesoftware.htmlunit.html.HtmlPage;
34
35 @FunctionalTest
36 public class TimesheetDocumentHeaderTest extends KPMEWebTestCase {
37
38
39
40 private static Long documentId = 1L;
41
42
43
44
45
46 @IntegrationTest
47 @Test
48 public void testDocumentHeaderPrevFetch() throws Exception{
49 TimesheetDocumentHeader timeHeader = new TimesheetDocumentHeader();
50 timeHeader.setDocumentId("1");
51 timeHeader.setPrincipalId("admin");
52 timeHeader.setDocumentStatus("F");
53 timeHeader.setBeginDateTime(new DateTime(2011, 1, 1, 0, 0, 0));
54 timeHeader.setEndDateTime(new DateTime(2011, 1, 15, 0, 0, 0));
55 KRADServiceLocator.getBusinessObjectService().save(timeHeader);
56 DateTime dateTime = new DateTime(2011,1,15,0,0,0,0);
57 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getPreviousDocumentHeader("admin", dateTime);
58 Assert.assertTrue(tdh!=null && StringUtils.equals(tdh.getDocumentId(),"1"));
59 }
60
61 @Ignore
62 @FunctionalTest
63 @Test
64 public void testDocumentHeaderMaint() throws Exception {
65
66
67
68
69
70
71
72 HtmlPage docHeaderLookUp = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.DOC_HEADER_MAINT_URL);
73 docHeaderLookUp = HtmlUnitUtil.clickInputContainingText(docHeaderLookUp, "search");
74 Assert.assertTrue("Page contains admin entry", docHeaderLookUp.asText().contains("admin"));
75 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(docHeaderLookUp, "edit",documentId.toString());
76 Assert.assertTrue("Maintenance Page contains admin entry",maintPage.asText().contains("admin"));
77 }
78
79 @Override
80 public void setUp() throws Exception {
81 super.setUp();
82 TimesheetDocumentHeader tdh = new TimesheetDocumentHeader();
83 tdh.setDocumentId("1234");
84 tdh.setPrincipalId("admin");
85 tdh.setBeginDate(LocalDate.now().toDate());
86 tdh.setEndDate(LocalDate.now().toDate());
87
88 KRADServiceLocator.getBusinessObjectService().save(tdh);
89
90 tdh = new TimesheetDocumentHeader();
91 tdh.setDocumentId("1000");
92 tdh.setPrincipalId("admin");
93 tdh.setBeginDate(LocalDate.now().toDate());
94 tdh.setEndDate(LocalDate.now().toDate());
95
96 KRADServiceLocator.getBusinessObjectService().save(tdh);
97
98 tdh = new TimesheetDocumentHeader();
99 tdh.setDocumentId("2345");
100 tdh.setPrincipalId("admin");
101 tdh.setBeginDate(LocalDate.now().toDate());
102 tdh.setEndDate(LocalDate.now().toDate());
103
104 KRADServiceLocator.getBusinessObjectService().save(tdh);
105 }
106 }