This is an automated email from the ASF dual-hosted git repository.
jleroux 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 240903b Improved: Convert testExpirePartyRate test from XML to Groovy (OFBIZ-11568) 240903b is described below commit 240903b6cbecc75e430f3fd0e1ec9beb46e6d7ee Author: Jacques Le Roux <[hidden email]> AuthorDate: Mon Jun 1 10:08:29 2020 +0200 Improved: Convert testExpirePartyRate test from XML to Groovy (OFBIZ-11568) This can be tested using ./gradlew "ofbiz --test component=accounting --test suitename=ratetests" Thanks: Rohit Hukkeri --- .../accounting/minilang/test/RateTests.xml | 21 --------- .../org/apache/ofbiz/accounting/RateTests.groovy | 50 ++++++++++++++++++++++ applications/accounting/testdef/ratetests.xml | 2 +- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/applications/accounting/minilang/test/RateTests.xml b/applications/accounting/minilang/test/RateTests.xml index 61f2e12..7aa8b2b 100644 --- a/applications/accounting/minilang/test/RateTests.xml +++ b/applications/accounting/minilang/test/RateTests.xml @@ -170,27 +170,6 @@ under the License. </assert> <check-errors/> </simple-method> - <simple-method method-name="testExpirePartyRate" short-description="test to expire PartyRate" login-required="false"> - <set field="serviceCtx.partyId" value="TEST_PARTY"/> - <set field="serviceCtx.rateTypeId" value="AVERAGE_PAY_RATE"/> - <set field="serviceCtx.fromDate" type="Timestamp" value="2013-07-04 00:00:00"/> - <set field="serviceCtx.rateAmountFromDate" type="Timestamp" value="2013-07-04 00:00:00"/> - <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="expirePartyRate" in-map-name="serviceCtx"/> - <entity-one entity-name="PartyRate" value-field="partyRate"> - <field-map field-name="rateTypeId" value="AVERAGE_PAY_RATE"/> - <field-map field-name="partyId" value="TEST_PARTY"/> - <field-map field-name="fromDate" value="2013-07-04 00:00:00"/> - </entity-one> - <assert> - <not><if-empty field="partyRate"/></not> - <not><if-empty field="partyRate.thruDate"/></not> - </assert> - <check-errors/> - </simple-method> <simple-method method-name="testFilterRateAmountList" short-description="test the service filterRateAmountList" login-required="false"> <entity-and entity-name="RateAmount" list="amountList"> <field-map field-name="rateTypeId" value="AVERAGE_PAY_RATE"/> diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/RateTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/RateTests.groovy new file mode 100644 index 0000000..ce1d3fd --- /dev/null +++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/RateTests.groovy @@ -0,0 +1,50 @@ +/* + * 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.service.testtools.OFBizTestCase +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.base.util.UtilDateTime + +import java.sql.Timestamp + +class RateTests extends OFBizTestCase { + public RateTests(String name) { + super(name) + } + + void testExpirePartyRate() { + Timestamp fromDate = UtilDateTime.toTimestamp("07/04/2013 00:00:00") + Map serviceCtx = [ + partyId : "TEST_PARTY", + rateTypeId : 'AVERAGE_PAY_RATE', + rateAmountFromDate : fromDate, + fromDate : fromDate, + userLogin : userLogin + + ] + Map serviceResult = dispatcher.runSync('expirePartyRate', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue partyRate = from("PartyRate").where("rateTypeId", "AVERAGE_PAY_RATE", "partyId", "TEST_PARTY", "fromDate", fromDate).queryOne() + assert partyRate; + assert partyRate.thruDate + } +} \ No newline at end of file diff --git a/applications/accounting/testdef/ratetests.xml b/applications/accounting/testdef/ratetests.xml index 21629a7..5fa8b23 100644 --- a/applications/accounting/testdef/ratetests.xml +++ b/applications/accounting/testdef/ratetests.xml @@ -26,6 +26,6 @@ </test-case> <test-case case-name="rate-tests"> - <simple-method-test location="component://accounting/minilang/test/RateTests.xml"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.RateTests"/> </test-case> </test-suite> |
Free forum by Nabble | Edit this page |