[ofbiz-framework] branch trunk updated: Improved: Convert PartyStatusChangeTests.xml to Groovy (OFBIZ-11853)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Convert PartyStatusChangeTests.xml to Groovy (OFBIZ-11853)

akashjain
This is an automated email from the ASF dual-hosted git repository.

akashjain pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 25fc51f  Improved: Convert PartyStatusChangeTests.xml to Groovy (OFBIZ-11853)
25fc51f is described below

commit 25fc51f961a01d78e1069b867fe2612a30b85928
Author: Akash Jain <[hidden email]>
AuthorDate: Tue Aug 4 22:23:10 2020 +0530

    Improved: Convert PartyStatusChangeTests.xml to Groovy (OFBIZ-11853)
---
 .../party/minilang/test/PartyStatusChangeTests.xml | 72 ---------------------
 applications/party/ofbiz-component.xml             |  1 +
 .../ofbiz/party/PartyStatusChangeTests.groovy      | 74 ++++++++++++++++++++++
 .../party/testdef/PartyStatusChangeTests.xml       |  8 +--
 applications/party/testdef/PartyTests.xml          |  7 --
 5 files changed, 79 insertions(+), 83 deletions(-)

diff --git a/applications/party/minilang/test/PartyStatusChangeTests.xml b/applications/party/minilang/test/PartyStatusChangeTests.xml
deleted file mode 100644
index a14b3f2..0000000
--- a/applications/party/minilang/test/PartyStatusChangeTests.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
-
-   <simple-method method-name="testSetPartyStatusToDisabled" short-description="Test case for changing party status to PARTY_DISABLED." login-required="false">
-        <now-timestamp field="nowTimestamp"/>
-        <set field="serviceCtx.locale" value="en"/>
-        <set field="serviceCtx.partyId" value="PARTY_ENABLED"/>
-        <set field="serviceCtx.statusId" value="PARTY_DISABLED"/>
-        <set field="serviceCtx.statusDate" from-field="nowTimestamp"/>      
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <call-service service-name="setPartyStatus" in-map-name="serviceCtx">
-            <results-to-map map-name="results"/>
-        </call-service>      
-        <entity-one entity-name="Party" value-field="party">
-            <field-map field-name="partyId" value="PARTY_ENABLED"/>
-        </entity-one>
-        <assert>
-            <not><if-empty field="results"/></not>
-            <if-compare field="party.statusId" operator="equals" value="PARTY_DISABLED"/>
-            <if-compare field="results.oldStatusId" operator="equals" value="PARTY_ENABLED"/>            
-        </assert>
-        <check-errors/>
-    </simple-method>      
-    
-    <simple-method method-name="testSetPartyStatusToEnabled" short-description="Test case for changing party status to PARTY_DISABLED." login-required="false">
-        <now-timestamp field="nowTimestamp"/>
-        <set field="serviceCtx.locale" value="en"/>
-        <set field="serviceCtx.partyId" value="PARTY_DISABLED"/>
-        <set field="serviceCtx.statusId" value="PARTY_ENABLED"/>
-        <set field="serviceCtx.statusDate" from-field="nowTimestamp"/>      
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <call-service service-name="setPartyStatus" in-map-name="serviceCtx">
-            <results-to-map map-name="results"/>
-        </call-service>
-        <entity-one entity-name="Party" value-field="party">
-            <field-map field-name="partyId" value="PARTY_DISABLED"/>
-        </entity-one>
-        <assert>
-            <not><if-empty field="results"/></not>        
-            <if-compare field="party.statusId" operator="equals" value="PARTY_ENABLED"/>
-            <if-compare field="results.oldStatusId" operator="equals" value="PARTY_DISABLED"/>            
-        </assert>
-        <check-errors/>
-    </simple-method>
-
-</simple-methods>
\ No newline at end of file
diff --git a/applications/party/ofbiz-component.xml b/applications/party/ofbiz-component.xml
index d393aec..056ea2b 100644
--- a/applications/party/ofbiz-component.xml
+++ b/applications/party/ofbiz-component.xml
@@ -38,6 +38,7 @@ under the License.
     
     <test-suite loader="main" location="testdef/PartyTests.xml"/>
     <test-suite loader="main" location="testdef/PartyContactMechTests.xml"/>
+    <test-suite loader="main" location="testdef/PartyStatusChangeTests.xml"/>
 
     <webapp name="party"
         title="Party"
diff --git a/applications/party/src/main/groovy/org/apache/ofbiz/party/PartyStatusChangeTests.groovy b/applications/party/src/main/groovy/org/apache/ofbiz/party/PartyStatusChangeTests.groovy
new file mode 100644
index 0000000..b3e1dc8
--- /dev/null
+++ b/applications/party/src/main/groovy/org/apache/ofbiz/party/PartyStatusChangeTests.groovy
@@ -0,0 +1,74 @@
+/*
+ * 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.entity.GenericValue
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class PartyStatusChangeTests extends OFBizTestCase {
+    public PartyStatusChangeTests(String name) {
+        super(name)
+    }
+
+    // Test case for changing party status to PARTY_DISABLED
+    void testSetPartyStatusToDisabled() {
+        String partyId = 'PARTY_ENABLED'
+        String statusId = 'PARTY_DISABLED'
+
+        Map serviceCtx = [
+                partyId: partyId,
+                statusId: statusId,
+                statusDate: UtilDateTime.nowTimestamp(),
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('setPartyStatus', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue party = from("Party")
+                .where('partyId', partyId)
+                .queryOne()
+        assert party
+        assert statusId.equals(party.statusId)
+        assert 'PARTY_ENABLED'.equals(serviceResult.oldStatusId)
+    }
+
+    // Test case for changing party status to PARTY_ENABLED
+    void testSetPartyStatusToEnabled() {
+        String partyId = 'PARTY_DISABLED'
+        String statusId = 'PARTY_ENABLED'
+
+        Map serviceCtx = [
+                partyId: partyId,
+                statusId: statusId,
+                statusDate: UtilDateTime.nowTimestamp(),
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('setPartyStatus', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue party = from("Party")
+                .where('partyId', partyId)
+                .queryOne()
+        assert party
+        assert statusId.equals(party.statusId)
+        assert 'PARTY_DISABLED'.equals(serviceResult.oldStatusId)
+    }
+}
\ No newline at end of file
diff --git a/applications/party/testdef/PartyStatusChangeTests.xml b/applications/party/testdef/PartyStatusChangeTests.xml
index d8ec01c..86ddd9b 100644
--- a/applications/party/testdef/PartyStatusChangeTests.xml
+++ b/applications/party/testdef/PartyStatusChangeTests.xml
@@ -23,10 +23,10 @@
 
     <test-case case-name="partystatuschangetestdata">
         <entity-xml action="load" entity-xml-url="component://party/testdef/data/PartyStatusChangeTestData.xml"/>
-    </test-case>    
-    
+    </test-case>
+
     <test-case case-name="partystatuschangetest">
-        <simple-method-test location="component://party/minilang/test/PartyStatusChangeTests.xml"/>
-    </test-case>  
+        <junit-test-suite class-name="org.apache.ofbiz.party.PartyStatusChangeTests"/>
+    </test-case>
 
 </test-suite>
diff --git a/applications/party/testdef/PartyTests.xml b/applications/party/testdef/PartyTests.xml
index afbad04..69adf09 100644
--- a/applications/party/testdef/PartyTests.xml
+++ b/applications/party/testdef/PartyTests.xml
@@ -29,11 +29,4 @@
         <simple-method-test location="component://party/minilang/test/PartyTests.xml"/>
         <junit-test-suite class-name="org.apache.ofbiz.party.PartyTests"/>
     </test-group>
-    <test-case case-name="partystatuschangetestdata">
-        <entity-xml action="load" entity-xml-url="component://party/testdef/data/PartyStatusChangeTestData.xml"/>
-    </test-case>
-    <test-case case-name="partystatuschangetest">
-        <simple-method-test location="component://party/minilang/test/PartyStatusChangeTests.xml"/>
-    </test-case>
-    
 </test-suite>