[ofbiz-framework] branch trunk updated: Improved: Convert InvoicePerShipmentTests.xml tests to groovy (OFBIZ-11553) (#208)

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 InvoicePerShipmentTests.xml tests to groovy (OFBIZ-11553) (#208)

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan 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 0f9307c  Improved: Convert InvoicePerShipmentTests.xml tests to groovy (OFBIZ-11553) (#208)
0f9307c is described below

commit 0f9307c0711fff7b8aef5c795918c21b0b9243d8
Author: Priya Sharma <[hidden email]>
AuthorDate: Sat Jun 27 18:09:34 2020 +0530

    Improved: Convert InvoicePerShipmentTests.xml tests to groovy (OFBIZ-11553) (#208)
   
    * Improved: Convert InvoicePerShipmentTests.xml tests to groovy (OFBIZ-11553)
    Done following:
    - converted all xml test implementation to groovy
    - used MockHttpServletRequest MockHttpServletResponse objects for triggering the events
    - removed the xml version of the test implementations
    - updated the test service mapping in the invoicetests.xml
    (OFBIZ-11553)
   
    * Improved: Moved the common code into a method so as to avoid duplication of code.
    - passed in two parameters i.e. product id and the invoicePerShipment flag, to be used as per the need of the testcase.
    (OFBIz-11553)
   
    * Improved: Added support to get access to the Debug log methods in the groovy tests. (OFBIZ-11553)
    - Also updated the references in the InvoicePerShipment tests.
   
    Co-authored-by: Priya Sharma <[hidden email]>
---
 .../minilang/test/InvoicePerShipmentTests.xml      | 526 ---------------------
 .../accounting/InvoicePerShipmentTests.groovy      | 190 ++++++++
 applications/accounting/testdef/invoicetests.xml   |   2 +-
 .../ofbiz/service/testtools/OFBizTestCase.java     |  14 +
 4 files changed, 205 insertions(+), 527 deletions(-)

diff --git a/applications/accounting/minilang/test/InvoicePerShipmentTests.xml b/applications/accounting/minilang/test/InvoicePerShipmentTests.xml
deleted file mode 100644
index dcf34f2..0000000
--- a/applications/accounting/minilang/test/InvoicePerShipmentTests.xml
+++ /dev/null
@@ -1,526 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-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="testInvoicePerShipmentSetFalse" short-description="Test Invoice Per Shipment Set False" login-required="false">
-        <!-- Test Invoice Per Shipment
-             Step 1) Set create.invoice.per.shipment=N in accounting.properties file.
-             Step 2) Create order and approve order.
-             Step 3) Pack Shipment For Ship Group.
-             Step 4) Check invoice should not created.
-        -->
-        <!-- Step 1 -->
-        <script>groovy:
-            import org.apache.ofbiz.base.util.UtilProperties;
-            UtilProperties.setPropertyValueInMemory("accounting", "create.invoice.per.shipment", "N");
-        </script>
-        <log level="info" message="===== >>> Set Accounting.properties / create.invoice.per.shipment = N"/>
-        <!-- Step 2 -->
-        <field-to-session field="nullField" session-name="orderMode"/>
-        <set field="request" from-field="parameters.request"/>
-        <set field="response" from-field="parameters.response"/>
-        <call-class-method method-name="routeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : routeOrderEntry, Response : ${result}"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="admin"/>
-        </entity-one>
-        <script>groovy:
-            request.setParameter("orderMode", "SALES_ORDER");
-            request.setParameter("productStoreId", "9000");
-            request.setParameter("partyId", "DemoCustomer");
-            request.setParameter("currencyUom", "USD");
-            session = request.getSession();
-            session.setAttribute("userLogin", userLogin);
-        </script>
-        <call-class-method method-name="initializeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : initializeOrderEntry, Response : ${result}"/>
-        <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response : ${result}"/>
-        <script>groovy:
-            request.setParameter("add_product_id", "GZ-1000");
-        </script>
-        <call-class-method method-name="addToCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : addToCart, Response : ${result}"/>
-        <script>groovy:
-            request.setParameter("checkoutpage", "quick");
-            request.setParameter("shipping_contact_mech_id", "9015");
-            request.setParameter("shipping_method", "GROUND@UPS");
-            request.setParameter("checkOutPaymentId", "EXT_COD");
-            request.setParameter("is_gift", "false");
-            request.setParameter("may_split", "false");
-        </script>
-        <field-to-request field="nullField" request-name="shoppingCart"/>
-        <call-class-method method-name="setQuickCheckOutOptions" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response : ${result}"/>
-        <call-class-method method-name="createOrder" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : createOrder, Response : ${result}"/>
-        <call-class-method method-name="processPayment" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : processPayment, Response : ${result}"/>
-        <call-service-asynch service-name="sendOrderConfirmation"/>
-        <call-class-method method-name="destroyCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/>
-        <!-- Step 3 -->
-        <entity-condition entity-name="OrderHeader" list="orderHeaders">
-            <condition-expr field-name="orderTypeId" value="SALES_ORDER"/>
-            <order-by field-name="-entryDate"/>
-        </entity-condition>
-        <first-from-list list="orderHeaders" entry="orderHeader"/>
-        <log level="info" message="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx : ${orderHeader}"/>
-        <script>groovy:
-            import org.apache.ofbiz.shipment.packing.PackingSession;
-            packingSession = new PackingSession(dispatcher, userLogin);
-            packingSession.setPrimaryOrderId(orderHeader.get("orderId"));
-            packingSession.setPrimaryShipGroupSeqId("00001");
-            parameters.put("packingSession", packingSession);
-        </script>
-        <set field="packInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="packInput.shipGroupSeqId" value="00001"/>
-        <set field="packInput.packingSession" from-field="parameters.packingSession"/>
-        <set field="packInput.nextPackageSeq" value="1" type="Integer"/>
-        <set field="packInput.userLogin" from-field="userLogin"/>
-        <!-- Items -->
-        <set field="packInput.selInfo._1" value="Y"/>
-        <set field="packInput.pkgInfo._1" value="1"/>
-        <set field="packInput.qtyInfo._1" value="1"/>
-        <set field="packInput.prdInfo._1" value="GZ-1000"/>
-        <set field="packInput.iteInfo._1" value="00001"/>
-        <set field="packInput.wgtInfo._1" value="0"/>
-        <set field="packInput.numPackagesInfo._1" value="1"/>
-        <call-service service-name="packBulkItems" in-map-name="packInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/>
-        <set-service-fields service-name="completePack" map="packInput" to-map="completePackInput"/>
-        <call-service service-name="completePack" in-map-name="completePackInput">
-            <result-to-field result-name="shipmentId"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/>
-        <!-- Step 4 -->
-        <entity-and entity-name="OrderItemBillingAndInvoiceAndItem" list="invoices">
-            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
-        </entity-and>
-        <assert>
-            <if-empty field="invoices"/>
-        </assert>
-        
-        <check-errors/>
-    </simple-method>
-    <simple-method method-name="testInvoicePerShipmentSetTrue" short-description="Test Invoice Per Shipment Set True" login-required="false">
-        <!-- Test Invoice Per Shipment
-             Step 1) Set create.invoice.per.shipment=N in accounting.properties file.
-             Step 2) Create order and approve order.
-             Step 3) Pack Shipment For Ship Group.
-             Step 4) Check invoice should created.
-        -->
-        <!-- Step 1 -->
-        <script>groovy:
-            import org.apache.ofbiz.base.util.UtilProperties;
-            UtilProperties.setPropertyValueInMemory("accounting", "create.invoice.per.shipment", "Y");
-        </script>
-        <log level="info" message="===== >>> Set Accounting.properties / create.invoice.per.shipment = Y"/>
-        <!-- Step 2 -->
-        <field-to-session field="nullField" session-name="orderMode"/>
-        <set field="request" from-field="parameters.request"/>
-        <set field="response" from-field="parameters.response"/>
-        <call-class-method method-name="routeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="admin"/>
-        </entity-one>
-        <script>groovy:
-            request.setParameter("orderMode", "SALES_ORDER");
-            request.setParameter("productStoreId", "9000");
-            request.setParameter("partyId", "DemoCustomer");
-            request.setParameter("currencyUom", "USD");
-            session = request.getSession();
-            session.setAttribute("userLogin", userLogin);
-        </script>
-        <call-class-method method-name="initializeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/>
-        <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("add_product_id", "GZ-1000");
-        </script>
-        <call-class-method method-name="addToCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("checkoutpage", "quick");
-            request.setParameter("shipping_contact_mech_id", "9015");
-            request.setParameter("shipping_method", "GROUND@UPS");
-            request.setParameter("checkOutPaymentId", "EXT_COD");
-            request.setParameter("is_gift", "false");
-            request.setParameter("may_split", "false");
-        </script>
-        <field-to-request field="nullField" request-name="shoppingCart"/>
-        <call-class-method method-name="setQuickCheckOutOptions" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/>
-        <call-class-method method-name="createOrder" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/>
-        <call-class-method method-name="processPayment" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/>
-        <call-service-asynch service-name="sendOrderConfirmation"/>
-        <call-class-method method-name="destroyCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/>
-        <!-- Step 3 -->
-        <entity-condition entity-name="OrderHeader" list="orderHeaders">
-            <condition-expr field-name="orderTypeId" value="SALES_ORDER"/>
-            <order-by field-name="-entryDate"/>
-        </entity-condition>
-        <first-from-list list="orderHeaders" entry="orderHeader"/>
-        <script>groovy:
-            import org.apache.ofbiz.shipment.packing.PackingSession;
-            packingSession = new PackingSession(dispatcher, userLogin);
-            packingSession.setPrimaryOrderId(orderHeader.get("orderId"));
-            packingSession.setPrimaryShipGroupSeqId("00001");
-            parameters.put("packingSession", packingSession);
-        </script>
-        <set field="packInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="packInput.shipGroupSeqId" value="00001"/>
-        <set field="packInput.packingSession" from-field="parameters.packingSession"/>
-        <set field="packInput.nextPackageSeq" value="1" type="Integer"/>
-        <set field="packInput.userLogin" from-field="userLogin"/>
-        <!-- Items -->
-        <set field="packInput.selInfo._1" value="Y"/>
-        <set field="packInput.pkgInfo._1" value="1"/>
-        <set field="packInput.qtyInfo._1" value="1"/>
-        <set field="packInput.prdInfo._1" value="GZ-1000"/>
-        <set field="packInput.iteInfo._1" value="00001"/>
-        <set field="packInput.wgtInfo._1" value="0"/>
-        <set field="packInput.numPackagesInfo._1" value="1"/>
-        <call-service service-name="packBulkItems" in-map-name="packInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/>
-        <set-service-fields service-name="completePack" map="packInput" to-map="completePackInput"/>
-        <call-service service-name="completePack" in-map-name="completePackInput">
-            <result-to-field result-name="shipmentId"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/>
-        <!-- Step 4 -->
-        <entity-and entity-name="OrderItemBillingAndInvoiceAndItem" list="invoices">
-            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
-        </entity-and>
-        <assert>
-            <not><if-empty field="invoices"/></not>
-        </assert>
-        <check-errors/>
-    </simple-method>
-    <simple-method method-name="testInvoicePerShipmentSetOrderFalse" short-description="Test Invoice Per Shipment Set Order False" login-required="false">
-        <!-- Test Invoice Per Shipment
-             Step 1) Create order and set invoicePerShipment=N.
-             Step 2) Pack Shipment For Ship Group.
-             Step 3) Check invoice should not created.
-        -->
-        <!-- Step 1 -->
-        <field-to-session field="nullField" session-name="orderMode"/>
-        <set field="request" from-field="parameters.request"/>
-        <set field="response" from-field="parameters.response"/>
-        <call-class-method method-name="routeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="admin"/>
-        </entity-one>
-        <script>groovy:
-            request.setParameter("orderMode", "SALES_ORDER");
-            request.setParameter("productStoreId", "9000");
-            request.setParameter("partyId", "DemoCustomer");
-            request.setParameter("currencyUom", "USD");
-            session = request.getSession();
-            session.setAttribute("userLogin", userLogin);
-        </script>
-        <call-class-method method-name="initializeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/>
-        <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("add_product_id", "GZ-2644");
-        </script>
-        <call-class-method method-name="addToCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("checkoutpage", "quick");
-            request.setParameter("shipping_contact_mech_id", "9015");
-            request.setParameter("shipping_method", "GROUND@UPS");
-            request.setParameter("checkOutPaymentId", "EXT_COD");
-            request.setParameter("is_gift", "false");
-            request.setParameter("may_split", "false");
-        </script>
-        <field-to-request field="nullField" request-name="shoppingCart"/>
-        <call-class-method method-name="setQuickCheckOutOptions" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/>
-        <call-class-method method-name="createOrder" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/>
-        <call-class-method method-name="processPayment" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/>
-        <call-service-asynch service-name="sendOrderConfirmation"/>
-        <call-class-method method-name="destroyCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/>
-        <entity-condition entity-name="OrderHeader" list="orderHeaders">
-            <condition-expr field-name="orderTypeId" value="SALES_ORDER"/>
-            <order-by field-name="-entryDate"/>
-        </entity-condition>
-        <first-from-list list="orderHeaders" entry="orderHeader"/>
-        <set field="orderInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="orderInput.invoicePerShipment" value="N"/>
-        <set field="orderInput.userLogin" from-field="userLogin"/>
-        <call-service service-name="updateOrderHeader" in-map-name="orderInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service : updateOrderHeader / invoicePerShipment = N,  Response = ${responseMessage}"/>
-        <!-- Step 2 -->
-        <script>groovy:
-            import org.apache.ofbiz.shipment.packing.PackingSession;
-            packingSession = new PackingSession(dispatcher, userLogin);
-            packingSession.setPrimaryOrderId(orderHeader.get("orderId"));
-            packingSession.setPrimaryShipGroupSeqId("00001");
-            parameters.put("packingSession", packingSession);
-        </script>
-        <set field="packInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="packInput.shipGroupSeqId" value="00001"/>
-        <set field="packInput.packingSession" from-field="parameters.packingSession"/>
-        <set field="packInput.nextPackageSeq" value="1" type="Integer"/>
-        <set field="packInput.userLogin" from-field="userLogin"/>
-        <!-- Items -->
-        <set field="packInput.selInfo._1" value="Y"/>
-        <set field="packInput.pkgInfo._1" value="1"/>
-        <set field="packInput.qtyInfo._1" value="1"/>
-        <set field="packInput.prdInfo._1" value="GZ-2644"/>
-        <set field="packInput.iteInfo._1" value="00001"/>
-        <set field="packInput.wgtInfo._1" value="0"/>
-        <set field="packInput.numPackagesInfo._1" value="1"/>
-        <call-service service-name="packBulkItems" in-map-name="packInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/>
-        <set-service-fields service-name="completePack" map="packInput" to-map="completePackInput"/>
-        <call-service service-name="completePack" in-map-name="completePackInput">
-            <result-to-field result-name="shipmentId"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/>
-        <!-- Step 3 -->
-        <entity-and entity-name="OrderItemBillingAndInvoiceAndItem" list="invoices">
-            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
-        </entity-and>
-        <assert>
-            <if-empty field="invoices"/>
-        </assert>
-        <check-errors/>
-    </simple-method>
-    <simple-method method-name="testInvoicePerShipmentSetOrderTrue" short-description="Test Invoice Per Shipment Set Order True" login-required="false">
-        <!-- Test Invoice Per Shipment
-             Step 1) Create order and set invoicePerShipment=Y.
-             Step 2) Pack Shipment For Ship Group.
-             Step 3) Check invoice should created.
-        -->
-        <!-- Step 1 -->
-        <field-to-session field="nullField" session-name="orderMode"/>
-        <set field="request" from-field="parameters.request"/>
-        <set field="response" from-field="parameters.response"/>
-        <call-class-method method-name="routeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : routeOrderEntry, Response = ${result}"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="admin"/>
-        </entity-one>
-        <script>groovy:
-            request.setParameter("orderMode", "SALES_ORDER");
-            request.setParameter("productStoreId", "9000");
-            request.setParameter("partyId", "DemoCustomer");
-            request.setParameter("currencyUom", "USD");
-            session = request.getSession();
-            session.setAttribute("userLogin", userLogin);
-        </script>
-        <call-class-method method-name="initializeOrderEntry" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : initializeOrderEntry, Response = ${result}"/>
-        <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("add_product_id", "GZ-2644");
-        </script>
-        <call-class-method method-name="addToCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : addToCart, Response = ${result}"/>
-        <script>groovy:
-            request.setParameter("checkoutpage", "quick");
-            request.setParameter("shipping_contact_mech_id", "9015");
-            request.setParameter("shipping_method", "GROUND@UPS");
-            request.setParameter("checkOutPaymentId", "EXT_COD");
-            request.setParameter("is_gift", "false");
-            request.setParameter("may_split", "false");
-        </script>
-        <field-to-request field="nullField" request-name="shoppingCart"/>
-        <call-class-method method-name="setQuickCheckOutOptions" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response = ${result}"/>
-        <call-class-method method-name="createOrder" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : createOrder, Response = ${result}"/>
-        <call-class-method method-name="processPayment" class-name="org.apache.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : processPayment, Response = ${result}"/>
-        <call-service-asynch service-name="sendOrderConfirmation"/>
-        <call-class-method method-name="destroyCart" class-name="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result">
-            <field field="request" type="javax.servlet.http.HttpServletRequest"/>
-            <field field="response" type="javax.servlet.http.HttpServletResponse"/>
-        </call-class-method>
-        <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/>
-        <entity-condition entity-name="OrderHeader" list="orderHeaders">
-            <condition-expr field-name="orderTypeId" value="SALES_ORDER"/>
-            <order-by field-name="-entryDate"/>
-        </entity-condition>
-        <first-from-list list="orderHeaders" entry="orderHeader"/>
-        <set field="orderInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="orderInput.invoicePerShipment" value="Y"/>
-        <set field="orderInput.userLogin" from-field="userLogin"/>
-        <call-service service-name="updateOrderHeader" in-map-name="orderInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service : updateOrderHeader / invoicePerShipment = Y,  Response = ${responseMessage}"/>
-        <!-- Step 2 -->
-        <script>groovy:
-            import org.apache.ofbiz.shipment.packing.PackingSession;
-            packingSession = new PackingSession(dispatcher, userLogin);
-            packingSession.setPrimaryOrderId(orderHeader.get("orderId"));
-            packingSession.setPrimaryShipGroupSeqId("00001");
-            parameters.put("packingSession", packingSession);
-        </script>
-        <set field="packInput.orderId" from-field="orderHeader.orderId"/>
-        <set field="packInput.shipGroupSeqId" value="00001"/>
-        <set field="packInput.packingSession" from-field="parameters.packingSession"/>
-        <set field="packInput.nextPackageSeq" value="1" type="Integer"/>
-        <set field="packInput.userLogin" from-field="userLogin"/>
-        <!-- Items -->
-        <set field="packInput.selInfo._1" value="Y"/>
-        <set field="packInput.pkgInfo._1" value="1"/>
-        <set field="packInput.qtyInfo._1" value="1"/>
-        <set field="packInput.prdInfo._1" value="GZ-2644"/>
-        <set field="packInput.iteInfo._1" value="00001"/>
-        <set field="packInput.wgtInfo._1" value="0"/>
-        <set field="packInput.numPackagesInfo._1" value="1"/>
-        <call-service service-name="packBulkItems" in-map-name="packInput">
-            <result-to-field result-name="responseMessage"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: packBulkItems, Response = ${responseMessage}"/>
-        <set-service-fields service-name="completePack" map="packInput" to-map="completePackInput"/>
-        <call-service service-name="completePack" in-map-name="completePackInput">
-            <result-to-field result-name="shipmentId"/>
-        </call-service>
-        <log level="info" message="===== >>> Service: completePack, shipmentId = ${shipmentId}"/>
-        <!-- Step 3 -->
-        <entity-and entity-name="OrderItemBillingAndInvoiceAndItem" list="invoices">
-            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
-        </entity-and>
-        <assert>
-            <not><if-empty field="invoices"/></not>
-        </assert>
-        <check-errors/>
-    </simple-method>
-</simple-methods>
diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/InvoicePerShipmentTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/InvoicePerShipmentTests.groovy
new file mode 100644
index 0000000..fe81f7d
--- /dev/null
+++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/InvoicePerShipmentTests.groovy
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ofbiz.accounting
+
+import javax.servlet.http.HttpSession
+import org.apache.ofbiz.base.util.UtilProperties
+import org.apache.ofbiz.base.util.UtilValidate
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.order.shoppingcart.CheckOutEvents
+import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
+import org.apache.ofbiz.security.Security
+import org.apache.ofbiz.security.SecurityFactory
+import org.apache.ofbiz.service.ModelService
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+import org.apache.ofbiz.shipment.packing.PackingSession
+import org.springframework.mock.web.MockHttpServletRequest
+import org.springframework.mock.web.MockHttpServletResponse
+
+
+public class InvoicePerShipmentTests extends OFBizTestCase {
+    public InvoicePerShipmentTests(String name) {
+        super(name)
+    }
+
+    def testInvoicePerShipment(String productId, String invoicePerShipment) {
+        MockHttpServletRequest request = new MockHttpServletRequest()
+        MockHttpServletResponse response = new MockHttpServletResponse()
+
+        Security security = SecurityFactory.getInstance(delegator)
+        request.setAttribute("security", security)
+        request.setAttribute("delegator", delegator)
+        request.setAttribute("dispatcher", dispatcher)
+        HttpSession session = request.getSession()
+        session.setAttribute("orderMode", null)
+
+        String result = ShoppingCartEvents.routeOrderEntry(request, response)
+        logInfo("===== >>> Event : routeOrderEntry, Response : " + result)
+
+        request.setParameter("orderMode", "SALES_ORDER")
+        request.setParameter("productStoreId", "9000")
+        request.setParameter("partyId", "DemoCustomer")
+        request.setParameter("currencyUom", "USD")
+        session.setAttribute("userLogin", userLogin)
+
+        result = ShoppingCartEvents.initializeOrderEntry(request, response)
+        logInfo("===== >>> Event : initializeOrderEntry, Response : " + result)
+
+        result = ShoppingCartEvents.setOrderCurrencyAgreementShipDates(request, response)
+        logInfo("===== >>> Event : setOrderCurrencyAgreementShipDates, Response : " + result)
+
+        request.setParameter("add_product_id", productId)
+
+        result = ShoppingCartEvents.addToCart(request, response)
+        logInfo("===== >>> Event : addToCart, Response : " + result)
+
+        request.setParameter("checkoutpage", "quick")
+        request.setParameter("shipping_contact_mech_id", "9015")
+        request.setParameter("shipping_method", "GROUND@UPS")
+        request.setParameter("checkOutPaymentId", "EXT_COD")
+        request.setParameter("is_gift", "false")
+        request.setParameter("may_split", "false")
+        request.setAttribute("shoppingCart", null)
+
+        result = CheckOutEvents.setQuickCheckOutOptions(request, response)
+        logInfo("===== >>> Event : setQuickCheckOutOptions, Response : " + result)
+
+        result = CheckOutEvents.createOrder(request, response)
+        logInfo("===== >>> Event : createOrder, Response : " + result)
+
+        result = CheckOutEvents.processPayment(request, response)
+        logInfo("===== >>> Event : processPayment, Response : " + result)
+
+        dispatcher.runAsync("sendOrderConfirmation", null)
+
+        result = ShoppingCartEvents.destroyCart(request, response)
+        logInfo("===== >>> Event : destroyCart, Response = " + result)
+
+        // Step 3
+        GenericValue orderHeader = from("OrderHeader").where("orderTypeId", "SALES_ORDER").orderBy("-entryDate").queryFirst()
+        logInfo("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx : " + orderHeader)
+
+        if (invoicePerShipment) {
+            // if this value is available that means we need to set this on the order
+            Map orderInput = [:]
+            orderInput.orderId = orderHeader.orderId
+            orderInput.invoicePerShipment = invoicePerShipment
+            orderInput.userLogin = userLogin
+            Map serviceResult = dispatcher.runSync("updateOrderHeader", orderInput)
+            logInfo("===== >>> Service : updateOrderHeader / invoicePerShipment = N,  Response = " + serviceResult.responseMessage)
+        }
+
+        PackingSession packingSession = new PackingSession(dispatcher, userLogin)
+        session.setAttribute("packingSession", packingSession)
+        packingSession.setPrimaryOrderId(orderHeader.orderId)
+        packingSession.setPrimaryShipGroupSeqId("00001")
+
+        Map packInput = [:]
+        packInput.orderId = orderHeader.orderId
+        packInput.shipGroupSeqId = "00001"
+        packInput.packingSession = packingSession
+        packInput.nextPackageSeq = 1
+        packInput.userLogin = userLogin
+
+        // Items
+        packInput.selInfo = [_1: "Y"]
+        packInput.pkgInfo = [_1: "1"]
+        packInput.qtyInfo = [_1: "1"]
+        packInput.prdInfo = [_1: productId]
+        packInput.iteInfo = [_1: "00001"]
+        packInput.wgtInfo = [_1: "0"]
+        packInput.numPackagesInfo = [_1: "1"]
+
+        Map serviceResult = dispatcher.runSync("packBulkItems", packInput)
+        assert ServiceUtil.isSuccess(serviceResult)
+        logInfo("===== >>> Service: packBulkItems, Response = " + serviceResult.responseMessage)
+
+        Map completePackInput = dispatcher.getDispatchContext().makeValidContext("completePack", ModelService.IN_PARAM, packInput)
+        serviceResult = dispatcher.runSync("completePack", completePackInput)
+        assert ServiceUtil.isSuccess(serviceResult)
+        logInfo("===== >>> Service: completePack, shipmentId = " + serviceResult.shipmentId)
+
+        // Step 4
+        List invoices = from("OrderItemBillingAndInvoiceAndItem").where("orderId", orderHeader.orderId).queryList()
+        return invoices
+    }
+    void testInvoicePerShipmentSetFalse() {
+        /* Test Invoice Per Shipment
+            Step 1) Set create.invoice.per.shipment=N in accounting.properties file.
+            Step 2) Create order and approve order.
+            Step 3) Pack Shipment For Ship Group.
+            Step 4) Check invoice should not created.
+        */
+        UtilProperties.setPropertyValueInMemory("accounting", "create.invoice.per.shipment", "N")
+        logInfo("===== >>> Set Accounting.properties / create.invoice.per.shipment = N")
+
+        List invoices = testInvoicePerShipment("GZ-1000", null)
+        assert UtilValidate.isEmpty(invoices)
+    }
+
+    void testInvoicePerShipmentSetTrue() {
+        /* Test Invoice Per Shipment
+             Step 1) Set create.invoice.per.shipment=Y in accounting.properties file.
+             Step 2) Create order and approve order.
+             Step 3) Pack Shipment For Ship Group.
+             Step 4) Check invoice should be created.
+         */
+        UtilProperties.setPropertyValueInMemory("accounting", "create.invoice.per.shipment", "Y")
+        logInfo("===== >>> Set Accounting.properties / create.invoice.per.shipment = Y")
+
+        List invoices = testInvoicePerShipment("GZ-1000", null)
+        assert UtilValidate.isNotEmpty(invoices)
+    }
+
+    void testInvoicePerShipmentSetOrderFalse() {
+        /* Test Invoice Per Shipment
+            Step 1) Create order and set invoicePerShipment=N.
+            Step 2) Pack Shipment For Ship Group.
+            Step 3) Check invoice should not be created.
+        */
+        List invoices = testInvoicePerShipment("GZ-2644", "N")
+        assert UtilValidate.isEmpty(invoices)
+    }
+
+    void testInvoicePerShipmentSetOrderTrue() {
+        /* Test Invoice Per Shipment
+            Step 1) Create order and set invoicePerShipment=Y
+            Step 2) Pack Shipment For Ship Group.
+            Step 3) Check invoice should be created.
+        */
+        List invoices = testInvoicePerShipment("GZ-2644", "Y")
+        assert UtilValidate.isNotEmpty(invoices)
+    }
+}
\ No newline at end of file
diff --git a/applications/accounting/testdef/invoicetests.xml b/applications/accounting/testdef/invoicetests.xml
index 09d2e5f..a3e8388 100644
--- a/applications/accounting/testdef/invoicetests.xml
+++ b/applications/accounting/testdef/invoicetests.xml
@@ -27,6 +27,6 @@
         <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoInvoiceTests"/>
     </test-group>
     <test-case case-name="invoice-per-shipment-tests">
-        <simple-method-test location="component://accounting/minilang/test/InvoicePerShipmentTests.xml"/>
+        <junit-test-suite class-name="org.apache.ofbiz.accounting.InvoicePerShipmentTests"/>
     </test-case>
 </test-suite>
diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/testtools/OFBizTestCase.java b/framework/service/src/main/java/org/apache/ofbiz/service/testtools/OFBizTestCase.java
index 257ae47..ca60fb7 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/testtools/OFBizTestCase.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/testtools/OFBizTestCase.java
@@ -19,6 +19,7 @@
 
 package org.apache.ofbiz.service.testtools;
 
+import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.entity.model.DynamicViewEntity;
@@ -31,6 +32,7 @@ import java.util.Set;
 public class OFBizTestCase extends EntityTestCase {
 
     protected LocalDispatcher dispatcher = null;
+    protected String MODULE = this.getClass().getName();
 
     public LocalDispatcher getDispatcher() {
         return dispatcher;
@@ -72,4 +74,16 @@ public class OFBizTestCase extends EntityTestCase {
     protected EntityQuery select(Set<String> fields) {
         return EntityQuery.use(delegator).select(fields);
     }
+
+    protected void logInfo(String msg) {
+        Debug.logInfo(msg, MODULE);
+    }
+
+    protected void logError(String msg) {
+        Debug.logError(msg, MODULE);
+    }
+
+    protected void logWarning(String msg) {
+        Debug.logWarning(msg, MODULE);
+    }
 }