Source Code Cross Referenced for AccountRuleTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » chart » rules » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.chart.rules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2006-2007 The Kuali Foundation.
0003:         * 
0004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0005:         * you may not use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         * 
0008:         * http://www.opensource.org/licenses/ecl1.php
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:        package org.kuali.module.chart.rules;
0017:
0018:        import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
0019:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapEmpty;
0020:        import static org.kuali.test.util.KualiTestAssertionUtils.assertGlobalErrorMapSize;
0021:
0022:        import java.sql.Timestamp;
0023:        import java.util.ArrayList;
0024:        import java.util.Calendar;
0025:        import java.util.List;
0026:
0027:        import org.apache.commons.lang.time.DateUtils;
0028:        import org.kuali.core.bo.user.AuthenticationUserId;
0029:        import org.kuali.core.bo.user.UniversalUser;
0030:        import org.kuali.core.document.MaintenanceDocument;
0031:        import org.kuali.core.exceptions.UserNotFoundException;
0032:        import org.kuali.core.service.BusinessObjectService;
0033:        import org.kuali.core.service.DateTimeService;
0034:        import org.kuali.core.service.UniversalUserService;
0035:        import org.kuali.core.util.GlobalVariables;
0036:        import org.kuali.kfs.KFSKeyConstants;
0037:        import org.kuali.kfs.bo.Options;
0038:        import org.kuali.kfs.context.SpringContext;
0039:        import org.kuali.kfs.service.OptionsService;
0040:        import org.kuali.module.chart.bo.Account;
0041:        import org.kuali.module.chart.bo.AccountGuideline;
0042:        import org.kuali.module.chart.bo.SubFundGroup;
0043:        import org.kuali.test.ConfigureContext;
0044:
0045:        @ConfigureContext(session=KHUNTLEY)
0046:        public class AccountRuleTest extends ChartRuleTestBase {
0047:
0048:            private class Accounts {
0049:                private class ChartCode {
0050:                    private static final String GOOD1 = "BL";
0051:                    private static final String CLOSED1 = "BL";
0052:                    private static final String EXPIRED1 = "BL";
0053:                    private static final String GOOD2 = "UA";
0054:                    private static final String BAD1 = "ZZ";
0055:                }
0056:
0057:                private class AccountNumber {
0058:                    private static final String GOOD1 = "1031400";
0059:                    private static final String CLOSED1 = "2231414";
0060:                    private static final String EXPIRED1 = "2231404";
0061:                    private static final String BAD1 = "9999999";
0062:                }
0063:
0064:                private class Org {
0065:                    private static final String GOOD1 = "ACAD";
0066:                    private static final String BAD1 = "1234";
0067:                }
0068:
0069:                private class Campus {
0070:                    private static final String GOOD1 = "BL";
0071:                    private static final String BAD1 = "99";
0072:                }
0073:
0074:                private class State {
0075:                    private static final String GOOD1 = "IN";
0076:                    private static final String BAD1 = "ZZ";
0077:                }
0078:
0079:                private class Zip {
0080:                    private static final String GOOD1 = "47405-3085";
0081:                    private static final String BAD1 = "12345-6789";
0082:                }
0083:
0084:                private class AccountType {
0085:                    private static final String GOOD1 = "NA";
0086:                    private static final String BAD1 = "ZZ";
0087:                }
0088:
0089:                private class SubFund {
0090:                    private class Code {
0091:                        private static final String CG1 = "HIEDUA";
0092:                        private static final String GF1 = "GENFND";
0093:                        private static final String GF_MPRACT = "MPRACT";
0094:                        private static final String EN1 = "ENDOW";
0095:                    }
0096:
0097:                    private class FundGroupCode {
0098:                        private static final String CG1 = "CG";
0099:                        private static final String GF1 = "GF";
0100:                        private static final String EN1 = "EN";
0101:                    }
0102:
0103:                    private static final String GOOD1 = "GENFND";
0104:                }
0105:
0106:                private class HigherEdFunction {
0107:                    private static final String GOOD1 = "AC";
0108:                }
0109:
0110:                private class RestrictedCode {
0111:                    private static final String GOOD1 = "U";
0112:                }
0113:
0114:                private class BudgetRecordingLevel {
0115:                    private static final String GOOD1 = "A";
0116:                }
0117:
0118:                private class User {
0119:                    private class McafeeAlan {
0120:                        private static final String UNIVERSAL_ID = "1509103107";
0121:                        private static final String USER_ID = "AEMCAFEE";
0122:                        private static final String EMP_ID = "0000000013";
0123:                        private static final String NAME = "Mcafee,Alan";
0124:                        private static final String EMP_STATUS = "A";
0125:                        private static final String EMP_TYPE = "P";
0126:                    }
0127:
0128:                    private class PhamAnibal {
0129:                        private static final String UNIVERSAL_ID = "1195901455";
0130:                        private static final String USER_ID = "AAPHAM";
0131:                        private static final String EMP_ID = "0000004686";
0132:                        private static final String NAME = "Pham,Anibal";
0133:                        private static final String EMP_STATUS = "A";
0134:                        private static final String EMP_TYPE = "P";
0135:                    }
0136:
0137:                    private class AhlersEsteban {
0138:                        private static final String UNIVERSAL_ID = "1959008511";
0139:                        private static final String USER_ID = "AHLERS";
0140:                        private static final String EMP_ID = "0000002820";
0141:                        private static final String NAME = "Ahlers,Esteban";
0142:                        private static final String EMP_STATUS = "A";
0143:                        private static final String EMP_TYPE = "P";
0144:                    }
0145:                }
0146:
0147:                private class FiscalOfficer {
0148:                    private static final String GOOD1 = "4318506633";
0149:                }
0150:
0151:                private class Supervisor {
0152:                    private static final String GOOD1 = "4052406505";
0153:                }
0154:
0155:                private class Manager {
0156:                    private static final String GOOD1 = "4318506633";
0157:                }
0158:
0159:                private class UserIds {
0160:                    private static final String SUPER1 = "HEAGLE";
0161:                    private static final String GOOD1 = "KCOPLEY";
0162:                    private static final String GOOD2 = "KHUNTLEY";
0163:                }
0164:
0165:                private class IndirectCostRecoveryTypeCode {
0166:                    private static final String GOOD1 = "";
0167:                }
0168:            }
0169:
0170:            private static UniversalUser FO;
0171:            private static UniversalUser SUPERVISOR;
0172:            private static UniversalUser MANAGER;
0173:            Account newAccount;
0174:
0175:            /**
0176:             * @see org.kuali.module.chart.rules.ChartRuleTestBase#setUp()
0177:             */
0178:            @Override
0179:            protected void setUp() throws Exception {
0180:                super .setUp();
0181:                newAccount = new Account();
0182:                newAccount
0183:                        .setAccountFiscalOfficerSystemIdentifier(Accounts.FiscalOfficer.GOOD1);
0184:                newAccount
0185:                        .setAccountsSupervisorySystemsIdentifier(Accounts.Supervisor.GOOD1);
0186:                newAccount
0187:                        .setAccountManagerSystemIdentifier(Accounts.Manager.GOOD1);
0188:            }
0189:
0190:            public void testDefaultExistenceChecks_Org_KnownGood() {
0191:
0192:                // create new account to test
0193:                newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0194:                newAccount.setOrganizationCode(Accounts.Org.GOOD1);
0195:
0196:                // run the test
0197:                testDefaultExistenceCheck(newAccount, "organizationCode", false);
0198:                assertGlobalErrorMapEmpty();
0199:
0200:            }
0201:
0202:            public void testDefaultExistenceChecks_Org_KnownBad() {
0203:
0204:                // create new account to test
0205:
0206:                newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0207:                newAccount.setOrganizationCode(Accounts.Org.BAD1);
0208:
0209:                // run the test
0210:                testDefaultExistenceCheck(newAccount, "organizationCode", true);
0211:                assertGlobalErrorMapSize(1);
0212:
0213:            }
0214:
0215:            public void testDefaultExistenceChecks_AccountPhysicalCampus_KnownGood() {
0216:
0217:                // create new account to test
0218:
0219:                newAccount.setAccountPhysicalCampusCode(Accounts.Campus.GOOD1);
0220:
0221:                // run the test
0222:                testDefaultExistenceCheck(newAccount,
0223:                        "accountPhysicalCampusCode", false);
0224:                assertGlobalErrorMapEmpty();
0225:
0226:            }
0227:
0228:            public void testDefaultExistenceChecks_AccountPhysicalCampus_KnownBad() {
0229:
0230:                // create new account to test
0231:
0232:                newAccount.setAccountPhysicalCampusCode(Accounts.Campus.BAD1);
0233:
0234:                // run the test
0235:                testDefaultExistenceCheck(newAccount,
0236:                        "accountPhysicalCampusCode", true);
0237:                assertGlobalErrorMapSize(1);
0238:
0239:            }
0240:
0241:            public void testDefaultExistenceChecks_AccountState_KnownGood() {
0242:
0243:                // create new account to test
0244:
0245:                newAccount.setAccountStateCode(Accounts.State.GOOD1);
0246:
0247:                // run the test
0248:                testDefaultExistenceCheck(newAccount, "accountStateCode", false);
0249:                assertGlobalErrorMapEmpty();
0250:
0251:            }
0252:
0253:            public void testDefaultExistenceChecks_AccountState_KnownBad() {
0254:
0255:                // create new account to test
0256:
0257:                newAccount.setAccountStateCode(Accounts.State.BAD1);
0258:
0259:                // run the test
0260:                testDefaultExistenceCheck(newAccount, "accountStateCode", true);
0261:                assertGlobalErrorMapSize(1);
0262:
0263:            }
0264:
0265:            public void testDefaultExistenceChecks_PostalZipCode_KnownGood() {
0266:
0267:                // create new account to test
0268:
0269:                newAccount.setAccountZipCode(Accounts.Zip.GOOD1);
0270:
0271:                // run the test
0272:                testDefaultExistenceCheck(newAccount, "accountZipCode", false);
0273:                assertGlobalErrorMapEmpty();
0274:
0275:            }
0276:
0277:            public void testDefaultExistenceChecks_PostalZipCode_KnownBad() {
0278:
0279:                // create new account to test
0280:
0281:                newAccount.setAccountZipCode(Accounts.Zip.BAD1);
0282:
0283:                // run the test
0284:                testDefaultExistenceCheck(newAccount, "accountZipCode", true);
0285:                assertGlobalErrorMapSize(1);
0286:
0287:            }
0288:
0289:            public void testDefaultExistenceChecks_AccountType_KnownGood() {
0290:
0291:                // create new account to test
0292:
0293:                newAccount.setAccountTypeCode(Accounts.AccountType.GOOD1);
0294:
0295:                // run the test
0296:                testDefaultExistenceCheck(newAccount, "accountTypeCode", false);
0297:                assertGlobalErrorMapEmpty();
0298:
0299:            }
0300:
0301:            public void testDefaultExistenceChecks_AccountType_KnownBad() {
0302:
0303:                // create new account to test
0304:
0305:                newAccount.setAccountTypeCode(Accounts.AccountType.BAD1);
0306:
0307:                // run the test
0308:                testDefaultExistenceCheck(newAccount, "accountTypeCode", true);
0309:                assertGlobalErrorMapSize(1);
0310:
0311:            }
0312:
0313:            // TODO: finish explicitly testing all the defaultExistenceChecks ... though this isnt hugely valuable
0314:
0315:            public void testGuidelinesConditionallyRequired_NullExpirationDate() {
0316:
0317:                boolean result;
0318:                Account account = new Account();
0319:                MaintenanceDocument maintDoc = newMaintDoc(account);
0320:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0321:                        AccountRule.class);
0322:
0323:                account.setAccountExpirationDate(null);
0324:                result = rule.areGuidelinesRequired(account);
0325:                assertEquals(
0326:                        "Guidelines should be required for Account with no ExpirationDate.",
0327:                        true, result);
0328:
0329:            }
0330:
0331:            public void testGuidelinesConditionallyRequired_FarPastDate() {
0332:
0333:                boolean result;
0334:                Account account = new Account();
0335:                MaintenanceDocument maintDoc = newMaintDoc(account);
0336:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0337:                        AccountRule.class);
0338:
0339:                // get an arbitrarily early date
0340:                Calendar testDate = Calendar.getInstance();
0341:                testDate.clear();
0342:                testDate.set(1900, 1, 1);
0343:                account.setAccountExpirationDate(new Timestamp(testDate
0344:                        .getTimeInMillis()));
0345:                result = rule.areGuidelinesRequired(account);
0346:                assertEquals(
0347:                        "Guidelines should not be required for Account with prior ExpirationDate",
0348:                        false, result);
0349:            }
0350:
0351:            public void testGuidelinesConditionallyRequired_TodaysDate() {
0352:
0353:                boolean result;
0354:                Account account = new Account();
0355:                MaintenanceDocument maintDoc = newMaintDoc(account);
0356:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0357:                        AccountRule.class);
0358:
0359:                // setup a var with today's date
0360:                Timestamp today = SpringContext.getBean(DateTimeService.class)
0361:                        .getCurrentTimestamp();
0362:                today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH)
0363:                        .getTime());
0364:                account.setAccountExpirationDate(today);
0365:                result = rule.areGuidelinesRequired(account);
0366:                assertEquals(
0367:                        "Guidelines should be required for Account expiring today.",
0368:                        true, result);
0369:
0370:            }
0371:
0372:            public void testGuidelinesConditionallyRequired_FarFutureDate() {
0373:
0374:                boolean result;
0375:                Account account = new Account();
0376:                MaintenanceDocument maintDoc = newMaintDoc(account);
0377:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0378:                        AccountRule.class);
0379:
0380:                // get an arbitrarily future date
0381:                Calendar testDate = Calendar.getInstance();
0382:                testDate.clear();
0383:                testDate.set(2100, 1, 1);
0384:                account.setAccountExpirationDate(new Timestamp(testDate
0385:                        .getTimeInMillis()));
0386:                result = rule.areGuidelinesRequired(account);
0387:                assertEquals(
0388:                        "Guidelines should be required for Account with future ExpirationDate",
0389:                        true, result);
0390:
0391:            }
0392:
0393:            public void testAccountNumberStartsWithAllowedPrefix() {
0394:
0395:                Account account = new Account();
0396:                MaintenanceDocument maintDoc = newMaintDoc(account);
0397:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0398:                        AccountRule.class);
0399:
0400:                boolean result;
0401:                List<String> illegalValues = new ArrayList();
0402:                String accountNumber;
0403:
0404:                accountNumber = "0100000";
0405:                illegalValues.add("0");
0406:                result = rule.accountNumberStartsWithAllowedPrefix(
0407:                        accountNumber, illegalValues);
0408:                assertEquals(false, result);
0409:
0410:                accountNumber = "9999990";
0411:                illegalValues.clear();
0412:                illegalValues.add("999999");
0413:                result = rule.accountNumberStartsWithAllowedPrefix(
0414:                        accountNumber, illegalValues);
0415:                assertEquals(false, result);
0416:
0417:                accountNumber = "1031400";
0418:                illegalValues.clear();
0419:                illegalValues.add("0");
0420:                result = rule.accountNumberStartsWithAllowedPrefix(
0421:                        accountNumber, illegalValues);
0422:                assertEquals(true, result);
0423:
0424:                accountNumber = "1031400";
0425:                illegalValues.clear();
0426:                illegalValues.add("0");
0427:                illegalValues.add("9");
0428:                illegalValues.add("Z");
0429:                result = rule.accountNumberStartsWithAllowedPrefix(
0430:                        accountNumber, illegalValues);
0431:                assertEquals(true, result);
0432:
0433:            }
0434:
0435:            private UniversalUser getKualiUserByUserName(String userName) {
0436:                AuthenticationUserId userId = new AuthenticationUserId(userName);
0437:                UniversalUser user = null;
0438:                try {
0439:                    user = SpringContext.getBean(UniversalUserService.class)
0440:                            .getUniversalUser(userId);
0441:                } catch (UserNotFoundException e) {
0442:                    assertTrue("An Exception should not be thrown.", false);
0443:                }
0444:                return user;
0445:            }
0446:
0447:            // public void testNonSystemSupervisorReopeningClosedAccount_NotBeingReopened() {
0448:            //
0449:            // Account oldAccount = new Account();
0450:            // 
0451:            // maintDoc = newMaintDoc(oldAccount, newAccount);
0452:            // AccountRule rule= (AccountRule) setupMaintDocRule(maintDoc, AccountRule.class);
0453:            //
0454:            // boolean result;
0455:            // KualiUser user = null;
0456:            //
0457:            // // setup common information
0458:            // oldAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0459:            // oldAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0460:            // newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0461:            // newAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0462:            //
0463:            // // document not being closed
0464:            // oldAccount.setAccountClosedIndicator(false);
0465:            // newAccount.setAccountClosedIndicator(false);
0466:            // user = getKualiUserByUserName(Accounts.UserIds.GOOD1);
0467:            // result = rule.isNonSystemSupervisorReopeningAClosedAccount(maintDoc, user);
0468:            // assertEquals("Account is not closed, and is not being reopened.", false, result);
0469:            //
0470:            // }
0471:
0472:            // public void testNonSystemSupervisorReopeningClosedAccount_BeingReopenedNotSupervisor() {
0473:            //
0474:            // Account oldAccount = new Account();
0475:            // 
0476:            // maintDoc = newMaintDoc(oldAccount, newAccount);
0477:            // AccountRule rule= (AccountRule) setupMaintDocRule(maintDoc, AccountRule.class);
0478:            //
0479:            // boolean result;
0480:            // KualiUser user = null;
0481:            //
0482:            // // setup common information
0483:            // oldAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0484:            // oldAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0485:            // newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0486:            // newAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0487:            //
0488:            // // document being closed, non-supervisor user
0489:            // oldAccount.setAccountClosedIndicator(true);
0490:            // newAccount.setAccountClosedIndicator(false);
0491:            // user = getKualiUserByUserName(Accounts.UserIds.GOOD1);
0492:            // result = rule.isNonSystemSupervisorReopeningAClosedAccount(maintDoc, user);
0493:            // assertEquals("Account is being reopened by a non-System-Supervisor.", true, result);
0494:            //
0495:            // }
0496:
0497:            // public void testNonSystemSupervisorReopeningClosedAccount_BeingReopenedBySupervisor() {
0498:            //
0499:            // Account oldAccount = new Account();
0500:            // 
0501:            // maintDoc = newMaintDoc(oldAccount, newAccount);
0502:            // AccountRule rule= (AccountRule) setupMaintDocRule(maintDoc, AccountRule.class);
0503:            //
0504:            // boolean result;
0505:            // KualiUser user = null;
0506:            //
0507:            // // setup common information
0508:            // oldAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0509:            // oldAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0510:            // newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0511:            // newAccount.setAccountNumber(Accounts.AccountNumber.GOOD1);
0512:            //
0513:            // // document being closed, supervisor user
0514:            // oldAccount.setAccountClosedIndicator(true);
0515:            // newAccount.setAccountClosedIndicator(false);
0516:            // user = getKualiUserByUserName(Accounts.UserIds.SUPER1);
0517:            // result = rule.isNonSystemSupervisorReopeningAClosedAccount(maintDoc, user);
0518:            // assertEquals("Account is being reopened by a System-Supervisor.", false, result);
0519:            //
0520:            // }
0521:
0522:            public void testHasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate_BothNull() {
0523:
0524:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0525:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0526:                        AccountRule.class);
0527:                boolean result;
0528:
0529:                // restricted status code blank, date not set
0530:                newAccount.setAccountRestrictedStatusCode(null);
0531:                newAccount.setAccountRestrictedStatusDate(null);
0532:                result = rule
0533:                        .hasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate(newAccount);
0534:                assertEquals("No error should be thrown if code is blank.",
0535:                        false, result);
0536:
0537:            }
0538:
0539:            public void testHasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate_NonTCodeAndNullDate() {
0540:
0541:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0542:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0543:                        AccountRule.class);
0544:                boolean result;
0545:
0546:                // restricted status code != T, date not set
0547:                newAccount.setAccountRestrictedStatusCode("U");
0548:                newAccount.setAccountRestrictedStatusDate(null);
0549:                result = rule
0550:                        .hasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate(newAccount);
0551:                assertEquals("No error should be thrown if code is not T.",
0552:                        false, result);
0553:
0554:            }
0555:
0556:            public void testHasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate_TCodeAndNullDate() {
0557:
0558:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0559:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0560:                        AccountRule.class);
0561:                boolean result;
0562:
0563:                // restricted status code == T, date not set
0564:                newAccount.setAccountRestrictedStatusCode("T");
0565:                newAccount.setAccountRestrictedStatusDate(null);
0566:                result = rule
0567:                        .hasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate(newAccount);
0568:                assertEquals(
0569:                        "An error should be thrown if code is not T, but date is not set.",
0570:                        true, result);
0571:
0572:            }
0573:
0574:            public void testHasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate_TCodeAndRealDate() {
0575:
0576:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0577:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0578:                        AccountRule.class);
0579:                boolean result;
0580:
0581:                // restricted status code == T, date set
0582:                newAccount.setAccountRestrictedStatusCode("T");
0583:                newAccount.setAccountRestrictedStatusDate(SpringContext
0584:                        .getBean(DateTimeService.class).getCurrentTimestamp());
0585:                result = rule
0586:                        .hasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate(newAccount);
0587:                assertEquals(
0588:                        "No error should be thrown if code is T but date is null.",
0589:                        false, result);
0590:
0591:            }
0592:
0593:            public void testCheckUserStatusAndType_NullUser() {
0594:
0595:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0596:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0597:                        AccountRule.class);
0598:                boolean result;
0599:
0600:                String fieldName = "userId";
0601:
0602:                // null user, should return true
0603:                result = rule.checkUserStatusAndType(fieldName, null);
0604:                assertEquals("Null user should return true.", true, result);
0605:                assertGlobalErrorMapEmpty();
0606:
0607:            }
0608:
0609:            public void testCheckUserStatusAndType_TermdAndNonProfessional() {
0610:
0611:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0612:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0613:                        AccountRule.class);
0614:                boolean result;
0615:
0616:                UniversalUser user = new UniversalUser();
0617:                String fieldName = "userId";
0618:
0619:                // User w/ T status and N type, should fail
0620:                user.setEmployeeStatusCode("T");
0621:                user.setEmployeeTypeCode("N");
0622:                result = rule.checkUserStatusAndType(fieldName, user);
0623:                assertEquals(
0624:                        "Terminated and Non-Professional staff should fail.",
0625:                        false, result);
0626:                assertFieldErrorExists(
0627:                        fieldName,
0628:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACTIVE_REQD_FOR_EMPLOYEE);
0629:                assertFieldErrorExists(
0630:                        fieldName,
0631:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PRO_TYPE_REQD_FOR_EMPLOYEE);
0632:                assertGlobalErrorMapSize(1);
0633:
0634:            }
0635:
0636:            public void testCheckUserStatusAndType_ActiveButNonProfessional() {
0637:
0638:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0639:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0640:                        AccountRule.class);
0641:                boolean result;
0642:
0643:                UniversalUser user = new UniversalUser();
0644:                String fieldName = "userId";
0645:
0646:                // User w/ A status and N type, should fail
0647:                user.setEmployeeStatusCode("A");
0648:                user.setEmployeeTypeCode("N");
0649:                result = rule.checkUserStatusAndType(fieldName, user);
0650:                assertEquals("Active but Non-Professional staff should fail.",
0651:                        false, result);
0652:                assertFieldErrorExists(
0653:                        fieldName,
0654:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PRO_TYPE_REQD_FOR_EMPLOYEE);
0655:                assertGlobalErrorMapSize(1);
0656:
0657:            }
0658:
0659:            public void testCheckUserStatusAndType_TermdButProfessional() {
0660:
0661:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0662:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0663:                        AccountRule.class);
0664:                boolean result;
0665:
0666:                UniversalUser user = new UniversalUser();
0667:                String fieldName = "userId";
0668:
0669:                // User w/ T status and N type, should fail
0670:                user.setEmployeeStatusCode("T");
0671:                user.setEmployeeTypeCode("P");
0672:                result = rule.checkUserStatusAndType(fieldName, user);
0673:                assertEquals("Terminated but Professional staff should fail.",
0674:                        false, result);
0675:                assertFieldErrorExists(
0676:                        fieldName,
0677:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACTIVE_REQD_FOR_EMPLOYEE);
0678:                assertGlobalErrorMapSize(1);
0679:
0680:            }
0681:
0682:            public void testCheckUserStatusAndType_ActiveAndProfessional() {
0683:
0684:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0685:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0686:                        AccountRule.class);
0687:                boolean result;
0688:
0689:                UniversalUser user = new UniversalUser();
0690:                String fieldName = "userId";
0691:
0692:                // User w/ T status and N type, should fail
0693:                user.setEmployeeStatusCode("A");
0694:                user.setEmployeeTypeCode("P");
0695:                result = rule.checkUserStatusAndType(fieldName, user);
0696:                assertEquals("Terminated but Professional staff should fail.",
0697:                        true, result);
0698:                assertGlobalErrorMapEmpty();
0699:
0700:            }
0701:
0702:            public void testAreTwoUsersTheSame_BothNull() {
0703:
0704:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0705:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0706:                        AccountRule.class);
0707:                boolean result;
0708:
0709:                UniversalUser user1 = new UniversalUser();
0710:                UniversalUser user2 = new UniversalUser();
0711:
0712:                // both null
0713:                result = rule.areTwoUsersTheSame(null, null);
0714:                assertEquals("Both users null should return false.", false,
0715:                        result);
0716:
0717:            }
0718:
0719:            public void testAreTwoUsersTheSame_User1Null() {
0720:
0721:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0722:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0723:                        AccountRule.class);
0724:                boolean result;
0725:
0726:                UniversalUser user1 = new UniversalUser();
0727:                UniversalUser user2 = new UniversalUser();
0728:
0729:                // user1 null, user2 not null
0730:                result = rule.areTwoUsersTheSame(user1, null);
0731:                assertEquals(
0732:                        "User1 null and User2 not null should return false.",
0733:                        false, result);
0734:
0735:            }
0736:
0737:            public void testAreTwoUsersTheSame_User2Null() {
0738:
0739:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0740:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0741:                        AccountRule.class);
0742:                boolean result;
0743:
0744:                UniversalUser user1 = new UniversalUser();
0745:                UniversalUser user2 = new UniversalUser();
0746:
0747:                // user1 not null, user2 null
0748:                result = rule.areTwoUsersTheSame(null, user2);
0749:                assertEquals(
0750:                        "User1 not null and User2 null should return false.",
0751:                        false, result);
0752:
0753:            }
0754:
0755:            public void testAreTwoUsersTheSame_UsersTheSame() {
0756:
0757:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0758:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0759:                        AccountRule.class);
0760:                boolean result;
0761:
0762:                UniversalUser user1 = new UniversalUser();
0763:                UniversalUser user2 = new UniversalUser();
0764:
0765:                // both users non-null, both populated with same UniversalID
0766:                user1
0767:                        .setPersonUniversalIdentifier(Accounts.User.AhlersEsteban.UNIVERSAL_ID);
0768:                user1
0769:                        .setPersonUserIdentifier(Accounts.User.AhlersEsteban.USER_ID);
0770:                user1
0771:                        .setPersonPayrollIdentifier(Accounts.User.AhlersEsteban.EMP_ID);
0772:                user1.setPersonName(Accounts.User.AhlersEsteban.NAME);
0773:                user2
0774:                        .setPersonUniversalIdentifier(Accounts.User.AhlersEsteban.UNIVERSAL_ID);
0775:                user2
0776:                        .setPersonUserIdentifier(Accounts.User.AhlersEsteban.USER_ID);
0777:                user2
0778:                        .setPersonPayrollIdentifier(Accounts.User.AhlersEsteban.EMP_ID);
0779:                user2.setPersonName(Accounts.User.AhlersEsteban.NAME);
0780:                result = rule.areTwoUsersTheSame(user1, user2);
0781:                assertEquals(
0782:                        "User1 and User2 are same person, diff objects, result true",
0783:                        true, result);
0784:
0785:            }
0786:
0787:            public void testAreTwoUsersTheSame_UsersDifferent() {
0788:
0789:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0790:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0791:                        AccountRule.class);
0792:                boolean result;
0793:
0794:                UniversalUser user1 = new UniversalUser();
0795:                UniversalUser user2 = new UniversalUser();
0796:
0797:                // both users non-null, each different people
0798:                user1
0799:                        .setPersonUniversalIdentifier(Accounts.User.AhlersEsteban.UNIVERSAL_ID);
0800:                user1
0801:                        .setPersonUserIdentifier(Accounts.User.AhlersEsteban.USER_ID);
0802:                user1
0803:                        .setPersonPayrollIdentifier(Accounts.User.AhlersEsteban.EMP_ID);
0804:                user1.setPersonName(Accounts.User.AhlersEsteban.NAME);
0805:                user2
0806:                        .setPersonUniversalIdentifier(Accounts.User.PhamAnibal.UNIVERSAL_ID);
0807:                user2.setPersonUserIdentifier(Accounts.User.PhamAnibal.USER_ID);
0808:                user2
0809:                        .setPersonPayrollIdentifier(Accounts.User.PhamAnibal.EMP_ID);
0810:                user2.setPersonName(Accounts.User.PhamAnibal.NAME);
0811:                result = rule.areTwoUsersTheSame(user1, user2);
0812:                assertEquals(
0813:                        "User1 and User2 are different persons, result should be false",
0814:                        false, result);
0815:
0816:            }
0817:
0818:            public void testCheckFringeBenefitAccountRule_FringeBenefitFlagTrue() {
0819:
0820:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0821:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0822:                        AccountRule.class);
0823:                boolean result;
0824:
0825:                // fringe benefit flag is checked TRUE
0826:                newAccount.setAccountsFringesBnftIndicator(true);
0827:                result = rule.checkFringeBenefitAccountRule(newAccount);
0828:                assertEquals(
0829:                        "If FringeBenefit is checked, then rule always returns true.",
0830:                        true, result);
0831:
0832:            }
0833:
0834:            public void testCheckFringeBenefitAccountRule_FringeBenefitChartCodeMissing() {
0835:
0836:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0837:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0838:                        AccountRule.class);
0839:                boolean result;
0840:
0841:                // fringe benefit chartCode missing
0842:                newAccount.setAccountsFringesBnftIndicator(false);
0843:                newAccount.setReportsToChartOfAccountsCode(null);
0844:                newAccount
0845:                        .setReportsToAccountNumber(Accounts.AccountNumber.GOOD1);
0846:                result = rule.checkFringeBenefitAccountRule(newAccount);
0847:                assertEquals("FringeBenefit ChartCode missing causes error.",
0848:                        false, result);
0849:                assertFieldErrorExists(
0850:                        "reportsToChartOfAccountsCode",
0851:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_RPTS_TO_ACCT_REQUIRED_IF_FRINGEBENEFIT_FALSE);
0852:                assertGlobalErrorMapSize(1);
0853:
0854:            }
0855:
0856:            public void testCheckFringeBenefitAccountRule_FringeBenefitAccountNumberMissing() {
0857:
0858:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0859:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0860:                        AccountRule.class);
0861:                boolean result;
0862:
0863:                // fringe benefit accountNumber missing
0864:                newAccount.setAccountsFringesBnftIndicator(false);
0865:                newAccount
0866:                        .setReportsToChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0867:                newAccount.setReportsToAccountNumber(null);
0868:                result = rule.checkFringeBenefitAccountRule(newAccount);
0869:                assertEquals(
0870:                        "FringeBenefit AccountNumber missing causes error.",
0871:                        false, result);
0872:                assertFieldErrorExists(
0873:                        "reportsToAccountNumber",
0874:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_RPTS_TO_ACCT_REQUIRED_IF_FRINGEBENEFIT_FALSE);
0875:                assertGlobalErrorMapSize(1);
0876:
0877:            }
0878:
0879:            public void testCheckFringeBenefitAccountRule_FringeBenefitAccountDoesntExist() {
0880:
0881:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0882:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0883:                        AccountRule.class);
0884:                boolean result;
0885:
0886:                // fringe benefit accountNumber missing
0887:                newAccount.setAccountsFringesBnftIndicator(false);
0888:                newAccount
0889:                        .setReportsToChartOfAccountsCode(Accounts.ChartCode.GOOD2);
0890:                newAccount
0891:                        .setReportsToAccountNumber(Accounts.AccountNumber.GOOD1);
0892:                result = rule.checkFringeBenefitAccountRule(newAccount);
0893:                assertEquals("FringeBenefit doesnt exist causes error.", false,
0894:                        result);
0895:                assertFieldErrorExists("reportsToAccountNumber",
0896:                        KFSKeyConstants.ERROR_EXISTENCE);
0897:                assertGlobalErrorMapSize(1);
0898:
0899:            }
0900:
0901:            public void testCheckFringeBenefitAccountRule_FringeBenefitAccountClosed() {
0902:
0903:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0904:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0905:                        AccountRule.class);
0906:                boolean result;
0907:
0908:                // fringe benefit accountNumber missing
0909:                newAccount.setAccountsFringesBnftIndicator(false);
0910:                newAccount
0911:                        .setReportsToChartOfAccountsCode(Accounts.ChartCode.CLOSED1);
0912:                newAccount
0913:                        .setReportsToAccountNumber(Accounts.AccountNumber.CLOSED1);
0914:                result = rule.checkFringeBenefitAccountRule(newAccount);
0915:                assertEquals("FringeBenefit Closed causes error.", false,
0916:                        result);
0917:                assertFieldErrorExists(
0918:                        "reportsToAccountNumber",
0919:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_RPTS_TO_ACCT_MUST_BE_FLAGGED_FRINGEBENEFIT);
0920:                assertGlobalErrorMapSize(1);
0921:
0922:            }
0923:
0924:            public void testCheckFringeBenefitAccountRule_FringeBenefitGood() {
0925:
0926:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0927:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0928:                        AccountRule.class);
0929:                boolean result;
0930:
0931:                // fringe benefit accountNumber missing
0932:                newAccount.setAccountsFringesBnftIndicator(false);
0933:                newAccount
0934:                        .setReportsToChartOfAccountsCode(Accounts.ChartCode.GOOD1);
0935:                newAccount
0936:                        .setReportsToAccountNumber(Accounts.AccountNumber.GOOD1);
0937:                result = rule.checkFringeBenefitAccountRule(newAccount);
0938:                assertEquals("Good FringeBenefit Account should not fail.",
0939:                        true, result);
0940:                assertGlobalErrorMapEmpty();
0941:
0942:            }
0943:
0944:            public void testIsContinuationAccountExpired_MissingChartCode() {
0945:
0946:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0947:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0948:                        AccountRule.class);
0949:                boolean result;
0950:
0951:                // continuation chartCode is missing
0952:                newAccount.setContinuationFinChrtOfAcctCd(null);
0953:                newAccount
0954:                        .setContinuationAccountNumber(Accounts.AccountNumber.GOOD1);
0955:                result = rule.isContinuationAccountExpired(newAccount);
0956:                assertEquals(
0957:                        "Missing continuation chartCode should return false.",
0958:                        false, result);
0959:
0960:            }
0961:
0962:            public void testIsContinuationAccountExpired_MissingAccountNumber() {
0963:
0964:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0965:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0966:                        AccountRule.class);
0967:                boolean result;
0968:
0969:                // continuation accountNumber is missing
0970:                newAccount
0971:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.GOOD1);
0972:                newAccount.setContinuationAccountNumber(null);
0973:                result = rule.isContinuationAccountExpired(newAccount);
0974:                assertEquals(
0975:                        "Missing continuation accountNumber should return false.",
0976:                        false, result);
0977:
0978:            }
0979:
0980:            public void testIsContinuationAccountExpired_InvalidContinuationAccount() {
0981:
0982:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
0983:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
0984:                        AccountRule.class);
0985:                boolean result;
0986:
0987:                // bad continuation chart/account
0988:                newAccount
0989:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.BAD1);
0990:                newAccount
0991:                        .setContinuationAccountNumber(Accounts.AccountNumber.GOOD1);
0992:                result = rule.isContinuationAccountExpired(newAccount);
0993:                assertEquals(
0994:                        "Bad continuation chartCode/Account should return false.",
0995:                        false, result);
0996:
0997:            }
0998:
0999:            public void testIsContinuationAccountExpired_ValidNonExpiredContinuationAccount() {
1000:
1001:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1002:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1003:                        AccountRule.class);
1004:                boolean result;
1005:
1006:                // non-expired continuation account
1007:                newAccount
1008:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.GOOD1);
1009:                newAccount
1010:                        .setContinuationAccountNumber(Accounts.AccountNumber.GOOD1);
1011:                result = rule.isContinuationAccountExpired(newAccount);
1012:                assertEquals(
1013:                        "Good and non-expired continuation account should return false.",
1014:                        false, result);
1015:
1016:            }
1017:
1018:            public void testIsContinuationAccountExpired_ValidExpiredContinuationAccount() {
1019:
1020:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1021:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1022:                        AccountRule.class);
1023:                boolean result;
1024:
1025:                // EXPIRED continuation account
1026:                newAccount
1027:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.EXPIRED1);
1028:                newAccount
1029:                        .setContinuationAccountNumber(Accounts.AccountNumber.EXPIRED1);
1030:                result = rule.isContinuationAccountExpired(newAccount);
1031:                assertEquals("A valid, expired account should return true.",
1032:                        true, result);
1033:
1034:            }
1035:
1036:            public void testCheckAccountExpirationDateTodayOrEarlier_NullDate() {
1037:
1038:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1039:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1040:                        AccountRule.class);
1041:                boolean result;
1042:
1043:                // empty expiration date - fail
1044:                newAccount.setAccountExpirationDate(null);
1045:                result = rule
1046:                        .checkAccountExpirationDateValidTodayOrEarlier(newAccount);
1047:                assertEquals("Null expiration date should fail.", false, result);
1048:                assertFieldErrorExists(
1049:                        "accountExpirationDate",
1050:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
1051:                assertGlobalErrorMapSize(1);
1052:
1053:            }
1054:
1055:            public void testCheckAccountExpirationDateTodayOrEarlier_PastDate() {
1056:
1057:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1058:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1059:                        AccountRule.class);
1060:                boolean result;
1061:                Calendar testCalendar;
1062:                Timestamp testTimestamp;
1063:
1064:                // get an arbitrarily early date
1065:                testCalendar = Calendar.getInstance();
1066:                testCalendar.clear();
1067:                testCalendar.set(1900, 1, 1);
1068:                testTimestamp = new Timestamp(testCalendar.getTimeInMillis());
1069:
1070:                // past expiration date - pass
1071:                newAccount.setAccountExpirationDate(testTimestamp);
1072:                result = rule
1073:                        .checkAccountExpirationDateValidTodayOrEarlier(newAccount);
1074:                assertEquals("Arbitrarily early date should fail.", true,
1075:                        result);
1076:                assertGlobalErrorMapEmpty();
1077:
1078:            }
1079:
1080:            public void testCheckAccountExpirationDateTodayOrEarlier_TodaysDate() {
1081:
1082:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1083:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1084:                        AccountRule.class);
1085:                boolean result;
1086:                Calendar testCalendar;
1087:                Timestamp testTimestamp;
1088:
1089:                // get today's date (or whatever's provided by the DateTimeService)
1090:                testCalendar = Calendar.getInstance();
1091:                testCalendar.setTime(SpringContext.getBean(
1092:                        DateTimeService.class).getCurrentDate());
1093:                testCalendar = DateUtils.truncate(testCalendar,
1094:                        Calendar.DAY_OF_MONTH);
1095:                testTimestamp = new Timestamp(testCalendar.getTimeInMillis());
1096:
1097:                // current date - pass
1098:                newAccount.setAccountExpirationDate(testTimestamp);
1099:                result = rule
1100:                        .checkAccountExpirationDateValidTodayOrEarlier(newAccount);
1101:                assertEquals("Today's date should pass.", true, result);
1102:                assertGlobalErrorMapEmpty();
1103:
1104:            }
1105:
1106:            public void testCheckAccountExpirationDateTodayOrEarlier_FutureDate() {
1107:
1108:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1109:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1110:                        AccountRule.class);
1111:                boolean result;
1112:                Calendar testCalendar;
1113:                Timestamp testTimestamp;
1114:
1115:                // get an arbitrarily late date - fail
1116:                testCalendar = Calendar.getInstance();
1117:                testCalendar.clear();
1118:                testCalendar.set(2100, 1, 1);
1119:                testTimestamp = new Timestamp(testCalendar.getTimeInMillis());
1120:
1121:                // past or today expiration date - pass
1122:                newAccount.setAccountExpirationDate(testTimestamp);
1123:                result = rule
1124:                        .checkAccountExpirationDateValidTodayOrEarlier(newAccount);
1125:                assertEquals("Arbitrarily late date should pass.", false,
1126:                        result);
1127:                assertFieldErrorExists(
1128:                        "accountExpirationDate",
1129:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
1130:                assertGlobalErrorMapSize(1);
1131:
1132:            }
1133:
1134:            private void disableBeginBalanceLoadInd() {
1135:                Options options = SpringContext.getBean(OptionsService.class)
1136:                        .getCurrentYearOptions();
1137:                options.setFinancialBeginBalanceLoadInd(true);
1138:                SpringContext.getBean(BusinessObjectService.class)
1139:                        .save(options);
1140:            }
1141:
1142:            public void testCheckCloseAccountContinuation_NullContinuationCoaCode() {
1143:
1144:                // set preconditions
1145:                disableBeginBalanceLoadInd();
1146:                Account oldAccount = new Account();
1147:
1148:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1149:                        newAccount);
1150:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1151:                        AccountRule.class);
1152:                boolean result;
1153:
1154:                // account must be being closed
1155:                oldAccount.setAccountClosedIndicator(false);
1156:                newAccount.setAccountClosedIndicator(true);
1157:                newAccount.setAccountExpirationDate(SpringContext.getBean(
1158:                        DateTimeService.class).getCurrentTimestamp());
1159:
1160:                // continuation coa code null
1161:                newAccount.setContinuationFinChrtOfAcctCd(null);
1162:                newAccount
1163:                        .setContinuationAccountNumber(Accounts.AccountNumber.GOOD1);
1164:                result = rule.checkCloseAccount(maintDoc);
1165:                assertEquals(
1166:                        "Null continuation coa code should fail with one error.",
1167:                        false, result);
1168:                assertFieldErrorExists(
1169:                        "continuationFinChrtOfAcctCd",
1170:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CLOSE_CONTINUATION_ACCT_REQD);
1171:                assertGlobalErrorMapSize(1);
1172:
1173:            }
1174:
1175:            public void testCheckCloseAccountContinuation_NullContinuationAccountNumber() {
1176:
1177:                // set preconditions
1178:                disableBeginBalanceLoadInd();
1179:                Account oldAccount = new Account();
1180:
1181:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1182:                        newAccount);
1183:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1184:                        AccountRule.class);
1185:                boolean result;
1186:
1187:                // account must be being closed
1188:                oldAccount.setAccountClosedIndicator(false);
1189:                newAccount.setAccountClosedIndicator(true);
1190:                newAccount.setAccountExpirationDate(SpringContext.getBean(
1191:                        DateTimeService.class).getCurrentTimestamp());
1192:
1193:                // continuation coa code null
1194:                newAccount
1195:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.GOOD1);
1196:                newAccount.setContinuationAccountNumber(null);
1197:                result = rule.checkCloseAccount(maintDoc);
1198:                assertEquals(
1199:                        "Null continuation account number should fail with one error.",
1200:                        false, result);
1201:                assertFieldErrorExists(
1202:                        "continuationAccountNumber",
1203:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CLOSE_CONTINUATION_ACCT_REQD);
1204:                assertGlobalErrorMapSize(1);
1205:
1206:            }
1207:
1208:            public void testCheckCloseAccountContinuation_ValidContinuationAccount() {
1209:
1210:                Account oldAccount = new Account();
1211:
1212:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1213:                        newAccount);
1214:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1215:                        AccountRule.class);
1216:                boolean result;
1217:
1218:                // account must be being closed
1219:                oldAccount.setAccountClosedIndicator(true);
1220:                newAccount.setAccountClosedIndicator(true);
1221:                newAccount.setAccountExpirationDate(SpringContext.getBean(
1222:                        DateTimeService.class).getCurrentTimestamp());
1223:
1224:                // continuation coa code null
1225:                newAccount
1226:                        .setContinuationFinChrtOfAcctCd(Accounts.ChartCode.GOOD1);
1227:                newAccount
1228:                        .setContinuationAccountNumber(Accounts.AccountNumber.GOOD1);
1229:                result = rule.checkCloseAccount(maintDoc);
1230:                assertEquals(
1231:                        "Valid continuation account info should not fail.",
1232:                        true, result);
1233:                assertGlobalErrorMapEmpty();
1234:
1235:            }
1236:
1237:            /**
1238:             * Note that we are not testing any of the other elements in the AccountRule.checkCloseAccount(). This is because there is no
1239:             * logic to them. They simple exercise GL service methods, and if those GL service methods return false, they add an error.
1240:             */
1241:            @SuppressWarnings("deprecation")
1242:            public void testCGFields_RequiredCGFields_Missing() {
1243:
1244:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1245:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1246:                        AccountRule.class);
1247:                boolean result;
1248:
1249:                // create the populated CG subfundgroup
1250:                SubFundGroup subFundGroup = new SubFundGroup();
1251:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1252:                subFundGroup
1253:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1254:                subFundGroup.setSubfundgrpActivityIndicator(true);
1255:
1256:                // add the subFundGroup info to Account
1257:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1258:                newAccount.setSubFundGroup(subFundGroup);
1259:
1260:                // make sure all the required fields are missing
1261:                newAccount.setContractControlFinCoaCode(null);
1262:                newAccount.setContractControlAccountNumber(null);
1263:                newAccount.setAcctIndirectCostRcvyTypeCd(null);
1264:                newAccount.setFinancialIcrSeriesIdentifier(null);
1265:                newAccount.setIndirectCostRcvyFinCoaCode(null);
1266:                newAccount.setIndirectCostRecoveryAcctNbr(null);
1267:                newAccount.setAccountCfdaNumber(null);
1268:
1269:                // run the rule
1270:                result = rule.checkCgRequiredFields(newAccount);
1271:                assertEquals("Rule should return false with missing fields.",
1272:                        false, result);
1273:                assertGlobalErrorMapSize(4);
1274:                assertFieldErrorExists("acctIndirectCostRcvyTypeCd",
1275:                        KFSKeyConstants.ERROR_REQUIRED);
1276:                assertFieldErrorExists("financialIcrSeriesIdentifier",
1277:                        KFSKeyConstants.ERROR_REQUIRED);
1278:                assertFieldErrorExists("indirectCostRcvyFinCoaCode",
1279:                        KFSKeyConstants.ERROR_REQUIRED);
1280:                assertFieldErrorExists("indirectCostRecoveryAcctNbr",
1281:                        KFSKeyConstants.ERROR_REQUIRED);
1282:
1283:            }
1284:
1285:            @SuppressWarnings("deprecation")
1286:            public void testCGFields_RequiredCGFields_AllPresent() {
1287:
1288:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1289:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1290:                        AccountRule.class);
1291:                boolean result;
1292:
1293:                // create the populated CG subfundgroup
1294:                SubFundGroup subFundGroup = new SubFundGroup();
1295:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1296:                subFundGroup
1297:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1298:                subFundGroup.setSubfundgrpActivityIndicator(true);
1299:
1300:                // add the subFundGroup info to Account
1301:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1302:                newAccount.setSubFundGroup(subFundGroup);
1303:
1304:                // make sure all the required fields are missing
1305:                newAccount
1306:                        .setContractControlFinCoaCode(Accounts.ChartCode.GOOD1);
1307:                newAccount
1308:                        .setContractControlAccountNumber(Accounts.AccountNumber.GOOD1);
1309:                newAccount.setAcctIndirectCostRcvyTypeCd("10");
1310:                newAccount.setFinancialIcrSeriesIdentifier("001");
1311:                newAccount
1312:                        .setIndirectCostRcvyFinCoaCode(Accounts.ChartCode.GOOD1);
1313:                newAccount
1314:                        .setIndirectCostRecoveryAcctNbr(Accounts.AccountNumber.GOOD1);
1315:                newAccount.setAccountCfdaNumber("001");
1316:
1317:                // run the rule
1318:                result = rule.checkCgRequiredFields(newAccount);
1319:                assertGlobalErrorMapEmpty();
1320:                assertEquals("Rule should return true with no missing fields.",
1321:                        true, result);
1322:            }
1323:
1324:            /**
1325:             * @RelatesTo KULRNE-4662 This test makes sure that if the account has a non-CG subfund group, no fields are allowed to be
1326:             *            filled in. (The contrary test--that if we have an account with a CG fund group, all fields are now required--
1327:             *            should be tested by testCGFields_RequiredCGFields_AllPresent()).
1328:             */
1329:            @SuppressWarnings("deprecation")
1330:            public void testCGFields_NotCGSubFund_NoFieldsPresent() {
1331:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1332:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1333:                        AccountRule.class);
1334:                boolean result;
1335:
1336:                // create the populated CG subfundgroup
1337:                SubFundGroup subFundGroup = new SubFundGroup();
1338:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.EN1);
1339:                subFundGroup
1340:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.EN1);
1341:                subFundGroup.setSubfundgrpActivityIndicator(true);
1342:
1343:                // add the subFundGroup info to Account
1344:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.EN1);
1345:                newAccount.setSubFundGroup(subFundGroup);
1346:
1347:                // make sure all the required fields are present, so the rule creates validation errors for all of them
1348:                newAccount
1349:                        .setContractControlFinCoaCode(Accounts.ChartCode.GOOD1);
1350:                newAccount
1351:                        .setContractControlAccountNumber(Accounts.AccountNumber.GOOD1);
1352:                newAccount.setAcctIndirectCostRcvyTypeCd("10");
1353:                newAccount.setFinancialIcrSeriesIdentifier("001");
1354:                newAccount
1355:                        .setIndirectCostRcvyFinCoaCode(Accounts.ChartCode.GOOD1);
1356:                newAccount
1357:                        .setIndirectCostRecoveryAcctNbr(Accounts.AccountNumber.GOOD1);
1358:                newAccount.setAccountCfdaNumber("001");
1359:
1360:                // run the rule
1361:                result = rule.checkCgRequiredFields(newAccount);
1362:                assertFieldErrorExists(
1363:                        "acctIndirectCostRcvyTypeCd",
1364:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_FIELDS_FILLED_FOR_NON_CG_ACCOUNT);
1365:                assertFieldErrorExists(
1366:                        "financialIcrSeriesIdentifier",
1367:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_FIELDS_FILLED_FOR_NON_CG_ACCOUNT);
1368:                assertFieldErrorExists(
1369:                        "indirectCostRcvyFinCoaCode",
1370:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_FIELDS_FILLED_FOR_NON_CG_ACCOUNT);
1371:                assertFieldErrorExists(
1372:                        "indirectCostRecoveryAcctNbr",
1373:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_FIELDS_FILLED_FOR_NON_CG_ACCOUNT);
1374:                assertFalse(
1375:                        "We do not have a C&G sub fund group, but we have all the fields filled; the rule run result should be false",
1376:                        result);
1377:            }
1378:
1379:            /**
1380:             * @RelatesTo KULRNE-4662
1381:             * @RelatesTo KULCG-111 This method makes sure that the new account can act as its own contract control account.
1382:             */
1383:            @SuppressWarnings("deprecation")
1384:            public void testCGFields_AccountCanBeCGAccount() {
1385:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1386:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1387:                        AccountRule.class);
1388:                boolean result;
1389:
1390:                // create the populated CG subfundgroup
1391:                SubFundGroup subFundGroup = new SubFundGroup();
1392:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1393:                subFundGroup
1394:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1395:                subFundGroup.setSubfundgrpActivityIndicator(true);
1396:
1397:                // add the subFundGroup info to Account
1398:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1399:                newAccount.setSubFundGroup(subFundGroup);
1400:
1401:                // set chart of accounts and account #, just for this test run
1402:                String oldNewAccountChart = newAccount.getChartOfAccountsCode();
1403:                String oldNewAccountsAcctNum = newAccount.getAccountNumber();
1404:                newAccount.setChartOfAccountsCode(Accounts.ChartCode.GOOD1);
1405:                newAccount.setAccountNumber(Accounts.AccountNumber.BAD1);
1406:
1407:                // make sure all the required fields are present
1408:                newAccount.setContractControlFinCoaCode(newAccount
1409:                        .getChartOfAccountsCode());
1410:                newAccount.setContractControlAccountNumber(newAccount
1411:                        .getAccountNumber());
1412:                newAccount.setAcctIndirectCostRcvyTypeCd("10");
1413:                newAccount.setFinancialIcrSeriesIdentifier("001");
1414:                newAccount
1415:                        .setIndirectCostRcvyFinCoaCode(Accounts.ChartCode.GOOD1);
1416:                newAccount
1417:                        .setIndirectCostRecoveryAcctNbr(Accounts.AccountNumber.GOOD1);
1418:                newAccount.setAccountCfdaNumber("001");
1419:
1420:                // run the rule
1421:                result = rule.checkCgRequiredFields(newAccount);
1422:                assertGlobalErrorMapEmpty();
1423:                assertTrue(
1424:                        "Rule should allow new account to be the contract control account.",
1425:                        result);
1426:
1427:                newAccount.setChartOfAccountsCode(oldNewAccountChart);
1428:                newAccount.setAccountNumber(oldNewAccountsAcctNum);
1429:            }
1430:
1431:            /**
1432:             * @RelatesTo KULCG-111 This method makes sure that any account specified as the contract control account must actually exist.
1433:             */
1434:            @SuppressWarnings("deprecation")
1435:            public void testCGFields_AccountMustBeReal() {
1436:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1437:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1438:                        AccountRule.class);
1439:                boolean result;
1440:
1441:                // create the populated CG subfundgroup
1442:                SubFundGroup subFundGroup = new SubFundGroup();
1443:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1444:                subFundGroup
1445:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1446:                subFundGroup.setSubfundgrpActivityIndicator(true);
1447:
1448:                // add the subFundGroup info to Account
1449:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1450:                newAccount.setSubFundGroup(subFundGroup);
1451:
1452:                // make sure all the required fields exist...we don't really want to test for that
1453:                newAccount
1454:                        .setContractControlFinCoaCode(Accounts.ChartCode.BAD1);
1455:                newAccount
1456:                        .setContractControlAccountNumber(Accounts.AccountNumber.BAD1);
1457:                newAccount.setAcctIndirectCostRcvyTypeCd("10");
1458:                newAccount.setFinancialIcrSeriesIdentifier("001");
1459:                newAccount
1460:                        .setIndirectCostRcvyFinCoaCode(Accounts.ChartCode.GOOD1);
1461:                newAccount
1462:                        .setIndirectCostRecoveryAcctNbr(Accounts.AccountNumber.GOOD1);
1463:                newAccount.setAccountCfdaNumber("001");
1464:
1465:                // run the rule
1466:                result = rule.checkCgRequiredFields(newAccount);
1467:                assertFieldErrorExists("contractControlAccountNumber",
1468:                        KFSKeyConstants.ERROR_EXISTENCE);
1469:                assertFalse("Rule should require contract account to be real.",
1470:                        result);
1471:            }
1472:
1473:            @SuppressWarnings("deprecation")
1474:            public void testCheckCgIncomeStreamRequired_NotApplicableAccount() {
1475:
1476:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1477:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1478:                        AccountRule.class);
1479:                boolean result;
1480:
1481:                // create the populated CG subfundgroup
1482:                SubFundGroup subFundGroup = new SubFundGroup();
1483:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.EN1);
1484:                subFundGroup
1485:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.EN1);
1486:                subFundGroup.setSubfundgrpActivityIndicator(true);
1487:
1488:                // add the subFundGroup info to Account
1489:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.EN1);
1490:                newAccount.setSubFundGroup(subFundGroup);
1491:
1492:                // make sure the income stream fields are blank
1493:                newAccount.setIncomeStreamFinancialCoaCode(null);
1494:                newAccount.setIncomeStreamAccountNumber(null);
1495:                newAccount.setIncomeStreamAccount(null);
1496:
1497:                // run the rule
1498:                result = rule.checkCgIncomeStreamRequired(newAccount);
1499:                assertEquals("Non-applicable accounts should not fail.", true,
1500:                        result);
1501:                assertGlobalErrorMapEmpty();
1502:
1503:            }
1504:
1505:            @SuppressWarnings("deprecation")
1506:            public void testCheckCgIncomeStreamRequired_GFMPRACTException() {
1507:
1508:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1509:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1510:                        AccountRule.class);
1511:                boolean result;
1512:
1513:                // create the populated CG subfundgroup
1514:                SubFundGroup subFundGroup = new SubFundGroup();
1515:                subFundGroup
1516:                        .setSubFundGroupCode(Accounts.SubFund.Code.GF_MPRACT);
1517:                subFundGroup
1518:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.GF1);
1519:                subFundGroup.setSubfundgrpActivityIndicator(true);
1520:
1521:                // add the subFundGroup info to Account
1522:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.GF_MPRACT);
1523:                newAccount.setSubFundGroup(subFundGroup);
1524:
1525:                // make sure the income stream fields are blank
1526:                newAccount.setIncomeStreamFinancialCoaCode(null);
1527:                newAccount.setIncomeStreamAccountNumber(null);
1528:                newAccount.setIncomeStreamAccount(null);
1529:
1530:                // run the rule
1531:                result = rule.checkCgIncomeStreamRequired(newAccount);
1532:                assertEquals("GF MPRACT account should not fail.", true, result);
1533:                assertGlobalErrorMapEmpty();
1534:
1535:            }
1536:
1537:            @SuppressWarnings("deprecation")
1538:            public void testCheckCgIncomeStreamRequired_CGAcctNoIncomeStreamFields() {
1539:
1540:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1541:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1542:                        AccountRule.class);
1543:                boolean result;
1544:
1545:                // create the populated CG subfundgroup
1546:                SubFundGroup subFundGroup = new SubFundGroup();
1547:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1548:                subFundGroup
1549:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1550:                subFundGroup.setSubfundgrpActivityIndicator(true);
1551:
1552:                // add the subFundGroup info to Account
1553:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1554:                newAccount.setSubFundGroup(subFundGroup);
1555:
1556:                // make sure the income stream fields are blank
1557:                newAccount.setIncomeStreamFinancialCoaCode(null);
1558:                newAccount.setIncomeStreamAccountNumber(null);
1559:                newAccount.setIncomeStreamAccount(null);
1560:
1561:                // run the rule
1562:                result = rule.checkCgIncomeStreamRequired(newAccount);
1563:                assertEquals(
1564:                        "CG Account with no Income Stream data should fail.",
1565:                        false, result);
1566:                assertFieldErrorExists(
1567:                        "incomeStreamFinancialCoaCode",
1568:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_COA_CANNOT_BE_EMPTY);
1569:                assertFieldErrorExists(
1570:                        "incomeStreamAccountNumber",
1571:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_NBR_CANNOT_BE_EMPTY);
1572:                assertGlobalErrorMapSize(2);
1573:
1574:            }
1575:
1576:            @SuppressWarnings("deprecation")
1577:            public void testCheckCgIncomeStreamRequired_CGAcctInvalidIncomeStreamAccount() {
1578:
1579:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1580:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1581:                        AccountRule.class);
1582:                boolean result;
1583:
1584:                // create the populated CG subfundgroup
1585:                SubFundGroup subFundGroup = new SubFundGroup();
1586:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1587:                subFundGroup
1588:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1589:                subFundGroup.setSubfundgrpActivityIndicator(true);
1590:
1591:                // add the subFundGroup info to Account
1592:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1593:                newAccount.setSubFundGroup(subFundGroup);
1594:
1595:                // make sure the income stream fields are blank
1596:                newAccount
1597:                        .setIncomeStreamFinancialCoaCode(Accounts.ChartCode.BAD1);
1598:                newAccount
1599:                        .setIncomeStreamAccountNumber(Accounts.AccountNumber.GOOD1);
1600:                newAccount.setIncomeStreamAccount(null);
1601:
1602:                // run the rule
1603:                result = rule.checkCgIncomeStreamRequired(newAccount);
1604:                assertEquals(
1605:                        "CG Account with invalid Income Stream data should fail.",
1606:                        false, result);
1607:                assertFieldErrorExists("incomeStreamAccountNumber",
1608:                        KFSKeyConstants.ERROR_EXISTENCE);
1609:                assertGlobalErrorMapSize(1);
1610:
1611:            }
1612:
1613:            @SuppressWarnings("deprecation")
1614:            public void testCheckCgIncomeStreamRequired_GFAcctNoIncomeStreamFields() {
1615:
1616:                MaintenanceDocument maintDoc = newMaintDoc(newAccount);
1617:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1618:                        AccountRule.class);
1619:                boolean result;
1620:
1621:                // create the populated CG subfundgroup
1622:                SubFundGroup subFundGroup = new SubFundGroup();
1623:                subFundGroup.setSubFundGroupCode(Accounts.SubFund.Code.GF1);
1624:                subFundGroup
1625:                        .setFundGroupCode(Accounts.SubFund.FundGroupCode.GF1);
1626:                subFundGroup.setSubfundgrpActivityIndicator(true);
1627:
1628:                // add the subFundGroup info to Account
1629:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.GF1);
1630:                newAccount.setSubFundGroup(subFundGroup);
1631:
1632:                // make sure the income stream fields are blank
1633:                newAccount.setIncomeStreamFinancialCoaCode(null);
1634:                newAccount.setIncomeStreamAccountNumber(null);
1635:                newAccount.setIncomeStreamAccount(null);
1636:
1637:                // run the rule
1638:                result = rule.checkCgIncomeStreamRequired(newAccount);
1639:                assertEquals(
1640:                        "GF Account with no Income Stream data should fail.",
1641:                        false, result);
1642:                assertFieldErrorExists(
1643:                        "incomeStreamFinancialCoaCode",
1644:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_COA_CANNOT_BE_EMPTY);
1645:                assertFieldErrorExists(
1646:                        "incomeStreamAccountNumber",
1647:                        KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_NBR_CANNOT_BE_EMPTY);
1648:                assertGlobalErrorMapSize(2);
1649:
1650:            }
1651:
1652:            public void testIsUpdateExpirationDateInvalid_BothExpirationDatesNull() {
1653:
1654:                Account oldAccount = new Account();
1655:
1656:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1657:                        newAccount);
1658:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1659:                        AccountRule.class);
1660:                boolean result;
1661:
1662:                // set both expiration dates to null
1663:                oldAccount.setAccountExpirationDate(null);
1664:                newAccount.setAccountExpirationDate(null);
1665:
1666:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1667:                assertEquals(
1668:                        "Doc with no expiration dates should return false.",
1669:                        false, result);
1670:
1671:            }
1672:
1673:            public void testIsUpdateExpirationDateInvalid_ExpirationDatesSame() {
1674:
1675:                Account oldAccount = new Account();
1676:
1677:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1678:                        newAccount);
1679:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1680:                        AccountRule.class);
1681:                boolean result;
1682:
1683:                // get today's date
1684:                Timestamp todaysDate = SpringContext.getBean(
1685:                        DateTimeService.class).getCurrentTimestamp();
1686:
1687:                // set both expiration dates to null
1688:                oldAccount.setAccountExpirationDate(todaysDate);
1689:                newAccount.setAccountExpirationDate(todaysDate);
1690:
1691:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1692:                assertEquals(
1693:                        "Doc with same expiration dates should return false.",
1694:                        false, result);
1695:
1696:            }
1697:
1698:            public void testIsUpdateExpirationDateInvalid_NewExpDateNull() {
1699:
1700:                Account oldAccount = new Account();
1701:
1702:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1703:                        newAccount);
1704:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1705:                        AccountRule.class);
1706:                boolean result;
1707:
1708:                // get today's date
1709:                Timestamp todaysDate = SpringContext.getBean(
1710:                        DateTimeService.class).getCurrentTimestamp();
1711:
1712:                // set both expiration dates to null
1713:                oldAccount.setAccountExpirationDate(todaysDate);
1714:                newAccount.setAccountExpirationDate(null);
1715:
1716:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1717:                assertEquals(
1718:                        "Doc with null new expiration dates should return false.",
1719:                        false, result);
1720:
1721:            }
1722:
1723:            @SuppressWarnings("deprecation")
1724:            public void testIsUpdateExpirationDateInvalid_SubFundGroupNull() {
1725:
1726:                Account oldAccount = new Account();
1727:
1728:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1729:                        newAccount);
1730:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1731:                        AccountRule.class);
1732:                boolean result;
1733:
1734:                // get today's date
1735:                Calendar calendar;
1736:                Timestamp todaysDate = SpringContext.getBean(
1737:                        DateTimeService.class).getCurrentTimestamp();
1738:
1739:                // old exp date
1740:                calendar = Calendar.getInstance();
1741:                calendar.set(1900, 1, 1);
1742:                Timestamp oldDate = new Timestamp(calendar.getTimeInMillis());
1743:
1744:                // new exp date
1745:                Timestamp newDate = todaysDate;
1746:
1747:                // set both expiration dates to null
1748:                oldAccount.setAccountExpirationDate(oldDate);
1749:                newAccount.setAccountExpirationDate(newDate);
1750:
1751:                // set subfund group to null
1752:                newAccount.setSubFundGroupCode(null);
1753:                newAccount.setSubFundGroup(null);
1754:
1755:                // run the rule
1756:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1757:                assertEquals(
1758:                        "Doc with changed exp dates, but no subfund group should false.",
1759:                        false, result);
1760:
1761:            }
1762:
1763:            @SuppressWarnings("deprecation")
1764:            public void testIsUpdateExpirationDateInvalid_ChangedNewInPast_CGSubFund() {
1765:
1766:                Account oldAccount = new Account();
1767:
1768:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1769:                        newAccount);
1770:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1771:                        AccountRule.class);
1772:                boolean result;
1773:
1774:                // get today's date
1775:                Calendar calendar;
1776:                Timestamp todaysDate = SpringContext.getBean(
1777:                        DateTimeService.class).getCurrentTimestamp();
1778:
1779:                // old exp date
1780:                calendar = Calendar.getInstance();
1781:                calendar.set(1900, 1, 1);
1782:                Timestamp oldDate = new Timestamp(calendar.getTimeInMillis());
1783:
1784:                // new exp date
1785:                calendar = Calendar.getInstance();
1786:                calendar.set(2000, 1, 1);
1787:                Timestamp newDate = new Timestamp(calendar.getTimeInMillis());
1788:
1789:                // set both expiration dates to null
1790:                oldAccount.setAccountExpirationDate(oldDate);
1791:                newAccount.setAccountExpirationDate(newDate);
1792:
1793:                // setup new subfund
1794:                SubFundGroup subFundGroup = new SubFundGroup();
1795:                subFundGroup.setFundGroupCode(Accounts.SubFund.Code.CG1);
1796:                subFundGroup
1797:                        .setSubFundGroupCode(Accounts.SubFund.FundGroupCode.CG1);
1798:
1799:                // set subfund group to null
1800:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.CG1);
1801:                newAccount.setSubFundGroup(subFundGroup);
1802:
1803:                // run the rule
1804:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1805:                assertEquals(
1806:                        "Doc with changed exp dates, CG fundgroup should be false.",
1807:                        false, result);
1808:
1809:            }
1810:
1811:            @SuppressWarnings("deprecation")
1812:            public void testIsUpdateExpirationDateInvalid_ChangedNewInPast_NonCGSubFund() {
1813:
1814:                Account oldAccount = new Account();
1815:
1816:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1817:                        newAccount);
1818:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1819:                        AccountRule.class);
1820:                boolean result;
1821:
1822:                // get today's date
1823:                Calendar calendar;
1824:                Timestamp todaysDate = SpringContext.getBean(
1825:                        DateTimeService.class).getCurrentTimestamp();
1826:
1827:                // old exp date
1828:                calendar = Calendar.getInstance();
1829:                calendar.set(1900, 1, 1);
1830:                Timestamp oldDate = new Timestamp(calendar.getTimeInMillis());
1831:
1832:                // new exp date
1833:                calendar = Calendar.getInstance();
1834:                calendar.set(2000, 1, 1);
1835:                Timestamp newDate = new Timestamp(calendar.getTimeInMillis());
1836:
1837:                // set both expiration dates to null
1838:                oldAccount.setAccountExpirationDate(oldDate);
1839:                newAccount.setAccountExpirationDate(newDate);
1840:
1841:                // setup new subfund
1842:                SubFundGroup subFundGroup = new SubFundGroup();
1843:                subFundGroup.setFundGroupCode(Accounts.SubFund.Code.GF1);
1844:                subFundGroup
1845:                        .setSubFundGroupCode(Accounts.SubFund.FundGroupCode.GF1);
1846:
1847:                // set subfund group to null
1848:                newAccount.setSubFundGroupCode(Accounts.SubFund.Code.GF1);
1849:                newAccount.setSubFundGroup(subFundGroup);
1850:
1851:                // run the rule
1852:                result = rule.isUpdatedExpirationDateInvalid(maintDoc);
1853:                assertEquals(
1854:                        "Doc with changed exp dates, exp in past should be false.",
1855:                        false, result);
1856:
1857:            }
1858:
1859:            @SuppressWarnings("deprecation")
1860:            public void testDataDictionaryValidation_AccountPurpose_TooLong() {
1861:                Account oldAccount = new Account();
1862:                newAccount.setAccountGuideline(new AccountGuideline());
1863:                newAccount
1864:                        .getAccountGuideline()
1865:                        .setAccountPurposeText(
1866:                                "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1867:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1868:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1869:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1870:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789");
1871:                assertTrue(
1872:                        "Purpose text should be more than 400 characters.  (was: "
1873:                                + newAccount.getAccountGuideline()
1874:                                        .getAccountPurposeText().length() + ")",
1875:                        newAccount.getAccountGuideline()
1876:                                .getAccountPurposeText().length() > 400);
1877:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1878:                        newAccount);
1879:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1880:                        AccountRule.class);
1881:                rule.processCustomRouteDocumentBusinessRules(maintDoc);
1882:                // System.out.println( GlobalVariables.getErrorMap().entrySet() );
1883:                assertFieldErrorExists("accountGuideline.accountPurposeText",
1884:                        KFSKeyConstants.ERROR_MAX_LENGTH);
1885:            }
1886:
1887:            @SuppressWarnings("deprecation")
1888:            public void testDataDictionaryValidation_AccountPurpose_GoodLength() {
1889:                Account oldAccount = new Account();
1890:                newAccount.setAccountGuideline(new AccountGuideline());
1891:                newAccount
1892:                        .getAccountGuideline()
1893:                        .setAccountPurposeText(
1894:                                "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1895:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1896:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1897:                                        + "01324567890123456789012345678901324567890132456789012345678901234567890132456789\r"
1898:                                        + "013245678901234567890123456789013245678901324567890123456789012345678901324");
1899:                System.out.println(newAccount.getAccountGuideline()
1900:                        .getAccountPurposeText().length());
1901:                assertTrue("Purpose text should be <= 400 characters.  (was: "
1902:                        + newAccount.getAccountGuideline()
1903:                                .getAccountPurposeText().length() + ")",
1904:                        newAccount.getAccountGuideline()
1905:                                .getAccountPurposeText().length() <= 400);
1906:                MaintenanceDocument maintDoc = newMaintDoc(oldAccount,
1907:                        newAccount);
1908:                AccountRule rule = (AccountRule) setupMaintDocRule(maintDoc,
1909:                        AccountRule.class);
1910:                rule.processCustomRouteDocumentBusinessRules(maintDoc);
1911:                System.out.println(GlobalVariables.getErrorMap().entrySet());
1912:                assertFieldErrorDoesNotExist(
1913:                        "accountGuideline.accountPurposeText",
1914:                        KFSKeyConstants.ERROR_MAX_LENGTH);
1915:            }
1916:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.