Improved: Convert FixedAssetTests from XML to Groovy. (OFBIZ-11546)(OFBIZ-11547)(OFBIZ-11548)(OFBIZ-11549)(OFBIZ-11550)(OFBIZ-11551)(OFBIZ-11552) Thanks: Rohit for reporting.
This commit is contained in:
committed by
Jacques Le Roux
parent
faf2827e67
commit
47e5a1ad5e
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
@@ -1,154 +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="testCreateFixedAssetRegistration" short-description="Test case for service createFixedAssetRegistration" login-required="false">
|
||||
<set field="serviceCtx.fixedAssetId" value="DEMO_VEHICLE_01"/>
|
||||
<set field="serviceCtx.licenseNumber" value="123456"/>
|
||||
<set field="serviceCtx.registrationNumber" value="123456"/>
|
||||
<set field="serviceCtx.registrationDate" value="2009-12-24 12:33:23.703" type="Timestamp"/>
|
||||
<set field="serviceCtx.fromDate" value="2009-12-24 12:33:08.247" type="Timestamp"/>
|
||||
<set field="serviceCtx.thruDate" value="2010-12-25 12:33:18.365" 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="createFixedAssetRegistration" in-map-name="serviceCtx"/>
|
||||
|
||||
<entity-one entity-name="FixedAssetRegistration" value-field="fixedAssetRegistration">
|
||||
<field-map field-name="fixedAssetId" from-field="serviceCtx.fixedAssetId"/>
|
||||
<field-map field-name="fromDate" from-field="serviceCtx.fromDate"/>
|
||||
</entity-one>
|
||||
<assert>
|
||||
<not><if-empty field="fixedAssetRegistration"/></not>
|
||||
</assert>
|
||||
<check-errors/>
|
||||
</simple-method>
|
||||
|
||||
<simple-method method-name="testUpdateFixedAssetRegistration" short-description="Test case for service updateFixedAssetRegistration" login-required="false">
|
||||
<set field="fixedAssetId" value="DEMO_VEHICLE_01"/>
|
||||
<set field="registrationDate" value="2010-12-24 12:33:23.703" type="Timestamp"/>
|
||||
<set field="fromDate" value="2009-12-24 12:33:08.247" type="Timestamp"/>
|
||||
<set field="thruDate" value="2033-12-25 12:33:18.365" 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"/>
|
||||
<set field="serviceCtx.fixedAssetId" from-field="fixedAssetId"/>
|
||||
<set field="serviceCtx.registrationDate" from-field="registrationDate"/>
|
||||
<set field="serviceCtx.fromDate" from-field="fromDate"/>
|
||||
<set field="serviceCtx.thruDate" from-field="thruDate"/>
|
||||
<call-service service-name="updateFixedAssetRegistration" in-map-name="serviceCtx"/>
|
||||
|
||||
<entity-one entity-name="FixedAssetRegistration" value-field="fixedAssetRegistration"/>
|
||||
<assert>
|
||||
<not><if-empty field="fixedAssetRegistration"/></not>
|
||||
<if-compare-field field="fixedAssetRegistration.thruDate" operator="equals" to-field="thruDate"/>
|
||||
<if-compare-field field="fixedAssetRegistration.registrationDate" operator="equals" to-field="registrationDate"/>
|
||||
</assert>
|
||||
<check-errors/>
|
||||
</simple-method>
|
||||
|
||||
<simple-method method-name="testDeleteFixedAssetRegistration" short-description="Test case for service deleteFixedAssetRegistration" login-required="false">
|
||||
<set field="fixedAssetId" value="DEMO_VEHICLE_01"/>
|
||||
<set field="fromDate" value="2009-12-24 12:33:08.247" 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"/>
|
||||
<set field="serviceCtx.fixedAssetId" from-field="fixedAssetId"/>
|
||||
<set field="serviceCtx.fromDate" from-field="fromDate"/>
|
||||
<call-service service-name="deleteFixedAssetRegistration" in-map-name="serviceCtx"/>
|
||||
|
||||
<entity-one entity-name="FixedAssetRegistration" value-field="fixedAssetRegistration"/>
|
||||
<assert>
|
||||
<if-empty field="fixedAssetRegistration"/>
|
||||
</assert>
|
||||
<check-errors/>
|
||||
</simple-method>
|
||||
|
||||
<simple-method method-name="testCreateFixedAssetMeter" short-description="Test case for service createFixedAssetMeter" 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="65" 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="createFixedAssetMeter" in-map-name="serviceCtx"/>
|
||||
|
||||
<entity-one entity-name="FixedAssetMeter" value-field="fixedAssetMeter"/>
|
||||
<assert>
|
||||
<not><if-empty field="fixedAssetMeter"/></not>
|
||||
</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"/>
|
||||
<set field="productMeterTypeId" value="ODOMETER"/>
|
||||
<set field="readingDate" value="2009-12-24 00:00:00.000" 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"/>
|
||||
<set field="serviceCtx.fixedAssetId" from-field="fixedAssetId"/>
|
||||
<set field="serviceCtx.productMeterTypeId" from-field="productMeterTypeId"/>
|
||||
<set field="serviceCtx.readingDate" from-field="readingDate"/>
|
||||
<call-service service-name="deleteFixedAssetMeter" in-map-name="serviceCtx"/>
|
||||
|
||||
<entity-one entity-name="FixedAssetMeter" value-field="fixedAssetMeter"/>
|
||||
<assert>
|
||||
<if-empty field="fixedAssetMeter"/>
|
||||
</assert>
|
||||
<check-errors/>
|
||||
</simple-method>
|
||||
|
||||
<simple-method method-name="testCreateFixedAssetGeoPoint" short-description="Test case for service createFixedAssetGeoPoint" login-required="false">
|
||||
<set field="geoPointId" value="9000"/>
|
||||
<set field="fixedAssetId" value="DEMO_VEHICLE_01"/>
|
||||
<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.geoPointId" from-field="geoPointId"/>
|
||||
<set field="serviceCtx.fixedAssetId" from-field="fixedAssetId"/>
|
||||
<call-service service-name="createFixedAssetGeoPoint" in-map-name="serviceCtx"/>
|
||||
<entity-and entity-name="FixedAssetGeoPoint" list="fixedAssetGeoPoints" filter-by-date="true">
|
||||
<field-map field-name="geoPointId"/>
|
||||
<field-map field-name="fixedAssetId"/>
|
||||
</entity-and>
|
||||
<first-from-list list="fixedAssetGeoPoints" entry="fixedAssetGeoPoint"/>
|
||||
<assert>
|
||||
<not><if-empty field="fixedAssetGeoPoint"/></not>
|
||||
<if-compare-field field="fixedAssetGeoPoint.geoPointId" operator="equals" to-field="geoPointId"/>
|
||||
<if-compare-field field="fixedAssetGeoPoint.fixedAssetId" operator="equals" to-field="fixedAssetId"/>
|
||||
</assert>
|
||||
<check-errors/>
|
||||
</simple-method>
|
||||
</simple-methods>
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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
|
||||
import java.sql.Timestamp
|
||||
|
||||
class FixedAssetTests extends OFBizTestCase {
|
||||
public FixedAssetTests(String name) {
|
||||
super(name)
|
||||
}
|
||||
void testCreateFixedAssetRegistration() {
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
licenseNumber : '123456',
|
||||
registrationNumber : 'abcdef',
|
||||
registrationDate : UtilDateTime.toTimestamp("01/01/2020 00:00:00"),
|
||||
fromDate : UtilDateTime.nowTimestamp(),
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('createFixedAssetRegistration', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetRegistration = EntityQuery.use(delegator).from('FixedAssetRegistration')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01')
|
||||
.filterByDate().queryFirst();
|
||||
assert fixedAssetRegistration
|
||||
}
|
||||
void testUpdateFixedAssetRegistration() {
|
||||
Timestamp fromDate = UtilDateTime.toTimestamp("04/01/2020 00:00:00")
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
licenseNumber : 'updated-123456',
|
||||
registrationNumber : 'updated-abcdef',
|
||||
registrationDate : UtilDateTime.toTimestamp("01/01/2020 00:00:00"),
|
||||
fromDate : fromDate,
|
||||
thruDate : UtilDateTime.nowTimestamp(),
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('updateFixedAssetRegistration', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetRegistration = EntityQuery.use(delegator).from('FixedAssetRegistration')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'fromDate', fromDate)
|
||||
.filterByDate().queryOne();
|
||||
assert fixedAssetRegistration == null
|
||||
}
|
||||
void testDeleteFixedAssetRegistration() {
|
||||
Timestamp fromDate = UtilDateTime.toTimestamp("04/01/2020 00:00:00")
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
fromDate : fromDate,
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('deleteFixedAssetRegistration', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetRegistration = EntityQuery.use(delegator).from('FixedAssetRegistration')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'fromDate', fromDate)
|
||||
.queryOne();
|
||||
assert fixedAssetRegistration == null
|
||||
}
|
||||
void testCreateFixedAssetMeter() {
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
productMeterTypeId : 'ODOMETER',
|
||||
readingDate : UtilDateTime.nowTimestamp(),
|
||||
meterValue : BigDecimal.valueOf(65),
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('createFixedAssetMeter', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetMeter = EntityQuery.use(delegator).from('FixedAssetMeter')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'productMeterTypeId', 'ODOMETER')
|
||||
.queryFirst();
|
||||
assert fixedAssetMeter
|
||||
}
|
||||
void testUpdateFixedAssetMeter() {
|
||||
Timestamp readingDate = UtilDateTime.toTimestamp("04/01/2020 00:00:00")
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
productMeterTypeId : 'ODOMETER',
|
||||
readingDate : readingDate,
|
||||
meterValue : BigDecimal.valueOf(85),
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('updateFixedAssetMeter', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetMeter = EntityQuery.use(delegator).from('FixedAssetMeter')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'productMeterTypeId', 'ODOMETER', 'readingDate', readingDate)
|
||||
.queryOne();
|
||||
assert fixedAssetMeter
|
||||
}
|
||||
void testDeleteFixedAssetMeter() {
|
||||
Timestamp readingDate = UtilDateTime.toTimestamp("04/01/2020 00:00:00")
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
productMeterTypeId : 'ODOMETER',
|
||||
readingDate : readingDate,
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('deleteFixedAssetMeter', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetMeter = EntityQuery.use(delegator).from('FixedAssetMeter')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'productMeterTypeId', 'ODOMETER', 'readingDate', readingDate)
|
||||
.queryOne();
|
||||
assert fixedAssetMeter == null
|
||||
}
|
||||
void testCreateFixedAssetGeoPoint() {
|
||||
Map serviceCtx = [
|
||||
fixedAssetId : 'DEMO_VEHICLE_01',
|
||||
geoPointId : '9000',
|
||||
userLogin : userLogin
|
||||
]
|
||||
Map serviceResult = dispatcher.runSync('createFixedAssetGeoPoint', serviceCtx)
|
||||
assert ServiceUtil.isSuccess(serviceResult)
|
||||
|
||||
GenericValue fixedAssetGeoPoint = EntityQuery.use(delegator).from('FixedAssetGeoPoint')
|
||||
.where('fixedAssetId', 'DEMO_VEHICLE_01', 'geoPointId', '9000')
|
||||
.filterByDate().queryFirst();
|
||||
assert fixedAssetGeoPoint
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,8 @@ under the License.
|
||||
<!-- For Testing service cancelFixedAssetStdCost -->
|
||||
<FixedAsset fixedAssetId="1000" fixedAssetTypeId="REAL_ESTATE" partyId="DEMO_COMPANY" roleTypeId="INTERNAL_ORGANIZATIO"/>
|
||||
<FixedAssetStdCost fixedAssetId="1000" fixedAssetStdCostTypeId="SETUP_COST" fromDate="2016-11-03 00:00:00" amountUomId="USD" amount="1000.00"/>
|
||||
<FixedAssetMeter fixedAssetId="DEMO_VEHICLE_01" meterValue="10.000000" productMeterTypeId="ODOMETER" readingDate="2020-04-01 00:00:00.0"/>
|
||||
<FixedAssetRegistration fixedAssetId="DEMO_VEHICLE_01" fromDate="2020-04-01 00:00:00.0" registrationDate="2020-04-01 00:00:00.0" registrationNumber="abcde"/>
|
||||
<!-- For Testing service copyInvoice -->
|
||||
<Invoice invoiceId="1000" invoiceTypeId="PURCHASE_INVOICE" partyIdFrom="DEMO_COMPANY" partyId="DEMO_COMPANY1" invoiceDate="2016-11-03 00:00:00"/>
|
||||
<Invoice invoiceId="1001" invoiceTypeId="PURCHASE_INVOICE" partyIdFrom="DEMO_COMPANY" partyId="DEMO_COMPANY1" invoiceDate="2016-11-03 00:00:00"/>
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
|
||||
|
||||
<test-case case-name="accounting-tests-data-load">
|
||||
<entity-xml action="load" entity-xml-url="component://accounting/testdef/data/AccountingTestsData.xml"/>
|
||||
</test-case>
|
||||
|
||||
<test-case case-name="fixedasset-tests">
|
||||
<junit-test-suite class-name="org.apache.ofbiz.accounting.FixedAssetTests"/>
|
||||
</test-case>
|
||||
|
||||
Reference in New Issue
Block a user