/* * The Kuali Financial System, a comprehensive financial management system for higher education. * * Copyright 2005-2014 The Kuali Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kuali.kfs.fp.document.validation.impl; import static org.kuali.kfs.sys.fixture.UserNameFixture.khuntley; import static org.kuali.kfs.sys.service.IsDebitTestUtils.Amount.NEGATIVE; import static org.kuali.kfs.sys.service.IsDebitTestUtils.Amount.POSITIVE; import org.kuali.kfs.fp.document.IndirectCostAdjustmentDocument; import org.kuali.kfs.sys.ConfigureContext; import org.kuali.kfs.sys.businessobject.AccountingLine; import org.kuali.kfs.sys.businessobject.SourceAccountingLine; import org.kuali.kfs.sys.businessobject.TargetAccountingLine; import org.kuali.kfs.sys.context.KualiTestBase; import org.kuali.kfs.sys.context.SpringContext; import org.kuali.kfs.sys.document.AccountingDocument; import org.kuali.kfs.sys.service.IsDebitTestUtils; import org.kuali.rice.core.api.util.type.KualiDecimal; import org.kuali.rice.kns.service.DataDictionaryService; import org.kuali.rice.krad.service.DocumentService; /** * This class tests the <code>{@link IndirectCostAdjustmentDocument}</code>'s rules and PE generation. This is not currently * implemented properly. When we get to building this document, we would need to extend AccountingDocumentRuleTestBase. For now it * contains commented out old fixtures code that will need to be fitted to the new xml based fixtures framework. */ @ConfigureContext(session = khuntley) public class IndirectCostAdjustmentDocumentRuleTest extends KualiTestBase { // //////////////////////////////////////////////////////////////////////// // Test methods start here // // //////////////////////////////////////////////////////////////////////// public final void testSave_nullDocument() throws Exception { boolean failedAsExpected = false; try { SpringContext.getBean(DocumentService.class).saveDocument(null); } catch (IllegalArgumentException e) { failedAsExpected = true; } assertTrue(failedAsExpected); } /** * tests an <code>IllegalStateException</code> is thrown for a positive income * * @throws Exception */ public void testIsDebit_source_income_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> for a negative income * * @throws Exception */ public void testIsDebit_source_income_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero income * * @throws Exception */ public void testIsDebit_source_income_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests true is returned for a positive expense * * @throws Exception */ public void testIsDebit_source_expense_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests false is returned for a negative expense * * @throws Exception */ public void testIsDebit_source_expense_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertFalse(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero expense * * @throws Exception */ public void testIsDebit_source_expense_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive asset * * @throws Exception */ public void testIsDebit_source_asset_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative asset * * @throws Exception */ public void testIsDebit_source_asset_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero asset * * @throws Exception */ public void testIsDebit_source_asset_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive liability * * @throws Exception */ public void testIsDebit_source_liability_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative liability * * @throws Exception */ public void testIsDebit_source_liability_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero liability * * @throws Exception */ public void testIsDebit_source_liability_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests false is returned for a positive income * * @throws Exception */ public void testIsDebit_target_income_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertFalse(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests true is returned for a negative income * * @throws Exception */ public void testIsDebit_target_income_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero income * * @throws Exception */ public void testIsDebit_target_income_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrnow for a positive expense * * @throws Exception */ public void testIsDebit_target_expense_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative expense * * @throws Exception */ public void testIsDebit_target_expense_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero expense * * @throws Exception */ public void testIsDebit_target_expense_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive asset * * @throws Exception */ public void testIsDebit_target_asset_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrnow for a negative asset * * @throws Exception */ public void testIsDebit_target_asset_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero asset * * @throws Exception */ public void testIsDebit_target_asset_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive liability * * @throws Exception */ public void testIsDebit_target_liability_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative liability * * @throws Exception */ public void testIsDebit_target_liability_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero liability * * @throws Exception */ public void testIsDebit_target_liability_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive income * * @throws Exception */ public void testIsDebit_errorCorrection_source_income_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative income * * @throws Exception */ public void testIsDebit_errorCorrection_source_income_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero income * * @throws Exception */ public void testIsDebit_errorCorrection_source_income_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests true is returned for positive expense * * @throws Exception */ public void testIsDebit_errorCorrection_source_expense_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests false is returned for a negative expense * * @throws Exception */ public void testIsDebit_errorCorrection_source_expense_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertFalse(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero expense * * @throws Exception */ public void testIsDebit_errorCorrection_source_expense_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive asset * * @throws Exception */ public void testIsDebit_errorCorrection_source_asset_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative asset * * @throws Exception */ public void testIsDebit_errorCorrection_source_asset_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero asset * * @throws Exception */ public void testIsDebit_errorCorrection_source_asset_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> for a positive liability * * @throws Exception */ public void testIsDebit_errorCorrection_source_liability_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> for a negative liability * * @throws Exception */ public void testIsDebit_errorCorrection_source_liability_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero liability * * @throws Exception */ public void testIsDebit_errorCorrection_source_liability_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, SourceAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests false is returned for a positive income * * @throws Exception */ public void testIsDebit_errorCorrection_target_income_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertFalse(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests true is returned for a negative income * * @throws Exception */ public void testIsDebit_errorCorrection_target_income_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebit(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero income * * @throws Exception */ public void testIsDebit_errorCorrection_target_income_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getIncomeLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive expense * * @throws Exception */ public void testIsDebit_errorCorrection_target_expense_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateExcpetion</code> is thrown for a negative expense * * @throws Exception */ public void testIsDebit_errorCorrection_target_expense_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero expense * * @throws Exception */ public void testIsDebit_errorCorrection_target_expense_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getExpenseLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive asset * * @throws Exception */ public void testIsDebit_errorCorrection_target_asset_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a negative asset * * @throws Exception */ public void testIsDebit_errorCorrection_target_asset_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero asset * * @throws Exception */ public void testIsDebit_errorCorrection_target_asset_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getAssetLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a positive liability * * @throws Exception */ public void testIsDebit_errorCorrection_target_liability_positveAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, POSITIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is throw for a negative liability * * @throws Exception */ public void testIsDebit_errorCorrection_target_liability_negativeAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, NEGATIVE); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /** * tests an <code>IllegalStateException</code> is thrown for a zero liability * * @throws Exception */ public void testIsDebit_errorCorrection_target_liability_zeroAmount() throws Exception { AccountingDocument accountingDocument = IsDebitTestUtils.getErrorCorrectionDocument(SpringContext.getBean(DocumentService.class), IndirectCostAdjustmentDocument.class); AccountingLine accountingLine = IsDebitTestUtils.getLiabilityLine(accountingDocument, TargetAccountingLine.class, KualiDecimal.ZERO); assertTrue(IsDebitTestUtils.isDebitIllegalStateException(SpringContext.getBean(DataDictionaryService.class), SpringContext.getBean(DataDictionaryService.class), accountingDocument, accountingLine)); } /* * TODO This was taken from the old fixtures class and contains valuable data that we should use when we get around to building * this document. This should be put into the new xml fixtures framework though. public void fixturesDefault() { addFixture( * KualiRuleTestCase.ACCOUNT, "1912610" ); addFixture( KualiRuleTestCase.BALANCE_TYPE, * AccountingDocumentRuleBase.BALANCE_TYPE_CODE.ACTUAL ); addFixture( KualiRuleTestCase.CHART, "UA" ); addFixture( * KualiRuleTestCase.OBJECT_TYPE_CODE, AccountingDocumentRuleBase.OBJECT_TYPE_CODE.CASH_NOT_INCOME ); addFixture( * KualiRuleTestCase.POSTING_YEAR, new Integer( 2005 ) ); addFixture( KualiRuleTestCase.PROJECT, "BOB" ); addFixture( * KualiRuleTestCase.SUBACCOUNT, "BEER" ); } public void fixturesPartiallyLoadedDoc() throws Exception { List sourceLines = new * ArrayList(); List targetLines = new ArrayList(); addFixture( KualiRuleTestCase.CHART, "UA" ); addFixture( * KualiRuleTestCase.ACCOUNT, "1912610" ); addFixture( KualiRuleTestCase.SUBACCOUNT, "BEER" ); addFixture( * KualiRuleTestCase.PROJECT, "BOB" ); addFixture( KualiRuleTestCase.DOCUMENT_DESCRIPTION, "test" ); addFixture( * KualiRuleTestCase.EXPLANATION, "This is a test document, " + "testing valid accounting line business rules." ); addFixture( * KualiRuleTestCase.OBJECT_CODE, "9912" ); sourceLines.add( fixtureSourceAccountingLine( null, "1000" ) ); addFixture( * KualiRuleTestCase.SOURCE_ACCOUNTING_LINES, sourceLines ); addFixture( KualiRuleTestCase.OBJECT_CODE, "9903" ); * targetLines.add( fixtureTargetAccountingLine( null, "1000" ) ); addFixture( KualiRuleTestCase.TARGET_ACCOUNTING_LINES, * targetLines ); } public void fixturesApplyAddAccountingLineBusinessRulesInvalidSubObjectCode() throws Exception { List * sourceLines = new ArrayList(); List targetLines = new ArrayList(); addFixture( KualiRuleTestCase.DOCUMENT_DESCRIPTION, "test" ); * addFixture( KualiRuleTestCase.EXPLANATION, "This is a test document, testing valid " + "accounting line business rules." ); * sourceLines.add( fixtureSourceAccountingLine( "9897", "1000" ) ); sourceLines.add( fixtureSourceAccountingLine( "9889", * "1000" ) ); addFixture( KualiRuleTestCase.SOURCE_ACCOUNTING_LINES, sourceLines ); targetLines.add( * fixtureTargetAccountingLine( "9891", "1000" ) ); targetLines.add( fixtureTargetAccountingLine( "9760", "1000" ) ); * addFixture( KualiRuleTestCase.TARGET_ACCOUNTING_LINES, targetLines ); } public void * fixturesApplyAddAccountingLineBusinessRulesValidSubObjectCode() throws Exception { List sourceLines = new ArrayList(); List * targetLines = new ArrayList(); addFixture( KualiRuleTestCase.DOCUMENT_DESCRIPTION, "testing " + * "IndirectCostAdjustmentDocumentServiceTest.createValidRuleDIDocument" ); addFixture( KualiRuleTestCase.EXPLANATION, "This is * a test document, " + "testing valid accounting line business rules." ); sourceLines.add( fixtureSourceAccountingLine( "1696", * "2000" ) ); sourceLines.add( fixtureSourceAccountingLine( "1696", "1000" ) ); addFixture( * KualiRuleTestCase.SOURCE_ACCOUNTING_LINES, sourceLines ); targetLines.add( fixtureTargetAccountingLine( "1696", "2000" ) ); * targetLines.add( fixtureTargetAccountingLine( "1696", "1000" ) ); addFixture( KualiRuleTestCase.TARGET_ACCOUNTING_LINES, * targetLines ); } public final void fixturesApplyRouteDocumentBusinessRulesNotInBalance() throws Exception { List sourceLines = * new ArrayList(); List targetLines = new ArrayList(); addFixture( KualiRuleTestCase.DOCUMENT_DESCRIPTION, "test" ); * addFixture( KualiRuleTestCase.EXPLANATION, "This is a test document, " + "testing valid accounting line business rules." ); * sourceLines.add( fixtureSourceAccountingLine( "9912", "2000" ) ); sourceLines.add( fixtureSourceAccountingLine( "1698", * "1000" ) ); addFixture( KualiRuleTestCase.SOURCE_ACCOUNTING_LINES, sourceLines ); targetLines.add( * fixtureTargetAccountingLine( "9912", "1000" ) ); targetLines.add( fixtureTargetAccountingLine( "1698", "2000" ) ); * addFixture( KualiRuleTestCase.TARGET_ACCOUNTING_LINES, targetLines ); } public final void * fixturesApplyRouteDocumentBusinessRulesInvalidSubObjectCode() throws Exception { * fixturesApplyAddAccountingLineBusinessRulesInvalidSubObjectCode(); } public final void * fixturesApplyRouteDocumentBusinessRules_validDocument() throws Exception { List sourceLines = new ArrayList(); List * targetLines = new ArrayList(); addFixture( KualiRuleTestCase.DOCUMENT_DESCRIPTION, "test" ); addFixture( * KualiRuleTestCase.EXPLANATION, "This is a test document, " + "testing valid accounting line business rules." ); * sourceLines.add( fixtureSourceAccountingLine( "5198", "2000" ) ); sourceLines.add( fixtureSourceAccountingLine( "1696", * "1000" ) ); addFixture( KualiRuleTestCase.SOURCE_ACCOUNTING_LINES, sourceLines ); targetLines.add( * fixtureTargetAccountingLine( "5198", "2000" ) ); targetLines.add( fixtureTargetAccountingLine( "1696", "1000" ) ); * addFixture( KualiRuleTestCase.TARGET_ACCOUNTING_LINES, targetLines ); } */ }