[ofbiz-framework] branch trunk updated: Fixed: The producttests test suite is brooken

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: Fixed: The producttests test suite is brooken

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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 6496145  Fixed: The producttests test suite is brooken
6496145 is described below

commit 649614507bab6ff955e243a5858c1353150dfd42
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Wed Apr 29 10:02:07 2020 +0200

    Fixed: The producttests test suite is brooken
   
    (OFBIZ-11620)
   
    It was initially broken by OFBIZ-9905 so only trunk was concerned.
    The fix is simple: there should be no space at the beginning of the file.
   
    But then, when running the test suite, other issues raise.
    I guess they  were hidden because of the initial issue.
   
    OFBIZ-10231 introduced 2 issues
    A syntax error:
    product.removeRelated("ProductKeyword", product)
    instead of
    product.removeRelated("ProductKeyword")
   
    A wrong usage of storeByCondition
   
    This fixes the 3 issues, to test:
    gradlew "ofbiz --test component=product --test suitename=producttests"
   
    Thanks: Pawan for initial report
---
 .../groovyScripts/product/product/ProductServices.groovy | 16 ++++++++++------
 applications/product/testdef/ProductTest.xml             |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/applications/product/groovyScripts/product/product/ProductServices.groovy b/applications/product/groovyScripts/product/product/ProductServices.groovy
index 21daa81..a520130 100644
--- a/applications/product/groovyScripts/product/product/ProductServices.groovy
+++ b/applications/product/groovyScripts/product/product/ProductServices.groovy
@@ -21,6 +21,7 @@
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilProperties
 import org.apache.ofbiz.base.util.UtilValidate
+import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.entity.GenericValue
 import org.apache.ofbiz.entity.serialize.XmlSerializer
 import org.apache.ofbiz.product.product.KeywordIndex
@@ -296,7 +297,7 @@ def forceIndexProductKeywords() {
  */
 def deleteProductKeywords() {
     GenericValue product = from("Product").where(parameters).cache().queryOne()
-    product.removeRelated("ProductKeyword", product)
+    product.removeRelated("ProductKeyword")
     return success()
 }
 
@@ -329,15 +330,18 @@ def discontinueProductSales() {
     product.salesDiscontinuationDate = nowTimestamp
     product.store()
 
+
     // expire product from all categories
+    exprBldr = new EntityConditionBuilder()
+    condition = exprBldr.AND() {
+        EQUALS(productId: product.productId)
+        EQUALS(thruDate: null)
+    }
     delegator.storeByCondition("ProductCategoryMember",
-            [thruDate: nowTimestamp],
-            [productId: product.productId, thruDate: null])
-
+            [thruDate: nowTimestamp], condition)
     // expire product from all associations going to it
     delegator.storeByCondition("ProducAssoc",
-            [thruDate: nowTimestamp],
-            [productIdTo: product.productId, thruDate: null])
+            [thruDate: nowTimestamp], condition)
     return success()
 }
 
diff --git a/applications/product/testdef/ProductTest.xml b/applications/product/testdef/ProductTest.xml
index 2dc1ba5..e67e2cc 100644
--- a/applications/product/testdef/ProductTest.xml
+++ b/applications/product/testdef/ProductTest.xml
@@ -1,4 +1,4 @@
- <?xml version="1.0" encoding="UTF-8"?>
+<?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