This is an automated email from the ASF dual-hosted git repository.
pawan 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 13ab014 Improved: Convert AutoAcctgFixedAssetTests from XML to Groovy
(OFBIZ-11520)(OFBIZ-11519)(OFBIZ-11517)
13ab014 is described below
commit 13ab014afbace5b3bf01f202b076e5c16b27bcfc
Author: Pawan Verma <[email protected]>
AuthorDate: Fri May 15 22:50:45 2020 +0530
Improved: Convert AutoAcctgFixedAssetTests from XML to Groovy
(OFBIZ-11520)(OFBIZ-11519)(OFBIZ-11517)
Thanks: Rohit for the report and patch and Suraj for the review.
---
.../minilang/test/AutoAcctgFixedAssetTests.xml | 89 ----------------------
.../accounting/AutoAcctgFixedAssetTests.groovy | 84 ++++++++++++++++++++
.../accounting/testdef/accountingtests.xml | 2 +-
3 files changed, 85 insertions(+), 90 deletions(-)
diff --git a/applications/accounting/minilang/test/AutoAcctgFixedAssetTests.xml
b/applications/accounting/minilang/test/AutoAcctgFixedAssetTests.xml
deleted file mode 100644
index 694e985..0000000
--- a/applications/accounting/minilang/test/AutoAcctgFixedAssetTests.xml
+++ /dev/null
@@ -1,89 +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="testCancelFixedAssetStdCost"
short-description="Test case for service cancelFixedAssetStdCost"
login-required="false">
- <set field="serviceCtx.fixedAssetId" value="1000"/>
- <set field="serviceCtx.fixedAssetStdCostTypeId" value="SETUP_COST"/>
- <set field="serviceCtx.fromDate" value="2016-11-03 00:00:00"
type="Timestamp"/>
- <entity-one entity-name="UserLogin" value-field="userLogin">
- <field-map field-name="userLoginId" value="system"/>
- </entity-one>
- <set field="serviceCtx.userLogin" from-field="userLogin"/>
- <call-service service-name="cancelFixedAssetStdCost"
in-map-name="serviceCtx"/>
- <entity-one entity-name="FixedAssetStdCost"
value-field="fixedAssetStdCost" >
- <field-map field-name="fixedAssetId" value="1000"/>
- <field-map field-name="fixedAssetStdCostTypeId"
value="SETUP_COST"/>
- <field-map field-name="fromDate" value="2016-11-03 00:00:00"/>
- </entity-one>
- <now-timestamp field="nowTimestamp"/>
- <assert>
- <not><if-empty field="fixedAssetStdCost"/></not>
- <if-compare-field field="fixedAssetStdCost.thruDate"
operator="less-equals" to-field="nowTimestamp"/>
- </assert>
- <check-errors/>
- </simple-method>
- <simple-method method-name="testCreateFixedAssetMaint"
short-description="Test case for service createFixedAssetMaint"
login-required="false">
- <set field="serviceCtx.fixedAssetId" value="1000"/>
- <set field="serviceCtx.statusId" value="FAM_CREATED"/>
- <entity-one entity-name="UserLogin" value-field="userLogin">
- <field-map field-name="userLoginId" value="system"/>
- </entity-one>
- <set field="serviceCtx.userLogin" from-field="userLogin"/>
- <call-service service-name="createFixedAssetMaint"
in-map-name="serviceCtx">
- <results-to-map map-name="serviceResult"/>
- </call-service>
- <entity-and list="fixedAssetMaintList" entity-name="FixedAssetMaint">
- <field-map field-name="fixedAssetId" value="1000"/>
- </entity-and>
- <first-from-list entry="fixedAssetMaint" list="fixedAssetMaintList"/>
- <assert>
- <not><if-empty field="fixedAssetMaint"/></not>
- <not><if-empty field="serviceResult.maintHistSeqId"/></not>
- </assert>
- <check-errors/>
- </simple-method>
- <simple-method method-name="testCreateFixedAssetMeter"
short-description="Test case for service createFixedAssetMeter"
login-required="false">
- <now-timestamp field="nowTimestamp"/>
- <set field="serviceCtx.fixedAssetId" value="1000"/>
- <set field="serviceCtx.productMeterTypeId" value="DISTANCE"/>
- <set field="serviceCtx.readingDate" from-field="nowTimestamp"/>
- <set field="serviceCtx.meterValue" value="10" 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"/>
- <call-service service-name="createFixedAssetMeter"
in-map-name="serviceCtx">
- <results-to-map map-name="serviceResult"/>
- </call-service>
- <entity-and list="fixedAssetMeterList" entity-name="FixedAssetMeter">
- <field-map field-name="fixedAssetId" value="1000"/>
- <field-map field-name="productMeterTypeId" value="DISTANCE"/>
- </entity-and>
- <first-from-list entry="fixedAssetMeter" list="fixedAssetMeterList"/>
- <assert>
- <not><if-empty field="fixedAssetMeter"/></not>
- <if-compare operator="equals" value="10"
field="fixedAssetMeter.meterValue"></if-compare>
- </assert>
- <check-errors/>
- </simple-method>
-
-</simple-methods>
\ No newline at end of file
diff --git
a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFixedAssetTests.groovy
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFixedAssetTests.groovy
new file mode 100644
index 0000000..69a876f
--- /dev/null
+++
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFixedAssetTests.groovy
@@ -0,0 +1,84 @@
+/*
+ * 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.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class AutoAcctgFixedAssetTests extends OFBizTestCase {
+ public AutoAcctgFixedAssetTests(String name) {
+ super(name)
+ }
+
+ void testCreateFixedAssetMaint() {
+ Map serviceCtx = [
+ fixedAssetId: '1000',
+ statusId: 'FAM_CREATED',
+ userLogin: userLogin
+ ]
+ Map serviceResult = dispatcher.runSync('createFixedAssetMaint',
serviceCtx)
+ assert ServiceUtil.isSuccess(serviceResult)
+
+ GenericValue fixedAssetMaint = from('FixedAssetMaint')
+ .where('fixedAssetId', '1000')
+ .queryFirst()
+
+ assert fixedAssetMaint
+ assert fixedAssetMaint.maintHistSeqId != null
+ }
+
+ void testCreateFixedAssetMeter() {
+ Map serviceCtx = [
+ fixedAssetId: '1000',
+ productMeterTypeId: 'DISTANCE',
+ readingDate: UtilDateTime.nowTimestamp(),
+ meterValue: new BigDecimal('10'),
+ userLogin: userLogin
+ ]
+ Map serviceResult = dispatcher.runSync('createFixedAssetMeter',
serviceCtx)
+ assert ServiceUtil.isSuccess(serviceResult)
+ GenericValue fixedAssetMeter = from('FixedAssetMeter')
+ .where('fixedAssetId', '1000', 'productMeterTypeId',
'DISTANCE')
+ .queryFirst()
+ assert fixedAssetMeter
+ assert fixedAssetMeter.meterValue == BigDecimal.TEN
+ }
+
+ void testCancelFixedAssetStdCost() {
+ Map serviceCtx = [
+ fixedAssetId: '1000',
+ fixedAssetStdCostTypeId: 'SETUP_COST',
+ fromDate: UtilDateTime.toTimestamp("11/03/2016
00:00:00"),
+ userLogin: userLogin
+ ]
+ Map serviceResult = dispatcher.runSync('cancelFixedAssetStdCost',
serviceCtx)
+ assert ServiceUtil.isSuccess(serviceResult)
+
+ GenericValue fixedAssetStdCost = from('FixedAssetStdCost')
+ .where('fixedAssetId', '1000', 'fixedAssetStdCostTypeId',
'SETUP_COST', 'fromDate', UtilDateTime.toTimestamp("11/03/2016 00:00:00"))
+ .queryFirst()
+
+ assert fixedAssetStdCost
+ assert fixedAssetStdCost.thruDate != null
+ }
+
+}
diff --git a/applications/accounting/testdef/accountingtests.xml
b/applications/accounting/testdef/accountingtests.xml
index 78bf7f1..c3693bb 100644
--- a/applications/accounting/testdef/accountingtests.xml
+++ b/applications/accounting/testdef/accountingtests.xml
@@ -52,7 +52,7 @@
<junit-test-suite
class-name="org.apache.ofbiz.accounting.AutoAcctgFinAccountTests"/>
</test-case>
<test-case case-name="auto-accounting-fixedasset-tests">
- <simple-method-test
location="component://accounting/minilang/test/AutoAcctgFixedAssetTests.xml"/>
+ <junit-test-suite
class-name="org.apache.ofbiz.accounting.AutoAcctgFixedAssetTests"/>
</test-case>
<test-case case-name="auto-accounting-invoice-tests">
<junit-test-suite
class-name="org.apache.ofbiz.accounting.AutoAcctgInvoiceTests"/>