1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.clock.log;
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.kpme.core.IntegrationTest;
24 import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
25 import org.kuali.kpme.tklm.api.time.timeblock.TimeBlock;
26 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
27 import org.kuali.kpme.tklm.time.timeblock.TimeBlockBo;
28
29 @IntegrationTest
30 public class ClockLogServiceTest extends TKLMIntegrationTestCase {
31
32 @Test
33 public void testGetUnapprovedIPWarning() throws Exception {
34 List<TimeBlock> tbLists = new ArrayList<TimeBlock>();
35 TimeBlockBo timeBlock = new TimeBlockBo();
36 timeBlock.setUserPrincipalId("testUser");
37 timeBlock.setClockLogCreated(true);
38 timeBlock.setClockLogEndId("5000");
39 tbLists.add(TimeBlockBo.to(timeBlock));
40
41 List<String> warningList = TkServiceLocator.getClockLogService().getUnapprovedIPWarning(tbLists);
42 Assert.assertTrue("There should be 1 warning message ", warningList.size()== 1);
43 String warning = warningList.get(0);
44 Assert.assertTrue("Warning message should be 'Warning: Action 'Clock Out' taken at 03/01/2012 08:08:08.000 was from an unapproved IP address - TEST', not " + warning,
45 warning.equals("Warning: Action 'Clock Out' taken at 03/01/2012 08:08:08.000 was from an unapproved IP address - TEST"));
46
47 }
48
49 @Test
50 public void testIsClockLogCreatedByMissedPunch() throws Exception {
51 boolean isMissedPunch = TkServiceLocator.getClockLogService().isClockLogCreatedByMissedPunch("5000");
52 Assert.assertTrue("Clock Log 5000 is created by Missed Punch", isMissedPunch);
53
54 isMissedPunch = TkServiceLocator.getClockLogService().isClockLogCreatedByMissedPunch("5001");
55 Assert.assertFalse("Clock Log 5001 is NOT created by Missed Punch", isMissedPunch);
56 }
57 }