[ofbiz-framework] branch trunk updated: Improved: Unit test case for service - createProductConfigOption (OFBIZ-9090)

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: Unit test case for service - createProductConfigOption (OFBIZ-9090)

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 121634f  Improved: Unit test case for service - createProductConfigOption (OFBIZ-9090)
121634f is described below

commit 121634f8f3cb36e307606846d797d01720613674
Author: Akash Jain <[hidden email]>
AuthorDate: Sat Aug 22 23:21:57 2020 +0530

    Improved: Unit test case for service - createProductConfigOption (OFBIZ-9090)
   
    Thanks, Pradhan Yash Sharma for your contribution
---
 applications/product/ofbiz-component.xml           |  1 +
 .../apache/ofbiz/product/ProductConfigTests.groovy | 46 ++++++++++++++++++++++
 .../product/testdef/ProductConfigTests.xml         | 32 +++++++++++++++
 .../product/testdef/data/ProductConfigTestData.xml | 23 +++++++++++
 4 files changed, 102 insertions(+)

diff --git a/applications/product/ofbiz-component.xml b/applications/product/ofbiz-component.xml
index 1cc86f0..bd9870c 100644
--- a/applications/product/ofbiz-component.xml
+++ b/applications/product/ofbiz-component.xml
@@ -74,6 +74,7 @@ under the License.
     <test-suite loader="main" location="testdef/ProductTagTest.xml"/>
     <test-suite loader="main" location="testdef/ProductTest.xml"/>
     <test-suite loader="main" location="testdef/ProductPromoTests.xml"/>
+    <test-suite loader="main" location="testdef/ProductConfigTests.xml"/>
 
     <webapp name="catalog"
         title="Catalog"
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductConfigTests.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductConfigTests.groovy
new file mode 100644
index 0000000..b2f0994
--- /dev/null
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/ProductConfigTests.groovy
@@ -0,0 +1,46 @@
+/*
+ * 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.service.testtools.OFBizTestCase
+import org.apache.ofbiz.service.ServiceUtil
+
+class ProductConfigTests extends OFBizTestCase {
+    public ProductConfigTests(String name) {
+        super(name)
+    }
+
+    void testCreateProductConfigOption() {
+        Map serviceCtx = [:]
+        serviceCtx.configItemId = 'testConfigItemId'
+        serviceCtx.configOptionName = 'Test Config Option'
+        serviceCtx.description = 'Test product config option'
+        serviceCtx.userLogin = userLogin
+        Map serviceResult = dispatcher.runSync('createProductConfigOption', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.configOptionId
+
+        GenericValue productConfigOption = from('ProductConfigOption')
+                .where('configItemId', 'testConfigItemId')
+                .queryFirst()
+        assert productConfigOption
+        assert 'Test Config Option'.equals(productConfigOption.configOptionName)
+    }
+}
diff --git a/applications/product/testdef/ProductConfigTests.xml b/applications/product/testdef/ProductConfigTests.xml
new file mode 100644
index 0000000..a9fc241
--- /dev/null
+++ b/applications/product/testdef/ProductConfigTests.xml
@@ -0,0 +1,32 @@
+<?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="productConfigTests"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
+
+
+    <test-case case-name="loadProductConfigTestData">
+        <entity-xml action="load" entity-xml-url="component://product/testdef/data/ProductConfigTestData.xml"/>
+    </test-case>
+    <test-case case-name="productConfigtests">
+        <junit-test-suite class-name="org.apache.ofbiz.product.ProductConfigTests"/>
+    </test-case>
+</test-suite>
\ No newline at end of file
diff --git a/applications/product/testdef/data/ProductConfigTestData.xml b/applications/product/testdef/data/ProductConfigTestData.xml
new file mode 100644
index 0000000..d0bd0c8
--- /dev/null
+++ b/applications/product/testdef/data/ProductConfigTestData.xml
@@ -0,0 +1,23 @@
+<?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>
+    <ProductConfigItem configItemId="testConfigItemId" configItemName="Test Config Item Name" configItemTypeId="SINGLE" description="Test Desc" />
+</entity-engine-xml>
\ No newline at end of file