[ofbiz-framework] branch trunk updated: Fixed: testIntegration issue caused due to mistakenly updated static string 'WITHDRAWAL' and updated variable in groovy test case. (OFBIZ-11926) Also used getter method for entity auto tests to get the dispatcher from OFBizTestCase.

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: testIntegration issue caused due to mistakenly updated static string 'WITHDRAWAL' and updated variable in groovy test case. (OFBIZ-11926) Also used getter method for entity auto tests to get the dispatcher from OFBizTestCase.

surajk
This is an automated email from the ASF dual-hosted git repository.

surajk 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 58a026f  Fixed: testIntegration issue caused due to mistakenly updated static string 'WITHDRAWAL' and updated variable in groovy test case. (OFBIZ-11926) Also used getter method for entity auto tests to get the dispatcher from OFBizTestCase.
     new 76139df  Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk
58a026f is described below

commit 58a026fbf842808e950fc013f50bf20675250b39
Author: Suraj Khurana <[hidden email]>
AuthorDate: Wed Aug 26 23:47:21 2020 +0530

    Fixed: testIntegration issue caused due to mistakenly updated static string 'WITHDRAWAL' and updated variable in groovy test case.
    (OFBIZ-11926)
    Also used getter method for entity auto tests to get the dispatcher from OFBizTestCase.
---
 .../finaccount/FinAccountPaymentServices.java      |  2 +-
 .../ofbiz/product/ProductPromoActionTests.groovy   |  3 +-
 .../ofbiz/service/test/ServiceEntityAutoTests.java | 57 ++++++++++++----------
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
index ca98db8..a13febf 100644
--- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
+++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
@@ -999,7 +999,7 @@ public class FinAccountPaymentServices {
             partyIdFrom = partyId;
             partyIdTo = coParty;
             paymentAmount = amount;
-        } else if ("withdrawal".equals(txType)) {
+        } else if ("WITHDRAWAL".equals(txType)) {
             paymentType = "DISBURSEMENT";
             partyIdFrom = coParty;
             partyIdTo = partyId;
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 aae4839..93fca31 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
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -197,7 +198,7 @@ class ProductPromoActionTests extends OFBizTestCase {
                 GenericValue product = from("Product").where("productId", item.getProductId()).queryOne()
                 if (product != null) {
                     product.put("includeInPromotions", "N")
-                    item._product = product
+                    item.product = product
                 }
             }
         }
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 c46cc7c..1c6eef1 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
@@ -29,7 +29,6 @@ import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.service.GenericServiceException;
-import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ServiceUtil;
 import org.apache.ofbiz.service.testtools.OFBizTestCase;
 
@@ -38,7 +37,6 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
     public ServiceEntityAutoTests(String name) {
         super(name);
     }
-    private final LocalDispatcher dispatcher = getDispatcher();
 
     @Override
     protected void setUp() throws Exception {
@@ -57,7 +55,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         Map<String, Object> testingPkPresentMap = new HashMap<>();
         testingPkPresentMap.put("testingId", "TESTING_1");
         testingPkPresentMap.put("testingName", "entity auto testing");
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoCreateTestingPkPresent", testingPkPresentMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoCreateTestingPkPresent", testingPkPresentMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testing = EntityQuery.use(delegator).from("Testing").where("testingId", "TESTING_1").queryOne();
         assertNotNull(testing);
@@ -65,13 +63,13 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test create with auto sequence
         Map<String, Object> testingPkMissingMap = new HashMap<>();
         testingPkPresentMap.put("testingName", "entity auto testing without pk part in");
-        results = dispatcher.runSync("testEntityAutoCreateTestingPkMissing", testingPkMissingMap);
+        results = getDispatcher().runSync("testEntityAutoCreateTestingPkMissing", testingPkMissingMap);
         assertTrue(ServiceUtil.isSuccess(results));
         testing = EntityQuery.use(delegator).from("Testing").where("testingId", results.get("testingId")).queryOne();
         assertNotNull(testing);
 
         //test collision
-        results = dispatcher.runSync("testEntityAutoCreateTestingPkPresent", testingPkPresentMap, 10, true);
+        results = getDispatcher().runSync("testEntityAutoCreateTestingPkPresent", testingPkPresentMap, 10, true);
         assertTrue(ServiceUtil.isError(results));
     }
 
@@ -84,7 +82,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
 
         //test create with given pk
         Map<String, Object> testingItemPkPresentMap = UtilMisc.toMap("testingId", "TESTING_2", "testingSeqId", "00001");
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoCreateTestingItemPkPresent", testingItemPkPresentMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoCreateTestingItemPkPresent", testingItemPkPresentMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testingItem = EntityQuery.use(delegator)
                                               .from("TestingItem")
@@ -94,7 +92,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
 
         //test create with auto sub-sequence
         Map<String, Object> testingItemPkMissingMap = UtilMisc.toMap("testingId", "TESTING_2");
-        results = dispatcher.runSync("testEntityAutoCreateTestingItemPkMissing", testingItemPkMissingMap);
+        results = getDispatcher().runSync("testEntityAutoCreateTestingItemPkMissing", testingItemPkMissingMap);
         assertTrue(ServiceUtil.isSuccess(results));
         testingItem = EntityQuery.use(delegator)
                                  .from("TestingItem")
@@ -104,7 +102,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         assertEquals("00002", testingItem.get("testingSeqId"));
 
         //test collision
-        results = dispatcher.runSync("testEntityAutoCreateTestingItemPkPresent", testingItemPkPresentMap, 10, true);
+        results = getDispatcher().runSync("testEntityAutoCreateTestingItemPkPresent", testingItemPkPresentMap, 10, true);
         assertTrue(ServiceUtil.isError(results));
         //assertEquals("", ServiceUtil.getErrorMessage(results));
     }
@@ -120,7 +118,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test create given pk
         Map<String, Object> testingNodeMemberPkPresentMap = UtilMisc.toMap("testingId", "TESTING_3",
                 "testingNodeId", "NODE_1", "fromDate", UtilDateTime.toTimestamp("01/01/2010 00:00:00"));
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoCreateTestingNodeMemberPkPresent", testingNodeMemberPkPresentMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoCreateTestingNodeMemberPkPresent", testingNodeMemberPkPresentMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testingNodeMember = EntityQuery.use(delegator)
                                                     .from("TestingNodeMember")
@@ -132,7 +130,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test create auto sub-sequence
         //test missing pk fromDate
         Map<String, Object> testingNodeMemberPkMissingMap = UtilMisc.toMap("testingId", "TESTING_3", "testingNodeId", "NODE_1");
-        results = dispatcher.runSync("testEntityAutoCreateTestingNodeMemberPkMissing", testingNodeMemberPkMissingMap, 10, true);
+        results = getDispatcher().runSync("testEntityAutoCreateTestingNodeMemberPkMissing", testingNodeMemberPkMissingMap, 10, true);
         assertTrue(ServiceUtil.isSuccess(results));
     }
 
@@ -145,14 +143,14 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
 
         //test update with exist pk
         Map<String, Object> testingUpdateMap = UtilMisc.toMap("testingId", "TESTING_4", "testingName", "entity auto testing updated");
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoUpdateTesting", testingUpdateMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoUpdateTesting", testingUpdateMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testing = EntityQuery.use(delegator).from("Testing").where("testingId", "TESTING_4").queryOne();
         assertEquals("entity auto testing updated", testing.getString("testingName"));
 
         //test update with bad pk
         Map<String, Object> testingUpdateFailedMap = UtilMisc.toMap("testingId", "TESTING_4_FAILED", "testingName", "entity auto testing updated");
-        results = dispatcher.runSync("testEntityAutoUpdateTesting", testingUpdateFailedMap, 10, true);
+        results = getDispatcher().runSync("testEntityAutoUpdateTesting", testingUpdateFailedMap, 10, true);
         assertTrue(ServiceUtil.isError(results));
         assertEquals(UtilProperties.getMessage("ServiceErrorUiLabels", "ServiceValueNotFound", Locale.ENGLISH), ServiceUtil.getErrorMessage(results));
     }
@@ -166,16 +164,17 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
 
         //test delete with exist pk
         Map<String, Object> testingDeleteMap = UtilMisc.toMap("testingId", "TESTING_5");
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoRemoveTesting", testingDeleteMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoRemoveTesting", testingDeleteMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testing = EntityQuery.use(delegator).from("Testing").where("testingId", "TESTING_5").queryOne();
         assertNull(testing);
 
         //test create with bad pk
         Map<String, Object> testingDeleteFailedMap = UtilMisc.toMap("testingId", "TESTING_5_FAILED");
-        results = dispatcher.runSync("testEntityAutoRemoveTesting", testingDeleteFailedMap);
+        results = getDispatcher().runSync("testEntityAutoRemoveTesting", testingDeleteFailedMap);
         assertTrue(ServiceUtil.isError(results));
-        assertEquals(UtilProperties.getMessage("ServiceErrorUiLabels", "ServiceValueNotFoundForRemove", Locale.ENGLISH), ServiceUtil.getErrorMessage(results));
+        assertEquals(UtilProperties.getMessage("ServiceErrorUiLabels", "ServiceValueNotFoundForRemove", Locale.ENGLISH),
+                ServiceUtil.getErrorMessage(results));
     }
 
     /**
@@ -190,14 +189,14 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         delegator.create("TestingNodeMember", testingNodeMemberPkMap);
 
         //test expire the thruDate
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoExpireTestingNodeMember", testingNodeMemberPkMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoExpireTestingNodeMember", testingNodeMemberPkMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testingNodeMember = EntityQuery.use(delegator).from("TestingNodeMember").where(testingNodeMemberPkMap).queryOne();
         Timestamp expireDate = testingNodeMember.getTimestamp("thruDate");
         assertNotNull("Expire thruDate set ", expireDate);
 
         //test expire to ensure the thruDate isn't update but extendThruDate is
-        results = dispatcher.runSync("testEntityAutoExpireTestingNodeMember", testingNodeMemberPkMap);
+        results = getDispatcher().runSync("testEntityAutoExpireTestingNodeMember", testingNodeMemberPkMap);
         assertTrue(ServiceUtil.isSuccess(results));
         testingNodeMember = EntityQuery.use(delegator).from("TestingNodeMember").where(testingNodeMemberPkMap).queryOne();
         assertTrue(expireDate.compareTo(testingNodeMember.getTimestamp("thruDate")) == 0);
@@ -206,7 +205,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test expire a specific field
         delegator.create("TestFieldType", "testFieldTypeId", "TESTING_6");
         Map<String, Object> testingExpireMap = UtilMisc.toMap("testFieldTypeId", "TESTING_6");
-        results = dispatcher.runSync("testEntityAutoExpireTestFieldType", testingExpireMap);
+        results = getDispatcher().runSync("testEntityAutoExpireTestFieldType", testingExpireMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testFieldType = EntityQuery.use(delegator).from("TestFieldType").where("testFieldTypeId", "TESTING_6").queryOne();
         assertNotNull("Expire dateTimeField set", testFieldType.getTimestamp("dateTimeField"));
@@ -214,7 +213,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test expire a specific field with in value
         delegator.create("TestFieldType", "testFieldTypeId", "TESTING_6bis");
         testingExpireMap = UtilMisc.toMap("testFieldTypeId", "TESTING_6bis", "dateTimeField", now);
-        results = dispatcher.runSync("testEntityAutoExpireTestFieldType", testingExpireMap);
+        results = getDispatcher().runSync("testEntityAutoExpireTestFieldType", testingExpireMap);
         assertTrue(ServiceUtil.isSuccess(results));
         testFieldType = EntityQuery.use(delegator).from("TestFieldType").where("testFieldTypeId", "TESTING_6bis").queryOne();
         assertTrue(now.compareTo(testFieldType.getTimestamp("dateTimeField")) == 0);
@@ -234,7 +233,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
 
         //test create testingStatus with userlogin
         Map<String, Object> testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE", "userLogin", userLogin);
-        Map<String, Object> results = dispatcher.runSync("testEntityAutoCreateTestingStatus", testingStatusCreateMap);
+        Map<String, Object> results = getDispatcher().runSync("testEntityAutoCreateTestingStatus", testingStatusCreateMap);
         assertTrue(ServiceUtil.isSuccess(results));
         GenericValue testing = EntityQuery.use(delegator).from("TestingStatus").where("testingId", "TESTING_7").queryFirst();
         assertNotNull(testing.getTimestamp("statusDate"));
@@ -243,28 +242,32 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
         //test create testingStatus without userLogin
         try {
             testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE");
-            results = dispatcher.runSync("testEntityAutoCreateTestingStatus", testingStatusCreateMap, 10, true);
+            results = getDispatcher().runSync("testEntityAutoCreateTestingStatus", testingStatusCreateMap, 10, true);
             assertTrue(ServiceUtil.isError(results));
         } catch (GenericServiceException e) {
-            assertEquals(e.toString(), "You call a creation on entity that require the userLogin to track the activity, please controle that your service definition has auth='true'");
+            assertEquals(e.toString(), "You call a creation on entity that require the userLogin to track the activity, "
+                    + "please control that your service definition has auth='true'");
         }
 
         //test update testingStatus
         try {
-            Map<String, Object> testingStatusUpdateMap = UtilMisc.toMap("testingStatusId", testing.get("testingStatusId"), "statusId", "TESTING_UPDATE", "userLogin", userLogin);
-            results = dispatcher.runSync("testEntityAutoUpdateTestingStatus", testingStatusUpdateMap, 10, true);
+            Map<String, Object> testingStatusUpdateMap = UtilMisc.toMap("testingStatusId", testing.get("testingStatusId"),
+                    "statusId", "TESTING_UPDATE", "userLogin", userLogin);
+            results = getDispatcher().runSync("testEntityAutoUpdateTestingStatus", testingStatusUpdateMap, 10, true);
             assertTrue(ServiceUtil.isError(results));
         } catch (GenericServiceException e) {
-            assertEquals(e.toString(), "You call a updating operation on entity that track the activity, sorry I can't do that, please amazing developer check your service definition;)");
+            assertEquals(e.toString(), "You call a updating operation on entity that track the activity, sorry I can't do that,"
+                    + "please amazing developer check your service definition;)");
         }
 
         //test delete testingStatus
         try {
             Map<String, Object> testingStatusDeleteMap = UtilMisc.toMap("testingStatusId", testing.get("testingStatusId"), "userLogin", userLogin);
-            results = dispatcher.runSync("testEntityAutoDeleteTestingStatus", testingStatusDeleteMap, 10, true);
+            results = getDispatcher().runSync("testEntityAutoDeleteTestingStatus", testingStatusDeleteMap, 10, true);
             assertTrue(ServiceUtil.isError(results));
         } catch (GenericServiceException e) {
-            assertEquals(e.toString(), "You call a deleting operation on entity that track the activity, sorry I can't do that, please amazing developer check your service definition;)");
+            assertEquals(e.toString(), "You call a deleting operation on entity that track the activity, sorry I can't do that, "
+                    + "please amazing developer check your service definition;)");
         }
     }
 }