1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.balancetransfer.validation;
17
18 import java.sql.Date;
19
20 import org.joda.time.DateTime;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
24 import org.kuali.hr.test.KPMETestCase;
25 import org.kuali.hr.time.util.TKUtils;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28 public class BalanceTransferValidationUtilsTest extends KPMETestCase {
29
30 @Test
31 public void TestValidateSstoTranser() {
32 Date leaveDate = new Date((new DateTime(2013, 1, 11, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
33 BalanceTransfer bt = new BalanceTransfer();
34 bt.setEffectiveDate(leaveDate);
35 bt.setPrincipalId("testUser");
36
37 boolean flag = BalanceTransferValidationUtils.validateSstoTranser(bt);
38 Assert.assertFalse("Validation should be false", flag);
39 Assert.assertTrue("There should be 1 error messages", GlobalVariables.getMessageMap().getErrorCount() == 1);
40 Assert.assertTrue("There should be error messages for SSTO does not exist", GlobalVariables.getMessageMap().containsMessageKey("balanceTransfer.transferSSTO.sstoDoesNotExis"));
41
42 GlobalVariables.getMessageMap().clearErrorMessages();
43 bt.setSstoId("5000");
44 bt.setFromAccrualCategory("fromAC");
45 flag = BalanceTransferValidationUtils.validateSstoTranser(bt);
46 Assert.assertFalse("Validation should be false", flag);
47 Assert.assertTrue("There should be 1 error messages", GlobalVariables.getMessageMap().getErrorCount() == 1);
48 Assert.assertTrue("There should be error messages for From Accrual category being wrong", GlobalVariables.getMessageMap().containsMessageKey("balanceTransfer.transferSSTO.fromACWrong"));
49
50 GlobalVariables.getMessageMap().clearErrorMessages();
51 bt.setFromAccrualCategory("ISU-HOL");
52 bt.setToAccrualCategory("ISU-HOL");
53 flag = BalanceTransferValidationUtils.validateSstoTranser(bt);
54 Assert.assertFalse("Validation should be false", flag);
55 Assert.assertTrue("There should be 1 error messages", GlobalVariables.getMessageMap().getErrorCount() == 1);
56 Assert.assertTrue("There should be error messages for From and To Accrual categories are the same", GlobalVariables.getMessageMap().containsMessageKey("balanceTransfer.transferSSTO.fromAndToACTheSame"));
57
58 GlobalVariables.getMessageMap().clearErrorMessages();
59 bt.setToAccrualCategory("ISU-HOL-TRF");
60 flag = BalanceTransferValidationUtils.validateSstoTranser(bt);
61 Assert.assertFalse("Validation should be false", flag);
62 Assert.assertTrue("There should be 1 error messages", GlobalVariables.getMessageMap().getErrorCount() == 1);
63 Assert.assertTrue("There should be error messages for Accrual categories does not exist", GlobalVariables.getMessageMap().containsMessageKey("balanceTransfer.transferSSTO.acDoesNotExist"));
64
65 leaveDate = new Date((new DateTime(2013, 2, 11, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
66 bt.setEffectiveDate(leaveDate);
67 GlobalVariables.getMessageMap().clearErrorMessages();
68 flag = BalanceTransferValidationUtils.validateSstoTranser(bt);
69 Assert.assertTrue("Validation should be true", flag);
70 Assert.assertTrue("There should be NO error messages", GlobalVariables.getMessageMap().getErrorCount() == 0);
71 }
72
73 }