[ofbiz-framework] branch trunk updated: Improved: Convert InventoryTests.xml to Groovy (OFBIZ-11851)

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: Improved: Convert InventoryTests.xml to Groovy (OFBIZ-11851)

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

akashjain 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 e111f19  Improved: Convert InventoryTests.xml to Groovy (OFBIZ-11851)
e111f19 is described below

commit e111f194b314bea89086156924c7ccf4888d04bd
Author: Akash Jain <[hidden email]>
AuthorDate: Wed Jul 8 11:47:35 2020 +0530

    Improved: Convert InventoryTests.xml to Groovy (OFBIZ-11851)
---
 .../minilang/product/test/InventoryTests.xml       | 53 ----------------------
 .../org/apache/ofbiz/product/InventoryTests.groovy | 53 ++++++++++++++++++++++
 applications/product/testdef/FacilityTest.xml      |  2 +-
 3 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/applications/product/minilang/product/test/InventoryTests.xml b/applications/product/minilang/product/test/InventoryTests.xml
deleted file mode 100644
index f40fe89..0000000
--- a/applications/product/minilang/product/test/InventoryTests.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-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.
--->
-
-<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
-
-    <simple-method method-name="testGetInventoryAvailableByFacility" short-description="Test case for service getInventoryAvailableByFacility" login-required="false">
-        <set field="serviceCtx.productId" value="GZ-2644"/>
-        <set field="serviceCtx.facilityId" value="WebStoreWarehouse"/>
-        <call-service service-name="getInventoryAvailableByFacility" in-map-name="serviceCtx">
-            <result-to-field result-name="quantityOnHandTotal"/>
-            <result-to-field result-name="availableToPromiseTotal"/>
-        </call-service>
-        <assert>
-            <if-compare field="quantityOnHandTotal" operator="equals" value="509" type="BigDecimal"/>
-            <if-compare field="availableToPromiseTotal" operator="equals" value="509" type="BigDecimal"/>
-        </assert>
-        <check-errors/>
-    </simple-method>
-
-    <!-- Test Physical Inventory Adjustment -->
-    <simple-method method-name="testCreatePhysicalInventoryAndVariance" short-description="Test to create physical inventory and variance" login-required="false">
-        <set field="serviceCtx.inventoryItemId" value="9024"/>
-        <set field="serviceCtx.varianceReasonId" value="VAR_LOST"/>
-        <entity-one entity-name="UserLogin" value-field="serviceCtx.userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <call-service service-name="createPhysicalInventoryAndVariance" in-map-name="serviceCtx">
-            <result-to-field result-name="physicalInventoryId" field="physicalInventoryId"/>
-        </call-service>
-        <assert>
-            <not><if-empty field="physicalInventoryId"/></not>
-        </assert>
-        <check-errors/>
-    </simple-method>
-</simple-methods>
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/InventoryTests.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/InventoryTests.groovy
new file mode 100644
index 0000000..8531968
--- /dev/null
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/InventoryTests.groovy
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.product
+
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class InventoryTests extends OFBizTestCase {
+    public InventoryTests(String name) {
+        super(name)
+    }
+
+    void testGetInventoryAvailableByFacility() {
+        Map serviceCtx = [
+                productId: 'GZ-2644',
+                facilityId: 'WebStoreWarehouse',
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('getInventoryAvailableByFacility', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.quantityOnHandTotal.compareTo(new BigDecimal('509')) == 0
+        assert serviceResult.availableToPromiseTotal.compareTo(new BigDecimal('509')) == 0
+    }
+
+    // Test Physical Inventory Adjustment
+    void testCreatePhysicalInventoryAndVariance() {
+        Map serviceCtx = [
+                inventoryItemId: '9024',
+                varianceReasonId: 'VAR_LOST',
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('createPhysicalInventoryAndVariance', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.physicalInventoryId
+    }
+}
\ No newline at end of file
diff --git a/applications/product/testdef/FacilityTest.xml b/applications/product/testdef/FacilityTest.xml
index c0c58d9..fff6c6e 100644
--- a/applications/product/testdef/FacilityTest.xml
+++ b/applications/product/testdef/FacilityTest.xml
@@ -28,7 +28,7 @@ under the License.
         <junit-test-suite class-name="org.apache.ofbiz.product.test.InventoryItemTransferTest"/>
     </test-case>
     <test-case case-name="inventory-tests">
-        <simple-method-test location="component://product/minilang/product/test/InventoryTests.xml"/>
+        <junit-test-suite class-name="org.apache.ofbiz.product.InventoryTests"/>
     </test-case>
 
     <test-case case-name="shipment-tests">