svn commit: r603777 - in /ofbiz/trunk/applications/order: ofbiz-component.xml src/org/ofbiz/order/test/PurchaseOrderTest.java testdef/ testdef/OrderTest.xml

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

svn commit: r603777 - in /ofbiz/trunk/applications/order: ofbiz-component.xml src/org/ofbiz/order/test/PurchaseOrderTest.java testdef/ testdef/OrderTest.xml

mrisaliti
Author: mrisaliti
Date: Wed Dec 12 15:28:12 2007
New Revision: 603777

URL: http://svn.apache.org/viewvc?rev=603777&view=rev
Log:
I have review and modified the patch from Shubham Goyal about JUnit test case for Creating a Purchase Order (OFBIZ-1464).

Added:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java   (with props)
    ofbiz/trunk/applications/order/testdef/
    ofbiz/trunk/applications/order/testdef/OrderTest.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=603777&r1=603776&r2=603777&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/order/ofbiz-component.xml Wed Dec 12 15:28:12 2007
@@ -46,6 +46,9 @@
     <service-resource type="model" loader="main" location="servicedef/services_opportunity.xml"/>
     <service-resource type="model" loader="main" location="servicedef/services_upgrade.xml"/>
     <service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
+    
+    <test-suite loader="main" location="testdef/OrderTest.xml"/>
+    
     <webapp name="order"
         title="Order"
         server="default-server"

Added: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java?rev=603777&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java (added)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java Wed Dec 12 15:28:12 2007
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.ofbiz.order.test;
+
+import junit.framework.TestCase;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.base.util.UtilMisc;
+import java.util.List;
+import java.util.Map;
+
+import javolution.util.FastMap;
+import javolution.util.FastList;
+
+public class PurchaseOrderTest extends TestCase {
+    
+    protected LocalDispatcher dispatcher = null;
+    protected GenericDelegator delegator = null;
+    protected GenericValue userLogin = null;
+    protected String orderId = null;
+    protected String statusId = null;
+
+    public PurchaseOrderTest(String name) {
+        super(name);
+    }
+    
+    protected void setUp() throws Exception {
+        delegator = GenericDelegator.getGenericDelegator("test");
+        dispatcher = GenericDispatcher.getLocalDispatcher("test-dispatcher", delegator);
+        userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
+    }
+    
+    protected void tearDown() throws Exception {
+    }
+    
+    public void testCreatePurchaseOrder() throws Exception {
+        Map <String, Object> ctx = FastMap.newInstance();
+        ctx.put("partyId", "Company");
+        ctx.put("orderTypeId", "PURCHASE_ORDER");
+        ctx.put("currencyUom", "USD");
+        ctx.put("productStoreId","9000");
+
+        GenericValue orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00001", "orderItemTypeId", "PRODUCT_ORDER_ITEM", "prodCatalogId", "DemoCatalog", "productId", "GZ-1000", "quantity", new Double(2), "isPromo", "N"));
+        orderItem.set("unitPrice", new Double(1399.5));
+        orderItem.set("unitListPrice", new Double(0));
+        orderItem.set("isModifiedPrice", "N");
+        orderItem.set("statusId", "ITEM_CREATED");
+        List <GenericValue> orderItems = FastList.newInstance();
+        orderItems.add(orderItem);
+        ctx.put("orderItems", orderItems);
+        
+        GenericValue orderContactMech = delegator.makeValue("OrderContactMech", UtilMisc.toMap("contactMechPurposeTypeId", "SHIPPING_LOCATION", "contactMechId", "9000"));
+        List <GenericValue> orderContactMechs = FastList.newInstance();
+        orderContactMechs.add(orderContactMech);
+        ctx.put("orderContactMechs", orderContactMechs);
+        
+        GenericValue orderItemContactMech = delegator.makeValue("OrderItemContactMech", UtilMisc.toMap("contactMechPurposeTypeId", "SHIPPING_LOCATION", "contactMechId", "9000", "orderItemSeqId", "00001"));
+        List <GenericValue> orderItemContactMechs = FastList.newInstance();
+        orderItemContactMechs.add(orderItemContactMech);
+        ctx.put("orderItemContactMechs", orderItemContactMechs);
+        
+        GenericValue orderItemShipGroup = delegator.makeValue("OrderItemShipGroup", UtilMisc.toMap("carrierPartyId", "UPS", "contactMechId", "9000", "isGift", "N", "maySplit", "N", "shipGroupSeqId", "00001", "shipmentMethodTypeId", "NEXT_DAY"));
+        orderItemShipGroup.set("carrierRoleTypeId","CARRIER");
+        List <GenericValue> orderItemShipGroupInfo = FastList.newInstance();
+        orderItemShipGroupInfo.add(orderItemShipGroup);
+        ctx.put("orderItemShipGroupInfo", orderItemShipGroupInfo);
+        
+        List <GenericValue> orderTerms = FastList.newInstance();
+        ctx.put("orderTerms", orderTerms);
+        
+        List <GenericValue> orderAdjustments = FastList.newInstance();
+        ctx.put("orderAdjustments", orderAdjustments);
+        
+        ctx.put("billToCustomerPartyId", "Company");
+        ctx.put("billFromVendorPartyId", "DemoSupplier");
+        ctx.put("shipFromVendorPartyId", "Company");
+        ctx.put("supplierAgentPartyId", "DemoSupplier");
+        ctx.put("userLogin", userLogin);
+
+        Map <String, Object> resp = dispatcher.runSync("storeOrder", ctx);
+        orderId = (String) resp.get("orderId");
+        statusId = (String) resp.get("statusId");
+        assertNotNull(orderId);
+        assertNotNull(statusId);
+    }
+}
\ No newline at end of file

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/PurchaseOrderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/applications/order/testdef/OrderTest.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/testdef/OrderTest.xml?rev=603777&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/testdef/OrderTest.xml (added)
+++ ofbiz/trunk/applications/order/testdef/OrderTest.xml Wed Dec 12 15:28:12 2007
@@ -0,0 +1,27 @@
+<?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="ordertests"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
+    <test-case case-name="purchaseOrder-test">
+        <junit-test-suite class-name="org.ofbiz.order.test.PurchaseOrderTest"/>
+    </test-case>
+</test-suite>
\ No newline at end of file

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

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

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