related to bug 27233: added test case
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 30 Jul 2014 15:33:11 +0200
changeset 24140 687d91cddde8
parent 24139 a496e0ae760c
child 24141 6b960d4ca8bb
related to bug 27233: added test case
src-test/org/openbravo/test/datasource/TestComboDatasource.java
--- a/src-test/org/openbravo/test/datasource/TestComboDatasource.java	Wed Jul 30 15:31:26 2014 +0200
+++ b/src-test/org/openbravo/test/datasource/TestComboDatasource.java	Wed Jul 30 15:33:11 2014 +0200
@@ -35,7 +35,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TestComboDatasource extends BaseDataSourceTestNoDal {
+public class TestComboDatasource extends BaseDataSourceTestDal {
 
   private static final Logger log = LoggerFactory.getLogger(TestComboDatasource.class);
 
@@ -107,6 +107,35 @@
   }
 
   /**
+   * Checks selected value not in 1st page
+   * 
+   * see issue #27233
+   */
+  public void testDefaultNotInFirstPage() throws Exception {
+    String US_ID = "100";
+
+    Map<String, String> params = new HashMap<String, String>();
+    params.put("fieldId", "1005500085"); // BP > Account > Country
+    params.put("_operationType", "fetch");
+    params.put("_startRow", "0");
+    params.put("_endRow", "75");
+    params.put("_currentValue", US_ID); // US
+
+    JSONObject jsonResponse = requestCombo(params);
+    JSONArray data = getData(jsonResponse);
+    assertTrue(getStatus(jsonResponse).equals(
+        String.valueOf(JsonConstants.RPCREQUEST_STATUS_SUCCESS)));
+
+    int totalRows = jsonResponse.getJSONObject("response").getInt("totalRows"); // 78
+    int endRow = jsonResponse.getJSONObject("response").getInt("endRow"); // 76
+    assertTrue("more than one page shoudl be detected", totalRows > endRow + 1);
+    String lastRowId = data.getJSONObject(data.length() - 1).getString("id");
+    assertFalse(
+        "selected record should not be added at the end of 1st page, because it is in a page after it",
+        lastRowId.equals(US_ID));
+  }
+
+  /**
    * Test to check filtering of the record using passed parameter
    * 
    * @throws Exception