[ofbiz-framework] branch trunk updated: Improved: Convert testTaxGeoId test from XML to Groovy (OFBIZ-11560)

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

[ofbiz-framework] branch trunk updated: Improved: Convert testTaxGeoId test from XML to Groovy (OFBIZ-11560)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3c22a3f  Improved: Convert testTaxGeoId test from XML to Groovy (OFBIZ-11560)
3c22a3f is described below

commit 3c22a3f9129deb1fd82fe5c0b18127c27bc0efc6
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Tue Jun 23 15:11:59 2020 +0200

    Improved: Convert testTaxGeoId test from XML to Groovy (OFBIZ-11560)
   
    This can be tested using
   
    ./gradlew "ofbiz --test component=accounting --test suitename=paymentappltests"
   
    Thanks: Rohit Hukkeri for report and Anushi Gupta for the patch
---
 .../minilang/test/PaymentApplicationTests.xml      | 40 ----------------------
 .../accounting/PaymentApplicationTests.groovy      | 26 ++++++++++++++
 .../accounting/testdef/paymentappltests.xml        |  1 -
 3 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/applications/accounting/minilang/test/PaymentApplicationTests.xml b/applications/accounting/minilang/test/PaymentApplicationTests.xml
index 8dbdb9c..106b207 100644
--- a/applications/accounting/minilang/test/PaymentApplicationTests.xml
+++ b/applications/accounting/minilang/test/PaymentApplicationTests.xml
@@ -21,45 +21,5 @@ under the License.
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
 
-    <simple-method method-name="testTaxGeoId" short-description="test the application of a payment against a tax geo id" login-required="false">
-        <!-- from the test data -->
-        <set field="serviceInMap.paymentId" value="appltest10000"/>
-        <set field="serviceInMap.taxAuthGeoId" value="UT"/>
-
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        
-        <set field="serviceInMap.userLogin" from-field="userLogin"/>
-        <call-service service-name="createPaymentApplication" in-map-name="serviceInMap" include-user-login="false">
-            <result-to-field result-name="amountApplied"/>
-            <result-to-field result-name="paymentApplicationId"/>
-        </call-service>
-        <entity-one entity-name="PaymentApplication" value-field="paymentApplication">
-            <field-map field-name="paymentApplicationId" from-field="paymentApplicationId"/>
-        </entity-one>
-        <entity-one entity-name="Payment" value-field="payment">
-            <field-map field-name="paymentId" from-field="serviceInMap.paymentId"/>
-        </entity-one>
-        <assert>
-            <not><if-empty field="paymentApplication"/></not>
-            <if-compare-field field="paymentApplication.taxAuthGeoId" operator="equals" to-field="serviceInMap.taxAuthGeoId"/>
-            <if-compare-field field="paymentApplication.paymentId" operator="equals" to-field="serviceInMap.paymentId"/>
-            <if-compare-field field="paymentApplication.amountApplied" operator="equals" to-field="payment.amount"/>
-        </assert>
-        <check-errors/>
-        <!-- payment should be completely applied -->
-        <call-class-method method-name="getPaymentNotApplied" class-name="org.apache.ofbiz.accounting.payment.PaymentWorker" ret-field="notAppliedPayment">
-            <field field="delegator" type="org.apache.ofbiz.entity.Delegator"/>
-            <field field="serviceInMap.paymentId"/>
-        </call-class-method>
-        <set field="zero" value="0" type="BigDecimal"/>
-        <assert>
-            <if-compare-field operator="equals" field="notAppliedPayment" to-field="zero"/>                        
-        </assert>
-        <check-errors/>
-        <remove-value value-field="paymentApplication"/>
-    </simple-method>
-
 
 </simple-methods>
diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy
index c932100..3149a62 100644
--- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy
+++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy
@@ -123,4 +123,30 @@ class PaymentApplicationTests extends OFBizTestCase {
         assert notAppliedPayment == BigDecimal.ZERO
         delegator.removeAll('PaymentApplication')
     }
+
+    void testTaxGeoId () {
+        Map serviceInMap = [:]
+        //from the test data
+        serviceInMap.paymentId = "appltest10000"
+        serviceInMap.taxAuthGeoId = "UT"
+        serviceInMap.userLogin = userLogin
+        Map serviceResult = dispatcher.runSync('createPaymentApplication', serviceInMap)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue paymentApplication = from('PaymentApplication')
+                .where('paymentApplicationId', serviceResult.paymentApplicationId).queryOne()
+        assert paymentApplication
+
+        GenericValue payment = from('Payment').where('paymentId', serviceInMap.paymentId).queryOne()
+        assert payment
+        assert paymentApplication != null
+        assert paymentApplication.taxAuthGeoId == serviceInMap.taxAuthGeoId
+        assert paymentApplication.paymentId == serviceInMap.paymentId
+        assert paymentApplication.amountApplied == payment.amount
+        // payment should be completely applied
+        BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(delegator, serviceInMap.paymentId)
+        assert notAppliedPayment == BigDecimal.ZERO
+        delegator.removeAll('PaymentApplication')
+    }
+
 }
diff --git a/applications/accounting/testdef/paymentappltests.xml b/applications/accounting/testdef/paymentappltests.xml
index f8ab446..caab5f6 100644
--- a/applications/accounting/testdef/paymentappltests.xml
+++ b/applications/accounting/testdef/paymentappltests.xml
@@ -26,7 +26,6 @@
         <entity-xml action="load" entity-xml-url="component://accounting/testdef/data/PaymentApplicationTestsData.xml"/>
     </test-case>
     <test-group case-name="application-tests">
-        <simple-method-test location="component://accounting/minilang/test/PaymentApplicationTests.xml"/>
         <junit-test-suite class-name="org.apache.ofbiz.accounting.PaymentApplicationTests"/>
     </test-group>