1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leavecode.service;
17
18 import java.math.BigDecimal;
19
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.kuali.hr.lm.leavecode.LeaveCode;
23 import org.kuali.hr.test.KPMETestCase;
24 import org.kuali.hr.time.service.base.TkServiceLocator;
25
26 public class LeaveCodeServiceTest extends KPMETestCase {
27
28 @Test
29 public void testRoundHrsWithLeaveCode() {
30 LeaveCode leaveCode = new LeaveCode();
31 leaveCode.setLeaveCode("testLC");
32 leaveCode.setEligibleForAccrual("Y");
33 leaveCode.setAccrualCategory("testAC");
34 leaveCode.setLeavePlan("testLP");
35 leaveCode.setUnitOfTime("M");
36
37 leaveCode.setFractionalTimeAllowed("99.999");
38
39 leaveCode.setRoundingOption("T");
40
41 BigDecimal hours = new BigDecimal("12.3846");
42 BigDecimal roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
43 Assert.assertTrue("Rounded hours should be 12.385", roundedHours.equals(new BigDecimal("12.385")));
44 hours = new BigDecimal("5.1234");
45 roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
46 Assert.assertTrue("Rounded hours should be 5.123", roundedHours.equals(new BigDecimal("5.123")));
47 hours = new BigDecimal("3.0");
48 roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
49 Assert.assertTrue("Rounded hours should be 3.000", roundedHours.equals(new BigDecimal("3.000")));
50
51
52 leaveCode.setRoundingOption("R");
53
54 hours = new BigDecimal("12.3846");
55 roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
56 Assert.assertTrue("Rounded hours should be 12.384", roundedHours.equals(new BigDecimal("12.384")));
57 hours = new BigDecimal("5.1234");
58 roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
59 Assert.assertTrue("Rounded hours should be 5.123", roundedHours.equals(new BigDecimal("5.123")));
60 hours = new BigDecimal("3.0");
61 roundedHours = TkServiceLocator.getLeaveCodeService().roundHrsWithLeaveCode(hours, leaveCode);
62 Assert.assertTrue("Rounded hours should be 3.000", roundedHours.equals(new BigDecimal("3.000")));
63 }
64
65 }