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.timecollection.rule; 017 018 import java.sql.Date; 019 import java.sql.Timestamp; 020 import java.util.Calendar; 021 022 import org.junit.Assert; 023 import org.junit.Test; 024 import org.kuali.hr.test.KPMETestCase; 025 import org.kuali.hr.time.collection.rule.TimeCollectionRule; 026 import org.kuali.hr.time.service.base.TkServiceLocator; 027 import org.kuali.rice.krad.service.KRADServiceLocator; 028 029 public class TimeCollectionRuleTest extends KPMETestCase{ 030 031 @Test 032 public void testTimeCollectionRuleFetch() throws Exception{ 033 loadData(); 034 TimeCollectionRule timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT", 035 1234L, new Date(System.currentTimeMillis())); 036 Assert.assertTrue("Time collection rule present" , timeCollection!=null); 037 038 timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME", 039 1234L, new Date(System.currentTimeMillis())); 040 Assert.assertTrue("Time collection rule present" , timeCollection!=null); 041 042 timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-DEPT", 043 234L, new Date(System.currentTimeMillis())); 044 Assert.assertTrue("Time collection rule present" , timeCollection!=null); 045 046 timeCollection = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule("TEST-ME", 047 234L, new Date(System.currentTimeMillis())); 048 Assert.assertTrue("Time collection rule present" , timeCollection!=null); 049 } 050 051 private void loadData() 052 { 053 TimeCollectionRule timeCollectionRule = new TimeCollectionRule(); 054 timeCollectionRule.setDept("TEST-DEPT"); 055 timeCollectionRule.setWorkArea(1234L); 056 timeCollectionRule.setEffectiveDate(new Date(System.currentTimeMillis())); 057 timeCollectionRule.setActive(true); 058 timeCollectionRule.setTimestamp(new Timestamp(Calendar.getInstance().getTimeInMillis())); 059 KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule); 060 061 TimeCollectionRule timeCollectionRule2 = new TimeCollectionRule(); 062 timeCollectionRule2.setDept("TEST-ME"); 063 timeCollectionRule2.setWorkArea(234L); 064 timeCollectionRule2.setEffectiveDate(new Date(System.currentTimeMillis())); 065 timeCollectionRule2.setActive(true); 066 timeCollectionRule2.setTimestamp(new Timestamp(Calendar.getInstance().getTimeInMillis())); 067 KRADServiceLocator.getBusinessObjectService().save(timeCollectionRule2); 068 } 069 }