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