You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by pa...@apache.org on 2020/04/30 16:30:31 UTC

[ofbiz-framework] branch trunk updated: Improved: Used utility provided by OFBizTestCase class for userLogin instead of fetching from DB test cases also removed unused fetching of userLogin in some cases (OFBIZ-11618)

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 ffe9c46  Improved: Used utility provided by OFBizTestCase class for userLogin instead of fetching from DB test cases also removed unused fetching of userLogin in some cases (OFBIZ-11618)
ffe9c46 is described below

commit ffe9c46cf0b42bbaba4c967f247d8ccffd66f068
Author: Pawan Verma <pa...@hotwaxsystems.com>
AuthorDate: Thu Apr 30 22:00:04 2020 +0530

    Improved: Used utility provided by OFBizTestCase class for userLogin instead of fetching from DB test cases also removed unused fetching of userLogin in some cases
    (OFBIZ-11618)
---
 .../java/org/apache/ofbiz/accounting/test/FinAccountTests.java |  2 +-
 .../src/main/java/org/apache/ofbiz/order/test/OrderTest.java   |  2 --
 .../java/org/apache/ofbiz/order/test/PurchaseOrderTest.java    |  8 +-------
 .../main/java/org/apache/ofbiz/order/test/SalesOrderTest.java  |  8 +-------
 .../org/apache/ofbiz/product/ProductPromoActionTests.groovy    |  3 +--
 .../org/apache/ofbiz/product/ProductPromoCondTests.groovy      |  3 +--
 .../apache/ofbiz/product/test/InventoryItemTransferTest.java   |  7 +------
 .../java/org/apache/ofbiz/product/test/StockMovesTest.java     |  8 +-------
 .../main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java |  9 +--------
 .../java/org/apache/ofbiz/common/test/PerformFindTests.java    | 10 +++++-----
 .../org/apache/ofbiz/service/test/ServiceEntityAutoTests.java  |  2 +-
 11 files changed, 14 insertions(+), 48 deletions(-)

diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/test/FinAccountTests.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/test/FinAccountTests.java
index 15b3cd4..11e0107 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/test/FinAccountTests.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/test/FinAccountTests.java
@@ -38,7 +38,7 @@ public class FinAccountTests extends OFBizTestCase {
     }
 
     public void testFinAccountOperations() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
+        GenericValue userLogin = getUserLogin("system");
         Map<String, Object> ctx = new HashMap<>();
         ctx.put("finAccountId", "TESTACCOUNT1");
         ctx.put("finAccountName", "Test Financial Account");
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTest.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTest.java
index 776e976..fa824fd 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTest.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTest.java
@@ -30,8 +30,6 @@ import java.util.Map;
 public class OrderTest extends OFBizTestCase {
     public static final String MODULE = OFBizTestCase.class.getName();
 
-    protected GenericValue userLogin = null;
-
     public OrderTest(String name) {
         super(name);
     }
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/PurchaseOrderTest.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/PurchaseOrderTest.java
index 57de778..cb8eb2b 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/test/PurchaseOrderTest.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/PurchaseOrderTest.java
@@ -34,7 +34,6 @@ import org.apache.ofbiz.service.ServiceUtil;
 public class PurchaseOrderTest extends OFBizTestCase {
     public static final String MODULE = OFBizTestCase.class.getName();
 
-    protected GenericValue userLogin = null;
     protected String orderId = null;
     protected String statusId = null;
 
@@ -43,11 +42,6 @@ public class PurchaseOrderTest extends OFBizTestCase {
     }
 
     @Override
-    protected void setUp() throws Exception {
-        userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
-    }
-
-    @Override
     protected void tearDown() throws Exception {
     }
 
@@ -93,7 +87,7 @@ public class PurchaseOrderTest extends OFBizTestCase {
         ctx.put("billFromVendorPartyId", "DemoSupplier");
         ctx.put("shipFromVendorPartyId", "Company");
         ctx.put("supplierAgentPartyId", "DemoSupplier");
-        ctx.put("userLogin", userLogin);
+        ctx.put("userLogin", getUserLogin("system"));
 
         Map <String, Object> resp = dispatcher.runSync("storeOrder", ctx);
         if (ServiceUtil.isError(resp)) {
diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java
index 5c9d919..7842d42 100644
--- a/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java
+++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java
@@ -33,18 +33,12 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
 public class SalesOrderTest extends OFBizTestCase {
     public static final String MODULE = OFBizTestCase.class.getName();
 
-    protected GenericValue userLogin = null;
 
     public SalesOrderTest(String name) {
         super(name);
     }
 
     @Override
-    protected void setUp() throws Exception {
-        userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
-    }
-
-    @Override
     protected void tearDown() throws Exception {
     }
 
@@ -141,7 +135,7 @@ public class SalesOrderTest extends OFBizTestCase {
         ctx.put("billToCustomerPartyId", "DemoCustomer");
         ctx.put("billFromVendorPartyId", "Company");
 
-        ctx.put("userLogin", userLogin);
+        ctx.put("userLogin", getUserLogin("system"));
         Map<String, Object> resp = dispatcher.runSync("storeOrder", ctx);
         if (ServiceUtil.isError(resp)) {
             Debug.logError(ServiceUtil.getErrorMessage(resp), MODULE);
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
index cbf7264..5784e77 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy
@@ -41,11 +41,10 @@ class ProductPromoActionTests extends OFBizTestCase {
     }
 
     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]
+                userLogin: getUserLogin("system")]
         Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
 
         return loadCartResp.shoppingCart
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
index b1f59e5..6942c88 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy
@@ -52,13 +52,12 @@ class ProductPromoCondTests extends OFBizTestCase {
     }
 
     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]
+                userLogin: getUserLogin("system")]
         Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
 
         return loadCartResp.shoppingCart
diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/test/InventoryItemTransferTest.java b/applications/product/src/main/java/org/apache/ofbiz/product/test/InventoryItemTransferTest.java
index a7c95d5..f3479e3 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/product/test/InventoryItemTransferTest.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/product/test/InventoryItemTransferTest.java
@@ -30,7 +30,6 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
 
 public class InventoryItemTransferTest extends OFBizTestCase {
 
-    protected GenericValue userLogin = null;
     static String inventoryTransferId = null;
     protected BigDecimal transferQty = BigDecimal.ONE;
 
@@ -39,15 +38,11 @@ public class InventoryItemTransferTest extends OFBizTestCase {
     }
 
     @Override
-    protected void setUp() throws Exception {
-        userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
-    }
-
-    @Override
     protected void tearDown() throws Exception {
     }
 
     public void testCreateInventoryItemsTransfer() throws Exception {
+        GenericValue userLogin = getUserLogin("system");
         // create
         Map<String, Object> ctx = new HashMap<>();
         String inventoryItemId = "9005";
diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/test/StockMovesTest.java b/applications/product/src/main/java/org/apache/ofbiz/product/test/StockMovesTest.java
index 5c67a39..960ea75 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/product/test/StockMovesTest.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/product/test/StockMovesTest.java
@@ -34,22 +34,16 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
  */
 public class StockMovesTest extends OFBizTestCase {
 
-    protected GenericValue userLogin = null;
-
     public StockMovesTest(String name) {
         super(name);
     }
 
     @Override
-    protected void setUp() throws Exception {
-        userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
-    }
-
-    @Override
     protected void tearDown() throws Exception {
     }
 
     public void testStockMoves() throws Exception {
+        GenericValue userLogin = getUserLogin("system");
         Map<String, Object> fsmnCtx = new HashMap<>();
         Map<?,?> stockMoveHandled = null;
         List<?> warningList;
diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java
index 165f056..c062fa1 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java
@@ -34,18 +34,11 @@ import org.apache.ofbiz.shipment.packing.PackingSession;
  */
 public class IssuanceTest extends OFBizTestCase {
 
-    protected GenericValue userLogin = null;
-
     public IssuanceTest(String name) {
         super(name);
     }
 
     @Override
-    protected void setUp() throws Exception {
-        userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
-    }
-
-    @Override
     protected void tearDown() throws Exception {
     }
 
@@ -57,7 +50,7 @@ public class IssuanceTest extends OFBizTestCase {
         String shipGroupSeqId="00001";
         String shipmentItemSeqId = "00001";
 
-        PackingSession packSession = new PackingSession(dispatcher, userLogin, facilityId, null, orderId, shipGroupSeqId);
+        PackingSession packSession = new PackingSession(dispatcher, getUserLogin("system"), facilityId, null, orderId, shipGroupSeqId);
         packSession.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, productId, BigDecimal.valueOf(6L), 1,
             BigDecimal.valueOf(1000L), false);
         String shipmentId = packSession.complete(false);
diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java
index e5a7c55..cfbedd6 100644
--- a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java
+++ b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java
@@ -112,7 +112,7 @@ public class PerformFindTests extends OFBizTestCase {
     }
 
     private void performFindConditionFieldEquals() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
         prepareData();
 
         Map<String, Object> inputFields = new HashMap<>();
@@ -149,7 +149,7 @@ public class PerformFindTests extends OFBizTestCase {
     }
 
     private void performFindConditionFieldLike() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
         prepareData();
 
         //first test like condition
@@ -186,7 +186,7 @@ public class PerformFindTests extends OFBizTestCase {
     }
 
     private void performFindConditionDistinct() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
         prepareData();
 
         //first test without distinct condition
@@ -207,7 +207,7 @@ public class PerformFindTests extends OFBizTestCase {
     }
 
     private void performFindFilterByDate() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
         prepareData();
 
         //first test without filterDate condition
@@ -227,7 +227,7 @@ public class PerformFindTests extends OFBizTestCase {
     }
 
     private void performFindFilterByDateWithDedicateDateField() throws Exception {
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
         prepareData();
 
         //first test without filterDate condition
diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java
index df208e1..345ec83 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java
@@ -200,7 +200,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         delegator.create("StatusType", "statusTypeId", "TESTINGSTATUS");
         delegator.create("StatusItem", "statusId", "TESTING_CREATE", "statusTypeId", "TESTINGSTATUS");
         delegator.create("StatusItem", "statusId", "TESTING_UPDATE", "statusTypeId", "TESTINGSTATUS");
-        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+        GenericValue userLogin = getUserLogin("system");
 
         //test create testingStatus with userlogin
         Map<String, Object> testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE", "userLogin", userLogin);