You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2017/11/29 19:18:51 UTC

svn commit: r1816645 - in /ofbiz/ofbiz-framework/trunk/applications/accounting: groovyScripts/budget/ groovyScripts/test/ minilang/test/ testdef/

Author: nmalin
Date: Wed Nov 29 19:18:51 2017
New Revision: 1816645

URL: http://svn.apache.org/viewvc?rev=1816645&view=rev
Log:
Improved: Migrate BudgetServiceTest from minilang to groovy
With the issue "Convert BudgetServices.xml mini lang to groovy" (OFBIZ-9985)
and issue "Implement Groovy test in testtools" (OFBIZ-9996)
I converted the related test AutoAcctgBudgetTests from minilang to groovy.

Added:
    ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/
    ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy   (with props)
Removed:
    ofbiz/ofbiz-framework/trunk/applications/accounting/minilang/test/AutoAcctgBudgetTests.xml
Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
    ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy?rev=1816645&r1=1816644&r2=1816645&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/budget/BudgetServices.groovy Wed Nov 29 19:18:51 2017
@@ -18,7 +18,7 @@
  */
 
 import org.apache.ofbiz.entity.GenericValue
-    
+
 
 def createBudget() {
     //create new entity and create all the fields

Added: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy?rev=1816645&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy Wed Nov 29 19:18:51 2017
@@ -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.
+ *******************************************************************************/
+
+
+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'
+    }
+}
\ No newline at end of file

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/test/AutoAcctgBudgetTests.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=1816645&r1=1816644&r2=1816645&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/testdef/accountingtests.xml Wed Nov 29 19:18:51 2017
@@ -26,7 +26,6 @@
         <entity-xml action="load" entity-xml-url="component://accounting/testdef/data/AccountingTestsData.xml"/>
     </test-case>
 
-
     <test-case case-name="accounting-tests">
         <junit-test-suite class-name="org.apache.ofbiz.accounting.test.FinAccountTests"/>
     </test-case>
@@ -44,7 +43,7 @@
         <simple-method-test location="component://accounting/minilang/test/AutoAcctgAgreementTests.xml"/>
     </test-case>
     <test-case case-name="auto-accounting-budget-tests">
-        <simple-method-test location="component://accounting/minilang/test/AutoAcctgBudgetTests.xml"/>
+        <groovy-test-suite location="component://accounting/groovyScripts/test/AutoAcctgBudgetTests.groovy"/>
     </test-case>
     <test-case case-name="auto-accounting-cost-tests">
         <simple-method-test location="component://accounting/minilang/test/AutoAcctgCostTests.xml"/>