svn commit: r794960 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/test/AutoPaymentTests.xml testdef/paymenttests.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r794960 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/test/AutoPaymentTests.xml testdef/paymenttests.xml

apatel-2
Author: apatel
Date: Fri Jul 17 04:53:26 2009
New Revision: 794960

URL: http://svn.apache.org/viewvc?rev=794960&view=rev
Log:
Unit tests for the "depositWithdrawPayments" service. Patch from Jira#2730. Thanks Rishi and Awdesh for patch.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml
    ofbiz/trunk/applications/accounting/testdef/paymenttests.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml?rev=794960&r1=794959&r2=794960&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml Fri Jul 17 04:53:26 2009
@@ -228,4 +228,68 @@
         <log level="info" message="Test case for cancelCheckRunPayments ran successfully for paymentGroupId = ${paymentGroupId}"/>
     </simple-method>
     
+    <simple-method method-name="testDepositWithdrawPayments" short-description="test depositWithdrawPayments service" login-required="false">
+        <set field="paymentIds[]" value="demo10010"/>
+        <set field="paymentIds[]" value="8000"/>
+        <set field="finAccountId" value="9000"/>
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="depositWithdrawPaymentsMap.paymentIds" from-field="paymentIds"/>
+        <set field="depositWithdrawPaymentsMap.finAccountId" from-field="finAccountId"/>
+        <set field="depositWithdrawPaymentsMap.userLogin" from-field="userLogin"/>
+        <call-service service-name="depositWithdrawPayments" in-map-name="depositWithdrawPaymentsMap"/>
+        <entity-condition entity-name="Payment" list="payments">
+            <condition-expr field-name="paymentId" operator="in" from-field="paymentIds"/>
+        </entity-condition>
+        <iterate list="payments" entry="payment">
+            <get-related-one value-field="payment" relation-name="FinAccountTrans" to-value-field="finAccountTrans"/>
+            <assert><not><if-empty field="finAccountTrans"/></not></assert>
+            <check-errors/>
+            <assert>
+                <or>
+                    <if-compare field="finAccountTrans.finAccountTransTypeId" operator="equals" value="DEPOSIT"/>
+                    <if-compare field="finAccountTrans.finAccountTransTypeId" operator="equals" value="WITHDRAWAL"/>
+                </or>
+                <if-compare-field field="finAccountTrans.amount" operator="equals" to-field="payment.amount"/>
+            </assert>
+            <check-errors/>
+        </iterate>
+        <log level="info" message="fin Account Trans has been created for passed payments"/>
+    </simple-method>
+    
+    <simple-method method-name="testDepositWithdrawPaymentsInSingleTrans" short-description="test depositWithdrawPayments service for single transaction" login-required="false">
+        <set field="paymentIds[]" value="demo10001"/>
+        <set field="finAccountId" value="9000"/>
+        <set field="groupInOneTransaction" value="Y"/>
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="depositWithdrawPaymentsMap.paymentIds" from-field="paymentIds"/>
+        <set field="depositWithdrawPaymentsMap.finAccountId" from-field="finAccountId"/>
+        <set field="depositWithdrawPaymentsMap.groupInOneTransaction" from-field="groupInOneTransaction"/>
+        <set field="depositWithdrawPaymentsMap.userLogin" from-field="userLogin"/>
+        <call-service service-name="depositWithdrawPayments" in-map-name="depositWithdrawPaymentsMap">
+            <result-to-field result-name="finAccountTransId"/>
+        </call-service>
+        <set field="paymentRunningTotal" type="BigDecimal" value="0"/>
+        <entity-condition entity-name="Payment" list="payments">
+            <condition-expr field-name="paymentId" operator="in" from-field="paymentIds"/>
+        </entity-condition>
+        <iterate list="payments" entry="payment">
+            <set field="paymentRunningTotal" value="${paymentRunningTotal + payment.amount}" type="BigDecimal"/>
+        </iterate>
+        <entity-one entity-name="FinAccountTrans" value-field="finAccountTrans"/>
+        <assert>
+            <if-compare-field field="finAccountTrans.amount" operator="equals" to-field="paymentRunningTotal"/>
+        </assert>
+        <check-errors/>
+        <iterate list="payments" entry="payment">
+            <assert>
+                <if-compare-field field="payment.finAccountTransId" operator="equals" to-field="finAccountTransId"/>
+            </assert>
+            <check-errors/>
+        </iterate>
+        <log level="info" message="fin Account Trans has been created with Id ${finAccountTransId}"/>
+    </simple-method>
 </simple-methods>
\ No newline at end of file

Modified: ofbiz/trunk/applications/accounting/testdef/paymenttests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/testdef/paymenttests.xml?rev=794960&r1=794959&r2=794960&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/testdef/paymenttests.xml (original)
+++ ofbiz/trunk/applications/accounting/testdef/paymenttests.xml Fri Jul 17 04:53:26 2009
@@ -46,4 +46,11 @@
         <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml" name="testCancelCheckRunPayments"/>
     </test-case>
     
+    <!-- Test case for deposit or withdraw payments -->
+    <test-case case-name="auto-tests-deposit-withdraw-payments">
+        <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml" name="testDepositWithdrawPayments"/>
+    </test-case>
+    <test-case case-name="auto-tests-deposit-withdraw-payments-In-single-trans">
+        <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml" name="testDepositWithdrawPaymentsInSingleTrans"/>
+    </test-case>
 </test-suite>
\ No newline at end of file