Author: mthl
Date: Fri Aug 23 18:00:01 2019 New Revision: 1865786 URL: http://svn.apache.org/viewvc?rev=1865786&view=rev Log: Improved: Compile groovy integration tests (OFBIZ-11165) Since there is no need for dynamic reload for integration tests, it is better to compile Groovy tests. Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoActionTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductPromoCondTests.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductTests.groovy (with props) ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/ ofbiz/ofbiz-framework/trunk/framework/base/src/main/groovy/org/apache/ofbiz/base/SimpleTests.groovy (with props) Removed: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/ ofbiz/ofbiz-framework/trunk/applications/content/groovyScripts/test/ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/test/ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/test/ ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/test/ ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/test/ ofbiz/ofbiz-framework/trunk/framework/base/groovyScripts/ Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml ofbiz/ofbiz-framework/trunk/applications/content/testdef/ContentTests.xml ofbiz/ofbiz-framework/trunk/applications/order/testdef/CustRequestTests.xml ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml ofbiz/ofbiz-framework/trunk/applications/order/testdef/QuoteTests.xml ofbiz/ofbiz-framework/trunk/applications/party/testdef/PartyContactMechTests.xml ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml ofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductTest.xml ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,52 @@ +/******************************************************************************* + * 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.entity.GenericValue +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class AutoAcctgBudgetTests extends GroovyScriptTestCase { + void testCreateBudget() { + Map serviceCtx = [:] + serviceCtx.budgetTypeId = 'CAPITAL_BUDGET' + serviceCtx.comments = 'Capital Budget' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').queryOne() + Map result = dispatcher.runSync('createBudget', serviceCtx) + assert ServiceUtil.isSuccess(result) + + GenericValue budget = EntityQuery.use(delegator).from('Budget').where(result).queryOne() + assert budget + assert budget.budgetTypeId == 'CAPITAL_BUDGET' + assert budget.comments == 'Capital Budget' + } + + void testUpdateBudgetStatus() { + Map serviceCtx = [:] + serviceCtx.budgetId = '9999' + serviceCtx.statusId = 'BG_APPROVED' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').queryOne() + Map result = dispatcher.runSync('updateBudgetStatus', serviceCtx) + + List<GenericValue> budgetStatuses = EntityQuery.use(delegator).from('BudgetStatus').where('budgetId', '9999').orderBy('-statusDate').queryList() + assert ! budgetStatuses?.isEmpty() + assert budgetStatuses[0].statusId == 'BG_APPROVED' + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgBudgetTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,51 @@ +/* + * 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.testtools.GroovyScriptTestCase +class AutoAcctgInvoiceTests extends GroovyScriptTestCase { + void testCreateInvoiceContent() { + def userLogin = EntityQuery.use(delegator).from('UserLogin') + .where('userLoginId', 'system') + .cache() + .queryOne() + + Map serviceCtx = [ + invoiceId: '1008', + contentId: '1000', + invoiceContentTypeId: 'COMMENTS', + fromDate: UtilDateTime.nowTimestamp(), + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('createInvoiceContent', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue invoiceContent = EntityQuery.use(delegator).from('InvoiceContent') + .where('invoiceId', serviceResult.invoiceId, + 'contentId', serviceResult.contentId, + 'invoiceContentTypeId', serviceResult.invoiceContentTypeId) + .queryFirst() + + assert invoiceContent.contentId == serviceResult.contentId + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgInvoiceTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.testtools.GroovyScriptTestCase + +class AutoAcctgLedgerTests extends GroovyScriptTestCase { + void testCreateAcctgTrans() { + Map serviceCtx = [:] + serviceCtx.acctgTransTypeId = 'CREDIT_MEMO' + serviceCtx.description = 'Test Credit Memo Transaction' + serviceCtx.transactionDate = UtilDateTime.nowTimestamp() + serviceCtx.glFiscalTypeId = 'BUDGET' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('createAcctgTrans', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue acctgTrans = EntityQuery.use(delegator).from('AcctgTrans').where('acctgTransId', serviceResult.acctgTransId).queryOne() + assert acctgTrans.acctgTransId == serviceResult.acctgTransId + assert acctgTrans.acctgTransTypeId == 'CREDIT_MEMO' + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgLedgerTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.entity.GenericValue +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class AutoAcctgPaymentGatewayTests extends GroovyScriptTestCase { + void testUpdatePaymentGatewayConfig() { + Map serviceCtx = [:] + serviceCtx.paymentGatewayConfigId = 'SAGEPAY_CONFIG' + serviceCtx.description = 'Test Payment Gateway Config Id' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('updatePaymentGatewayConfig', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue paymentGatewayConfig = EntityQuery.use(delegator).from('PaymentGatewayConfig').where('paymentGatewayConfigId', 'SAGEPAY_CONFIG').queryOne() + assert paymentGatewayConfig + assert paymentGatewayConfig.description == 'Test Payment Gateway Config Id' + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentGatewayTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.entity.GenericValue +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class AutoAcctgPaymentTests extends GroovyScriptTestCase { + void testCreatePayment() { + Map serviceCtx = [:] + serviceCtx.paymentTypeId = 'CUSTOMER_PAYMENT' + serviceCtx.partyIdFrom = 'Company' + serviceCtx.partyIdTo = 'DemoCustCompany' + serviceCtx.amount = new BigDecimal('100.00') + serviceCtx.paymentMethodTypeId = 'COMPANY_CHECK' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('createPayment', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue payment = EntityQuery.use(delegator).from('Payment').where('paymentId', serviceResult.paymentId).queryOne() + assert payment.paymentTypeId == 'CUSTOMER_PAYMENT' + assert payment.paymentMethodTypeId == 'COMPANY_CHECK' + } + + void testSetPaymentStatus() { + Map serviceCtx = [:] + serviceCtx.paymentId = '1000' + serviceCtx.statusId = 'PAYMENT_AUTHORIZED' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('setPaymentStatus', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue payment = EntityQuery.use(delegator).from('Payment').where('paymentId', '1000').queryOne() + assert payment + assert serviceResult.oldStatusId == 'PAYMENT_NOT_AUTH' + } + + void testQuickSendPayment() { + Map serviceCtx = [:] + serviceCtx.paymentId = '1001' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('quickSendPayment', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue payment = EntityQuery.use(delegator).from('Payment').where('paymentId', '1001').queryOne() + assert payment + assert payment.statusId == 'PMNT_SENT' + } + + void testGetPayments() { + Map serviceCtx = [ + finAccountTransId: '1001', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + + Map serviceResult = dispatcher.runSync('getPayments', serviceCtx) + + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.payments != null + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgPaymentTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml Fri Aug 23 18:00:01 2019 @@ -43,7 +43,7 @@ <simple-method-test location="component://accounting/minilang/test/AutoAcctgAgreementTests.xml"/> </test-case> <test-case case-name="auto-accounting-budget-tests"> - <groovy-test-suite location="component://accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgBudgetTests"/> </test-case> <test-case case-name="auto-accounting-cost-tests"> <simple-method-test location="component://accounting/minilang/test/AutoAcctgCostTests.xml"/> @@ -58,15 +58,15 @@ <simple-method-test location="component://accounting/minilang/test/AutoAcctgInvoiceTests.xml"/> </test-case> <test-case case-name="auto-accounting-invoice-tests"> - <simple-method-test location="component://accounting/groovyScripts/test/AutoAcctgInvoiceTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgInvoiceTests"/> </test-case> <test-case case-name="auto-accounting-payment-tests"> - <groovy-test-suite location="component://accounting/groovyScripts/test/AutoAcctgPaymentTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgPaymentTests"/> </test-case> <test-case case-name="auto-accounting-paymentgateway-tests"> - <groovy-test-suite location="component://accounting/groovyScripts/test/AutoAcctgPaymentGatewayTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgPaymentGatewayTests"/> </test-case> <test-case case-name="auto-accounting-ledger-tests"> - <groovy-test-suite location="component://accounting/groovyScripts/test/AutoAcctgLedgerTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoAcctgLedgerTests"/> </test-case> </test-suite> Added: ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.content + +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.testtools.GroovyScriptTestCase + +class ContentTests extends GroovyScriptTestCase { + void testGetDataResource() { + Map serviceCtx = [:] + serviceCtx.dataResourceId = 'TEST_RESOURCE' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map serviceResult = dispatcher.runSync('getDataResource', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.resultData.dataResource.dataResourceId == 'TEST_RESOURCE' + assert serviceResult.resultData.dataResource.dataResourceTypeId == 'TEST_RESOURCE_TYPE' + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/content/src/main/groovy/org/apache/ofbiz/content/ContentTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/content/testdef/ContentTests.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/testdef/ContentTests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/testdef/ContentTests.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/testdef/ContentTests.xml Fri Aug 23 18:00:01 2019 @@ -26,7 +26,7 @@ </test-case> <test-case case-name="content-tests"> - <groovy-test-suite location="component://content/groovyScripts/test/ContentTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.content.ContentTests"/> </test-case> </test-suite> Added: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,140 @@ +/* + * 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.order + +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class OrderTests extends GroovyScriptTestCase { + void testAddRequirementTask() { + Map serviceCtx = [ + requirementId: '1000', + workEffortId: '9000', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync("addRequirementTask", serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + void testCreateReturnAdjustment() { + Map serviceCtx = [ + amount: '2.0000', + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('createReturnAdjustment', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.returnAdjustmentId != null + } + void testQuickReturnOrder() { + Map serviceCtx = [ + orderId: 'TEST_DEMO10090', + returnHeaderTypeId: 'CUSTOMER_RETURN', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('quickReturnOrder', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.returnId != null + } + void testCreateReturnAndItemOrAdjustment() { + Map serviceCtx = [ + orderId: 'DEMO10090', + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('createReturnAndItemOrAdjustment', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.returnAdjustmentId != null + } + void testCheckReturnComplete() { + Map serviceCtx = [ + amount: '2.0000', + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('checkReturnComplete', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.statusId != null + } + void testCheckPaymentAmountForRefund() { + Map serviceCtx = [ + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('checkPaymentAmountForRefund', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + //TODO: This can be moved to a different file + void testCheckCreateProductRequirementForFacility() { + Map serviceCtx = [ + facilityId: 'WebStoreWarehouse', + orderItemSeqId: '00001', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('checkCreateProductRequirementForFacility', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + void testCreateReturnItemShipment() { + Map serviceCtx = [ + shipmentId: '1014', + shipmentItemSeqId: '00001', + returnId: '1009', + returnItemSeqId: '00001', + quantity: new BigDecimal('2.0000'), + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('createReturnItemShipment', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + void testCreateReturnStatus() { + Map serviceCtx = [ + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('createReturnStatus', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + void testCreateReturnHeader() { + Map serviceCtx = [ + toPartyId: 'Company', + returnHeaderTypeId: 'CUSTOMER_RETURN', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('createReturnHeader', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.returnId != null + } + void testGetReturnAmountByOrder() { + Map serviceCtx = [ + returnId: '1009', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('getReturnAmountByOrder', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } + void testCheckCreateStockRequirementQoh() { + Map serviceCtx = [ + orderId: 'TEST_DEMO10090', + orderItemSeqId: '00001', + userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + ] + Map serviceResult = dispatcher.runSync('checkCreateStockRequirementQoh', serviceCtx) + assert ServiceUtil.isSuccess(serviceResult) + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,516 @@ +/* + * 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.order + +import org.apache.ofbiz.testtools.GroovyScriptTestCase +import org.apache.ofbiz.order.shoppingcart.ShoppingCart +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.base.util.Debug + +import java.sql.Timestamp + +import static org.apache.ofbiz.base.util.UtilDateTime.nowTimestamp +import static org.apache.ofbiz.entity.condition.EntityCondition.makeCondition +import static org.apache.ofbiz.entity.condition.EntityComparisonOperator.GREATER_THAN_EQUAL_TO + +class QuoteTests extends GroovyScriptTestCase { + + // Retrieves a particular login record. + private GenericValue getUserLogin(String userLoginId) { + GenericValue userLogin = EntityQuery.use(delegator) + .from('UserLogin').where(userLoginId: userLoginId).queryOne() + assert userLogin + return userLogin + } + + // Test case for successfully creating a QuoteWorkEffort record. + void testCreateQuoteWorkEffort() { + GenericValue userLogin = getUserLogin('DemoRepStore') + + def quoteId = '9001' + def workEffortId = '9007' + + def input = [userLogin: userLogin, quoteId: quoteId, workEffortId: workEffortId] + Map serviceResult = dispatcher.runSync('ensureWorkEffortAndCreateQuoteWorkEffort', input) + + // Confirm the service output parameters. + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.workEffortId == input.workEffortId + + // Confirm the database changes. + GenericValue quoteWorkEffort = EntityQuery.use(delegator) + .from('QuoteWorkEffort').where(quoteId: quoteId, workEffortId: workEffortId).queryOne() + assert quoteWorkEffort + } + + // Test case for unsuccessfully creating a QuoteWorkEffort record by attempting + // to use a quoteId and workEffortId that has already been used in an existing + // QuoteWorkEffortRecord. + void testCreateQuoteWorkEffortFail() { + // Use to confirm nothing has changed at the end of the test + Timestamp startTime = nowTimestamp() + GenericValue userLogin = getUserLogin('DemoRepStore') + + def quoteId = '9001' + def workEffortId = '9007' + + // Execute the service, note break-on-error is false so that the test + // itself doesn't fail and we also need a separate transaction so our + // lookup below doesn't fail due to the rollback + def input = [userLogin: userLogin, quoteId: quoteId, workEffortId: workEffortId] + Map serviceResult + try { + serviceResult = dispatcher.runSync('ensureWorkEffortAndCreateQuoteWorkEffort', input) + } catch (Exception e) { + serviceResult = ServiceUtil.returnError(e.toString()) + } + assert ServiceUtil.isError(serviceResult) + + // Confirm the database changes, in this case nothing should have changed + GenericValue quoteWorkEffort = EntityQuery.use(delegator) + .from('QuoteWorkEffort').where( + makeCondition(quoteId: quoteId, workEffortId: workEffortId), + makeCondition('lastUpdatedStamp', GREATER_THAN_EQUAL_TO, startTime) + ).queryOne() + + assert !quoteWorkEffort + } + + // Test case for CheckUpdateQuotestatus + void testCheckUpdateQuotestatus() { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9001', + ] + + Map serviceResult = dispatcher.runSync('checkUpdateQuoteStatus', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quote = EntityQuery.use(delegator).from('Quote').where(quoteId: '9001').queryOne() + assert quote.statusId == 'QUO_ORDERED' + } + + // Test case for calling createQuoteWorkEffort without a workEffortId which + // triggers an ECA to create the WorkEffort first. + void testCreateWorkEffortAndQuoteWorkEffort() { + GenericValue userLogin = getUserLogin('flexadmin') + + // Use the bare minimum inputs necessary to create the work effort as we + // aren't testing that service, only that it plays well as an ECA. + def input = [ + currentStatusId: 'ROU_ACTIVE', + workEffortName: 'Test WorkEffort', + workEffortTypeId: 'ROUTING', + quoteId: '9000', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('ensureWorkEffortAndCreateQuoteWorkEffort', input) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.workEffortId + + // Confirm that a matching WorkEffort was created. + GenericValue workEfforts = EntityQuery.use(delegator) + .from('WorkEffort').where( + workEffortId: serviceResult.workEffortId, + currentStatusId: input.currentStatusId, + workEffortName: input.workEffortName, + workEffortTypeId: input.workEffortTypeId + ).queryOne() + assert workEfforts + + GenericValue quoteWorkEffort = EntityQuery.use(delegator) + .from('WorkEffort').where( + quoteId: input.quoteId, + workEffortId: serviceResult.workEffortId + ).queryOne() + assert quoteWorkEffort + } + + // Test createQuote service + void testCreateQuote () { + GenericValue userLogin = getUserLogin('system') + Map input = [ + userLogin: userLogin, + partyId: 'Company' + ] + Map serviceResult = dispatcher.runSync('createQuote', input) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.quoteId + GenericValue quote = EntityQuery.use(delegator).from('Quote').where(quoteId: serviceResult.quoteId).queryOne() + assert quote + } + + // Test updateQuote service + void testUpdateQuote() { + GenericValue userLogin = getUserLogin('system') + Map input = [ + userLogin: userLogin, + quoteId: '9000', + statusId: 'QUO_APPROVED' + ] + Map serviceResult = dispatcher.runSync('updateQuote', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quote = EntityQuery.use(delegator).from('Quote').where(quoteId: '9000').queryOne() + assert quote.statusId == 'QUO_APPROVED' + + input.statusId = 'QUO_CREATED' + serviceResult = dispatcher.runSync('updateQuote', input) + assert ServiceUtil.isError(serviceResult) + } + + // Test copyQuote service + void testCopyQuote() { + GenericValue userLogin = getUserLogin('system') + Map input = [ + userLogin: userLogin, + quoteId: '9000' + ] + Map serviceResult = dispatcher.runSync('copyQuote', input) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.quoteId + } + + // Test createQuoteItem service + void testCreateQuoteItem() { + GenericValue userLogin = getUserLogin('system') + Map input = [ + userLogin: userLogin, + quoteId: '9000', + quoteItemSeqId: '00004', + productId: 'GZ-1001' + ] + Map serviceResult = dispatcher.runSync('createQuoteItem', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where(quoteId: '9000', quoteItemSeqId: '00004').queryOne() + assert quoteItem.quoteUnitPrice + } + + // Test updateQuoteItem service + void testUpdateQuoteItem() { + GenericValue userLogin = getUserLogin('system') + + Map input = [ + userLogin: userLogin, + quoteId: '9000', + quoteItemSeqId: '00002', + productId: 'GZ-1001' + ] + Map serviceResult = dispatcher.runSync('updateQuoteItem', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where(quoteId: '9000', quoteItemSeqId: '00002').queryOne() + assert quoteItem.productId == 'GZ-1001' + } + + // Test removeQuoteItem service + void testRemoveQuoteItem() { + GenericValue userLogin = getUserLogin('system') + + Map input = [ + userLogin: userLogin, + quoteId: '9000', + quoteItemSeqId: '00002' + ] + Map serviceResult = dispatcher.runSync('removeQuoteItem', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where(quoteId: '9000', quoteItemSeqId: '00002').queryOne() + assert !quoteItem + GenericValue quoteTerm = EntityQuery.use(delegator).from('QuoteTerm').where(quoteId: '9000', quoteItemSeqId: '00002', termTypeId: 'FIN_PAYMENT_DISC').queryOne() + assert !quoteTerm + } + + // test create a Term + void testCreateQuoteTerm () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + termTypeId: 'FIN_PAYMENT_DISC', + quoteId: '9000', + quoteItemSeqId: '00001', + termValue: 40L, + termDays: 4L, + uomId: 'CNY', + description: 'create quoteTerm' + ] + + Map serviceResult = dispatcher.runSync('createQuoteTerm', input) + List<GenericValue> terms = EntityQuery.use(delegator).from('QuoteTerm') + .where(termTypeId: 'FIN_PAYMENT_DISC', quoteId: '9000', quoteItemSeqId: '00001').queryList() + + assert ServiceUtil.isSuccess(serviceResult) + assert terms + GenericValue term = terms[0] + assert input.termTypeId == term.termTypeId + assert input.termValue == term.termValue + assert input.termDays == term.termDays + assert input.uomId == term.uomId + assert input.description == term.description + } + + // Update a term. + void testUpdateQuoteTerm() { + GenericValue userLogin = getUserLogin('system') + def input = [ + termTypeId: 'FIN_PAYMENT_DISC', + quoteId: '9000', + quoteItemSeqId: '00002', + termValue: 30L, + termDays: 3L, + uomId: 'CNY', + description: 'update quoteterm', + userLogin: userLogin + ] + Map serviceResult = dispatcher.runSync('updateQuoteTerm', input) + assert ServiceUtil.isSuccess(serviceResult) + + // Confirm that a matching Quoteterm was updated + GenericValue quoteTerm = EntityQuery.use(delegator) + .from('QuoteTerm').where( + termTypeId: input.termTypeId, + quoteId: input.quoteId, + quoteItemSeqId: input.quoteItemSeqId + ).queryOne() + assert quoteTerm + assert quoteTerm.termTypeId == input.termTypeId + assert quoteTerm.quoteId == input.quoteId + assert quoteTerm.quoteItemSeqId == input.quoteItemSeqId + assert quoteTerm.termValue == input.termValue + assert quoteTerm.termDays == input.termDays + assert quoteTerm.uomId == input.uomId + assert quoteTerm.description == input.description + } + + // delete a term + void testDeleteQuoteTerm () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + termTypeId: 'FIN_PAYMENT_DISC', + quoteId: '9000', + quoteItemSeqId: '00003' + ] + + Map serviceResult = dispatcher.runSync('deleteQuoteTerm', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteTerm = EntityQuery.use(delegator).from('QuoteTerm').where(termTypeId: serviceResult.termTypeId, quoteId: serviceResult.quoteId, quoteItemSeqId: serviceResult.quoteItemSeqId).queryOne() + assert !quoteTerm + } + + // Create Quote Attribute + void testCreateQuoteAttribute () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9001', + attrName: 'Test' + ] + + Map serviceResult = dispatcher.runSync('createQuoteAttribute', input) + assert ServiceUtil.isSuccess(serviceResult) + } + + // Create Quote Coefficient + void testCreateQuoteCoefficient () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9001', + coeffName: 'Test' + ] + + Map serviceResult = dispatcher.runSync('createQuoteCoefficient', input) + assert ServiceUtil.isSuccess(serviceResult) + } + + // Get Next Quote Id + void testGetNextQuoteId () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + partyId: 'DemoCustomer-1' + ] + + Map serviceResult = dispatcher.runSync('getNextQuoteId', input) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.quoteId + } + + // Test Quote Sequence Enforced + void testQuoteSequenceEnforced() { + GenericValue userLogin = getUserLogin('system') + GenericValue partyAcctgPreference = EntityQuery.use(delegator) + .from('PartyAcctgPreference').where('partyId', 'DemoCustomer').queryOne() + Long lastQuoteNumber = partyAcctgPreference.lastQuoteNumber + if (!lastQuoteNumber) { + lastQuoteNumber = 0 + } + + def input = [ + userLogin: userLogin, + partyId: 'DemoCustomer', + partyAcctgPreference: partyAcctgPreference + ] + + Map serviceResult = dispatcher.runSync('quoteSequenceEnforced', input) + assert ServiceUtil.isSuccess(serviceResult) + assert serviceResult.quoteId == lastQuoteNumber +1L + } + + // Copy Quote Item + void testCopyQuoteItem () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9001', + quoteItemSeqId: '00001', + quoteIdTo: '9001', + quoteItemSeqIdTo: '00002', + copyQuoteAdjustments: 'Y' + ] + + Map serviceResult = dispatcher.runSync('copyQuoteItem', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteAdjustment = EntityQuery.use(delegator).from('QuoteAdjustment').where('quoteId', '9001', 'quoteItemSeqId', '00002', 'quoteAdjustmentTypeId', 'SALES_TAX').queryFirst() + assert quoteAdjustment + } + + // Test createQuoteAndQuoteItemForRequest + void testCreateQuoteAndQuoteItemForRequest () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + custRequestId: '9000', + custRequestItemSeqId: '00001' + ] + Map serviceResult = dispatcher.runSync('createQuoteAndQuoteItemForRequest', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where('quoteId', serviceResult.quoteId, 'custRequestItemSeqId', '00001').queryFirst() + assert quoteItem + } + + // Test createQuoteFromCart + void testCreateQuoteFromCart() { + GenericValue userLogin = getUserLogin('system') + String productId = 'SV-1001' + String partyId = 'DemoCustomer' + + ShoppingCart cart = new ShoppingCart(delegator, '9000', Locale.getDefault(), 'USD') + cart.setOrderType('SALES_ORDER') + cart.setChannelType('WEB_SALES_CHANNEL') + cart.setBillToCustomerPartyId(partyId) + cart.setPlacingCustomerPartyId(partyId) + cart.setShipToCustomerPartyId(partyId) + cart.setEndUserCustomerPartyId(partyId) + cart.setUserLogin(userLogin, dispatcher) + cart.addOrIncreaseItem(productId, null, BigDecimal.ONE, null, null, null, + null, null, null, null, 'DemoCatalog', null, null, + null, null, dispatcher) + cart.setDefaultCheckoutOptions(dispatcher) + + def input = [ + userLogin: userLogin, + cart: cart, + applyStorePromotions: 'Y' + ] + Map serviceResult = dispatcher.runSync('createQuoteFromCart', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where('quoteId', serviceResult.quoteId, 'productId', productId).queryFirst() + assert quoteItem + GenericValue quoteAdjustment = EntityQuery.use(delegator).from('QuoteAdjustment').where('quoteId', serviceResult.quoteId).queryFirst() + assert quoteAdjustment + } + + // Test createQuoteFromShoppingList + void testCreateQuoteFromShoppingList() { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + shoppingListId: '9000', + applyStorePromotions: 'Y' + ] + Map serviceResult = dispatcher.runSync('createQuoteFromShoppingList', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where('quoteId', serviceResult.quoteId, 'productId', 'SV-1001').queryFirst() + assert quoteItem + GenericValue quoteAdjustment = EntityQuery.use(delegator).from('QuoteAdjustment').where('quoteId', serviceResult.quoteId).queryFirst() + assert quoteAdjustment + } + + // Test autoUpdateQuotePrice + void testAutoUpdateQuotePrice() { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9000', + quoteItemSeqId: '00001', + defaultQuoteUnitPrice: BigDecimal.valueOf(12) + ] + Map serviceResult = dispatcher.runSync('autoUpdateQuotePrice', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where('quoteId', '9000', 'quoteItemSeqId', '00001').queryOne() + assert quoteItem.quoteUnitPrice == 12 + } + + // Test createQuoteFromCustRequest + void testCreateQuoteFromCustRequest () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + custRequestId: '9000' + ] + Map serviceResult = dispatcher.runSync('createQuoteFromCustRequest', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue quoteItem = EntityQuery.use(delegator).from('QuoteItem').where('quoteId', serviceResult.quoteId, 'custRequestId', '9000').queryFirst() + assert quoteItem + } + + // Test autoCreateQuoteAdjustments + void testAutoCreateQuoteAdjustments () { + GenericValue userLogin = EntityQuery.use(delegator) + .from('UserLogin').where(userLoginId: 'system').queryOne() + assert userLogin + GenericValue quote = EntityQuery.use(delegator) + .from('Quote').where(quoteId: '9001').queryOne() + + def input = [ + userLogin: userLogin, + quoteId: '9001' + ] + Map serviceResult = dispatcher.runSync('autoCreateQuoteAdjustments', input) + assert ServiceUtil.isSuccess(serviceResult) + GenericValue promoQuoteAdjustment = EntityQuery.use(delegator).from('QuoteAdjustment').where('quoteId', '9001', 'quoteAdjustmentTypeId', 'PROMOTION_ADJUSTMENT').queryFirst() + assert promoQuoteAdjustment + } + + // Create Quote Note + void testCreateQuoteNote () { + GenericValue userLogin = getUserLogin('system') + def input = [ + userLogin: userLogin, + quoteId: '9001', + noteName: 'Test Note', + noteInfo: 'This is a test' + ] + + Map serviceResult = dispatcher.runSync('createQuoteNote', input) + assert ServiceUtil.isSuccess(serviceResult) + } + +} Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/QuoteTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.order + +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class TestCustRequestPermissionCheck extends GroovyScriptTestCase { + void testCustRequestPermission() { + Map serviceCtx = [:] + serviceCtx.fromPartyId = 'Company' + serviceCtx.mainAction = 'TEST' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map result = dispatcher.runSync('custRequestPermissionCheck', serviceCtx) + assert ServiceUtil.isSuccess(result) + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/order/src/main/groovy/org/apache/ofbiz/order/TestCustRequestPermissionCheck.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/order/testdef/CustRequestTests.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/testdef/CustRequestTests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/testdef/CustRequestTests.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/testdef/CustRequestTests.xml Fri Aug 23 18:00:01 2019 @@ -27,6 +27,6 @@ under the License. </test-case> <test-case case-name="test-cust-request-permission-check"> - <groovy-test-suite location="component://order/groovyScripts/order/test/TestCustRequestPermissionCheck.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.order.TestCustRequestPermissionCheck"/> </test-case> </test-suite> Modified: ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/testdef/OrderTest.xml Fri Aug 23 18:00:01 2019 @@ -34,6 +34,6 @@ under the License. <simple-method-test location="component://order/minilang/test/OrderTests.xml"/> </test-case> <test-case case-name="order-tests"> - <groovy-test-suite location="component://order/groovyScripts/test/OrderTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.order.OrderTests"/> </test-case> </test-suite> Modified: ofbiz/ofbiz-framework/trunk/applications/order/testdef/QuoteTests.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/testdef/QuoteTests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/testdef/QuoteTests.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/testdef/QuoteTests.xml Fri Aug 23 18:00:01 2019 @@ -28,6 +28,6 @@ under the License. <!-- <test-case case-name="quote-tests"> <simple-method-test location="component://order/minilang/test/QuoteTests.xml"/> </test-case> --> <test-case case-name="quoteTests"> - <groovy-test-suite name="quoteTests" location="component://order/groovyScripts/test/QuoteTests.groovy"/> + <junit-test-suite class-name="org.apache.ofbiz.order.QuoteTests"/> </test-case> </test-suite> Added: ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,177 @@ +/******************************************************************************* + * 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.party + +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.party.contact.ContactMechWorker +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class ContactMechWorkerTests extends GroovyScriptTestCase { + + void testPartyContactMechResolution() { + //control for the DemoCustomer that postal, email, telecom and ftp contact are present and return correct information + List partyContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, "DemoCustomer", true) + assert partyContactMechValueMaps + assert partyContactMechValueMaps.size() == 7 + boolean foundPostalAddress, foundTelecom, foundEmailAddress, foundFtpAddress = false + partyContactMechValueMaps.forEach { + Map partyContactMechValueMap -> + switch (partyContactMechValueMap?.contactMech?.contactMechId) { + case '9015': + foundPostalAddress = true + assert partyContactMechValueMap.contactMech.contactMechTypeId == 'POSTAL_ADDRESS' + assert partyContactMechValueMap.partyContactMech + assert partyContactMechValueMap.contactMechType + assert partyContactMechValueMap.partyContactMechPurposes + assert partyContactMechValueMap.partyContactMechPurposes.size() == 3 + assert partyContactMechValueMap.postalAddress + assert partyContactMechValueMap.postalAddress.contactMechId == '9015' + assert partyContactMechValueMap.postalAddress.address1 == '2004 Factory Blvd' + break + case '9027': + foundTelecom = true + assert partyContactMechValueMap.contactMech.contactMechTypeId == 'TELECOM_NUMBER' + assert partyContactMechValueMap.partyContactMech + assert partyContactMechValueMap.contactMechType + assert partyContactMechValueMap.partyContactMechPurposes + assert partyContactMechValueMap.partyContactMechPurposes.size() == 1 + assert partyContactMechValueMap.telecomNumber + assert partyContactMechValueMap.telecomNumber.contactMechId == '9027' + assert partyContactMechValueMap.telecomNumber.contactNumber == '444-4444' + break + case '9126': + foundEmailAddress = true + assert partyContactMechValueMap.contactMech.contactMechTypeId == 'EMAIL_ADDRESS' + assert partyContactMechValueMap.contactMech.infoString == '[hidden email]' + assert partyContactMechValueMap.partyContactMech + assert partyContactMechValueMap.contactMechType + assert partyContactMechValueMap.partyContactMechPurposes + assert partyContactMechValueMap.partyContactMechPurposes.size() == 2 + break + case '9127': + foundFtpAddress = true + assert partyContactMechValueMap.contactMech.contactMechTypeId == 'FTP_ADDRESS' + assert partyContactMechValueMap.partyContactMech + assert partyContactMechValueMap.contactMechType + assert !partyContactMechValueMap.partyContactMechPurposes + assert partyContactMechValueMap.ftpAddress + assert partyContactMechValueMap.ftpAddress.hostname == "ftp://apacheofbiz.foo.com" + break + } + } + assert foundPostalAddress && foundTelecom && foundEmailAddress && foundFtpAddress + + //Restart a search at now, the email 9126 need to have only one purpose + partyContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, "DemoCustomer", false, "EMAIL_ADDRESS") + partyContactMechValueMaps.forEach { + Map partyContactMechValueMap -> + switch (partyContactMechValueMap?.contactMech?.contactMechId) { + case '9126': + assert partyContactMechValueMap.partyContactMechPurposes.size() == 1 + break + } + } + + //Restart a search at 05/13/2001 10:00:00.000, the email 9126 need to have two purposes + partyContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, "DemoCustomer", UtilDateTime.toTimestamp("05/13/2001 10:00:00.000"), "EMAIL_ADDRESS") + partyContactMechValueMaps.forEach { + Map partyContactMechValueMap -> + switch (partyContactMechValueMap?.contactMech?.contactMechId) { + case '9126': + assert partyContactMechValueMap.partyContactMechPurposes.size() == 2 + break + } + } + } + + void testOrderContactMechResolution() { + List orderContactMechValueMaps = ContactMechWorker.getOrderContactMechValueMaps(delegator, "Demo1002") + assert orderContactMechValueMaps + assert orderContactMechValueMaps.size() == 3 + + boolean foundBillingAddress, foundShippingAddress, foundOrderEmail = false + orderContactMechValueMaps.forEach { + Map orderContactMechValueMap -> + switch (orderContactMechValueMap.contactMech?.contactMechId) { + case '9015': + assert orderContactMechValueMap.contactMech.contactMechTypeId == 'POSTAL_ADDRESS' + assert orderContactMechValueMap.contactMechType + assert orderContactMechValueMap.contactMechPurposeType + assert orderContactMechValueMap.orderContactMech + assert orderContactMechValueMap.postalAddress + assert orderContactMechValueMap.postalAddress.contactMechId == '9015' + assert orderContactMechValueMap.postalAddress.address1 == '2004 Factory Blvd' + foundBillingAddress = foundBillingAddress?: orderContactMechValueMap.contactMechPurposeType.contactMechPurposeTypeId == 'BILLING_LOCATION' + foundShippingAddress = foundShippingAddress?: orderContactMechValueMap.contactMechPurposeType.contactMechPurposeTypeId == 'SHIPPING_LOCATION' + break + case '9026': + assert orderContactMechValueMap.contactMech.contactMechTypeId == 'EMAIL_ADDRESS' + assert orderContactMechValueMap.contactMech.infoString == '[hidden email]' + assert orderContactMechValueMap.orderContactMech + assert orderContactMechValueMap.contactMechType + foundOrderEmail = orderContactMechValueMap.contactMechPurposeType.contactMechPurposeTypeId == 'ORDER_EMAIL' + break + default: + assert false + break + } + } + assert foundBillingAddress && foundShippingAddress && foundOrderEmail + } + + void testWorkEffortContactMechResolution() { + List workEffortContactMechValueMaps = ContactMechWorker.getWorkEffortContactMechValueMaps(delegator, "TEST_CM_WORKER") + assert workEffortContactMechValueMaps + assert workEffortContactMechValueMaps.size() == 3 + + boolean foundPostalAddress, foundPhone, foundEmail = false + workEffortContactMechValueMaps.forEach { + Map workEffortContactMechValueMap -> + switch (workEffortContactMechValueMap.contactMech?.contactMechId) { + case '9015': + assert workEffortContactMechValueMap.contactMech.contactMechTypeId == 'POSTAL_ADDRESS' + assert workEffortContactMechValueMap.contactMechType + assert workEffortContactMechValueMap.workEffortContactMech + assert workEffortContactMechValueMap.postalAddress + assert workEffortContactMechValueMap.postalAddress.contactMechId == '9015' + assert workEffortContactMechValueMap.postalAddress.address1 == '2004 Factory Blvd' + foundPostalAddress = true + break + case '9126': + assert workEffortContactMechValueMap.contactMech.contactMechTypeId == 'EMAIL_ADDRESS' + assert workEffortContactMechValueMap.contactMech.infoString == '[hidden email]' + assert workEffortContactMechValueMap.workEffortContactMech + assert workEffortContactMechValueMap.contactMechType + foundEmail = true + break + case '9125': + assert workEffortContactMechValueMap.contactMech.contactMechTypeId == 'TELECOM_NUMBER' + assert workEffortContactMechValueMap.workEffortContactMech + assert workEffortContactMechValueMap.contactMechType + assert workEffortContactMechValueMap.telecomNumber.contactNumber == '555-5555' + foundPhone = true + break + default: + assert false + break + } + } + assert foundPostalAddress && foundEmail && foundPhone + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/party/src/main/groovy/org/apache/ofbiz/party/ContactMechWorkerTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/party/testdef/PartyContactMechTests.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/testdef/PartyContactMechTests.xml?rev=1865786&r1=1865785&r2=1865786&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/party/testdef/PartyContactMechTests.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/party/testdef/PartyContactMechTests.xml Fri Aug 23 18:00:01 2019 @@ -25,7 +25,7 @@ <entity-xml action="load" entity-xml-url="component://party/testdef/data/PartyContactMechTestData.xml"/> </test-case> <test-case case-name="ContactMechWorker-tests"> - <groovy-test-suite name="contactMechWorker" location="component://party/groovyScripts/test/ContactMechWorkerTests.groovy"/> + <junit-test-suite className="org.apache.ofbiz.party.ContactMechWorkerTests"/> </test-case> <test-case case-name="partyContactMech-tests"> <simple-method-test location="component://party/minilang/test/PartyContactMechTests.xml"/> Added: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy?rev=1865786&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy Fri Aug 23 18:00:01 2019 @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.product + +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.entity.util.EntityQuery +import org.apache.ofbiz.service.ServiceUtil +import org.apache.ofbiz.testtools.GroovyScriptTestCase + +class ProductFeatureTypeTests extends GroovyScriptTestCase { + void testCreateProductFeatureType() { + Map serviceCtx = [:] + serviceCtx.productFeatureTypeId = 'testProdFeat' + serviceCtx.description = 'Test Description' + serviceCtx.hasTable = 'N' + serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne() + Map result = dispatcher.runSync('createProductFeatureType', serviceCtx) + assert ServiceUtil.isSuccess(result) + + GenericValue productFeatureType = EntityQuery.use(delegator).from('ProductFeatureType').where('productFeatureTypeId', 'testProdFeat').queryOne() + assert productFeatureType.productFeatureTypeId == 'testProdFeat' + } +} Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductFeatureTypeTests.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |