001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.gl.service;
017:
018: import java.util.List;
019: import java.util.UUID;
020:
021: import org.kuali.core.dbplatform.RawSQL;
022: import org.kuali.core.util.UnitTestSqlDao;
023: import org.kuali.kfs.context.KualiTestBase;
024: import org.kuali.kfs.context.SpringContext;
025: import org.kuali.test.ConfigureContext;
026:
027: /**
028: * A test that allows manual testing of report generation for nightly out (ie, creates results and then people can look at those results and make certain they were expected)
029: */
030: @ConfigureContext
031: @RawSQL
032: public class ReportServiceTest extends KualiTestBase {
033:
034: private NightlyOutService nightlyOutService;
035: private ReportService reportService;
036: private UnitTestSqlDao unitTestSqlDao;
037:
038: /**
039: * Sets up the services needed by this test
040: * @see junit.framework.TestCase#setUp()
041: */
042: @Override
043: protected void setUp() throws Exception {
044: super .setUp();
045:
046: nightlyOutService = SpringContext
047: .getBean(NightlyOutService.class);
048: reportService = SpringContext.getBean(ReportService.class);
049: unitTestSqlDao = SpringContext.getBean(UnitTestSqlDao.class);
050: }
051:
052: /**
053: * This method isn't as much a test as an easy way to fire off the report generation process so that the reports can be checked.
054: *
055: * @throws Exception thrown if any exception is encountered for any reason
056: */
057: public void testPendingEntryReport() throws Exception {
058:
059: // Empty out the origin entry group & origin entry tables
060: unitTestSqlDao.sqlCommand("delete from gl_origin_entry_t");
061: unitTestSqlDao.sqlCommand("delete from gl_origin_entry_grp_t");
062:
063: // Empty out the pending entry table & doc header table
064: unitTestSqlDao
065: .sqlCommand("delete from fp_doc_header_t where fdoc_nbr in ('1','2','3','4','5','6')");
066: unitTestSqlDao.sqlCommand("delete from gl_pending_entry_t");
067:
068: // Add a few documents
069: unitTestSqlDao
070: .sqlCommand("insert into fp_doc_header_t (fdoc_nbr,obj_id,ver_nbr,fdoc_status_cd,fdoc_desc,fdoc_total_amt,org_doc_nbr,"
071: + "fdoc_in_err_nbr,fdoc_tmpl_nbr) values ('1','"
072: + UUID.randomUUID().toString()
073: + "',1,'A','a',100,'OA',null,null)");
074: unitTestSqlDao
075: .sqlCommand("insert into fp_doc_header_t (fdoc_nbr,obj_id,ver_nbr,fdoc_status_cd,fdoc_desc,fdoc_total_amt,org_doc_nbr,"
076: + "fdoc_in_err_nbr,fdoc_tmpl_nbr) values ('2','"
077: + UUID.randomUUID().toString()
078: + "',1,'A','b',100,'OB',null,null)");
079: unitTestSqlDao
080: .sqlCommand("insert into fp_doc_header_t (fdoc_nbr,obj_id,ver_nbr,fdoc_status_cd,fdoc_desc,fdoc_total_amt,org_doc_nbr,"
081: + "fdoc_in_err_nbr,fdoc_tmpl_nbr) values ('3','"
082: + UUID.randomUUID().toString()
083: + "',1,'A','c',100,'OC',null,null)");
084:
085: unitTestSqlDao
086: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
087: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
088: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
089: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
090: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','1',1,'"
091: + UUID.randomUUID().toString()
092: + "',1,'BA','123456',"
093: + "null,'4161',null,'AC','EX',2004,'01','Description',100,'D',"
094: + unitTestSqlDao.getDbPlatform()
095: .getCurTimeFunction()
096: + ",'JV',11,null,null,null,null,null,null,' ','A','4166',null,null)");
097:
098: unitTestSqlDao
099: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
100: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
101: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
102: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
103: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','1',2,'"
104: + UUID.randomUUID().toString()
105: + "',1,'BA','123456',"
106: + "null,'4162',null,'AC','EX',2004,'01','Description',100,'C',"
107: + unitTestSqlDao.getDbPlatform()
108: .getCurTimeFunction()
109: + ",'JV',12,null,null,null,null,null,null,' ','A','4166',null,null)");
110:
111: unitTestSqlDao
112: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
113: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
114: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
115: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
116: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','2',3,'"
117: + UUID.randomUUID().toString()
118: + "',1,'BA','223456',"
119: + "null,'4163',null,'AC','EX',2004,'01','Description',100,'D',"
120: + unitTestSqlDao.getDbPlatform()
121: .getCurTimeFunction()
122: + ",'JV',13,null,null,null,null,null,null,' ','A','4166',null,null)");
123:
124: unitTestSqlDao
125: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
126: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
127: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
128: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
129: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','2',4,'"
130: + UUID.randomUUID().toString()
131: + "',1,'BA','223456',"
132: + "null,'4164',null,'AC','EX',2004,'01','Description',100,'C',"
133: + unitTestSqlDao.getDbPlatform()
134: .getCurTimeFunction()
135: + ",'JV',14,null,null,null,null,null,null,' ','A','4166',null,null)");
136:
137: unitTestSqlDao
138: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
139: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
140: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
141: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
142: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','3',5,'"
143: + UUID.randomUUID().toString()
144: + "',1,'BA','323456',"
145: + "null,'4165',null,'AC','EX',2004,'01','Description',100,'',"
146: + unitTestSqlDao.getDbPlatform()
147: .getCurTimeFunction()
148: + ",'JV',15,null,null,null,null,null,null,' ','A','4166',null,null)");
149:
150: unitTestSqlDao
151: .sqlCommand("insert into gl_pending_entry_t (fs_origin_cd,fdoc_nbr,trn_entr_seq_nbr,obj_id,ver_nbr,fin_coa_cd,account_nbr,"
152: + "sub_acct_nbr,fin_object_cd,fin_sub_obj_cd,fin_balance_typ_cd,fin_obj_typ_cd,univ_fiscal_yr,univ_fiscal_prd_cd,"
153: + "trn_ldgr_entr_desc,trn_ldgr_entr_amt,trn_debit_crdt_cd,transaction_dt,fdoc_typ_cd,org_doc_nbr,project_cd,"
154: + "org_reference_id,fdoc_ref_typ_cd,fs_ref_origin_cd,fdoc_ref_nbr,fdoc_reversal_dt,trn_encum_updt_cd,fdoc_approved_cd,"
155: + "acct_sf_finobj_cd,trn_entr_ofst_cd,trnentr_process_tm) values ('01','3',6,'"
156: + UUID.randomUUID().toString()
157: + "',1,'BA','323456',"
158: + "null,'4166',null,'AC','EX',2004,'01','Description',100,'',"
159: + unitTestSqlDao.getDbPlatform()
160: .getCurTimeFunction()
161: + ",'JV',16,null,null,null,null,null,null,' ','A','4166',null,null)");
162:
163: nightlyOutService.copyApprovedPendingLedgerEntries();
164:
165: List groups = unitTestSqlDao
166: .sqlSelect("select * from gl_origin_entry_grp_t");
167: assertEquals("Should have 1 group", 1, groups.size());
168:
169: List entries = unitTestSqlDao
170: .sqlSelect("select * from gl_origin_entry_t");
171: assertEquals("Should have 6 entries", 6, entries.size());
172: // TODO: fix this
173: // reportService.generatePendingEntryReport();
174:
175: }
176:
177: }
|