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.clocklog.service;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.junit.Assert;
022 import org.junit.Test;
023 import org.kuali.hr.test.KPMETestCase;
024 import org.kuali.hr.time.service.base.TkServiceLocator;
025 import org.kuali.hr.time.timeblock.TimeBlock;
026
027 public class ClockLogServiceTest extends KPMETestCase {
028
029 @Test
030 public void testGetUnapprovedIPWarning() throws Exception {
031 List<TimeBlock> tbLists = new ArrayList<TimeBlock>();
032 TimeBlock timeBlock = new TimeBlock();
033 timeBlock.setUserPrincipalId("testUser");
034 timeBlock.setClockLogCreated(true);
035 timeBlock.setClockLogEndId("5000");
036 tbLists.add(timeBlock);
037
038 List<String> warningList = TkServiceLocator.getClockLogService().getUnapprovedIPWarning(tbLists);
039 Assert.assertTrue("There should be 1 warning message ", warningList.size()== 1);
040 String warning = warningList.get(0);
041 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,
042 warning.equals("Warning: Action 'Clock Out' taken at 2012-03-01 08:08:08.0 was from an unapproved IP address - TEST"));
043
044 }
045 }