001    /**
002     * Copyright 2004-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.workarea;
017    
018    import java.sql.Date;
019    
020    import org.junit.Assert;
021    import org.junit.Test;
022    import org.kuali.hr.test.KPMETestCase;
023    import org.kuali.hr.time.service.base.TkServiceLocator;
024    import org.kuali.hr.time.test.HtmlUnitUtil;
025    import org.kuali.hr.time.util.TKUtils;
026    import org.kuali.hr.time.util.TkConstants;
027    import org.kuali.rice.krad.service.KRADServiceLocator;
028    
029    import com.gargoylesoftware.htmlunit.html.HtmlPage;
030    
031    public class WorkAreaMaintenanceTest extends KPMETestCase {
032    
033            @Test
034            public void testWorkAreaMaintenanceScreen() throws Exception{
035            String baseUrl = HtmlUnitUtil.getBaseURL() + "/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.hr.time.workarea.WorkArea&returnLocation=" + HtmlUnitUtil.getBaseURL() + "/portal.do&hideReturnLink=true&docFormKey=88888888";
036            HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
037            setFieldValue(page,"workArea","30");
038            page = HtmlUnitUtil.clickInputContainingText(page, "search");
039            page = HtmlUnitUtil.clickAnchorContainingText(page, "edit");
040            Assert.assertTrue("Test that maintenance screen rendered", page.asText().contains("30"));
041            }
042    
043            @Override
044            public void setUp() throws Exception {
045                    super.setUp();
046                    WorkArea workArea = new WorkArea();
047                    workArea.setTkWorkAreaId("1111");
048                    workArea.setWorkArea(4444L);
049                    workArea.setOvertimeEditRole(TkConstants.ROLE_TK_EMPLOYEE);
050                    workArea.setEffectiveDate(new Date(System.currentTimeMillis()));
051                    KRADServiceLocator.getBusinessObjectService().save(workArea);
052            }
053    
054            @Override
055            public void tearDown() throws Exception {
056                    WorkArea workArea = (WorkArea)KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(WorkArea.class, 1111);
057                    KRADServiceLocator.getBusinessObjectService().delete(workArea);
058                    super.tearDown();
059            }
060            
061            @Test
062            public void testWorkAreaFetch() throws Exception{
063                    WorkArea workArea = TkServiceLocator.getWorkAreaService().getWorkArea(1234L, TKUtils.getCurrentDate());
064                    Assert.assertTrue("Work area is not null and valid", workArea != null && workArea.getWorkArea().longValue() == 1234L);
065            }
066            
067    }