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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new fd2690afb Improvements in example plugin component. Adding test cases 
for reference purposes for updateExample and deleteExample service (#149)
fd2690afb is described below

commit fd2690afb3660f4095a427319796939c41731898
Author: Ashish Vijaywargiya <[email protected]>
AuthorDate: Sat Feb 7 17:13:07 2026 +0530

    Improvements in example plugin component. Adding test cases for reference 
purposes for updateExample and deleteExample service (#149)
---
 .../org/apache/ofbiz/example/ExampleTests.groovy   | 56 ++++++++++++++++++++++
 .../{tests.xml => data/ExampleTestData.xml}        | 18 ++-----
 example/testdef/tests.xml                          |  6 +++
 3 files changed, 66 insertions(+), 14 deletions(-)

diff --git 
a/example/src/main/groovy/org/apache/ofbiz/example/ExampleTests.groovy 
b/example/src/main/groovy/org/apache/ofbiz/example/ExampleTests.groovy
new file mode 100644
index 000000000..a6059f87f
--- /dev/null
+++ b/example/src/main/groovy/org/apache/ofbiz/example/ExampleTests.groovy
@@ -0,0 +1,56 @@
+/*
+ * 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.example
+
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.service.ServiceUtil
+import org.apache.ofbiz.service.testtools.OFBizTestCase
+
+class ExampleTests extends OFBizTestCase {
+    public ExampleTests(String name) {
+        super(name)
+    }
+
+    void testUpdateExample() {
+        Map<String, Object> serviceCtx = [:]
+        serviceCtx.exampleId = "TestExampleUpdate"
+        serviceCtx.exampleName = "Updated Test Example Name"
+        serviceCtx.userLogin = userLogin
+
+        Map<String, Object> serviceResult = 
dispatcher.runSync("updateExample", serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue example = from("Example").where("exampleId", 
"TestExampleUpdate").queryOne()
+        assert example != null
+        assert "Updated Test Example Name".equals(example.exampleName)
+    }
+
+    void testDeleteExample() {
+        Map<String, Object> serviceCtx = [:]
+        serviceCtx.exampleId = "TestExampleDelete"
+        serviceCtx.userLogin = userLogin
+
+        Map<String, Object> serviceResult = 
dispatcher.runSync("deleteExample", serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue example = from("Example").where("exampleId", 
"TestExampleDelete").queryOne()
+        assert example == null
+    }
+}
diff --git a/example/testdef/tests.xml 
b/example/testdef/data/ExampleTestData.xml
similarity index 51%
copy from example/testdef/tests.xml
copy to example/testdef/data/ExampleTestData.xml
index 38140096b..36aba3608 100644
--- a/example/testdef/tests.xml
+++ b/example/testdef/data/ExampleTestData.xml
@@ -18,17 +18,7 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<test-suite suite-name="example-tests"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-        
xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/test-suite.xsd";>
-
-    <test-case case-name="userLoginEntityXmlAssert">
-        <entity-xml action="assert" 
entity-xml-url="component://example/testdef/assertdata/TestUserLoginData.xml"/>
-    </test-case>
-    <test-case case-name="testCreateExampleService Through Service Engine">
-        <service-test service-name="testCreateExampleService"/>
-    </test-case>
-    <test-case case-name="testCreateExampleService Direct Simple Method">
-        <simple-method-test 
location="component://example/minilang/example/ExampleServices.xml" 
name="testCreateExampleService"/>
-    </test-case>
-</test-suite>
+<entity-engine-xml>
+    <Example exampleId="TestExampleUpdate" exampleTypeId="CONTRIVED" 
statusId="EXST_IN_DESIGN" exampleName="Test Example for Update"/>
+    <Example exampleId="TestExampleDelete" exampleTypeId="CONTRIVED" 
statusId="EXST_IN_DESIGN" exampleName="Test Example for Delete"/>
+</entity-engine-xml>
diff --git a/example/testdef/tests.xml b/example/testdef/tests.xml
index 38140096b..d61917034 100644
--- a/example/testdef/tests.xml
+++ b/example/testdef/tests.xml
@@ -31,4 +31,10 @@ under the License.
     <test-case case-name="testCreateExampleService Direct Simple Method">
         <simple-method-test 
location="component://example/minilang/example/ExampleServices.xml" 
name="testCreateExampleService"/>
     </test-case>
+    <test-case case-name="load-example-test-data">
+        <entity-xml action="load" 
entity-xml-url="component://example/testdef/data/ExampleTestData.xml"/>
+    </test-case>
+    <test-case case-name="example-tests-groovy">
+        <junit-test-suite class-name="org.apache.ofbiz.example.ExampleTests"/>
+    </test-case>
 </test-suite>

Reply via email to