1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.department.earncode.service;
17
18 import java.util.Calendar;
19 import java.util.List;
20
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.kuali.hr.earncodesec.EarnCodeSecurity;
25 import org.kuali.hr.earncodesec.service.EarnCodeSecurityService;
26 import org.kuali.hr.test.KPMETestCase;
27 import org.kuali.hr.time.service.base.TkServiceLocator;
28
29 public class EarnCodeSecurityServiceImplTest extends KPMETestCase {
30
31 public static final String TEST_TEST_DEPT = "TEST-DEPT";
32 public static final String TEST_LORA = "LORA-DEPT";
33 public static final String TEST_SAL_GROUP_A10 = "A10";
34 public static final String TEST_SAL_GROUP_A = "A";
35 public static final String TEST_LOCATION = "";
36 private static final java.sql.Date TEST_DATE=new java.sql.Date(Calendar.getInstance().getTimeInMillis());
37 private EarnCodeSecurityService earnCodeSecurityService = null;
38
39 @Before
40 public void setUp() throws Exception {
41 super.setUp();
42 earnCodeSecurityService=TkServiceLocator.getEarnCodeSecurityService();
43 }
44
45 @Test
46 public void testGetEarnCodeSecurities() throws Exception {
47
48 List<EarnCodeSecurity> earnCodeSecurities = earnCodeSecurityService.getEarnCodeSecurities(TEST_LORA, TEST_SAL_GROUP_A10, TEST_LOCATION, TEST_DATE);
49 Assert.assertEquals("Wrong number of earn codes returned.", 5, earnCodeSecurities.size());
50
51 Assert.assertEquals("First Earn Code should be RGH", "RGH", earnCodeSecurities.get(0).getEarnCode());
52 Assert.assertEquals("Second Earn Code should be SCK", "SCK", earnCodeSecurities.get(1).getEarnCode());
53 Assert.assertEquals("Third Earn Code should be VAC", "VAC", earnCodeSecurities.get(2).getEarnCode());
54 Assert.assertEquals("Forth Earn Code should be XYZ", "XYZ", earnCodeSecurities.get(3).getEarnCode());
55 Assert.assertEquals("Fifth Earn Code should be XZZ", "XZZ", earnCodeSecurities.get(4).getEarnCode());
56
57 for (EarnCodeSecurity ec : earnCodeSecurities) {
58 Assert.assertTrue("Wrong department earn code.", ((ec.getDept()).equals("LORA-DEPT") || (ec.getDept()).equals("%")) );
59 Assert.assertTrue("Wrong SAL_GROUP.", (ec.getHrSalGroup()).equals(TEST_SAL_GROUP_A10) || (ec.getHrSalGroup()).equals("%") );
60 }
61
62
63 List<EarnCodeSecurity> earnCodesSec1 = earnCodeSecurityService.getEarnCodeSecurities(TEST_TEST_DEPT, TEST_SAL_GROUP_A, TEST_LOCATION, TEST_DATE);
64 Assert.assertEquals("Wrong number of earn codes returned.", 2, earnCodesSec1.size());
65
66 for (EarnCodeSecurity ec1 : earnCodesSec1) {
67 Assert.assertTrue("Wrong department earn code.", ((ec1.getDept()).equals(TEST_TEST_DEPT) || (ec1.getDept()).equals("%")) );
68 Assert.assertTrue("Wrong SAL_GROUP.", (ec1.getHrSalGroup()).equals(TEST_SAL_GROUP_A) || (ec1.getHrSalGroup()).equals("%") );
69 }
70 }
71
72 }