1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.block.history;
17
18 import java.math.BigDecimal;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.joda.time.DateTime;
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.kuali.kpme.core.IntegrationTest;
26 import org.kuali.kpme.core.util.TKUtils;
27 import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
28 import org.kuali.kpme.tklm.api.common.TkConstants;
29 import org.kuali.kpme.tklm.api.time.timeblock.TimeBlock;
30 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
31 import org.kuali.kpme.tklm.time.timeblock.TimeBlockHistory;
32 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
33 import org.kuali.kpme.tklm.utils.TkTestUtils;
34
35 @IntegrationTest
36 public class TimeBlockHistoryTest extends TKLMIntegrationTestCase {
37
38 private static DateTime DEFAULT_EFFDT =new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
39 private static DateTime beginDateTime = new DateTime(2010, 1, 1, 8, 0, 0, 0, TKUtils.getSystemDateTimeZone());
40 private static DateTime endDateTime = new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone());
41
42 @Test
43 public void testTimeBlockHistory() throws Exception {
44 TimesheetDocument td = TkTestUtils.populateBlankTimesheetDocument(DEFAULT_EFFDT, "admin");
45 List<TimeBlock> tbs = TkServiceLocator.getTimeBlockService().buildTimeBlocks(td.getPrincipalId(), td.getCalendarEntry(), td.getAllAssignments().get(0), "RGH",
46 td.getDocumentId(), beginDateTime, endDateTime, new BigDecimal("8"), BigDecimal.ZERO, true, false, "admin", null, null);
47 TkServiceLocator.getTimeBlockService().saveOrUpdateTimeBlocks(td.getTimeBlocks(), tbs, "admin");
48
49 List<TimeBlockHistory> tbhs = new ArrayList<TimeBlockHistory>();
50 for(TimeBlock tb : td.getTimeBlocks()) {
51 tbhs.addAll(TkServiceLocator.getTimeBlockHistoryService().getTimeBlockHistoryByTkTimeBlockId(tb.getTkTimeBlockId()));
52 }
53
54 for(TimeBlockHistory tbh : tbhs) {
55 Assert.assertEquals(TkConstants.ACTIONS.ADD_TIME_BLOCK, tbh.getActionHistory());
56 }
57 }
58 }