details: https://code.openbravo.com/erp/devel/pi/rev/641370759303 changeset: 29456:641370759303 user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Wed May 11 12:28:00 2016 +0200 summary: Related to issue 32912: Test added to check the correct behavior when refresh
When the WHERE_AND_FILTER_CLAUSE parameter was an empty string, the behavior was wrong, it was adding an "and" at the beginning of the where clause and this was not corret. This behavior has been fixed and this test has been added to check that the datasource response is now correct. The parameters used in the datasource of this test are the same paramertes that where used in the datasource of the child tab of the "Price List" window after refreshing the browser. This is to imitate the behavior of refreshing the browser having a child tab opened. The fact of having these parameters, makes that the WHERE_AND_FILTER_CLAUSE parameter is the empty string, so we can now check that the request works fine now. diffstat: src-test/src/org/openbravo/test/AllWebserviceTests.java | 4 +- src-test/src/org/openbravo/test/datasource/EmptyStringWhereAndFilterClauseParameter.java | 72 ++++++++++ 2 files changed, 75 insertions(+), 1 deletions(-) diffs (96 lines): diff -r 3ae4e605e43f -r 641370759303 src-test/src/org/openbravo/test/AllWebserviceTests.java --- a/src-test/src/org/openbravo/test/AllWebserviceTests.java Tue May 10 10:56:40 2016 +0200 +++ b/src-test/src/org/openbravo/test/AllWebserviceTests.java Wed May 11 12:28:00 2016 +0200 @@ -33,6 +33,7 @@ import org.openbravo.test.datasource.TestComboDatasource; import org.openbravo.test.datasource.FetchDSNoActiveEntityObjects; import org.openbravo.test.datasource.TestNoteDatasource; +import org.openbravo.test.datasource.EmptyStringWhereAndFilterClauseParameter; import org.openbravo.test.security.ExplicitCrossOrganizationReference; import org.openbravo.test.datasource.DataSourceSecurity; import org.openbravo.test.webservice.JSONWebServices; @@ -72,6 +73,7 @@ WSWithNoActiveDalObjects.class, // FetchDSNoActiveEntityObjects.class, // ExplicitCrossOrganizationReference.class, // - DataSourceSecurity.class }) + DataSourceSecurity.class, // + EmptyStringWhereAndFilterClauseParameter.class }) public class AllWebserviceTests { } diff -r 3ae4e605e43f -r 641370759303 src-test/src/org/openbravo/test/datasource/EmptyStringWhereAndFilterClauseParameter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-test/src/org/openbravo/test/datasource/EmptyStringWhereAndFilterClauseParameter.java Wed May 11 12:28:00 2016 +0200 @@ -0,0 +1,72 @@ +/* + ************************************************************************* + * 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)2016 Openbravo SLU + * All Rights Reserved. + * Contributor(s): ______________________________________. + ************************************************************************ + */ +package org.openbravo.test.datasource; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.jettison.json.JSONException; +import org.codehaus.jettison.json.JSONObject; +import org.junit.Test; +import org.openbravo.service.json.JsonConstants; + +/** + * This test is for the https://issues.openbravo.com/view.php?id=32912 issue. With these datasource + * parameters, the WHERE_AND_FILTER_CLAUSE parameter is the empty string and that was the case that + * was failing. This test checks that the request to the datasource is correct and the response is + * 0, which is the successful request status. + * + * @author Naroa Iriarte + * + */ +public class EmptyStringWhereAndFilterClauseParameter extends BaseDataSourceTestDal { + private Map<String, String> params; + + public EmptyStringWhereAndFilterClauseParameter() { + params = new HashMap<String, String>(); + params.put("_targetRecordId", "17435FB915B14A93B51F3A6375B12BEE"); + params.put("_filterByParentProperty", "priceList"); + params.put("windowId", "146"); + params.put("tabId", "238"); + params.put("_operationType", "fetch"); + params.put("_startRow", "0"); + params.put("_endRow", "100"); + } + + @Test + public void datasourceRequestStatusShouldBeSuccessful() throws Exception { + String datasourceResponse = getDataSourceResponse(); + JSONObject jsonResponse = new JSONObject(datasourceResponse); + assertThat("The request status should be successful.", getStatus(jsonResponse), + is(String.valueOf(JsonConstants.RPCREQUEST_STATUS_SUCCESS))); + } + + private String getDataSourceResponse() throws Exception { + String response = doRequest("/org.openbravo.service.datasource/" + "PricingPriceListVersion", + params, 200, "POST"); + return response; + } + + private String getStatus(JSONObject jsonResponse) throws JSONException { + return jsonResponse.getJSONObject("response").get("status").toString(); + } +} ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits