You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2010/02/15 16:02:37 UTC

svn commit: r910229 - in /ofbiz/trunk/applications/order: servicedef/services.xml src/org/ofbiz/order/test/OrderTestServices.java

Author: jacopoc
Date: Mon Feb 15 15:02:37 2010
New Revision: 910229

URL: http://svn.apache.org/viewvc?rev=910229&view=rev
Log:
Slightly enhanced the testorder service to accept an optional productId.

Modified:
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/test/OrderTestServices.java

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=910229&r1=910228&r2=910229&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Mon Feb 15 15:02:37 2010
@@ -866,6 +866,7 @@
         location="org.ofbiz.order.test.OrderTestServices" invoke="createTestSalesOrderSingle">
         <description>Bulk create test sales orders. Note that default-values depend on demo data in ecommerce/data.</description>
         <attribute name="productCategoryId" type="String" mode="IN" optional="true" default-value="100"/>
+        <attribute name="productId" type="String" mode="IN" optional="true"/>
         <attribute name="productStoreId" type="String" mode="IN" optional="true" default-value="9000"/>
         <attribute name="currencyUomId" type="String" mode="IN" optional="true" default-value="USD"/>
         <attribute name="partyId" type="String" mode="IN" optional="true" default-value="DemoCustomer"/>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/OrderTestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/test/OrderTestServices.java?rev=910229&r1=910228&r2=910229&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/test/OrderTestServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/test/OrderTestServices.java Mon Feb 15 15:02:37 2010
@@ -78,6 +78,7 @@
         String productStoreId = (String) context.get("productStoreId");
         String currencyUomId = (String) context.get("currencyUomId");
         String partyId = (String) context.get("partyId");
+        String productId = (String) context.get("productId");
         Integer numberOfOrders = (Integer) context.get("numberOfOrders");
         Integer numberOfProductsPerOrder = (Integer) context.get("numberOfProductsPerOrder");
         String salesChannel = (String) context.get("salesChannel");
@@ -85,19 +86,22 @@
             salesChannel = "WEB_SALES_CHANNEL";
         }
 
-        int numberOfProductsPerOrderInt = numberOfProductsPerOrder.intValue();
-
         List productsList = FastList.newInstance();
         try {
-            Map result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
-            if (result.get("categoryMembers") != null) {
-                List productCategoryMembers = (List)result.get("categoryMembers");
-                if (productCategoryMembers != null) {
-                    Iterator i = productCategoryMembers.iterator();
-                    while (i.hasNext()) {
-                        GenericValue prodCatMemb = (GenericValue) i.next();
-                        if (prodCatMemb != null) {
-                            productsList.add(prodCatMemb.getString("productId"));
+            if (UtilValidate.isNotEmpty(productId)) {
+                productsList.add(productId);
+                numberOfProductsPerOrder = Integer.valueOf(1);
+            } else {
+                Map result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
+                if (result.get("categoryMembers") != null) {
+                    List productCategoryMembers = (List)result.get("categoryMembers");
+                    if (productCategoryMembers != null) {
+                        Iterator i = productCategoryMembers.iterator();
+                        while (i.hasNext()) {
+                            GenericValue prodCatMemb = (GenericValue) i.next();
+                            if (prodCatMemb != null) {
+                                productsList.add(prodCatMemb.getString("productId"));
+                            }
                         }
                     }
                 }
@@ -125,6 +129,7 @@
         } catch (Exception exc) {
             Debug.logWarning("Error setting userLogin in the cart: " + exc.getMessage(), module);
         }
+        int numberOfProductsPerOrderInt = numberOfProductsPerOrder.intValue();
         for (int j = 1; j <= numberOfProductsPerOrderInt; j++) {
             // get a product
             int k = r.nextInt(productsList.size());