Hi Tom,
Hope you well :)
I have not deeply investigated the true cause of the errors, but I did
not update the latest-data.sql with the new database version.
This did not reflect as an issue by a test failing but errors did
cascade into other tests because of this.
I will look into getting a test to fail should the aforementioned
scenario reoccur.
Here is the patch, I added the offsetting tests to the AccountsTestSuite.
svn Revision: 12213
Thanks,
Dion
On Dec 4, 2007 4:30 AM, Dion Dodgen <[EMAIL PROTECTED]> wrote:
> Thanks Tom, will do so and apply it to the patch.
>
>
> On Dec 4, 2007 3:54 AM, Tom Bostelmann <[EMAIL PROTECTED]> wrote:
> > most likely that's just an uncaught, ignored exception from:
> >
> >
> > org.mifos.application.accounts.struts.action.TestApplyAdjustmentAction.testAdjustmentForZeroPmnt(TestApplyAdjustmentAction.java:309)
> >
> > to fix this, you should add a catch block for this exception and explicitly
> > ignore it so that it doesn't fall into stdout and confuse other developers.
> >
> >
> >
> > On Dec 4, 2007 3:05 AM, Dion Dodgen <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > I seem to be getting 1 error when running the test suite for revision
> > > 12211, but all tests seem to be passing.
> > >
> > > <system-out><![CDATA[ERROR, org.mifos, MifosExceptionHandler,
> > > logException , 72, No resource is associated with key
> > > "exception.accounts.ApplicationException.CannotAdjust"., 04 Dec 2007
> > > 01:07:50
> > > ERROR, org.mifos, MifosExceptionHandler, logException , 72,
> > > exception.accounts.ApplicationException.CannotAdjust, 04 Dec 2007
> > > 01:07:50
> > > org.mifos.application.accounts.exceptions.AccountException:
> > > exception.accounts.ApplicationException.CannotAdjust
> > > at
> > org.mifos.application.accounts.business.AccountBO.adjustLastPayment(AccountBO.java
> > :370)
> > > at
> > org.mifos.application.accounts.struts.action.ApplyAdjustment.applyAdjustment(ApplyAdjustment.java:144)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke
> > (NativeMethodAccessorImpl.java:39)
> > > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > at org.apache.struts.actions.DispatchAction.dispatchMethod
> > (DispatchAction.java:274)
> > > at
> > org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
> > > at
> > org.mifos.framework.struts.action.BaseAction.execute(BaseAction.java:72)
> > > at org.apache.struts.action.RequestProcessor.processActionPerform
> > (RequestProcessor.java:419)
> > > at
> > org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
> > > at
> > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
> > > at org.apache.struts.action.ActionServlet.doPost
> > (ActionServlet.java:432)
> > > at
> > servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:290)
> > > at
> > org.mifos.application.accounts.struts.action.TestApplyAdjustmentAction.testAdjustmentForZeroPmnt
> > (TestApplyAdjustmentAction.java:309)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > at sun.reflect.DelegatingMethodAccessorImpl.invoke
> > (DelegatingMethodAccessorImpl.java:25)
> > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > at junit.framework.TestCase.runTest(TestCase.java:168)
> > > at junit.framework.TestCase.runBare(TestCase.java :134)
> > > at junit.framework.TestResult$1.protect(TestResult.java:110)
> > > at junit.framework.TestResult.runProtected(TestResult.java:128)
> > > at junit.framework.TestResult.run(TestResult.java:113)
> > > at junit.framework.TestCase.run(TestCase.java:124)
> > > at junit.framework.TestSuite.runTest(TestSuite.java:232)
> > > at junit.framework.TestSuite.run(TestSuite.java:227)
> > > at junit.framework.TestSuite.runTest (TestSuite.java:232)
> > > at junit.framework.TestSuite.run(TestSuite.java:227)
> > > at junit.framework.TestSuite.runTest(TestSuite.java:232)
> > > at junit.framework.TestSuite.run(TestSuite.java:227)
> > > at
> > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
> > > at
> > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
> > > at
> > org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main
> > (JUnitTestRunner.java:766)
> > > ERROR, org.mifos, MifosExceptionHandler, logException , 72, You do not
> > > have permissions to perform this activity. Contact your system
> > > administrator to grant you required permissions and try again., 04 Dec
> > > 2007 01:08:45
> > > org.mifos.framework.exceptions.ServiceException:
> > error.activity.not.allowed
> > > at
> > org.mifos.application.accounts.business.service.AccountBusinessService.checkPermissionForStatusChange(AccountBusinessService.java
> > :332)
> > > at
> > org.mifos.application.accounts.struts.action.EditStatusAction.checkPermission(EditStatusAction.java:245)
> > > at
> > org.mifos.application.accounts.struts.action.EditStatusAction.update(EditStatusAction.java
> > :130)
> > >
> > >
> > > Does anybody else get this?
> > >
> > > Thanks,
> > > Dion
> > >
> > >
> > >
> > >
> > >
> > > On Dec 3, 2007 1:57 PM, Tom Bostelmann <[EMAIL PROTECTED] > wrote:
> > > > Thanks Dion, apologies for taking a while before getting back to you on
> > > > this. Almost there :)
> > > >
> > > > If you're adding a new test, please add it to a package test suite and
> > not
> > > > the main ApplicationTestSuite. If you end up having to create a new
> > package
> > > > test suite, then add that test suite to the parent package's test suite.
> > > >
> > > > Also as a side-note to other developers, make sure that all tests can
> > be
> > > > executed independently, they should not have a dependency on another
> > test.
> > > > Dion, your tests look fine here. I'm just adding this as a reminder to
> > the
> > > > other developers.
> > > >
> > > >
> > > >
> > > > On Nov 25, 2007 10:56 PM, Dion Dodgen <[EMAIL PROTECTED]> wrote:
> > > > > Hi Tom,
> > > > >
> > > > > Hope you had a good weekend :) I have integrated all resources into
> > > > > the single patch file.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 11/22/07, Tom Bostelmann < [EMAIL PROTECTED]> wrote:
> > > > > > Dion, the patch needs contain all of the contents of the patch in
> > one
> > > > file.
> > > > > > There are a couple files, namely 'OffsetTestSuite.java' and
> > > > > > 'TestOffsetAccountBO.java ' that should be incorporated in the
> > patch.
> > > > > >
> > > > > > Can you fix this and then submit it again? It'd make my life a
> > little
> > > > > > easier ;)
> > > > > >
> > > > > >
> > > > > > On Nov 17, 2007 11:17 PM, Dion Dodgen < [EMAIL PROTECTED] >
> > > > wrote:
> > > > > > > Great thanks Tom.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Nov 16, 2007 6:07 PM, Tom Bostelmann < [EMAIL PROTECTED]>
> > > > wrote:
> > > > > > > > Thanks Dion! I added it to the patch queue - probably going to
> > be
> > > > next
> > > > > > week
> > > > > > > > before I get back to you, though. Here's the queue wiki:
> > > > > > > >
> > > > > > > > http://mifos.org/developers/wiki/MifosPatchQueue
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Nov 14, 2007 4:58 AM, Dion Dodgen <
> > [EMAIL PROTECTED]>
> > > > wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hi Tom, all,
> > > > > > > > >
> > > > > > > > > Sorry for the delay, hope you well.
> > > > > > > > > I have reworked the initial patch. All tests pass using the
> > > > correct
> > > > > > > > > time zone and db use_lower_case_table_names=1.
> > > > > > > > > I would like to patch this dependency as soon as offsetting
> > > > reaches
> > > > > > > > maturity.
> > > > > > > > >
> > > > > > > > > This patch covers all the persistence needs for the Offsetting
> > > > module.
> > > > > > > > >
> > > > > > > > > I am now on suse 10.3 :)
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > > Dion
> > > > > > > > >
> > > > > > > > >
> > > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > > > > > This SF.net email is sponsored by: Splunk Inc.
> > > > > > > > > Still grepping through log files to find problems? Stop.
> > > > > > > > > Now Search log events and configuration files using AJAX and a
> > > > > > browser.
> > > > > > > > > Download your FREE copy of Splunk now >>
> > http://get.splunk.com/
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > > > > This SF.net email is sponsored by: Microsoft
> > > > > > > > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > > > This SF.net email is sponsored by: Microsoft
> > > > > > > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > > This SF.net email is sponsored by: Microsoft
> > > > > > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > > > >
> > > > >
> > > > >
> > -------------------------------------------------------------------------
> > > > > This SF.net email is sponsored by: Microsoft
> > > > > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > > >
> > > >
> > > >
> > > >
> > -------------------------------------------------------------------------
> > > > SF.Net email is sponsored by: The Future of Linux Business White Paper
> > > > from Novell. From the desktop to the data center, Linux is going
> > > > mainstream. Let it simplify your IT future.
> > > > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> > > >
> > >
> > > -------------------------------------------------------------------------
> > > SF.Net email is sponsored by: The Future of Linux Business White Paper
> > > from Novell. From the desktop to the data center, Linux is going
> > > mainstream. Let it simplify your IT future.
> > > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> > >
> >
> >
> > -------------------------------------------------------------------------
>
> > SF.Net email is sponsored by: The Future of Linux Business White Paper
> > from Novell. From the desktop to the data center, Linux is going
> > mainstream. Let it simplify your IT future.
> > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> >
>
Index: test/org/mifos/application/accounts/AccountTestSuite.java
===================================================================
--- test/org/mifos/application/accounts/AccountTestSuite.java (revision 12213)
+++ test/org/mifos/application/accounts/AccountTestSuite.java (working copy)
@@ -20,6 +20,7 @@
import org.mifos.application.accounts.business.TestLoanTrxnDetailEntity;
import org.mifos.application.accounts.business.service.TestAccountService;
import org.mifos.application.accounts.financial.business.service.TestFinancialBusinessService;
+import org.mifos.application.accounts.offsetting.TestOffsetAccountBO;
import org.mifos.application.accounts.persistence.TestAccountPersistence;
import org.mifos.application.accounts.struts.action.TestAccountAction;
import org.mifos.application.accounts.struts.action.TestApplyAdjustmentAction;
@@ -61,9 +62,10 @@
testSuite.addTestSuite(TestNotesAction.class);
testSuite.addTestSuite(TestAccountStateMachine.class);
testSuite.addTestSuite(TestEditStatusAction.class);
- testSuite.addTestSuite(TestApplyChargeAction.class);
+ testSuite.addTestSuite(TestApplyChargeAction.class);
+ testSuite.addTestSuite(TestOffsetAccountBO.class);
+ testSuite.addTest(AddAccountStateFlagTest.suite());
- testSuite.addTest(AddAccountStateFlagTest.suite());
return testSuite;
}
Index: test/org/mifos/application/accounts/offsetting/TestOffsetAccountBO.java
===================================================================
--- test/org/mifos/application/accounts/offsetting/TestOffsetAccountBO.java (revision 0)
+++ test/org/mifos/application/accounts/offsetting/TestOffsetAccountBO.java (revision 0)
@@ -0,0 +1,89 @@
+package org.mifos.application.accounts.offsetting;
+
+import static org.mifos.application.meeting.util.helpers.MeetingType.CUSTOMER_MEETING;
+import static org.mifos.application.meeting.util.helpers.RecurrenceType.WEEKLY;
+import static org.mifos.framework.util.helpers.TestObjectFactory.EVERY_WEEK;
+
+import java.util.Date;
+
+import org.junit.Test;
+import org.mifos.application.accounts.loan.business.LoanBO;
+import org.mifos.application.accounts.persistence.AccountPersistence;
+import org.mifos.application.accounts.util.helpers.AccountState;
+import org.mifos.application.customer.business.CustomerBO;
+import org.mifos.application.customer.util.helpers.CustomerStatus;
+import org.mifos.application.meeting.business.MeetingBO;
+import org.mifos.application.productdefinition.business.LoanOfferingBO;
+import org.mifos.application.productdefinition.util.helpers.ApplicableTo;
+import org.mifos.application.productdefinition.util.helpers.InterestType;
+import org.mifos.application.productdefinition.util.helpers.PrdStatus;
+import org.mifos.framework.MifosTestCase;
+import org.mifos.framework.util.helpers.TestObjectFactory;
+
+public class TestOffsetAccountBO extends MifosTestCase {
+
+ protected LoanBO accountBO=null;
+ protected CustomerBO center=null;
+ protected CustomerBO group=null;
+ protected AccountPersistence accountPersistence;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ accountBO = createLoanAccount();
+ accountPersistence = new AccountPersistence();
+
+ /**
+ if (super.accountBO == null) {
+ //Calling super setup on the TestAccount
+ //with a currently existing TestAccount causes
+ //a "duplicate AccountBO object insertion error".
+ //First cleaning up if a TestAccount exists then get
+ //get a new TestAccount.
+ super.setUp();
+ }
+ */
+ }
+
+ @Test
+ public void testLoanAccountBOOfsetAllowablePersistence() {
+ assertTrue(accountBO.getOffsettingAllowable().intValue() == 1);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ try {
+ TestObjectFactory.cleanUp(accountBO);
+ TestObjectFactory.cleanUp(group);
+ TestObjectFactory.cleanUp(center);
+ accountPersistence = null;
+ }
+ catch (Exception e) {
+ // throwing here tends to mask failures
+ e.printStackTrace();
+ }
+
+ super.tearDown();
+ }
+
+ public LoanBO createLoanAccount() {
+ MeetingBO meeting = TestObjectFactory.createMeeting(
+ TestObjectFactory.getNewMeetingForToday(
+ WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
+ center=TestObjectFactory.createCenter("OffsetCenter",meeting);
+ group=TestObjectFactory.createGroupUnderCenter(
+ "OffsetGroup1", CustomerStatus.GROUP_ACTIVE, center);
+
+ LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(
+ "OffsetLoan1", ApplicableTo.GROUPS,
+ new Date(System.currentTimeMillis()),
+ PrdStatus.LOAN_ACTIVE,
+ 300.0,1.2,(short)3,
+ InterestType.FLAT, true, true, meeting);
+
+ return TestObjectFactory.createLoanAccount(
+ "42423142342",group, AccountState.LOANACC_ACTIVEINGOODSTANDING,
+ new Date(System.currentTimeMillis()),loanOffering);
+ }
+}
Index: src/org/mifos/application/accounts/business/AccountBO.hbm.xml
===================================================================
--- src/org/mifos/application/accounts/business/AccountBO.hbm.xml (revision 12213)
+++ src/org/mifos/application/accounts/business/AccountBO.hbm.xml (working copy)
@@ -13,6 +13,7 @@
<version name="versionNo" column="VERSION_NO" type="integer"
unsaved-value="null" />
+ <property name="offsettingAllowable" column="OFFSETTING_ALLOWABLE" type="integer" />
<property name="globalAccountNum" column="GLOBAL_ACCOUNT_NUM"
access="field" />
<property name="createdBy" column="CREATED_BY" not-null="true"
Index: src/org/mifos/application/accounts/business/AccountBO.java
===================================================================
--- src/org/mifos/application/accounts/business/AccountBO.java (revision 12213)
+++ src/org/mifos/application/accounts/business/AccountBO.java (working copy)
@@ -94,6 +94,8 @@
private Set<AccountCustomFieldEntity> accountCustomFields;
private Date closedDate;
+
+ private Integer offsettingAllowable;
protected AccountBO() {
this(null);
@@ -115,6 +117,7 @@
accountNotes = new HashSet<AccountNotesEntity>();
accountStatusChangeHistory = new HashSet<AccountStatusChangeHistoryEntity>();
accountFlags = new HashSet<AccountFlagMapping>();
+ offsettingAllowable = new Integer(1);
}
protected AccountBO(UserContext userContext, CustomerBO customer,
@@ -137,6 +140,7 @@
this.office = customer.getOffice();
this.personnel = customer.getPersonnel();
this.setAccountState(new AccountStateEntity(accountState));
+ offsettingAllowable = new Integer(1);
setCreateDetails();
}
@@ -1346,4 +1350,12 @@
}
}
+ public Integer getOffsettingAllowable() {
+ return offsettingAllowable;
+ }
+
+ public void setOffsettingAllowable(Integer offsettingAllowable) {
+ this.offsettingAllowable = offsettingAllowable;
+ }
+
}
Index: src/org/mifos/framework/persistence/DatabaseVersionPersistence.java
===================================================================
--- src/org/mifos/framework/persistence/DatabaseVersionPersistence.java (revision 12213)
+++ src/org/mifos/framework/persistence/DatabaseVersionPersistence.java (working copy)
@@ -27,7 +27,7 @@
public class DatabaseVersionPersistence {
- public static final int APPLICATION_VERSION = 160;
+ public static final int APPLICATION_VERSION = 161;
public static final int FIRST_NUMBERED_VERSION = 100;
public static void register(Map<Integer, Upgrade> register, Upgrade upgrade) {
Index: sql/downgrade_from_161.sql
===================================================================
--- sql/downgrade_from_161.sql (revision 0)
+++ sql/downgrade_from_161.sql (revision 0)
@@ -0,0 +1,3 @@
+ALTER TABLE ACCOUNT DROP COLUMN OFFSETTING_ALLOWABLE;
+UPDATE DATABASE_VERSION SET DATABASE_VERSION = 160 WHERE DATABASE_VERSION = 161;
+
Index: sql/latest-schema.sql
===================================================================
--- sql/latest-schema.sql (revision 12213)
+++ sql/latest-schema.sql (working copy)
@@ -2109,6 +2109,7 @@
UPDATED_DATE DATE,
CLOSED_DATE DATE,
VERSION_NO INTEGER,
+ OFFSETTING_ALLOWABLE SMALLINT NOT NULL,
PRIMARY KEY(ACCOUNT_ID),
FOREIGN KEY(ACCOUNT_STATE_ID)
REFERENCES ACCOUNT_STATE(ACCOUNT_STATE_ID)
Index: sql/upgrade_to_161.sql
===================================================================
--- sql/upgrade_to_161.sql (revision 0)
+++ sql/upgrade_to_161.sql (revision 0)
@@ -0,0 +1,4 @@
+ALTER TABLE ACCOUNT ADD COLUMN OFFSETTING_ALLOWABLE SMALLINT NOT NULL;
+UPDATE ACCOUNT SET OFFSETTING_ALLOWABLE = 1 WHERE OFFSETTING_ALLOWABLE IS NULL;
+UPDATE DATABASE_VERSION SET DATABASE_VERSION = 161 WHERE DATABASE_VERSION = 160;
+
Index: sql/latest-data.sql
===================================================================
--- sql/latest-data.sql (revision 12213)
+++ sql/latest-data.sql (working copy)
@@ -17,7 +17,7 @@
-- apply Index.sql
-- apply all upgrades to date
-INSERT INTO DATABASE_VERSION(DATABASE_VERSION) VALUES(160);
+INSERT INTO DATABASE_VERSION(DATABASE_VERSION) VALUES(161);
/* The table Currency holds configuration related items for a currency like display symbol,rounding mode etc which is to be applied on a currency -- Configuration */
/* To set the default currency, enter 1 in the default_currency field */
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4