Author: deepak
Date: Thu Nov 3 21:16:42 2016 New Revision: 1767977 URL: http://svn.apache.org/viewvc?rev=1767977&view=rev Log: Improved: Added unit test case for following product related services - createProduct, updateProduct - duplicateProduct - quickAddVariant - deleteProductKeywords - discontinueProductSales - createProductReview - updateProductReview - findProductById - createProductPrice, updateProductPrice, deleteProductPrice - createProductCategory (OFBIZ-8412)(OFBIZ-8506)(OFBIZ-8571)(OFBIZ-8654)(OFBIZ-8572)(OFBIZ-8573)(OFBIZ-8574) (OFBIZ-8656)(OFBIZ-8575)(OFBIZ-8576)(OFBIZ-8577)(OFBIZ-8578)(OFBIZ-8655) Thanks Akash Jain and Yash Sharma for your contribution. Added: ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml (with props) ofbiz/trunk/applications/product/testdef/ProductTest.xml (with props) ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml (with props) Modified: ofbiz/trunk/applications/product/ofbiz-component.xml Added: ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml?rev=1767977&view=auto ============================================================================== --- ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml (added) +++ ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml Thu Nov 3 21:16:42 2016 @@ -0,0 +1,330 @@ +<?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="testCreateProduct" short-description="Test create Product" login-required="false"> + <set field="serviceCtx.internalName" value="Test_product"/> + <set field="serviceCtx.productTypeId" value="Test_type"/> + <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="createProduct" in-map-name="serviceCtx"> + <result-to-field result-name="productId"/> + </call-service> + <entity-one entity-name="Product" value-field="product"/> + <assert> + <not> + <if-empty field="product"/> + </not> + <if-compare field="product.internalName" operator="equals" value="Test_product"/> + <if-compare field="product.productTypeId" operator="equals" value="Test_type"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testUpdateProduct" short-description="Test update Product" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_A"/> + <set field="serviceCtx.productName" value="Test_name_B"/> + <set field="serviceCtx.description" value="Updated description"/> + <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="updateProduct" in-map-name="serviceCtx"/> + <entity-one entity-name="Product" value-field="product"> + <field-map field-name="productId" value="Test_product_A"/> + </entity-one> + <assert> + <not> + <if-empty field="product"/> + </not> + <if-compare field="product.productName" operator="equals" value="Test_name_B"/> + <if-compare field="product.description" operator="equals" value="Updated description"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testDuplicateProduct" short-description="Test duplicate Product" login-required="false"> + <set field="serviceCtx.productId" value="Duplicate_Id"/> + <set field="serviceCtx.oldProductId" value="Test_product_B"/> + <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="duplicateProduct" in-map-name="serviceCtx"/> + <entity-one entity-name="Product" value-field="product"> + <field-map field-name="productId" value="Duplicate_Id"/> + </entity-one> + <assert> + <not> + <if-empty field="product"/> + </not> + <if-compare field="product.productTypeId" operator="equals" value="Test_type"/> + <if-compare field="product.productName" operator="equals" value="Test_name_C"/> + <if-compare field="product.description" operator="equals" value="This is product description"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testQuickAddVariant" short-description="Test Add Variant" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_B"/> + <set field="serviceCtx.productFeatureIds" value="Test_feature"/> + <set field="serviceCtx.productVariantId" value="Test_variant"/> + <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="quickAddVariant" in-map-name="serviceCtx"/> + <entity-one entity-name="Product" value-field="product"> + <field-map field-name="productId" value="Test_variant"/> + </entity-one> + <assert> + <not> + <if-empty field="product"/> + </not> + <if-compare field="product.productTypeId" operator="equals" value="Test_type"/> + <if-compare field="product.productName" operator="equals" value="Test_name_C"/> + <if-compare field="product.description" operator="equals" value="This is product description"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testDeleteProductKeywords" short-description="Test delete Product Keywords" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_C"/> + <entity-one entity-name="UserLogin" value-field="userLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="serviceCtx.userLogin" from-field="userLogin"/> + <entity-and entity-name="ProductKeyword" list="keywords"> + <field-map field-name="productId" value="Test_product_C"/> + </entity-and> + <assert> + <not> + <if-empty field="keywords"/> + </not> + </assert> + <call-service service-name="deleteProductKeywords" in-map-name="serviceCtx"/> + <entity-and entity-name="ProductKeyword" list="keywords"> + <field-map field-name="productId" value="Test_product_C"/> + </entity-and> + <assert> + <if-empty field="keywords"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testDiscontinueProductSales" short-description="Test discontinue Product Sales" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_C"/> + <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="discontinueProductSales" in-map-name="serviceCtx"/> + <entity-one entity-name="Product" value-field="product"> + <field-map field-name="productId" value="Test_product_C"/> + </entity-one> + <assert> + <not> + <if-empty field="product.salesDiscontinuationDate"/> + </not> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testCreateProductReview" short-description="Test create Product Review" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_C"/> + <set field="serviceCtx.productStoreId" value="Test_store"/> + <set field="serviceCtx.productRating" type="BigDecimal" value="5"/> + <set field="serviceCtx.productReview" value="Test review"/> + <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="createProductReview" in-map-name="serviceCtx"> + <result-to-field result-name="productReviewId"/> + </call-service> + <entity-one entity-name="ProductReview" value-field="review"/> + <assert> + <not> + <if-empty field="review"/> + </not> + <if-compare field="review.productId" operator="equals" value="Test_product_C"/> + <if-compare field="review.productStoreId" operator="equals" value="Test_store"/> + <if-compare field="review.productRating" operator="equals" value="5.000000"/> + <if-compare field="review.productReview" operator="equals" value="Test review"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testUpdateProductReview" short-description="Test update Product Review" login-required="false"> + <set field="serviceCtx.productReviewId" value="Test_review"/> + <set field="serviceCtx.productRating" type="BigDecimal" value="3"/> + <set field="serviceCtx.productReview" value="Updated review"/> + <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="updateProductReview" in-map-name="serviceCtx"/> + <entity-one entity-name="ProductReview" value-field="review"> + <field-map field-name="productReviewId" value="Test_review"/> + </entity-one> + <assert> + <not> + <if-empty field="review"/> + </not> + <if-compare field="review.productId" operator="equals" value="Test_product_C"/> + <if-compare field="review.productRating" operator="equals" value="3.000000"/> + <if-compare field="review.productReview" operator="equals" value="Updated review"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testFindProductById" short-description="Test find Product By Id" login-required="false"> + <set field="serviceCtx.idToFind" value="Test_product_C"/> + <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="findProductById" in-map-name="serviceCtx"> + <result-to-field result-name="product"/> + </call-service> + <assert> + <not> + <if-empty field="product"/> + </not> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testCreateProductPrice" short-description="Test create Product Price" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_A"/> + <set field="serviceCtx.productPriceTypeId" value="AVERAGE_COST"/> + <set field="serviceCtx.productPricePurposeId" value="COMPONENT_PRICE"/> + <set field="serviceCtx.productStoreGroupId" value="Test_group"/> + <set field="serviceCtx.currencyUomId" value="USD"/> + <set field="serviceCtx.price" type="BigDecimal" value="50"/> + <set field="serviceCtx.fromDate" type="Timestamp" value="2013-07-04 00:00:00"/> + <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="createProductPrice" in-map-name="serviceCtx"/> + <entity-one entity-name="ProductPrice" value-field="prodPrice"> + <field-map field-name="productId" value="Test_product_A"/> + <field-map field-name="productPriceTypeId" value="AVERAGE_COST"/> + <field-map field-name="productPricePurposeId" value="COMPONENT_PRICE"/> + <field-map field-name="productStoreGroupId" value="Test_group"/> + <field-map field-name="currencyUomId" value="USD"/> + <field-map field-name="fromDate" value="2013-07-04 00:00:00"/> + </entity-one> + <assert> + <not> + <if-empty field="prodPrice"/> + </not> + <if-compare field="prodPrice.price" operator="equals" value="50"/> + <if-compare field="prodPrice.productPriceTypeId" operator="equals" value="AVERAGE_COST"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testUpdateProductPrice" short-description="Test update Product Price" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_C"/> + <set field="serviceCtx.productPriceTypeId" value="AVERAGE_COST"/> + <set field="serviceCtx.productPricePurposeId" value="COMPONENT_PRICE"/> + <set field="serviceCtx.productStoreGroupId" value="Test_group"/> + <set field="serviceCtx.currencyUomId" value="USD"/> + <set field="serviceCtx.price" type="BigDecimal" value="50"/> + <set field="serviceCtx.fromDate" type="Timestamp" value="2013-07-04 00:00:00"/> + <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="updateProductPrice" in-map-name="serviceCtx"> + <result-to-field result-name="fromDate"/> + </call-service> + <entity-one entity-name="ProductPrice" value-field="price"> + <field-map field-name="productId" value="Test_product_C"/> + <field-map field-name="productPriceTypeId" value="AVERAGE_COST"/> + <field-map field-name="productPricePurposeId" value="COMPONENT_PRICE"/> + <field-map field-name="productStoreGroupId" value="Test_group"/> + <field-map field-name="currencyUomId" value="USD"/> + <field-map field-name="fromDate" value="2013-07-04 00:00:00"/> + </entity-one> + <assert> + <not> + <if-empty field="price"/> + </not> + <if-compare field="price.price" operator="equals" value="50"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testDeleteProductPrice" short-description="Test delete Product Price" login-required="false"> + <set field="serviceCtx.productId" value="Test_product_C"/> + <set field="serviceCtx.productPriceTypeId" value="AVERAGE_COST"/> + <set field="serviceCtx.productPricePurposeId" value="COMPONENT_PRICE"/> + <set field="serviceCtx.productStoreGroupId" value="Test_group"/> + <set field="serviceCtx.currencyUomId" value="USD"/> + <set field="serviceCtx.fromDate" type="Timestamp" value="2013-07-04 00:00:00"/> + <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="deleteProductPrice" in-map-name="serviceCtx"> + <result-to-field result-name="fromDate"/> + </call-service> + <entity-one entity-name="ProductPrice" value-field="price"> + <field-map field-name="productId" value="Test_product_C"/> + <field-map field-name="productPriceTypeId" value="AVERAGE_COST"/> + <field-map field-name="productPricePurposeId" value="COMPONENT_PRICE"/> + <field-map field-name="productStoreGroupId" value="Test_group"/> + <field-map field-name="currencyUomId" value="USD"/> + <field-map field-name="fromDate" value="2013-07-04 00:00:00"/> + </entity-one> + <assert> + <if-empty field="price"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testCreateProductCategory" short-description="Test create Product Category" login-required="false"> + <set field="serviceCtx.productCategoryId" value="TEST_CATEGORY"/> + <set field="serviceCtx.productCategoryTypeId" value="USAGE_CATEGORY"/> + <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="createProductCategory" in-map-name="serviceCtx"> + <result-to-field result-name="productCategoryId"/> + </call-service> + <entity-one entity-name="ProductCategory" value-field="productCategory"/> + <assert> + <not> + <if-empty field="productCategory"/> + </not> + <if-compare field="productCategory.productCategoryTypeId" operator="equals" value="USAGE_CATEGORY"/> + </assert> + <check-errors/> + </simple-method> + +</simple-methods> \ No newline at end of file Propchange: ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/minilang/product/test/ProductTest.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/applications/product/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/ofbiz-component.xml?rev=1767977&r1=1767976&r2=1767977&view=diff ============================================================================== --- ofbiz/trunk/applications/product/ofbiz-component.xml (original) +++ ofbiz/trunk/applications/product/ofbiz-component.xml Thu Nov 3 21:16:42 2016 @@ -75,6 +75,7 @@ under the License. <test-suite loader="main" location="testdef/CostTests.xml"/> <test-suite loader="main" location="testdef/GroupOrderTest.xml"/> <test-suite loader="main" location="testdef/ProductTagTest.xml"/> + <test-suite loader="main" location="testdef/ProductTest.xml"/> <webapp name="catalog" title="Catalog" Added: ofbiz/trunk/applications/product/testdef/ProductTest.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/testdef/ProductTest.xml?rev=1767977&view=auto ============================================================================== --- ofbiz/trunk/applications/product/testdef/ProductTest.xml (added) +++ ofbiz/trunk/applications/product/testdef/ProductTest.xml Thu Nov 3 21:16:42 2016 @@ -0,0 +1,33 @@ +<?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="producttests" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd"> + + <test-case case-name="loadProductTestData"> + <entity-xml action="load" entity-xml-url="component://product/testdef/data/ProductTestData.xml"/> + </test-case> + + <test-case case-name="producttest"> + <simple-method-test location="component://product/minilang/product/test/ProductTest.xml"/> + </test-case> + +</test-suite> \ No newline at end of file Propchange: ofbiz/trunk/applications/product/testdef/ProductTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/testdef/ProductTest.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/testdef/ProductTest.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml?rev=1767977&view=auto ============================================================================== --- ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml (added) +++ ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml Thu Nov 3 21:16:42 2016 @@ -0,0 +1,33 @@ +<?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> + <ProductType productTypeId="Test_type"/> + <Product productId="Test_product_A" productTypeId="Test_type" productName="Test_name_A" description="This is original description"/> + <Product productId="Test_product_B" productTypeId="Test_type" productName="Test_name_C" description="This is product description"/> + <ProductFeature productFeatureId="Test_feature" description="Feature for testing purpose"/> + <Product productId="Test_product_C" productTypeId="Test_type" description="description"/> + <ProductStore productStoreId="Test_store"/> + <ProductReview productReviewId="Test_review" productId="Test_product_C" productStoreId="Test_store" productRating="1.000000" productReview="Original review"/> + <ProductStoreGroup productStoreGroupId="Test_group" productStoreGroupName="test group"/> + <ProductPrice productId="Test_product_C" productPriceTypeId="AVERAGE_COST" productPricePurposeId="COMPONENT_PRICE" currencyUomId="USD" productStoreGroupId="Test_group" fromDate="2013-07-04 00:00:00" price="20"/> + <ProductCategory productCategoryId="Test_category_A" productCategoryTypeId="USAGE_CATEGORY" longDescription="Original description" categoryName="Original_name"/> + <ProductCategory productCategoryId="Test_category_B" productCategoryTypeId="USAGE_CATEGORY" longDescription="Category description" categoryName="Category_name"/> +</entity-engine-xml> \ No newline at end of file Propchange: ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/product/testdef/data/ProductTestData.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml |
Free forum by Nabble | Edit this page |