You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2019/10/08 11:04:22 UTC

svn commit: r1868128 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy

Author: jleroux
Date: Tue Oct  8 11:04:22 2019
New Revision: 1868128

URL: http://svn.apache.org/viewvc?rev=1868128&view=rev
Log:
Improved: Refactor OrderTests.groovy and separate order and return test services
(OFBIZ-11239)

Forgot to commit OrderNotificationTests.groovy in last commit

Added:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy
      - copied, changed from r1868077, ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy

Copied: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy (from r1868077, ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy)
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy?p2=ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy&p1=ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy&r1=1868077&r2=1868128&rev=1868128&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderNotificationTests.groovy Tue Oct  8 11:04:22 2019
@@ -22,211 +22,25 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.service.ServiceUtil
 import org.apache.ofbiz.service.testtools.OFBizTestCase
 
-class OrderTests extends OFBizTestCase {
-    public OrderTests(String name) {
+class OrderNotificationTests extends OFBizTestCase {
+    public OrderNotificationTests(String name) {
         super(name)
     }
-
-    void testAddRequirementTask() {
-        Map serviceCtx = [
-            requirementId: '1000',
-            workEffortId: '9000',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync("addRequirementTask", serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCreateReturnAdjustment() {
-        Map serviceCtx = [
-            amount: '2.0000',
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('createReturnAdjustment', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.returnAdjustmentId != null
-    }
-    void testQuickReturnOrder() {
-        Map serviceCtx = [
-            orderId: 'TEST_DEMO10090',
-            returnHeaderTypeId: 'CUSTOMER_RETURN',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('quickReturnOrder', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.returnId != null
-    }
-    void testCreateReturnAndItemOrAdjustment() {
-        Map serviceCtx = [
-            orderId: 'DEMO10090',
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('createReturnAndItemOrAdjustment', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.returnAdjustmentId != null
-    }
-    void testCheckReturnComplete() {
-        Map serviceCtx = [
-            amount: '2.0000',
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('checkReturnComplete', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.statusId != null
-    }
-    void testCheckPaymentAmountForRefund() {
-        Map serviceCtx = [
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('checkPaymentAmountForRefund', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    //TODO: This can be moved to a different file
-    void testCheckCreateProductRequirementForFacility() {
-        Map serviceCtx = [
-            facilityId: 'WebStoreWarehouse',
-            orderItemSeqId: '00001',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('checkCreateProductRequirementForFacility', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCreateReturnItemShipment() {
-        Map serviceCtx = [
-            shipmentId: '1014',
-            shipmentItemSeqId: '00001',
-            returnId: '1009',
-            returnItemSeqId: '00001',
-            quantity: new BigDecimal('2.0000'),
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('createReturnItemShipment', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCreateReturnStatus() {
-        Map serviceCtx = [
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('createReturnStatus', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCreateReturnHeader() {
-        Map serviceCtx = [
-            toPartyId: 'Company',
-            returnHeaderTypeId: 'CUSTOMER_RETURN',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('createReturnHeader', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.returnId != null
-    }
-    void testGetReturnAmountByOrder() {
-        Map serviceCtx = [
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('getReturnAmountByOrder', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCheckCreateStockRequirementQoh() {
+    void testSendOrderChangeNotification() {
         Map serviceCtx = [
             orderId: 'TEST_DEMO10090',
-            orderItemSeqId: '00001',
+            sendTo: 'test_email@example.com',
             userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
         ]
-        Map serviceResult = dispatcher.runSync('checkCreateStockRequirementQoh', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessWaitReplacementReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processWaitReplacementReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessWaitReplacementReservedReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processWaitReplacementReservedReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult != null
-    }
-    void testProcessSubscriptionReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processSubscriptionReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessReplacementReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                returnTypeId: 'RTN_REFUND',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processReplacementReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessReplaceImmediatelyReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                orderItemSeqId: '00001',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processReplaceImmediatelyReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessRefundOnlyReturn() {
-        Map serviceCtx = [
-                returnId: '1009',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processRefundOnlyReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testCheckCreateStockRequirementAtp() {
-        Map serviceCtx = [
-                orderId: 'TEST_DEMO10090',
-                orderItemSeqId: '00001',
-                shipGroupSeqId: '00001',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('checkCreateStockRequirementAtp', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testAssociatedRequirementWithRequestItem() {
-        Map serviceCtx = [
-                requirementId: '1000',
-                custRequestId: '9000',
-                custRequestItemSeqId: '00001',
-                userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('associatedRequirementWithRequestItem', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testSendOrderChangeNotification() {
-        Map serviceCtx = [
-                  orderId: 'TEST_DEMO10090',
-                  sendTo: 'test_email@example.com',
-                  userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
         Map serviceResult = dispatcher.runSync('sendOrderChangeNotification', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
         assert serviceResult.emailType.equals("PRDS_ODR_CHANGE")
     }
     void testSendOrderBackorderNotification() {
         Map serviceCtx = [
-                  orderId: 'TEST_DEMO10090',
-                  sendTo: 'test_email@example.com',
-                  userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
+            orderId: 'TEST_DEMO10090',
+            sendTo: 'test_email@example.com',
+            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
         ]
         Map serviceResult = dispatcher.runSync('sendOrderBackorderNotification', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
@@ -234,9 +48,9 @@ class OrderTests extends OFBizTestCase {
     }
     void testsendOrderPayRetryNotification() {
         Map serviceCtx = [
-                  orderId: 'TEST_DEMO10090',
-                  sendTo: 'test_email@example.com',
-                  userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
+            orderId: 'TEST_DEMO10090',
+            sendTo: 'test_email@example.com',
+            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
         ]
         Map serviceResult = dispatcher.runSync('sendOrderPayRetryNotification', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
@@ -244,72 +58,12 @@ class OrderTests extends OFBizTestCase {
     }
     void testsendOrderCompleteNotification() {
         Map serviceCtx = [
-                  orderId: 'TEST_DEMO10090',
-                  sendTo: 'test_email@example.com',
-                  userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('sendOrderCompleteNotification', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.emailType.equals("PRDS_ODR_COMPLETE")
-    }
-    void testCheckCreateOrderRequirement() {
-        Map serviceCtx = [
             orderId: 'TEST_DEMO10090',
-            orderItemSeqId: '00001',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('checkCreateOrderRequirement', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessCreditReturn() {
-        Map serviceCtx = [
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processCreditReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessCrossShipReplacementReturn() {
-        Map serviceCtx = [
-            returnId: '1009',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processCrossShipReplacementReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testProcessRefundImmediatelyReturn() {
-        Map serviceCtx = [
-            returnId: '1009',
+            sendTo: 'test_email@example.com',
             userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
         ]
-        Map serviceResult = dispatcher.runSync('processRefundImmediatelyReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testGetReturnItemInitialCost() {
-        Map serviceCtx = [
-            returnId: '1009',
-            returnItemSeqId: '00001',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('getReturnItemInitialCost', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-        assert serviceResult.initialItemCost != null
-    }
-    void testProcessRefundReturn() {
-        Map serviceCtx = [
-            returnId: '1009',
-            returnTypeId: 'RTN_REFUND',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('processRefundReturn', serviceCtx)
-        assert ServiceUtil.isSuccess(serviceResult)
-    }
-    void testAutoAssignRequirementToSupplier() {
-        Map serviceCtx = [
-            requirementId: '1000',
-            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
-        ]
-        Map serviceResult = dispatcher.runSync('autoAssignRequirementToSupplier', serviceCtx)
+        Map serviceResult = dispatcher.runSync('sendOrderCompleteNotification', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.emailType.equals("PRDS_ODR_COMPLETE")
     }
 }