details:   https://code.openbravo.com/erp/devel/pi/rev/3d8b217d74c1
changeset: 22895:3d8b217d74c1
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Tue Apr 22 10:15:36 2014 +0200
summary:   related to issue 26317: added test case

diffstat:

 src-test/org/openbravo/test/AllWebserviceTests.java                       |   
2 +
 src-test/org/openbravo/test/datasource/ProductSelectorDataSourceTest.java |  
84 ++++++++++
 2 files changed, 86 insertions(+), 0 deletions(-)

diffs (107 lines):

diff -r bde8cc5b9fd9 -r 3d8b217d74c1 
src-test/org/openbravo/test/AllWebserviceTests.java
--- a/src-test/org/openbravo/test/AllWebserviceTests.java       Tue Apr 22 
09:22:32 2014 +0200
+++ b/src-test/org/openbravo/test/AllWebserviceTests.java       Tue Apr 22 
10:15:36 2014 +0200
@@ -22,6 +22,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.openbravo.test.datasource.ProductSelectorDataSourceTest;
 import org.openbravo.test.datasource.SelectorFieldPropertySelectorDSTest;
 import org.openbravo.test.datasource.TestCSVEncoding;
 import org.openbravo.test.webservice.PerformanceTest;
@@ -46,6 +47,7 @@
     suite.addTestSuite(WSAddRecordWithComputedColumns.class);
     suite.addTestSuite(TestCSVEncoding.class);
     suite.addTestSuite(SelectorFieldPropertySelectorDSTest.class);
+    suite.addTestSuite(ProductSelectorDataSourceTest.class);
 
     // $JUnit-END$
     return suite;
diff -r bde8cc5b9fd9 -r 3d8b217d74c1 
src-test/org/openbravo/test/datasource/ProductSelectorDataSourceTest.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/datasource/ProductSelectorDataSourceTest.java 
Tue Apr 22 10:15:36 2014 +0200
@@ -0,0 +1,84 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2014 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.datasource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * Test Product Complete Selector DataSource
+ * 
+ * @author alostale
+ * 
+ */
+public class ProductSelectorDataSourceTest extends BaseDataSourceTestNoDal {
+
+  /**
+   * Obtains a list of all warehouses from the selector. Test for issue #26317
+   */
+  public void testWarehouseFKDropDown() throws Exception {
+    JSONObject resp = performRequest(false);
+
+    assertEquals("Data should have 4 warehouses", 4, 
resp.getJSONArray("data").length());
+  }
+
+  /**
+   * Obtains a list of filtered warehouses. Test for issue #26317
+   */
+  public void testWarehouseFKDropDownFilter() throws Exception {
+    JSONObject resp = performRequest(true);
+    assertEquals("Data should have 2 warehouses", 2, 
resp.getJSONArray("data").length());
+  }
+
+  private JSONObject performRequest(boolean addFilter) throws Exception {
+    Map<String, String> params = new HashMap<String, String>();
+    params.put("_selectorDefinitionId", "4C8BC3E8E56441F4B8C98C684A0C9212");
+    params.put("filterClass", 
"org.openbravo.userinterface.selector.SelectorDataSourceFilter");
+    params.put("_where", "e.active='Y'");
+    params.put("_sortBy", "_identifier");
+    params.put("_requestType", "Window");
+    params.put("_distinct", "storageBin$warehouse");
+
+    params.put("_operationType", "fetch");
+    params.put("_startRow", "0");
+    params.put("_endRow", "75");
+    params.put("_textMatchStyle", "substring");
+
+    if (addFilter) {
+      JSONObject criteria = new JSONObject();
+      criteria.put("fieldName", "storageBin$warehouse$_identifier");
+      criteria.put("operator", "iContains");
+      criteria.put("value", "US");
+
+      params.put("criteria", criteria.toString());
+    }
+
+    String response = 
doRequest("/org.openbravo.service.datasource/ProductStockView", params, 200,
+        "POST");
+    System.out.println(response);
+    JSONObject resp = new JSONObject(response).getJSONObject("response");
+
+    assertTrue("Response should have data", resp.has("data"));
+    return resp;
+  }
+
+}

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to