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

[ofbiz-framework] branch trunk updated: Improved: Converted testUpdateFixedAssetMeter test from XML to Groovy. (OFBIZ-11550) Thanks Rohit Hukkeri for reporting and Aishwary Shrivastava for providing the patch.

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 9dda9fe  Improved: Converted testUpdateFixedAssetMeter test from XML to Groovy. (OFBIZ-11550) Thanks Rohit Hukkeri for reporting and Aishwary Shrivastava for providing the patch.
     new 6ededae  Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk
9dda9fe is described below

commit 9dda9fec3f699444653228d76a84940b54362e73
Author: Suraj Khurana <su...@apache.org>
AuthorDate: Sun Apr 26 19:49:49 2020 +0530

    Improved: Converted testUpdateFixedAssetMeter test from XML to Groovy.
    (OFBIZ-11550)
    Thanks Rohit Hukkeri for reporting and Aishwary Shrivastava for providing the patch.
---
 applications/accounting/FixedAssetTests.groovy     | 47 ++++++++++++++++++++++
 .../accounting/minilang/test/FixedAssetTests.xml   | 22 ----------
 .../accounting/testdef/fixedassettests.xml         |  2 +-
 3 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/applications/accounting/FixedAssetTests.groovy b/applications/accounting/FixedAssetTests.groovy
new file mode 100644
index 0000000..dc718d0
--- /dev/null
+++ b/applications/accounting/FixedAssetTests.groovy
@@ -0,0 +1,47 @@
+/*
+ * 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.accounting;
+
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class FixedAssetTests extends OFBizTestCase {
+    public FixedAssetTests(String name) {
+        super(name)
+    }
+    void testUpdateFixedAssetMeter() {
+        Map serviceCtx = [
+                fixedAssetId           : '1000',
+                productMeterTypeId     : 'ODOMETER',
+                readingDate            : UtilDateTime.toTimestamp("24/12/2019 00:00:00"),
+                userLogin              : userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('updateFixedAssetMeter', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue FixedAssetMeter = EntityQuery.use(delegator).from('FixedAssetMeter')
+                .where('fixedAssetId', '1000', 'productMeterTypeId', 'ODOMETER')
+                .filterByDate()
+                .queryOne();
+        assert FixedAssetMeter
+    }
+}
\ No newline at end of file
diff --git a/applications/accounting/minilang/test/FixedAssetTests.xml b/applications/accounting/minilang/test/FixedAssetTests.xml
index 7e1e625..5e2d549 100644
--- a/applications/accounting/minilang/test/FixedAssetTests.xml
+++ b/applications/accounting/minilang/test/FixedAssetTests.xml
@@ -108,28 +108,6 @@ under the License.
         <check-errors/>
     </simple-method>
 
-    <simple-method method-name="testUpdateFixedAssetMeter" short-description="Test case for service updateFixedAssetMeter" login-required="false">
-        <set field="fixedAssetId" value="DEMO_VEHICLE_01"/>
-        <set field="productMeterTypeId" value="ODOMETER"/>
-        <set field="readingDate" value="2009-12-24 00:00:00.000" type="Timestamp"/>
-        <set field="meterValue" value="85" type="BigDecimal"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <set field="serviceCtx.fixedAssetId" from-field="fixedAssetId"/>
-        <set field="serviceCtx.productMeterTypeId" from-field="productMeterTypeId"/>
-        <set field="serviceCtx.readingDate" from-field="readingDate"/>
-        <set field="serviceCtx.meterValue" from-field="meterValue"/>
-        <call-service service-name="updateFixedAssetMeter" in-map-name="serviceCtx"/>
-
-        <entity-one entity-name="FixedAssetMeter" value-field="fixedAssetMeter"/>
-        <assert>
-            <not><if-empty field="fixedAssetMeter"/></not>
-            <if-compare-field field="fixedAssetMeter.meterValue" operator="equals" to-field="meterValue"/>
-        </assert>
-        <check-errors/>
-    </simple-method>
 
     <simple-method method-name="testDeleteFixedAssetMeter" short-description="Test case for service deleteFixedAssetMeter" login-required="false">
         <set field="fixedAssetId" value="DEMO_VEHICLE_01"/>
diff --git a/applications/accounting/testdef/fixedassettests.xml b/applications/accounting/testdef/fixedassettests.xml
index 99fb04c..29b5366 100644
--- a/applications/accounting/testdef/fixedassettests.xml
+++ b/applications/accounting/testdef/fixedassettests.xml
@@ -23,7 +23,7 @@
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
 
     <test-case case-name="fixedasset-tests">
-        <simple-method-test location="component://accounting/minilang/test/FixedAssetTests.xml"/>
+        <junit-test-suite class-name="org.apache.ofbiz.accounting.FixedAssetTests"/>
     </test-case>
 
 </test-suite>