001: /*
002: * Copyright 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.labor.util;
017:
018: import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
019:
020: import java.util.ArrayList;
021: import java.util.List;
022:
023: import junit.framework.TestCase;
024:
025: import org.kuali.kfs.KFSPropertyConstants;
026: import org.kuali.module.gl.web.TestDataGenerator;
027: import org.kuali.module.labor.bo.LaborOriginEntry;
028: import org.kuali.test.ConfigureContext;
029:
030: @ConfigureContext(session=KHUNTLEY)
031: public class LaborLedgerUnitOfWorkTest extends TestCase {
032:
033: private TestDataGenerator testDataGenerator;
034: private LaborOriginEntry laborOriginEntry;
035: private LaborLedgerUnitOfWork laborLedgerUnitOfWork;
036:
037: public LaborLedgerUnitOfWorkTest() throws Exception {
038: String messageFileName = "test/src/org/kuali/module/labor/testdata/message.properties";
039: String propertiesFileName = "test/src/org/kuali/module/labor/testdata/laborLedgerUnitOfWork.properties";
040:
041: laborOriginEntry = new LaborOriginEntry();
042: testDataGenerator = new TestDataGenerator(propertiesFileName,
043: messageFileName);
044: testDataGenerator.generateTransactionData(laborOriginEntry);
045: }
046:
047: public void testLaborLedgerUnitOfWork() throws Exception {
048: laborLedgerUnitOfWork = new LaborLedgerUnitOfWork(
049: laborOriginEntry);
050: String charAccountsCode = laborLedgerUnitOfWork
051: .getWorkingEntry().getChartOfAccountsCode();
052: assertTrue(charAccountsCode.equals(laborOriginEntry
053: .getChartOfAccountsCode()));
054: }
055:
056: public void testResetLaborLedgerUnitOfWork() throws Exception {
057: laborLedgerUnitOfWork = new LaborLedgerUnitOfWork();
058: laborLedgerUnitOfWork
059: .resetLaborLedgerUnitOfWork(laborOriginEntry);
060:
061: String charAccountsCode = laborLedgerUnitOfWork
062: .getWorkingEntry().getChartOfAccountsCode();
063: assertTrue(charAccountsCode.equals(laborOriginEntry
064: .getChartOfAccountsCode()));
065:
066: List keyList = new ArrayList();
067: keyList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
068: laborLedgerUnitOfWork.resetLaborLedgerUnitOfWork(
069: laborOriginEntry, keyList);
070:
071: charAccountsCode = laborLedgerUnitOfWork.getWorkingEntry()
072: .getChartOfAccountsCode();
073: assertFalse(charAccountsCode.equals(laborOriginEntry
074: .getChartOfAccountsCode()));
075:
076: String objectCode = laborLedgerUnitOfWork.getWorkingEntry()
077: .getFinancialObjectCode();
078: assertTrue(objectCode.equals(laborOriginEntry
079: .getFinancialObjectCode()));
080: }
081:
082: public void testAddEntryIntoUnit() throws Exception {
083: laborLedgerUnitOfWork = new LaborLedgerUnitOfWork(
084: laborOriginEntry);
085: assertTrue(laborLedgerUnitOfWork.getNumOfMember() == 1);
086:
087: assertTrue(laborLedgerUnitOfWork
088: .addEntryIntoUnit(laborOriginEntry));
089: assertTrue(laborLedgerUnitOfWork.getNumOfMember() == 2);
090:
091: assertTrue(laborLedgerUnitOfWork
092: .addEntryIntoUnit(laborOriginEntry));
093: assertTrue(laborLedgerUnitOfWork.getNumOfMember() == 3);
094:
095: laborOriginEntry.setUniversityFiscalYear(1000);
096: assertFalse(laborLedgerUnitOfWork
097: .addEntryIntoUnit(laborOriginEntry));
098: assertFalse(laborLedgerUnitOfWork.getNumOfMember() == 4);
099: }
100:
101: public void testCanContain() throws Exception {
102: laborLedgerUnitOfWork = new LaborLedgerUnitOfWork();
103: assertFalse(laborLedgerUnitOfWork.canContain(laborOriginEntry));
104:
105: laborLedgerUnitOfWork
106: .resetLaborLedgerUnitOfWork(laborOriginEntry);
107: assertTrue(laborLedgerUnitOfWork.canContain(laborOriginEntry));
108:
109: laborOriginEntry.setUniversityFiscalYear(1000);
110: assertFalse(laborLedgerUnitOfWork.canContain(laborOriginEntry));
111: }
112:
113: public void testHasSameKey() throws Exception {
114: laborLedgerUnitOfWork = new LaborLedgerUnitOfWork();
115: assertFalse(laborLedgerUnitOfWork.hasSameKey(laborOriginEntry));
116:
117: laborLedgerUnitOfWork
118: .resetLaborLedgerUnitOfWork(laborOriginEntry);
119: assertTrue(laborLedgerUnitOfWork.hasSameKey(laborOriginEntry));
120:
121: laborOriginEntry.setUniversityFiscalYear(1000);
122: assertFalse(laborLedgerUnitOfWork.hasSameKey(laborOriginEntry));
123: }
124: }
|