svn commit: r1817578 - in /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test: FinAccountTest.java OrderTestServices.java SalesOrderTest.java

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

svn commit: r1817578 - in /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test: FinAccountTest.java OrderTestServices.java SalesOrderTest.java

mbrohl
Author: mbrohl
Date: Fri Dec  8 21:51:16 2017
New Revision: 1817578

URL: http://svn.apache.org/viewvc?rev=1817578&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.order.test.
(OFBIZ-9732)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/FinAccountTest.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/FinAccountTest.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/FinAccountTest.java?rev=1817578&r1=1817577&r2=1817578&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/FinAccountTest.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/FinAccountTest.java Fri Dec  8 21:51:16 2017
@@ -18,6 +18,8 @@
  *******************************************************************************/
 package org.apache.ofbiz.order.test;
 
+import java.util.Locale;
+
 import org.apache.ofbiz.base.util.UtilMisc;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.order.finaccount.FinAccountHelper;
@@ -33,7 +35,7 @@ public class FinAccountTest extends OFBi
         GenericValue account;
 
         finAccountCode = FinAccountHelper.getNewFinAccountCode(20, delegator);
-        System.err.printf("finAccountCode=%s\n", finAccountCode);
+        System.err.printf("finAccountCode=%s%n", finAccountCode);
         assertNotNull(finAccountCode);
 
         account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator);
@@ -44,10 +46,10 @@ public class FinAccountTest extends OFBi
         account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator);
         assertNotNull(account);
         assertEquals(finAccountCode, account.get("finAccountCode"));
-        account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toUpperCase(), delegator);
+        account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toUpperCase(Locale.getDefault()), delegator);
         assertNotNull(account);
         assertEquals(finAccountCode, account.get("finAccountCode"));
-        account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toLowerCase(), delegator);
+        account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toLowerCase(Locale.getDefault()), delegator);
         assertNotNull(account);
         assertEquals(finAccountCode, account.get("finAccountCode"));
 

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java?rev=1817578&r1=1817577&r2=1817578&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java Fri Dec  8 21:51:16 2017
@@ -33,7 +33,9 @@ import org.apache.ofbiz.base.util.UtilVa
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.order.order.OrderChangeHelper;
+import org.apache.ofbiz.order.shoppingcart.CartItemModifyException;
 import org.apache.ofbiz.order.shoppingcart.CheckOutHelper;
+import org.apache.ofbiz.order.shoppingcart.ItemNotFoundException;
 import org.apache.ofbiz.order.shoppingcart.ShoppingCart;
 import org.apache.ofbiz.service.DispatchContext;
 import org.apache.ofbiz.service.GenericServiceException;
@@ -137,7 +139,7 @@ public class OrderTestServices {
                 cart.addOrIncreaseItem(productsList.get(k), null, BigDecimal.ONE, null, null, null,
                                        null, null, null, null,
                                        null /*catalogId*/, null, null/*itemType*/, null/*itemGroupNumber*/, null, dispatcher);
-            } catch (Exception exc) {
+            } catch (CartItemModifyException | ItemNotFoundException exc) {
                 Debug.logWarning("Error adding product with id " + productsList.get(k) + " to the cart: " + exc.getMessage(), module);
             }
         }

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java?rev=1817578&r1=1817577&r2=1817578&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java Fri Dec  8 21:51:16 2017
@@ -73,36 +73,36 @@ public class SalesOrderTest extends OFBi
         orderItemShipGroupInfo.add(orderAdjustment);
 
         orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224153",
-                "primaryGeoId", "UT", "shipGroupSeqId", "00001", "sourcePercentage", new BigDecimal(4.7)));
+                "primaryGeoId", "UT", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(4.7)));
         orderAdjustment.set("taxAuthGeoId", "UT");
         orderAdjustment.set("taxAuthPartyId", "UT_TAXMAN");
         orderAdjustment.set("taxAuthorityRateSeqId", "9004");
-        orderAdjustment.set("amount", new BigDecimal(1.824));
+        orderAdjustment.set("amount", BigDecimal.valueOf(1.824));
         orderAdjustment.set("comments", "Utah State Sales Tax");
         orderItemShipGroupInfo.add(orderAdjustment);
 
         orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224153",
-                "primaryGeoId", "UT-UTAH", "shipGroupSeqId", "00001", "sourcePercentage", new BigDecimal(0.1)));
+                "primaryGeoId", "UT-UTAH", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(0.1)));
         orderAdjustment.set("taxAuthGeoId", "UT-UTAH");
         orderAdjustment.set("taxAuthPartyId", "UT_UTAH_TAXMAN");
         orderAdjustment.set("taxAuthorityRateSeqId", "9005");
-        orderAdjustment.set("amount", new BigDecimal(0.039));
+        orderAdjustment.set("amount", BigDecimal.valueOf(0.039));
         orderAdjustment.set("comments", "Utah County, Utah Sales Tax");
         orderItemShipGroupInfo.add(orderAdjustment);
 
         orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224000",
-                "primaryGeoId", "_NA_", "shipGroupSeqId", "00001", "sourcePercentage", new BigDecimal(1)));
+                "primaryGeoId", "_NA_", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(1)));
         orderAdjustment.set("taxAuthGeoId", "_NA_");
         orderAdjustment.set("taxAuthPartyId", "_NA_");
         orderAdjustment.set("taxAuthorityRateSeqId", "9000");
-        orderAdjustment.set("amount", new BigDecimal(0.384));
+        orderAdjustment.set("amount", BigDecimal.valueOf(0.384));
         orderAdjustment.set("comments", "1% OFB _NA_ Tax");
         orderItemShipGroupInfo.add(orderAdjustment);
 
         ctx.put("orderItemShipGroupInfo", orderItemShipGroupInfo);
 
         List<GenericValue> orderAdjustments = new LinkedList<GenericValue>();
-        orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", "productPromoActionSeqId", "01", "productPromoId", "9011", "productPromoRuleId", "01", "amount", new BigDecimal(-3.84)));
+        orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", "productPromoActionSeqId", "01", "productPromoId", "9011", "productPromoRuleId", "01", "amount", BigDecimal.valueOf(-3.84)));
         orderAdjustments.add(orderAdjustment);
         ctx.put("orderAdjustments", orderAdjustments);
 
@@ -131,8 +131,6 @@ public class SalesOrderTest extends OFBi
         GenericValue OrderContactMech = delegator.makeValue("OrderContactMech");
         OrderContactMech.set("contactMechPurposeTypeId", "SHIPPING_LOCATION");
         OrderContactMech.set("contactMechId", "10000");
-        List<GenericValue> orderContactMechs = new LinkedList<GenericValue>();
-        orderContactMechs.add(OrderContactMech);
 
         ctx.put("placingCustomerPartyId", "DemoCustomer");
         ctx.put("endUserCustomerPartyId", "DemoCustomer");