001/** 002 * Copyright 2004-2014 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 */ 016package org.kuali.hr.time.systemlunch; 017 018import org.joda.time.DateTime; 019import org.junit.Assert; 020import org.junit.Test; 021import org.kuali.hr.KPMEWebTestCase; 022import org.kuali.kpme.core.FunctionalTest; 023import org.kuali.kpme.core.util.TKUtils; 024import org.kuali.kpme.tklm.time.rules.lunch.sys.SystemLunchRule; 025import org.kuali.kpme.tklm.time.service.TkServiceLocator; 026 027@FunctionalTest 028public class SystemLunchRuleTest extends KPMEWebTestCase { 029 030 SystemLunchRule systemLunchRule; 031 DateTime date = new DateTime(2010, 1, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone()); 032 033 @Test 034 public void testSystemLunchRuleFetch() throws Exception{ 035 this.systemLunchRule = TkServiceLocator.getSystemLunchRuleService().getSystemLunchRule(date.toLocalDate()); 036 Assert.assertTrue("System lunch rule is pulled back", this.systemLunchRule!=null); 037 } 038 039 /** 040 * Test if the lunch in/out button shows and if the time block is created with the correct clock action 041 */ 042 // KPME-3532 system lunch is always off now, so there is no need for this test 043 /* 044 @Test 045 public void testSystemLunchRule() throws Exception { 046 047 systemLunchRule = TkServiceLocator.getSystemLunchRuleService().getSystemLunchRule(date.toLocalDate()); 048 Assert.assertTrue("System lunch rule is pulled back", systemLunchRule!=null); 049 050 String baseUrl = TkTestConstants.Urls.CLOCK_URL; 051 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl, false); 052 Thread.sleep(3000); 053// HtmlPage page = HtmlUnitUtil.gotoPageAnBatchJobEntryTestdLogin(TkTestConstants.Urls.CLOCK_URL); 054 Assert.assertNotNull(page); 055 056 Map<String, Object> criteria = new LinkedHashMap<String, Object>(); 057 criteria.put("selectedAssignment", new String[]{HrTestConstants.FormElementTypes.DROPDOWN, "IU-BL_2_1234_2"}); 058 HtmlUnitUtil.createTempFile(page); 059 // choose the first assignment from the drop down 060 page = HtmlUnitUtil.fillOutForm(page, criteria); 061 Assert.assertNotNull(page); 062 //Thread.sleep(3000); 063 // clock in 064 page = HtmlUnitUtil.clickClockInOrOutButton(page); 065 Thread.sleep(3000); 066 HtmlUnitUtil.createTempFile(page); 067 Assert.assertTrue("The take lunch button didn't appear", page.asXml().contains("lunchOut")); 068 Thread.sleep(3000); 069 // the lunch in button should display after clocking in 070 page = HtmlUnitUtil.clickLunchInOrOutButton(page, "LO"); 071 //Thread.sleep(3000); 072 Assert.assertTrue("The return from lunch button didn't appear", page.asXml().contains("lunchIn")); 073 Thread.sleep(3000); 074 Assert.assertEquals(TkConstants.LUNCH_OUT, TkServiceLocator.getClockLogService().getLastClockLog("admin").getClockAction()); 075 076 if(systemLunchRule.getShowLunchButton()) { 077 //should be in its own test case, but do not want to expect the exception for purposes of another operation encountering it. 078 HtmlForm defaultForm = HtmlUnitUtil.getDefaultForm(page); 079 try { 080 @SuppressWarnings("unused") 081 HtmlSubmitInput input = defaultForm.getInputByName("clockAction"); 082 } catch (Exception e) { 083 Assert.assertTrue("Clock Out button should not be present", e instanceof ElementNotFoundException); 084 } 085 086 } 087 //Thread.sleep(3000); 088 // the lunch out button should display after lunching in 089 page = HtmlUnitUtil.clickLunchInOrOutButton(page, "LI"); 090 Thread.sleep(3000); 091 Assert.assertEquals(TkConstants.LUNCH_IN, TkServiceLocator.getClockLogService().getLastClockLog("admin").getClockAction()); 092 093 } */ 094}