1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.accural;
17
18 import java.sql.Date;
19 import java.sql.Timestamp;
20 import java.util.Calendar;
21
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.kuali.hr.time.accrual.AccrualCategory;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.test.HtmlUnitUtil;
27 import org.kuali.hr.time.test.TkTestConstants;
28 import org.kuali.rice.krad.service.KRADServiceLocator;
29
30 import com.gargoylesoftware.htmlunit.html.HtmlPage;
31
32 public class AccuralCategoryMaintTest extends KPMETestCase {
33
34 private static final String TEST_CODE = "_T";
35 private static String accrualCategoryId;
36 private static final Date TEST_DATE = new Date(Calendar.getInstance().getTimeInMillis());
37 private static final Timestamp TEST_TIMESTAMP = new Timestamp(Calendar.getInstance().getTimeInMillis());
38
39 @Test
40 public void testAccrualCategoryMaint() throws Exception {
41 HtmlPage accuralCategoryLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.ACCRUAL_CATEGORY_MAINT_URL);
42 Assert.assertEquals("Active is not default to Yes", accuralCategoryLookup.getElementById("activeYes").asText(), "checked");
43 accuralCategoryLookup = HtmlUnitUtil.clickInputContainingText(accuralCategoryLookup, "search");
44 Assert.assertTrue("Page contains test AccuralCategory", accuralCategoryLookup.asText().contains(TEST_CODE.toString()));
45 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(accuralCategoryLookup, "edit", accrualCategoryId.toString());
46 Assert.assertTrue("Maintenance Page contains test AccuralCategory", maintPage.asText().contains(TEST_CODE));
47 }
48
49 @Override
50 public void setUp() throws Exception {
51 super.setUp();
52 AccrualCategory accrualCategory = new AccrualCategory();
53 accrualCategory.setAccrualCategory(TEST_CODE);
54 accrualCategory.setActive(true);
55 accrualCategory.setDescr(TEST_CODE);
56 accrualCategory.setEffectiveDate(TEST_DATE);
57 accrualCategory.setTimestamp(TEST_TIMESTAMP);
58 accrualCategory.setUnitOfTime("");
59 KRADServiceLocator.getBusinessObjectService().save(accrualCategory);
60 accrualCategoryId = accrualCategory.getLmAccrualCategoryId();
61 }
62
63 @Override
64 public void tearDown() throws Exception {
65 AccrualCategory accrualCategory = KRADServiceLocator
66 .getBusinessObjectService().findBySinglePrimaryKey(
67 AccrualCategory.class, accrualCategoryId);
68 KRADServiceLocator.getBusinessObjectService().delete(accrualCategory);
69 super.tearDown();
70 }
71
72 }