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 fbf8531 Improved: Convert AutoAcctgInvoiceTests Unit Test from XML to Groovy (OFBIZ-11277) fbf8531 is described below commit fbf8531e493c82e89ef9b2910078e685510dee22 Author: Pawan Verma <[hidden email]> AuthorDate: Mon Nov 11 12:12:21 2019 +0530 Improved: Convert AutoAcctgInvoiceTests Unit Test from XML to Groovy (OFBIZ-11277) Thanks: Jacques Le Roux for the review. --- .../minilang/test/AutoAcctgInvoiceTests.xml | 202 --------------------- .../ofbiz/accounting/AutoAcctgInvoiceTests.groovy | 150 +++++++++++++++ .../accounting/testdef/accountingtests.xml | 3 - 3 files changed, 150 insertions(+), 205 deletions(-) diff --git a/applications/accounting/minilang/test/AutoAcctgInvoiceTests.xml b/applications/accounting/minilang/test/AutoAcctgInvoiceTests.xml index 50b089e..e69de29 100644 --- a/applications/accounting/minilang/test/AutoAcctgInvoiceTests.xml +++ b/applications/accounting/minilang/test/AutoAcctgInvoiceTests.xml @@ -1,202 +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="testCopyInvoice" short-description="Test case for service copyInvoice" login-required="false"> - <set field="serviceCtx.invoiceIdToCopyFrom" value="1000"/> - <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="copyInvoice" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult"/></not> - <not><if-empty field="serviceResult.invoiceId"/></not> - </assert> - <check-errors/> - </simple-method> - - <simple-method method-name="testCreateInvoice" short-description="Test case for service createInvoice" login-required="false"> - <now-timestamp field="nowTimestamp"/> - <set field="serviceCtx.invoiceTypeId" value="PURCHASE_INVOICE"/> - <set field="serviceCtx.partyIdFrom" value="DEMO_COMPANY"/> - <set field="serviceCtx.partyId" value="DEMO_COMPANY1"/> - <set field="serviceCtx.invoiceDate" from-field="nowTimestamp" /> - <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="createInvoice" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult"/></not> - <not><if-empty field="serviceResult.invoiceId"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testGetInvoice" short-description="Test case for service getInvoice" login-required="false"> - <set field="serviceCtx.invoiceId" value="1001"/> - <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="getInvoice" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult.invoice"/></not> - <not><if-empty field="serviceResult.invoiceItems"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testSetInvoiceStatus" short-description="Test case for service setInvoiceStatus" login-required="false"> - <set field="serviceCtx.invoiceId" value="1002"/> - <set field="serviceCtx.statusId" value="INVOICE_APPROVED"/> - <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="setInvoiceStatus" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <entity-one entity-name="Invoice" value-field="invoice"> - <field-map field-name="invoiceId" value="1002"/> - </entity-one> - <assert> - <not><if-empty field="invoice"/></not> - <if-compare operator="equals" value="INVOICE_APPROVED" field="invoice.statusId"></if-compare> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCopyInvoiceToTemplate" short-description="Test case for service copyInvoiceToTemplate" login-required="false"> - <set field="serviceCtx.invoiceId" value="1002"/> - <set field="serviceCtx.invoiceTypeId" value="PURCHASE_INVOICE"/> - <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="copyInvoiceToTemplate" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult"/></not> - <not><if-empty field="serviceResult.invoiceId"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCreateInvoiceItem" short-description="Test case for service createInvoiceItem" login-required="false"> - <set field="serviceCtx.invoiceId" value="1003"/> - <set field="serviceCtx.invoiceItemTypeId" value="PINV_FXASTPRD_ITEM"/> - <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="createInvoiceItem" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult"/></not> - <not><if-empty field="serviceResult.invoiceItemSeqId"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCreateInvoiceStatus" short-description="Test case for service createInvoiceStatus" login-required="false"> - <now-timestamp field="nowTimestamp"/> - <set field="serviceCtx.invoiceId" value="1004"/> - <set field="serviceCtx.statusId" value="INVOICE_IN_PROCESS"/> - <set field="serviceCtx.statusDate" from-field="nowTimestamp"/> - <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="createInvoiceStatus" in-map-name="serviceCtx"/> - <entity-one entity-name="InvoiceStatus" value-field="invoiceStatus"> - <field-map field-name="invoiceId" value="1004"/> - <field-map field-name="statusId" value="INVOICE_IN_PROCESS"/> - <field-map field-name="statusDate" from-field="nowTimestamp"/> - </entity-one> - <assert> - <not><if-empty field="invoiceStatus"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCreateInvoiceStatus" short-description="Test case for service createInvoiceRole" login-required="false"> - <set field="serviceCtx.invoiceId" value="1005"/> - <set field="serviceCtx.partyId" value="DEMO_COMPANY"/> - <set field="serviceCtx.roleTypeId" value="INTERNAL_ORGANIZATIO"/> - <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="createInvoiceRole" in-map-name="serviceCtx"/> - <entity-one entity-name="InvoiceRole" value-field="invoiceRole"> - <field-map field-name="invoiceId" value="1005"/> - <field-map field-name="partyId" value="DEMO_COMPANY"/> - <field-map field-name="roleTypeId" value="INTERNAL_ORGANIZATIO"/> - </entity-one> - <assert> - <not><if-empty field="invoiceRole"/></not> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCreateInvoiceTerm" short-description="Test case for service createInvoiceTerm" login-required="false"> - <set field="serviceCtx.invoiceId" value="1006"/> - <set field="serviceCtx.invoiceItemSeqId" value="00001"/> - <set field="serviceCtx.termTypeId" value="FINANCIAL_TERM"/> - <set field="serviceCtx.termValue" value="50.00"/> - <set field="serviceCtx.termDays" value="10"/> - <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="createInvoiceTerm" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <entity-one entity-name="InvoiceTerm" value-field="invoiceTerm"> - <field-map field-name="invoiceTermId" from-field="serviceResult.invoiceTermId"/> - </entity-one> - <assert> - <not><if-empty field="invoiceTerm"/></not> - <if-compare operator="equals" value="1006" field="invoiceTerm.invoiceId"></if-compare> - <if-compare operator="equals" value="00001" field="invoiceTerm.invoiceItemSeqId"></if-compare> - <if-compare operator="equals" value="50.00" field="invoiceTerm.termValue"></if-compare> - </assert> - <check-errors/> - </simple-method> - <simple-method method-name="testCancelInvoice" short-description="Test case for service cancelInvoice" login-required="false"> - <set field="serviceCtx.invoiceId" value="1007"/> - <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="cancelInvoice" in-map-name="serviceCtx"> - <results-to-map map-name="serviceResult"/> - </call-service> - <assert> - <not><if-empty field="serviceResult"/></not> - <not><if-empty field="serviceResult.invoiceTypeId"/></not> - </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/AutoAcctgInvoiceTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy index 55b8529..e391449 100644 --- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy +++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy @@ -23,6 +23,9 @@ 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 AutoAcctgInvoiceTests extends OFBizTestCase { public AutoAcctgInvoiceTests(String name) { super(name) @@ -78,4 +81,151 @@ class AutoAcctgInvoiceTests extends OFBizTestCase { assert invoiceContent != null } + + void testCopyInvoice() { + Map serviceCtx = [ + invoiceIdToCopyFrom: '1000', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('copyInvoice', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + assert serviceResult.invoiceId != null + } + + void testCreateInvoice() { + Map serviceCtx = [ + invoiceTypeId: 'PURCHASE_INVOICE', + partyIdFrom: 'DEMO_COMPANY', + partyId: 'DEMO_COMPANY1', + invoiceDate: UtilDateTime.nowTimestamp(), + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoice', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + assert serviceResult.invoiceId != null + } + + void testGetInvoice() { + Map serviceCtx = [ + invoiceId: '1001', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('getInvoice', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + assert serviceResult.invoice != null + assert serviceResult.invoiceItems != null + } + + void testSetInvoiceStatus() { + Map serviceCtx = [ + invoiceId: '1002', + statusId: 'INVOICE_APPROVED', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('setInvoiceStatus', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue invoice = EntityQuery.use(delegator).from('Invoice') + .where('invoiceId', '1002') + .queryOne() + + assert invoice != null + assert invoice.statusId == 'INVOICE_APPROVED' + } + + void testCopyInvoiceToTemplate() { + Map serviceCtx = [ + invoiceId: '1002', + invoiceTypeId: 'PURCHASE_INVOICE', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('copyInvoiceToTemplate', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + assert serviceResult.invoiceId != null + } + + void testCreateInvoiceItem() { + Map serviceCtx = [ + invoiceId: '1003', + invoiceTypeId: 'PINV_FXASTPRD_ITEM', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoiceItem', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + assert serviceResult.invoiceItemSeqId != null + } + + void testCreateInvoiceStatus() { + Timestamp nowTimestamp = UtilDateTime.nowTimestamp() + Map serviceCtx = [ + invoiceId: '1004', + statusId: 'INVOICE_IN_PROCESS', + statusDate: nowTimestamp, + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoiceStatus', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue invoiceStatus = EntityQuery.use(delegator).from('InvoiceStatus') + .where('invoiceId', '1004', + 'statusId', 'INVOICE_IN_PROCESS', + 'statusDate', nowTimestamp) + .queryOne() + + assert invoiceStatus != null + } + + void testCreateInvoiceRole() { + Map serviceCtx = [ + invoiceId: '1006', + partyId: 'DEMO_COMPANY', + roleTypeId: 'INTERNAL_ORGANIZATIO', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoiceRole', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue invoiceRole = EntityQuery.use(delegator).from('InvoiceRole') + .where('invoiceId', '1006', + 'partyId', 'DEMO_COMPANY', + 'roleTypeId', 'INTERNAL_ORGANIZATIO') + .queryOne() + + assert invoiceRole != null + } + + void testCreateInvoiceTerm() { + Map serviceCtx = [ + invoiceId: '1006', + invoiceItemSeqId: '00001', + termTypeId: 'FINANCIAL_TERM', + termValue: 50.00, + termDays: 10, + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoiceTerm', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue invoiceTerm = EntityQuery.use(delegator).from('InvoiceTerm') + .where('invoiceTermId', serviceResult.invoiceTermId) + .queryOne() + + assert invoiceTerm != null + } + + void testCancelInvoice() { + Map serviceCtx = [ + invoiceId: '1007', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('cancelInvoice', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.invoiceTypeId != null + } + } diff --git a/applications/accounting/testdef/accountingtests.xml b/applications/accounting/testdef/accountingtests.xml index 38629f0..687eb71 100644 --- a/applications/accounting/testdef/accountingtests.xml +++ b/applications/accounting/testdef/accountingtests.xml @@ -55,9 +55,6 @@ <simple-method-test location="component://accounting/minilang/test/AutoAcctgFixedAssetTests.xml"/> </test-case> <test-case case-name="auto-accounting-invoice-tests"> - <simple-method-test location="component://accounting/minilang/test/AutoAcctgInvoiceTests.xml"/> - </test-case> - <test-case case-name="auto-accounting-invoice-tests"> <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgInvoiceTests"/> </test-case> <test-case case-name="auto-accounting-payment-tests"> |
Free forum by Nabble | Edit this page |