1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timeblock;
17
18 import java.math.BigDecimal;
19 import java.sql.Date;
20 import java.sql.Timestamp;
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.joda.time.DateTime;
25 import org.joda.time.DateTimeZone;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.kuali.hr.test.KPMETestCase;
29 import org.kuali.hr.time.service.base.TkServiceLocator;
30 import org.kuali.hr.time.test.TkTestUtils;
31 import org.kuali.hr.time.timesheet.TimesheetDocument;
32 import org.kuali.hr.time.util.TKContext;
33 import org.kuali.hr.time.util.TKUtils;
34 import org.kuali.hr.time.util.TkConstants;
35
36 public class TimeBlockHistoryTest extends KPMETestCase {
37
38 private static Date DEFAULT_EFFDT = new Date((new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
39 Timestamp beginTimestamp = new Timestamp(new DateTime(2010, 1, 1, 8, 0, 0, 0, TKUtils.getSystemDateTimeZone()).getMillis());
40 Timestamp endTimestamp = new Timestamp(new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()).getMillis());
41
42 @Test
43 public void testTimeBlockHistory() throws Exception {
44 TimesheetDocument td = TkTestUtils.populateBlankTimesheetDocument(DEFAULT_EFFDT);
45 List<TimeBlock> tbs = TkServiceLocator.getTimeBlockService().buildTimeBlocks(td.getAssignments().get(0), "RGH", td, beginTimestamp, endTimestamp, new BigDecimal("8"), BigDecimal.ZERO, true, false, TKContext.getPrincipalId());
46 TkServiceLocator.getTimeBlockService().saveTimeBlocks(td.getTimeBlocks(), tbs, TKContext.getPrincipalId());
47
48 List<TimeBlockHistory> tbhs = new ArrayList<TimeBlockHistory>();
49 for(TimeBlock tb : td.getTimeBlocks()) {
50 tbhs.add(TkServiceLocator.getTimeBlockHistoryService().getTimeBlockHistoryByTkTimeBlockId(tb.getTkTimeBlockId()));
51 }
52
53 for(TimeBlockHistory tbh : tbhs) {
54 Assert.assertEquals(TkConstants.ACTIONS.ADD_TIME_BLOCK, tbh.getActionHistory());
55 }
56 }
57 }