svn commit: r1868126 - in /ofbiz/ofbiz-framework/trunk/applications/order: src/main/groovy/org/apache/ofbiz/order/ testdef/

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

svn commit: r1868126 - in /ofbiz/ofbiz-framework/trunk/applications/order: src/main/groovy/org/apache/ofbiz/order/ testdef/

jleroux@apache.org
Author: jleroux
Date: Tue Oct  8 10:50:18 2019
New Revision: 1868126

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

Based on Suraj's patch
This also moves
  testQuickReturnOrder to OrderReturnTests.groovy
  the requirement tests in OrderRequirementTests.groovy
  renames OrderTest.groovy to OrderNotificationTests.groovy since it contains
  only that
  renames test-case for OrderTests.xml "order-tests-xml"
 
Test pass

Thanks: Suraj for initial patch

Added:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy   (with props)
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy   (with props)
Removed:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy
Modified:
    ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml

Added: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy?rev=1868126&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy Tue Oct  8 10:50:18 2019
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ofbiz.order
+
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class OrderRequirementTests extends OFBizTestCase {
+    public OrderRequirementTests(String name) {
+        super(name)
+    }
+    // Requirement related test services
+    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 testCheckCreateStockRequirementQoh() {
+        Map serviceCtx = [
+            orderId: 'TEST_DEMO10090',
+            orderItemSeqId: '00001',
+            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
+        ]
+        Map serviceResult = dispatcher.runSync('checkCreateStockRequirementQoh', 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 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 testAutoAssignRequirementToSupplier() {
+        Map serviceCtx = [
+            requirementId: '1000',
+            userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
+        ]
+        Map serviceResult = dispatcher.runSync('autoAssignRequirementToSupplier', 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 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)
+    }
+
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy?rev=1868126&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy Tue Oct  8 10:50:18 2019
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ofbiz.order
+
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class OrderReturnTests extends OFBizTestCase {
+    public OrderReturnTests(String name) {
+        super(name)
+    }
+    // Return related test services
+    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 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',
+            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 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 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 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 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 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)
+    }
+    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 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 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
+    }
+}
\ No newline at end of file

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderReturnTests.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml?rev=1868126&r1=1868125&r2=1868126&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml Tue Oct  8 10:50:18 2019
@@ -30,10 +30,16 @@ under the License.
     <test-case case-name="salesOrder-test">
         <junit-test-suite class-name="org.apache.ofbiz.order.test.SalesOrderTest"/>
     </test-case>
-    <test-case case-name="order-test">
+    <test-case case-name="order-tests-xml">
         <simple-method-test location="component://order/minilang/test/OrderTests.xml"/>
     </test-case>
-    <test-case case-name="order-tests">
-        <junit-test-suite class-name="org.apache.ofbiz.order.OrderTests"/>
+    <test-case case-name="order-notification-tests">
+        <junit-test-suite class-name="org.apache.ofbiz.order.OrderNotificationTests"/>
+    </test-case>
+    <test-case case-name="order-return-tests">
+        <junit-test-suite class-name="org.apache.ofbiz.order.OrderReturnTests"/>
+    </test-case>
+    <test-case case-name="order-requirement-tests">
+        <junit-test-suite class-name="org.apache.ofbiz.order.OrderRequirementTests"/>
     </test-case>
 </test-suite>