View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.time.accrual;
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.lm.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 AccrualCategoryMaintTest 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.setLeavePlan("");
59          accrualCategory.setAccrualEarnInterval("");
60          accrualCategory.setUnitOfTime("");
61          accrualCategory.setEarnCode("OC1");
62  		KRADServiceLocator.getBusinessObjectService().save(accrualCategory);
63  		accrualCategoryId = accrualCategory.getLmAccrualCategoryId();
64  	}
65  
66  	@Override
67  	public void tearDown() throws Exception {
68  		AccrualCategory accrualCategory = KRADServiceLocator
69  				.getBusinessObjectService().findBySinglePrimaryKey(
70  						AccrualCategory.class, accrualCategoryId);
71  		KRADServiceLocator.getBusinessObjectService().delete(accrualCategory);
72  		super.tearDown();
73  	}
74  
75  }