001: /*
002: * Copyright 2005-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.financial.document;
017:
018: import static org.kuali.module.financial.document.AccountingDocumentTestUtils.testGetNewDocument_byDocumentClass;
019: import static org.kuali.test.fixtures.AccountingLineFixture.ICA_LINE;
020: import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
021:
022: import java.util.ArrayList;
023: import java.util.List;
024:
025: import org.kuali.core.document.Document;
026: import org.kuali.core.service.DataDictionaryService;
027: import org.kuali.core.service.DocumentService;
028: import org.kuali.core.service.TransactionalDocumentDictionaryService;
029: import org.kuali.kfs.bo.SourceAccountingLine;
030: import org.kuali.kfs.bo.TargetAccountingLine;
031: import org.kuali.kfs.context.KualiTestBase;
032: import org.kuali.kfs.context.SpringContext;
033: import org.kuali.test.ConfigureContext;
034: import org.kuali.test.DocumentTestUtils;
035: import org.kuali.test.fixtures.AccountingLineFixture;
036:
037: /**
038: * This class is used to test the IndirectCostAdjustmentDocument.
039: */
040: @ConfigureContext(session=KHUNTLEY)
041: public class IndirectCostAdjustmentDocumentTest extends KualiTestBase {
042: public static final Class<IndirectCostAdjustmentDocument> DOCUMENT_CLASS = IndirectCostAdjustmentDocument.class;
043:
044: private Document getDocumentParameterFixture() throws Exception {
045: return DocumentTestUtils.createDocument(SpringContext
046: .getBean(DocumentService.class),
047: IndirectCostAdjustmentDocument.class);
048: }
049:
050: private List<AccountingLineFixture> getTargetAccountingLineParametersFromFixtures() {
051: return new ArrayList<AccountingLineFixture>();
052: }
053:
054: private List<AccountingLineFixture> getSourceAccountingLineParametersFromFixtures() {
055: List<AccountingLineFixture> list = new ArrayList<AccountingLineFixture>();
056: list.add(ICA_LINE);
057: return list;
058: }
059:
060: public final void testAddAccountingLine() throws Exception {
061: List<SourceAccountingLine> sourceLines = generateSouceAccountingLines();
062: List<TargetAccountingLine> targetLines = generateTargetAccountingLines();
063: int expectedSourceTotal = sourceLines.size();
064: int expectedTargetTotal = targetLines.size()
065: + expectedSourceTotal;
066: AccountingDocumentTestUtils.testAddAccountingLine(
067: DocumentTestUtils
068: .createDocument(SpringContext
069: .getBean(DocumentService.class),
070: DOCUMENT_CLASS), sourceLines,
071: targetLines, expectedSourceTotal, expectedTargetTotal);
072: }
073:
074: public final void testGetNewDocument() throws Exception {
075: testGetNewDocument_byDocumentClass(DOCUMENT_CLASS,
076: SpringContext.getBean(DocumentService.class));
077: }
078:
079: public final void testConvertIntoCopy_copyDisallowed()
080: throws Exception {
081: AccountingDocumentTestUtils.testConvertIntoCopy_copyDisallowed(
082: buildDocument(), SpringContext
083: .getBean(DataDictionaryService.class));
084:
085: }
086:
087: public final void testConvertIntoErrorCorrection_documentAlreadyCorrected()
088: throws Exception {
089: AccountingDocumentTestUtils
090: .testConvertIntoErrorCorrection_documentAlreadyCorrected(
091: buildDocument(),
092: SpringContext
093: .getBean(TransactionalDocumentDictionaryService.class));
094: }
095:
096: public final void testConvertIntoErrorCorrection_errorCorrectionDisallowed()
097: throws Exception {
098: AccountingDocumentTestUtils
099: .testConvertIntoErrorCorrection_errorCorrectionDisallowed(
100: buildDocument(), SpringContext
101: .getBean(DataDictionaryService.class));
102: }
103:
104: @ConfigureContext(session=KHUNTLEY,shouldCommitTransactions=true)
105: // @RelatesTo(RelatesTo.JiraIssue.KULRNE5779)
106: public final void testConvertIntoErrorCorrection() throws Exception {
107: AccountingDocumentTestUtils
108: .testConvertIntoErrorCorrection(
109: buildDocument(),
110: getExpectedPrePeCount(),
111: SpringContext.getBean(DocumentService.class),
112: SpringContext
113: .getBean(TransactionalDocumentDictionaryService.class));
114: }
115:
116: @ConfigureContext(session=KHUNTLEY,shouldCommitTransactions=true)
117: // @RelatesTo(RelatesTo.JiraIssue.KULRNE5779)
118: public final void testRouteDocument() throws Exception {
119: AccountingDocumentTestUtils.testRouteDocument(buildDocument(),
120: SpringContext.getBean(DocumentService.class));
121: }
122:
123: @ConfigureContext(session=KHUNTLEY,shouldCommitTransactions=true)
124: // @RelatesTo(RelatesTo.JiraIssue.KULRNE5779)
125: public final void testSaveDocument() throws Exception {
126: AccountingDocumentTestUtils.testSaveDocument(buildDocument(),
127: SpringContext.getBean(DocumentService.class));
128: }
129:
130: @ConfigureContext(session=KHUNTLEY,shouldCommitTransactions=true)
131: // @RelatesTo(RelatesTo.JiraIssue.KULRNE5779)
132: public final void testConvertIntoCopy() throws Exception {
133: AccountingDocumentTestUtils.testConvertIntoCopy(
134: buildDocument(), SpringContext
135: .getBean(DocumentService.class),
136: getExpectedPrePeCount());
137: }
138:
139: // test util methods
140: private List<SourceAccountingLine> generateSouceAccountingLines()
141: throws Exception {
142: List<SourceAccountingLine> sourceLines = new ArrayList<SourceAccountingLine>();
143: // set accountinglines to document
144: for (AccountingLineFixture sourceFixture : getSourceAccountingLineParametersFromFixtures()) {
145: sourceLines.add(sourceFixture.createSourceAccountingLine());
146: }
147:
148: return sourceLines;
149: }
150:
151: private List<TargetAccountingLine> generateTargetAccountingLines()
152: throws Exception {
153: List<TargetAccountingLine> targetLines = new ArrayList<TargetAccountingLine>();
154: for (AccountingLineFixture targetFixture : getTargetAccountingLineParametersFromFixtures()) {
155: targetLines.add(targetFixture.createTargetAccountingLine());
156: }
157:
158: return targetLines;
159: }
160:
161: private IndirectCostAdjustmentDocument buildDocument()
162: throws Exception {
163: // put accounting lines into document parameter for later
164: IndirectCostAdjustmentDocument document = (IndirectCostAdjustmentDocument) getDocumentParameterFixture();
165:
166: // set accountinglines to document
167: for (AccountingLineFixture sourceFixture : getSourceAccountingLineParametersFromFixtures()) {
168: sourceFixture.addAsSourceTo(document);
169: }
170:
171: for (AccountingLineFixture targetFixture : getTargetAccountingLineParametersFromFixtures()) {
172: targetFixture.addAsTargetTo(document);
173: }
174:
175: return document;
176: }
177:
178: private int getExpectedPrePeCount() {
179: return 4;
180: }
181:
182: }
|