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 com.gargoylesoftware.htmlunit.html.HtmlPage;
19 import org.apache.commons.lang.StringUtils;
20 import org.joda.time.DateTime;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.kuali.hr.test.KPMETestCase;
24 import org.kuali.hr.time.service.base.TkServiceLocator;
25 import org.kuali.hr.time.test.HtmlUnitUtil;
26 import org.kuali.hr.time.test.TkTestConstants;
27 import org.kuali.hr.time.test.TkTestUtils;
28 import org.kuali.hr.time.util.TKUtils;
29 import org.kuali.hr.time.workflow.TimesheetDocumentHeader;
30 import org.kuali.rice.krad.service.KRADServiceLocator;
31
32 public class DocumentHeaderTest extends KPMETestCase {
33
34
35
36 private static Long documentId = 1L;
37
38
39
40
41
42 @Test
43 public void testDocumentHeaderPrevFetch() throws Exception{
44 TimesheetDocumentHeader timeHeader = new TimesheetDocumentHeader();
45 timeHeader.setDocumentId("1");
46 timeHeader.setPrincipalId("admin");
47 timeHeader.setDocumentStatus("F");
48 timeHeader.setPayBeginDate(TkTestUtils.createDate(1, 1, 2011, 0, 0, 0));
49 timeHeader.setPayEndDate(TkTestUtils.createDate(1, 15, 2011, 0, 0, 0));
50 KRADServiceLocator.getBusinessObjectService().save(timeHeader);
51 DateTime dateTime = new DateTime(2011,1,15,0,0,0,0);
52 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getPreviousDocumentHeader("admin", new java.util.Date(dateTime.getMillis()));
53 Assert.assertTrue(tdh!=null && StringUtils.equals(tdh.getDocumentId(),"1"));
54 }
55
56 @Test
57 public void testDocumentHeaderMaint() throws Exception {
58 HtmlPage docHeaderLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.DOC_HEADER_MAINT_URL);
59 docHeaderLookUp = HtmlUnitUtil.clickInputContainingText(docHeaderLookUp, "search");
60 Assert.assertTrue("Page contains admin entry", docHeaderLookUp.asText().contains("admin"));
61 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(docHeaderLookUp, "edit",documentId.toString());
62 Assert.assertTrue("Maintenance Page contains admin entry",maintPage.asText().contains("admin"));
63 }
64
65 @Override
66 public void setUp() throws Exception {
67 super.setUp();
68 TimesheetDocumentHeader tdh = new TimesheetDocumentHeader();
69 tdh.setDocumentId("1234");
70 tdh.setPrincipalId("admin");
71 tdh.setPayBeginDate(TKUtils.getCurrentDate());
72 tdh.setPayEndDate(TKUtils.getCurrentDate());
73
74 KRADServiceLocator.getBusinessObjectService().save(tdh);
75
76 tdh = new TimesheetDocumentHeader();
77 tdh.setDocumentId("1000");
78 tdh.setPrincipalId("admin");
79 tdh.setPayBeginDate(TKUtils.getCurrentDate());
80 tdh.setPayEndDate(TKUtils.getCurrentDate());
81
82 KRADServiceLocator.getBusinessObjectService().save(tdh);
83
84 tdh = new TimesheetDocumentHeader();
85 tdh.setDocumentId("2345");
86 tdh.setPrincipalId("admin");
87 tdh.setPayBeginDate(TKUtils.getCurrentDate());
88 tdh.setPayEndDate(TKUtils.getCurrentDate());
89
90 KRADServiceLocator.getBusinessObjectService().save(tdh);
91 }
92 }