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 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
35
36 @FunctionalTest
37 public class TimesheetDocumentHeaderTest extends KPMEWebTestCase {
38
39
40
41 private static Long documentId = 1L;
42
43
44
45
46
47 @IntegrationTest
48 @Test
49 public void testDocumentHeaderPrevFetch() throws Exception{
50 TimesheetDocumentHeader timeHeader = new TimesheetDocumentHeader();
51 timeHeader.setDocumentId("1");
52 timeHeader.setPrincipalId("admin");
53 timeHeader.setDocumentStatus("F");
54 timeHeader.setBeginDateTime(new DateTime(2011, 1, 1, 0, 0, 0));
55 timeHeader.setEndDateTime(new DateTime(2011, 1, 15, 0, 0, 0));
56 KRADServiceLocatorWeb.getLegacyDataAdapter().save(timeHeader);
57 DateTime dateTime = new DateTime(2011,1,15,0,0,0,0);
58 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getPreviousDocumentHeader("admin", dateTime);
59 Assert.assertTrue(tdh!=null && StringUtils.equals(tdh.getDocumentId(),"1"));
60 }
61
62 @Ignore
63 @FunctionalTest
64 @Test
65 public void testDocumentHeaderMaint() throws Exception {
66
67
68
69
70
71
72
73 HtmlPage docHeaderLookUp = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.DOC_HEADER_MAINT_URL);
74 docHeaderLookUp = HtmlUnitUtil.clickInputContainingText(docHeaderLookUp, "search");
75 Assert.assertTrue("Page contains admin entry", docHeaderLookUp.asText().contains("admin"));
76 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(docHeaderLookUp, "edit",documentId.toString());
77 Assert.assertTrue("Maintenance Page contains admin entry",maintPage.asText().contains("admin"));
78 }
79
80 @Override
81 public void setUp() throws Exception {
82 super.setUp();
83 TimesheetDocumentHeader tdh = new TimesheetDocumentHeader();
84 tdh.setDocumentId("1234");
85 tdh.setPrincipalId("admin");
86 tdh.setBeginDate(LocalDate.now().toDate());
87 tdh.setEndDate(LocalDate.now().toDate());
88
89 KRADServiceLocatorWeb.getLegacyDataAdapter().save(tdh);
90
91 tdh = new TimesheetDocumentHeader();
92 tdh.setDocumentId("1000");
93 tdh.setPrincipalId("admin");
94 tdh.setBeginDate(LocalDate.now().toDate());
95 tdh.setEndDate(LocalDate.now().toDate());
96
97 KRADServiceLocatorWeb.getLegacyDataAdapter().save(tdh);
98
99 tdh = new TimesheetDocumentHeader();
100 tdh.setDocumentId("2345");
101 tdh.setPrincipalId("admin");
102 tdh.setBeginDate(LocalDate.now().toDate());
103 tdh.setEndDate(LocalDate.now().toDate());
104
105 KRADServiceLocatorWeb.getLegacyDataAdapter().save(tdh);
106 }
107 }