svn commit: r1865786 [2/2] - in /ofbiz/ofbiz-framework/trunk: applications/accounting/groovyScripts/test/ applications/accounting/src/main/groovy/ applications/accounting/src/main/groovy/org/ applications/accounting/src/main/groovy/org/apache/ applicat...

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

svn commit: r1865786 [2/2] - in /ofbiz/ofbiz-framework/trunk: applications/accounting/groovyScripts/test/ applications/accounting/src/main/groovy/ applications/accounting/src/main/groovy/org/ applications/accounting/src/main/groovy/org/apache/ applicat...

mthl
Added: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy?rev=1865786&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy Fri Aug 23 18:00:01 2019
@@ -0,0 +1,356 @@
+/*
+ * 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.product
+
+import org.apache.ofbiz.base.util.Debug
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilMisc
+import org.apache.ofbiz.base.util.UtilValidate
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.order.shoppingcart.CheckOutHelper
+import org.apache.ofbiz.order.shoppingcart.ShoppingCart
+import org.apache.ofbiz.order.shoppingcart.ShoppingCartItem
+import org.apache.ofbiz.testtools.GroovyScriptTestCase
+import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker
+import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker.ActionResultInfo
+import org.apache.ofbiz.service.ServiceUtil
+
+import java.sql.Timestamp
+import java.util.Map
+
+class ProductPromoActionTest extends GroovyScriptTestCase {
+
+    ShoppingCart loadOrder(String orderId) {
+        GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
+        Map<String, Object> serviceCtx = [orderId: orderId,
+                skipInventoryChecks: true, // the items are already reserved, no need to check again
+                skipProductChecks: true, // the products are already in the order, no need to check their validity now
+                userLogin: permUserLogin]
+        Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
+
+        return loadCartResp.shoppingCart
+    }
+
+    Map prepareConditionMap(ShoppingCart cart, BigDecimal amount, boolean persist) {
+        GenericValue productPromoAction = delegator.makeValue("ProductPromoAction", [amount: amount, orderAdjustmentTypeId:'PROMOTION_ADJUSTMENT'])
+        if (persist) {
+            GenericValue productPromo = delegator.makeValue("ProductPromo", [productPromoId: 'TEST'])
+            delegator.createOrStore(productPromo)
+            GenericValue productPromoRule = delegator.makeValue("ProductPromoRule", [productPromoId: 'TEST', productPromoRuleId:'01'])
+            delegator.createOrStore(productPromoRule)
+            productPromoAction.productPromoId = 'TEST'
+            productPromoAction.productPromoRuleId = '01'
+            productPromoAction.productPromoActionSeqId = '01'
+            delegator.createOrStore(productPromoAction)
+        }
+        return  [shoppingCart: cart, nowTimestamp: UtilDateTime.nowTimestamp(), actionResultInfo: new ActionResultInfo(), productPromoAction: productPromoAction]
+    }
+
+    /**
+     * This test check if the function productTaxPercent work correctly
+     *  1. test failed with passing non valid value
+     *  2. test success if the tax percent promo is set for tax percent
+     */
+    void testActionProductTaxPercent() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, true)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActTaxPercent", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+
+        //Increase item quantity to generate higher tax amount
+        for (ShoppingCartItem item : cart.items()) {
+            if (!item.getIsPromo()) {
+                item.setQuantity(300, dispatcher, cart)
+            }
+        }
+
+        //Add tax to cart
+        CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
+        coh.calcAndAddTax(false);
+
+        serviceResult = dispatcher.runSync("productPromoActTaxPercent", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+
+    /**
+     * This test check if the function productShipCharge work correctly
+     *  1. test failed with passing non valid value
+     *  2. test success if the ship charge promo is set for the shipping amount
+     */
+    void testProductShipCharge() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, true)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActShipCharge", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+
+        //Add shipgroup estimate to cart
+        cart.setItemShipGroupEstimate(22 , 0)
+
+        serviceResult = dispatcher.runSync("productPromoActShipCharge", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+
+    /**
+     * This test check if the function PoductSpecialPrice work correctly
+     *  1. test failed with passing non valid value
+     *  2. test success if the special price is set
+     */
+    void testPoductSpecialPrice() {
+        ShoppingCart cart = loadOrder("DEMO10091")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9013", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActProdSpecialPrice", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+
+        //Add item to cart to trigger action
+        int itemIndex = cart.addItemToEnd("WG-1111", 100, 10, null, null, null, null, null, dispatcher, null, null)
+        ShoppingCartItem item = cart.findCartItem(itemIndex)
+        if (item) {
+            item.setSpecialPromoPrice(BigDecimal.valueOf(22))
+        }
+
+        serviceResult = dispatcher.runSync("productPromoActProdSpecialPrice", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+
+    /**
+     * This test check if the function ProductOrderAmount work correctly
+     *  1. test success if the order amount off is set
+     */
+    void testProductOrderAmount() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9012", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActOrderAmount", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+
+        // no condition so no false test
+    }
+
+    /**
+     * This test check if the function productOrderPercent work correctly
+     *  1. test success if the order percent off promo is set
+     *  2. test failed with passing non valid value
+     */
+    void testProductOrderPercent() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9019", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActOrderPercent", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+
+        //Update cart to cancel trigger action
+        cart.clearAllAdjustments()
+        for (ShoppingCartItem item : cart.items()) {
+            if (!item.getIsPromo()) {
+                GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", item.getProductId()).queryOne()
+                if (product != null) {
+                    product.put("includeInPromotions", "N")
+                    item._product = product
+                }
+            }
+        }
+
+        serviceContext.shoppingCart = cart
+        serviceContext.actionResultInfo = new ActionResultInfo()
+        serviceResult = dispatcher.runSync("productPromoActOrderPercent", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+    }
+
+    /**
+     * This test check if the function productPromoActProdPrice work correctly
+     *  1. test failed with passing non valid value
+     *  2. test success if promo is applied
+     */
+    void testProductPrice() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9015", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActProdPrice", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+
+        //Update cart to trigger action
+        for (ShoppingCartItem item : cart.items()) {
+            if (!item.getIsPromo()) {
+                item.setQuantity(20, dispatcher, cart)
+            }
+        }
+
+        serviceContext.shoppingCart = cart
+        serviceContext.actionResultInfo = new ActionResultInfo()
+        serviceResult = dispatcher.runSync("productPromoActProdPrice", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+
+    /**
+     * This test check if the function productPromoActProdAMDISC work correctly
+     *  1. test success if promo is applied
+     *  2. test failed with passing already applied promo
+     */
+    void testProductAMDISC() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9015", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActProdAMDISC", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+
+        serviceContext.shoppingCart = cart
+        serviceContext.actionResultInfo = new ActionResultInfo()
+        serviceResult = dispatcher.runSync("productPromoActProdAMDISC", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+    }
+
+    /**
+     * This test check if the function productPromoActProdDISC work correctly
+     *  1. test success if promo is applied
+     *  2. test failed with passing already applied promo
+     */
+    void testProductDISC() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, false)
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9015", "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActProdDISC", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+
+        //Check result service false test
+        serviceContext.shoppingCart = cart
+        serviceContext.actionResultInfo = new ActionResultInfo()
+        serviceResult = dispatcher.runSync("productPromoActProdDISC", serviceContext)
+
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+    }
+
+    /**
+     * This test check if the function ProductGWP work correctly
+     *  1. test failed with passing non valid value
+     *  2. test success if gift with purchase promo is set for order
+     */
+    void testProductGWP() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, true)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActGiftGWP", serviceContext)
+
+        //Check result service false test
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert !serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount == 0
+
+        serviceContext.shoppingCart = cart
+        serviceContext.actionResultInfo = new ActionResultInfo()
+        GenericValue productPromoAction = EntityQuery.use(delegator).from("ProductPromoAction").where("productPromoId", "9017",  "productPromoRuleId", "01", "productPromoActionSeqId", "01").queryOne()
+        serviceContext.productPromoAction = productPromoAction
+        serviceResult = dispatcher.runSync("productPromoActGiftGWP", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+
+    /**
+     * This test check if the function productActFreeShip work correctly
+     *  1. test success if the free shipping promo is set for tax percent
+     *  2. don't need to make false test because this fonction doesn't need condition
+     */
+    void testFreeShippingAct() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+
+        Map<String, Object> serviceContext = prepareConditionMap(cart, 10, true)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoActFreeShip", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.actionResultInfo.ranAction
+        assert serviceResult.actionResultInfo.totalDiscountAmount != null
+    }
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy?rev=1865786&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy Fri Aug 23 18:00:01 2019
@@ -0,0 +1,379 @@
+/*
+ * 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.product
+
+import java.sql.Timestamp
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilMisc
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.order.shoppingcart.ShoppingCart
+import org.apache.ofbiz.testtools.GroovyScriptTestCase
+import org.apache.ofbiz.service.ServiceUtil
+
+class ProductPromoCondTest extends GroovyScriptTestCase {
+
+    Map prepareConditionMap(ShoppingCart cart, String condValue) {
+        return prepareConditionMap(cart, condValue, false)
+    }
+
+    Map prepareConditionMap(ShoppingCart cart, String condValue, boolean persist) {
+        GenericValue productPromoCond = delegator.makeValue("ProductPromoCond", [condValue: condValue])
+        if (persist) {
+            GenericValue productPromo = delegator.makeValue("ProductPromo", [productPromoId: 'TEST'])
+            delegator.createOrStore(productPromo)
+            GenericValue productPromoRule = delegator.makeValue("ProductPromoRule", [productPromoId: 'TEST', productPromoRuleId:'01'])
+            delegator.createOrStore(productPromoRule)
+            productPromoCond.productPromoId = 'TEST'
+            productPromoCond.productPromoRuleId = '01'
+            productPromoCond.productPromoCondSeqId = '01'
+            delegator.createOrStore(productPromoCond)
+        }
+        return  [shoppingCart: cart, nowTimestamp: UtilDateTime.nowTimestamp(), productPromoCond: productPromoCond]
+    }
+
+    ShoppingCart loadOrder(String orderId) {
+        GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
+        Map<String, Object> serviceCtx = [orderId: orderId,
+                skipInventoryChecks: true, // the items are already reserved, no need to check again
+                skipProductChecks: true, // the products are already in the order, no need to check their validity now
+                includePromoItems: false,
+                createAsNewOrder: 'Y',
+                userLogin: permUserLogin]
+        Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
+
+        return loadCartResp.shoppingCart
+    }
+
+    /**
+     * This test check if the function productPartyID work correctly
+     *  1. test success with a valid partyId
+     *  2. test failed with passing non valid value
+     */
+    void testPartyIdPromo() {
+        String condValue = "FrenchCustomer"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId(condValue)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyID", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondPartyID", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productNewACCT work correctly
+     *  1. test success if the customer is subscribed more than the "condValue"
+     *  2. test failed with passing non valid value
+     */
+    void testNewACCTPromo() {
+        String condValue = "1095"
+        GenericValue frenchCustomer = delegator.makeValue("Party", [partyId: "FrenchCustomer", createdDate: Timestamp.valueOf("2010-01-01 00:00:00")])
+        frenchCustomer.store()
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        Timestamp nowTimestamp = UtilDateTime.nowTimestamp()
+        cart.setOrderPartyId("FrenchCustomer")
+        cart.getPartyDaysSinceCreated(nowTimestamp)
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondNewACCT", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase >= 0
+
+        //2.test promo nonvalid
+        frenchCustomer.createdDate = nowTimestamp
+        frenchCustomer.store()
+        cart.getPartyDaysSinceCreated(nowTimestamp)
+        serviceResult = dispatcher.runSync("productPromoCondNewACCT", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase < 0
+    }
+
+    /**
+     * This test check if the function productPartyClass work correctly
+     *  1. test success if the login user is from part of classification of the promoCondition
+     *  2. test failed with passing non valid value
+     */
+    void testPartyClassPromo() {
+        String condValue = "PROMO_TEST"
+        GenericValue partyClassGroup = delegator.makeValue("PartyClassificationGroup", [partyClassificationGroupId: condValue])
+        delegator.createOrStore(partyClassGroup)
+        GenericValue partyClassification = delegator.makeValue("PartyClassification",
+                [partyId: "FrenchCustomer", partyClassificationGroupId: condValue,
+                 fromDate: Timestamp.valueOf("2010-01-01 00:00:00"),
+                 thruDate: null])
+        delegator.createOrStore(partyClassification)
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId("FrenchCustomer")
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyClass", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        partyClassification.refresh()
+        partyClassification.thruDate = Timestamp.valueOf("2010-01-01 00:00:00")
+        partyClassification.store()
+        serviceResult = dispatcher.runSync("productPromoCondPartyClass", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 1
+    }
+
+    /**
+     * This test check if the function productPartyGM work correctly
+     *  1. test success if the login user is from part of the Group member of the promoCondition
+     *  2. test failed with passing non valid value
+     */
+    void testPartyGMPromo() {
+        String condValue = "HUMAN_RES"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId(condValue)
+        GenericValue partyRole = delegator.makeValue("PartyRole", [partyId: "FrenchCustomer", roleTypeId: "_NA_"])
+        delegator.createOrStore(partyRole)
+        partyRole.partyId = condValue
+        delegator.createOrStore(partyRole)
+        GenericValue relation = delegator.makeValue("PartyRelationship", [partyIdFrom: "FrenchCustomer", roleTypeIdFrom: "_NA_",
+                                               partyIdTo: condValue, roleTypeIdTo: "_NA_",
+                                               fromDate: Timestamp.valueOf("2010-01-01 00:00:00"),
+                                               partyRelationshipTypeId: "GROUP_ROLLUP"])
+        delegator.createOrStore(relation)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPartyGM", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondPartyGM", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 1
+    }
+
+    /**
+     * This test check if the function productRoleType work correctly
+     *  1. test success if the login user role type is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testRoleTypePromo() {
+        String condValue = "APPROVER"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        cart.setOrderPartyId("FrenchCustomer")
+        GenericValue partyRole = delegator.makeValue("PartyRole", [partyId: "FrenchCustomer", roleTypeId: condValue])
+        delegator.createOrStore(partyRole)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondRoleType", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart.setOrderPartyId("OtherPartyId")
+        serviceResult = dispatcher.runSync("productPromoCondRoleType", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productGeoID work correctly
+     *  1. test success if the shipping address is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testCondGeoIdPromo() {
+        ShoppingCart cart = loadOrder("DEMO10090")
+        cart.setShippingContactMechId(0, "9200")
+        GenericValue productPromoCond = EntityQuery.use(delegator).from("ProductPromoCond").where("productPromoId", "9022", "productPromoRuleId", "01", "productPromoCondSeqId", "01").queryOne()
+
+        // call service promo
+        Map<String, Object> serviceContext = [shoppingCart: cart, nowTimestamp: UtilDateTime.nowTimestamp(), productPromoCond: productPromoCond]
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondGeoID", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        cart = loadOrder("DEMO10091")
+        cart.setShippingContactMechId(0, "10000")
+        serviceContext.shoppingCart = cart
+        serviceResult = dispatcher.runSync("productPromoCondGeoID", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productOrderTotal work correctly
+     *  1. test success if the order total is equal or greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testCondOrderTotalPromo() {
+        String condValue = "34.56"
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(loadOrder("DEMO10090"), condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondOrderTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        serviceContext.shoppingCart = loadOrder("Demo1002")
+        serviceResult = dispatcher.runSync("productPromoCondOrderTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase > 0
+    }
+
+    /**
+     * This test check if the function productPromoRecurrence work correctly
+     *  1. test success if the recurrence is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testRecurrencePromo() {
+        String condValue = "TEST_PROMO"
+        ShoppingCart cart = new ShoppingCart(delegator, "9000", Locale.getDefault(), "EUR")
+        GenericValue reccurenceRule = delegator.makeValue("RecurrenceRule", [recurrenceRuleId: condValue, frequency: "DAILY", intervalNumber: 1l,
+                                                                       countNumber: -1l, byDayList: "MO,TU,WE,TH,FR,SA,SU"])
+        delegator.createOrStore(reccurenceRule)
+        GenericValue reccurenceInfo = delegator.makeValue("RecurrenceInfo", [recurrenceInfoId: condValue, startDateTime: Timestamp.valueOf("2008-01-01 00:00:00.000"),
+                                                                       recurrenceRuleId: condValue, recurrenceCount: 0l])
+        delegator.createOrStore(reccurenceInfo)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondPromoRecurrence", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        condValue = "3"
+        serviceContext = prepareConditionMap(cart, condValue)
+        serviceResult = dispatcher.runSync("productPromoCondPromoRecurrence", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productShipTotal work correctly
+     *  1. test success if ship total is greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testShipTotalPromo() {
+        String condValue = "20"
+        BigDecimal amount = BigDecimal.valueOf(25)
+        ShoppingCart cart = loadOrder("DEMO10090")
+        cart.setItemShipGroupEstimate(amount, 0)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondOrderShipTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase > 0
+
+        //2.test promo nonvalid
+        amount = BigDecimal.valueOf(19)
+        cart.setItemShipGroupEstimate(amount, 0)
+        serviceResult = dispatcher.runSync("productPromoCondOrderShipTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase <= 0
+    }
+
+    /**
+     * This test check if the function productAmount work correctly
+     *  1. test success if the amount of specific product is equal to the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testProductAmountPromo() {
+        String condValue = "30"
+        String orderId = "DEMO10090"
+        ShoppingCart cart = loadOrder(orderId)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, condValue, true)
+        GenericValue productPromoProduct = delegator.makeValue("ProductPromoProduct",
+                [productPromoId: 'TEST', productPromoRuleId: '01', productPromoCondSeqId: '01',
+                 productId: 'GZ-2644', productPromoApplEnumId: 'PPPA_INCLUDE', productPromoActionSeqId: '_NA_'])
+        delegator.createOrStore(productPromoProduct)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondProductAmount", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase == 0
+
+        //2.test promo nonvalid
+        condValue = "50"
+        serviceContext = prepareConditionMap(cart, condValue, true)
+        serviceResult = dispatcher.runSync("productPromoCondProductAmount", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase != 0
+    }
+
+    /**
+     * This test check if the function productTotal work correctly
+     *  1. test success if the total amount of product is equal or greater than the condValue
+     *  2. test failed with passing non valid value
+     */
+    void testProductTotalPromo() {
+        String orderId = "Demo1002"
+        ShoppingCart cart = loadOrder(orderId)
+
+        // call service promo
+        Map<String, Object> serviceContext = prepareConditionMap(cart, "50", true)
+        GenericValue productPromoProduct = delegator.makeValue("ProductPromoProduct",
+            [productPromoId: 'TEST', productPromoRuleId: '01', productPromoCondSeqId: '01',
+             productId: 'WG-1111', productPromoApplEnumId: 'PPPA_INCLUDE', productPromoActionSeqId: '_NA_'])
+        delegator.createOrStore(productPromoProduct)
+        Map<String, Object> serviceResult = dispatcher.runSync("productPromoCondProductTotal", serviceContext)
+
+        //Check result service
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase >= 0
+
+
+        //2.test promo nonvalid
+        cart = loadOrder(orderId)
+        serviceContext = prepareConditionMap(cart, "150", true)
+        serviceResult = dispatcher.runSync("productPromoCondProductTotal", serviceContext)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.compareBase < 0
+    }
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy?rev=1865786&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy Fri Aug 23 18:00:01 2019
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.product
+
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.testtools.GroovyScriptTestCase
+
+class ProductTests extends GroovyScriptTestCase {
+    void testUpdateProductCategory() {
+        Map serviceCtx = [:]
+        serviceCtx.categoryName = 'Updated Test Product Category'
+        serviceCtx.longDescription = 'Updated Long Test Product Category Description'
+        serviceCtx.productCategoryId = 'CATALOG1_BEST_SELL'
+        serviceCtx.productCategoryTypeId = 'BEST_SELL_CATEGORY'
+        serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
+        Map serviceResult = dispatcher.runSync('updateProductCategory', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue prodCategory = EntityQuery.use(delegator).from('ProductCategory').where('productCategoryId', 'CATALOG1_BEST_SELL').queryOne()
+        assert prodCategory.categoryName == 'Updated Test Product Category'
+        assert prodCategory.productCategoryTypeId == 'BEST_SELL_CATEGORY'
+    }
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml Fri Aug 23 18:00:01 2019
@@ -23,10 +23,9 @@
             xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
 
     <test-group case-name="product-Conditions-tests">
-        <groovy-test-suite name="prodCond" location="component://product/groovyScripts/product/test/ProductPromoCondTests.groovy"/>
-        <!--groovy-test-suite name="productPromoCondTests" location="component://product/groovyScripts/product/test/ProductPromoCondTests.groovy"/-->
+        <junit-test-suite class-name="org.apache.ofbiz.product.ProductPromoCondTests"/>
     </test-group>
     <test-group case-name="product-Action-tests">
-        <groovy-test-suite name="productPromoActionTests" location="component://product/groovyScripts/product/test/ProductPromoActionTests.groovy"/>
+        <junit-test-suite class-name="org.apache.ofbiz.product.ProductPromoActionTests"/>
     </test-group>
 </test-suite>

Modified: ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductTest.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductTest.xml?rev=1865786&r1=1865785&r2=1865786&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductTest.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductTest.xml Fri Aug 23 18:00:01 2019
@@ -31,9 +31,9 @@ under the License.
     </test-case>
 
     <test-case case-name="product-tests">
-        <groovy-test-suite location="component://product/groovyScripts/test/ProductTests.groovy"/>
+        <junit-test-suite class-name="org.apache.ofbiz.product.ProductTests"/>
     </test-case>
-</test-suite>    <test-case case-name="testCreateProductFeatureType">
-        <groovy-test-suite location="component://product/groovyScripts/product/test/ProductFeatureTypeTests.groovy"/>
+    <test-case case-name="testCreateProductFeatureType">
+        <junit-test-suite class-name="org.apache.ofbiz.product.ProductFeatureTypeTests"/>
     </test-case>
 </test-suite>

Added: ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy?rev=1865786&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy Fri Aug 23 18:00:01 2019
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.base
+
+import org.apache.ofbiz.testtools.GroovyScriptTestCase
+
+class BaseTest extends GroovyScriptTestCase {
+    void testTrue() {
+        assert 1, 1
+    }
+
+    void testFalse() {
+        assertNotSame 1, 0
+    }
+
+    void testDelegator() {
+        assert delegator
+    }
+
+    void testDispatcher() {
+        assert dispatcher
+    }
+
+    void testSecurity() {
+        assert security
+    }
+}

Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml Fri Aug 23 18:00:01 2019
@@ -25,6 +25,6 @@
         <junit-test-suite class-name="org.apache.ofbiz.base.util.test.UtilObjectTests"/>
         <junit-test-suite class-name="org.apache.ofbiz.base.util.string.test.FlexibleStringExpanderTests"/>
         <junit-test-suite class-name="org.apache.ofbiz.base.util.collections.test.FlexibleMapAccessorTests"/>
-        <groovy-test-suite name="simple" location="component://base/groovyScripts/test/SimpleTests.groovy"/>
+        <junit-test-suite class-name="org.apache.ofbiz.base.SimpleTests"/>
     </test-group>
 </test-suite>