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.user.pref;
17  
18  import java.sql.Timestamp;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.junit.Assert;
24  import org.junit.Test;
25  import org.kuali.hr.test.KPMETestCase;
26  import org.kuali.hr.time.service.base.TkServiceLocator;
27  import org.kuali.hr.time.timeblock.TimeBlock;
28  import org.kuali.hr.time.util.TKUtils;
29  
30  public class UserPrefTest extends KPMETestCase{
31  	@Test
32  	public void testUserPrefFetch() throws Exception{
33  		UserPreferences userPref = TkServiceLocator.getUserPreferenceService().getUserPreferences("admin");
34  		Assert.assertTrue("User Pref is valid", userPref!=null && StringUtils.equals(userPref.getTimezone(),"America/Indianapolis"));
35  	}
36  
37  	@Test
38  	public void testTimeZoneTranslate() throws Exception{
39  		TimeBlock tb = new TimeBlock();
40  		tb.setBeginTimestamp(new Timestamp(TKUtils.getCurrentDate().getTime()));
41  		tb.setEndTimestamp(new Timestamp(TKUtils.getCurrentDate().getTime()));
42  
43  		List<TimeBlock> tbs = new ArrayList<TimeBlock>();
44  		tbs.add(tb);
45  
46  		TkServiceLocator.getTimezoneService().translateForTimezone(tbs, "America/Indianapolis");
47  	}
48  
49  }