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.clocklog.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.junit.Assert;
22  import org.junit.Test;
23  import org.kuali.hr.test.KPMETestCase;
24  import org.kuali.hr.time.service.base.TkServiceLocator;
25  import org.kuali.hr.time.timeblock.TimeBlock;
26  
27  public class ClockLogServiceTest extends KPMETestCase {
28  	
29  	@Test
30  	public void testGetUnapprovedIPWarning() throws Exception {
31  		List<TimeBlock> tbLists = new ArrayList<TimeBlock>();
32  		TimeBlock timeBlock = new TimeBlock();
33          timeBlock.setUserPrincipalId("testUser");
34          timeBlock.setClockLogCreated(true);
35          timeBlock.setClockLogEndId("5000");
36          tbLists.add(timeBlock);		
37  		
38  		List<String> warningList = TkServiceLocator.getClockLogService().getUnapprovedIPWarning(tbLists);
39  		Assert.assertTrue("There should be 1 warning message ", warningList.size()== 1);
40  		String warning = warningList.get(0);
41  		Assert.assertTrue("Warning message should be 'Warning: Action 'Clock Out' taken at 2012-03-01 08:08:08.0 was from an unapproved IP address - TEST', not " + warning, 
42  				warning.equals("Warning: Action 'Clock Out' taken at 2012-03-01 08:08:08.0 was from an unapproved IP address - TEST"));
43  		
44  	}
45  }