1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timeblock.service;
17
18 import java.sql.Date;
19 import java.util.Map;
20
21 import org.joda.time.DateTime;
22 import org.junit.Assert;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.detail.web.ActionFormUtils;
27 import org.kuali.hr.time.service.base.TkServiceLocator;
28 import org.kuali.hr.time.test.TkTestUtils;
29 import org.kuali.hr.time.timeblock.TimeBlock;
30 import org.kuali.hr.time.timesheet.TimesheetDocument;
31 import org.kuali.hr.time.util.TKUtils;
32 import org.kuali.hr.time.util.TkConstants;
33 @Ignore
34 public class TimeBlockServiceTest extends KPMETestCase {
35 @Test
36 public void testBuildAssignmentStyleClassMap() {
37 Date aDate = new Date((new DateTime(2011, 7, 7, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
38 TimesheetDocument doc = TkTestUtils.populateTimesheetDocument(aDate);
39 Map<String, String> aMap = ActionFormUtils.buildAssignmentStyleClassMap(doc.getTimeBlocks());
40 Assert.assertEquals("Wrong number of classes in style class map", 8, aMap.size());
41 Assert.assertEquals("Wrong key for class assignment0", "assignment0", aMap.get("1_1234_1"));
42 Assert.assertEquals("Wrong key for class assignment7", "assignment7", aMap.get("6_1100_5"));
43 }
44
45 @Test
46 public void testIsTimeBlockEditable() {
47
48 TimeBlock tb = new TimeBlock();
49 tb.setClockLogCreated(false);
50 tb.setJobNumber(new Long(30));
51 tb.setUserPrincipalId("admin");
52
53 Boolean editable = TkServiceLocator.getTimeBlockService().isTimeBlockEditable(tb);
54 Assert.assertEquals("TimeBlock created by admin should be editable by admin", true, editable);
55
56
57 tb.setUserPrincipalId("fran");
58 editable = TkServiceLocator.getTimeBlockService().isTimeBlockEditable(tb);
59 Assert.assertEquals("TimeBlock created by fran should be editable by admin", true, editable);
60
61
62
63
64
65
66
67
68
69 tb.setUserPrincipalId("fran");
70 tb.setClockLogCreated(true);
71 editable = TkServiceLocator.getTimeBlockService().isTimeBlockEditable(tb);
72 Assert.assertEquals("TimeBlock created by Clock in/out should NOT be editable by fran", false, editable);
73
74 }
75
76 }