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

svn commit: r889922 - in /ofbiz/trunk/applications/order: ofbiz-component.xml script/org/ofbiz/order/test/ script/org/ofbiz/order/test/QuoteTests.xml testdef/data/ testdef/data/QuoteTestData.xml testdef/quotetests.xml

Author: lektran
Date: Sat Dec 12 10:51:17 2009
New Revision: 889922

URL: http://svn.apache.org/viewvc?rev=889922&view=rev
Log:
A few tests for the createQuoteWorkEffort service

Added:
    ofbiz/trunk/applications/order/script/org/ofbiz/order/test/
    ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml   (with props)
    ofbiz/trunk/applications/order/testdef/data/
    ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml   (with props)
    ofbiz/trunk/applications/order/testdef/quotetests.xml   (with props)
Modified:
    ofbiz/trunk/applications/order/ofbiz-component.xml

Modified: ofbiz/trunk/applications/order/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/ofbiz-component.xml?rev=889922&r1=889921&r2=889922&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/order/ofbiz-component.xml Sat Dec 12 10:51:17 2009
@@ -48,6 +48,7 @@
     <service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
 
     <test-suite loader="main" location="testdef/OrderTest.xml"/>
+    <test-suite loader="main" location="testdef/quotetests.xml"/>
 
     <webapp name="order"
         title="Order"

Added: ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml?rev=889922&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml (added)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml Sat Dec 12 10:51:17 2009
@@ -0,0 +1,126 @@
+<?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"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
+
+    <simple-method method-name="testCreateQuoteWorkEffort" short-description="Test case for successfully creating a QuoteWorkEffort record." login-required="false">
+        <entity-one entity-name="UserLogin" value-field="serviceCtx.userLogin">
+            <field-map field-name="userLoginId" value="DemoRepStore"/>
+        </entity-one>
+        <set field="serviceCtx.quoteId" value="9000"/>
+        <set field="serviceCtx.workEffortId" value="9007"/>
+
+        <!-- Execute the service -->
+        <call-service service-name="createQuoteWorkEffort" in-map-name="serviceCtx">
+            <results-to-map map-name="serviceResult"/>
+        </call-service>
+
+        <!-- Confirm the service output parameters -->
+        <assert>
+            <if-compare-field field="serviceResult.quoteId" operator="equals" to-field="serviceCtx.quoteId"/>
+            <if-compare-field field="serviceResult.workEffortId" operator="equals" to-field="serviceCtx.workEffortId"/>
+        </assert>
+
+        <!-- Confirm the database changes -->
+        <entity-one value-field="quoteWorkEffort" entity-name="QuoteWorkEffort">
+            <field-map field-name="quoteId" from-field="serviceCtx.quoteId"/>
+            <field-map field-name="workEffortId" from-field="serviceCtx.workEffortId"/>
+        </entity-one>
+        <assert><not><if-empty field="quoteWorkEffort"/></not></assert>
+    </simple-method>
+    
+    <simple-method method-name="testCreateQuoteWorkEffortFail" 
+        short-description="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." login-required="false">
+
+        <!-- Use to confirm nothing has changed at the end of the test -->
+        <set field="startTime" value="${date:nowTimestamp()}" type="Timestamp"/>
+
+        <entity-one entity-name="UserLogin" value-field="serviceCtx.userLogin">
+            <field-map field-name="userLoginId" value="DemoRepStore"/>
+        </entity-one>
+
+        <set field="serviceCtx.quoteId" value="9000"/>
+        <set field="serviceCtx.workEffortId" value="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 -->
+        <call-service service-name="createQuoteWorkEffort" in-map-name="serviceCtx" 
+            break-on-error="false" require-new-transaction="true">
+            <results-to-map map-name="serviceResult"/>
+        </call-service>
+        <!-- Clear these because break-on-error="false" doesn't seem to work as it should at the moment -->
+        <clear-field field="responseMessage"/>
+        <clear-field field="errorMessageList"/>
+
+        <!-- Confirm the service output parameters, in this case the presence of an error response -->
+        <assert><if-compare field="serviceResult.responseMessage" operator="equals" value="error"/></assert>
+
+        <!-- Confirm the database changes, in this case nothing should have changed -->
+        <entity-condition list="quoteWorkEfforts" entity-name="QuoteWorkEffort">
+            <condition-list>
+                <condition-expr field-name="lastUpdatedStamp" operator="greater-equals" from-field="startTime"/>
+                <condition-expr field-name="quoteId" from-field="serviceCtx.quoteId"/>
+                <condition-expr field-name="workEffortId" from-field="serviceCtx.workEffortId"/>
+            </condition-list>
+        </entity-condition>
+        <!--  Should be empty -->
+        <assert><if-empty field="quoteWorkEffort"/></assert>
+    </simple-method>
+
+    <simple-method method-name="testCreateWorkEffortAndQuoteWorkEffort" login-required="false"
+        short-description="Test case for calling createQuoteWorkEffort without a workEffortId which triggers an ECA to create the WorkEffort first">
+        <entity-one entity-name="UserLogin" value-field="serviceCtx.userLogin">
+            <field-map field-name="userLoginId" value="flexadmin"/>
+        </entity-one>
+        <!-- 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 -->
+        <set field="serviceCtx.currentStatusId" value="ROU_ACTIVE"/>
+        <set field="serviceCtx.workEffortName" value="Test WorkEffort"/>
+        <set field="serviceCtx.workEffortTypeId" value="ROUTING"/>
+        <set field="serviceCtx.quoteId" value="9000"/>
+
+        <call-service service-name="createQuoteWorkEffort" in-map-name="serviceCtx">
+            <results-to-map map-name="serviceResult"/>
+        </call-service>
+
+        <assert>
+            <and>
+                <if-compare-field field="serviceResult.quoteId" operator="equals" to-field="serviceCtx.quoteId"/>
+                <not><if-empty field="serviceResult.workEffortId"/></not>
+            </and>
+        </assert>
+        
+        <!-- Confirm that a matching WorkEffort was created -->
+        <entity-and list="workEfforts" entity-name="WorkEffort">
+            <field-map field-name="workEffortId" from-field="serviceResult.workEffortId"/>
+            <field-map field-name="currentStatusId" from-field="serviceCtx.currentStatusId"/>
+            <field-map field-name="workEffortName" from-field="serviceCtx.workEffortName"/>
+            <field-map field-name="workEffortTypeId" from-field="serviceCtx.workEffortTypeId"/>
+        </entity-and>
+        <assert>
+            <not><if-empty field="workEfforts"/></not>
+        </assert>
+
+        <entity-one value-field="quoteWorkEffort" entity-name="QuoteWorkEffort">
+            <field-map field-name="quoteId" from-field="serviceCtx.quoteId"/>
+            <field-map field-name="workEffortId" from-field="serviceResult.workEffortId"/>
+        </entity-one>
+    </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/order/script/org/ofbiz/order/test/QuoteTests.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml?rev=889922&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml (added)
+++ ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml Sat Dec 12 10:51:17 2009
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<entity-engine-xml>
+    <Quote quoteId="9000" quoteTypeId="PRODUCT_QUOTE" partyId="DemoCustomer" issueDate="2009-12-11 12:00:00.000" statusId="QUO_CREATED" currencyUomId="USD" productStoreId="9000" salesChannelEnumId="EMAIL_SALES_CHANNEL" validFromDate="2009-12-11 12:00:00.000" quoteName="Most competitive quote ever"/>
+    <WorkEffort workEffortId="9007" workEffortTypeId="TASK" currentStatusId="PTS_CREATED" workEffortName="Quote WorkEffort"/>
+</entity-engine-xml>
\ No newline at end of file

Propchange: ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/order/testdef/data/QuoteTestData.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/applications/order/testdef/quotetests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/testdef/quotetests.xml?rev=889922&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/testdef/quotetests.xml (added)
+++ ofbiz/trunk/applications/order/testdef/quotetests.xml Sat Dec 12 10:51:17 2009
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<test-suite suite-name="quotetests"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
+        
+    <test-case case-name="loadQuoteTestData">
+        <entity-xml action="load" entity-xml-url="component://order/testdef/data/QuoteTestData.xml"/>
+    </test-case>
+
+    <test-case case-name="testCreateQuoteWorkEffort">
+        <simple-method-test location="component://order/script/org/ofbiz/order/test/QuoteTests.xml" name="testCreateQuoteWorkEffort"/>
+    </test-case>
+
+    <test-case case-name="testCreateQuoteWorkEffortFail">
+        <simple-method-test location="component://order/script/org/ofbiz/order/test/QuoteTests.xml" name="testCreateQuoteWorkEffortFail"/>
+    </test-case>
+
+    <test-case case-name="testCreateWorkEffortAndQuoteWorkEffort">
+        <simple-method-test location="component://order/script/org/ofbiz/order/test/QuoteTests.xml" name="testCreateWorkEffortAndQuoteWorkEffort"/>
+    </test-case>
+</test-suite>
\ No newline at end of file

Propchange: ofbiz/trunk/applications/order/testdef/quotetests.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/testdef/quotetests.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/order/testdef/quotetests.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml