details: https://code.openbravo.com/erp/devel/pi/rev/b178a4410127 changeset: 28090:b178a4410127 user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Wed Dec 02 13:02:40 2015 +0100 summary: Related with issue 28478: The tests have been improved.
The tests for the issue 28478 have been improved and test class is now in the proper testsuite. diffstat: src-test/src/org/openbravo/test/AllAntTaskTests.java | 6 +- src-test/src/org/openbravo/test/AllTests.java | 6 +- src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java | 274 +++++---- 3 files changed, 148 insertions(+), 138 deletions(-) diffs (truncated from 462 to 300 lines): diff -r d17c2694db1c -r b178a4410127 src-test/src/org/openbravo/test/AllAntTaskTests.java --- a/src-test/src/org/openbravo/test/AllAntTaskTests.java Wed Dec 02 11:13:07 2015 +0100 +++ b/src-test/src/org/openbravo/test/AllAntTaskTests.java Wed Dec 02 13:02:40 2015 +0100 @@ -84,6 +84,7 @@ import org.openbravo.test.system.SystemValidatorTest; import org.openbravo.test.system.TestInfrastructure; import org.openbravo.test.taxes.TaxesTest; +import org.openbravo.test.views.ViewGenerationWithDifferentConfigLevelTest; import org.openbravo.test.xml.ClientExportImportTest; import org.openbravo.test.xml.DatasetExportTest; import org.openbravo.test.xml.DefaultsDataset; @@ -209,7 +210,10 @@ RoleInheritanceTestSuite.class, // // db - SqlCallableStatement.class + SqlCallableStatement.class, + + // grid configuration + ViewGenerationWithDifferentConfigLevelTest.class }) public class AllAntTaskTests { diff -r d17c2694db1c -r b178a4410127 src-test/src/org/openbravo/test/AllTests.java --- a/src-test/src/org/openbravo/test/AllTests.java Wed Dec 02 11:13:07 2015 +0100 +++ b/src-test/src/org/openbravo/test/AllTests.java Wed Dec 02 13:02:40 2015 +0100 @@ -48,7 +48,6 @@ import org.openbravo.test.security.AllowedOrganizationsTest; import org.openbravo.test.security.EntityAccessTest; import org.openbravo.test.security.WritableReadableOrganizationClientTest; -import org.openbravo.test.views.ViewGenerationWithDifferentConfigLevelTest; import org.openbravo.test.xml.DefaultsDataset; import org.openbravo.test.xml.EntityXMLImportTestBusinessObject; import org.openbravo.test.xml.EntityXMLImportTestReference; @@ -104,9 +103,8 @@ ClassicSelectorTest.class, // cdi - CdiInfrastructure.class, + CdiInfrastructure.class - // view generation - ViewGenerationWithDifferentConfigLevelTest.class }) +}) public class AllTests { } diff -r d17c2694db1c -r b178a4410127 src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java --- a/src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java Wed Dec 02 11:13:07 2015 +0100 +++ b/src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java Wed Dec 02 13:02:40 2015 +0100 @@ -19,17 +19,16 @@ package org.openbravo.test.views; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; -import java.util.HashMap; -import java.util.Map; - +import org.codehaus.jettison.json.JSONObject; import org.junit.Test; import org.openbravo.base.provider.OBProvider; import org.openbravo.client.application.GCField; import org.openbravo.client.application.GCSystem; import org.openbravo.client.application.GCTab; +import org.openbravo.client.application.window.OBViewUtil; import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; import org.openbravo.model.ad.system.Client; @@ -39,252 +38,261 @@ import org.openbravo.test.datasource.BaseDataSourceTestDal; /** - * Test cases for checking the correct generation of the views, with the different configurations in - * tab, field and in system level. + * Test cases for check if the correct configurations are set, with the different grid + * configurations in tab, field and in system level. * * @author NaroaIriarte * */ public class ViewGenerationWithDifferentConfigLevelTest extends BaseDataSourceTestDal { - private static final String BUSINESS_PARTNER_WINDOW_ID = "_123"; private static final String CLIENT_FOR_GC_SYSTEM_FIELD_TAB = "0"; private static final String ZERO_ORGANIZATION = "0"; private static final String BUSINESS_PARTNER_TAB_ID = "220"; private static final String BUSINESS_PARTNER_CATEGORY_FIELD_ID = "3955"; + private static final String BUSINESS_PARTNER_TAB_CURRENCY_FIELD_ID = "0C6C5DF6CB874BC5A77C946231AA4E07"; + private static final String CAN_SORT_FALSE = "\"canSort\":false"; + private static final String CAN_SORT_TRUE = "\"canSort\":true"; + private static final String CAN_FILTER_FALSE = "\"canFilter\":false"; + private static final String CAN_FILTER_TRUE = "\"canFilter\":true"; /** - * Test to ensure that the the view retrieves the expected values, having only grid configuration - * in System level. In the configuration, the "by default allow filtering" checkbox is checked, - * so, the expression "canFilter: true" must be found in the view. - * - * @throws Exception + * Having only grid configuration in System level. In the configuration, the + * "by default allow filtering" checkbox is checked, so, the expression "canFilter: true" must be + * found. */ @Test public void gridConfigurationSystemLevel() throws Exception { + GCSystem gcsystem = null; OBContext.setAdminMode(false); try { - GCSystem gcsystem = OBProvider.getInstance().get(GCSystem.class); + gcsystem = OBProvider.getInstance().get(GCSystem.class); gcsystem.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gcsystem.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); gcsystem.setFilterable(true); OBDal.getInstance().save(gcsystem); - OBDal.getInstance().commitAndClose(); - String theResponse = getViewResponse(); - OBDal.getInstance().remove(gcsystem); - OBDal.getInstance().commitAndClose(); - boolean existsCanFilter; - existsCanFilter = theResponse.contains("canFilter: true"); - assertThat(existsCanFilter, is(true)); + OBDal.getInstance().flush(); + + JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get( + Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID)); + + assertThat("Grid configuration at system level with filtering enabled:", + systemConfig.toString(), containsString(CAN_FILTER_TRUE)); } finally { - OBDal.getInstance().commitAndClose(); + OBDal.getInstance().rollbackAndClose(); OBContext.restorePreviousMode(); } } /** - * Test to ensure that the the view retrieves the expected values, having only grid configuration - * at tab level. The "allow filtering" property in the grid configuration at tab level, in the - * Businsess Partner tab has been set to "No". So this test checks that the "canFiler: false" - * expression is present in the view. + * Having only grid configuration at tab level. The "allow filtering" property in the grid + * configuration at tab level, in the Business Partner tab has been set to "No". So this test + * checks that the "canFilter: false" expression is present. */ @Test public void gridConfigurationTabLevel() throws Exception { + GCTab gctab = null; OBContext.setAdminMode(false); try { - GCTab gctab = OBProvider.getInstance().get(GCTab.class); + gctab = OBProvider.getInstance().get(GCTab.class); gctab.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gctab.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); gctab.setFilterable("N"); - gctab.setTab(OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID)); + Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID); + tab.getOBUIAPPGCTabList().add(gctab); OBDal.getInstance().save(gctab); - OBDal.getInstance().commitAndClose(); - String theResponse = getViewResponse(); - OBDal.getInstance().remove(gctab); - OBDal.getInstance().commitAndClose(); - boolean existsCanFilter; - existsCanFilter = theResponse.contains("canFilter: false"); - assertThat(existsCanFilter, is(true)); + + JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get( + Tab.class, BUSINESS_PARTNER_TAB_ID)); + + assertThat("Grid configuration at tab level with filtering disabled:", tabConfig.toString(), + containsString(CAN_FILTER_FALSE)); } finally { - OBDal.getInstance().commitAndClose(); + OBDal.getInstance().rollbackAndClose(); OBContext.restorePreviousMode(); } } /** - * Test to ensure that the the view retrieves the expected values, having grid configuration at - * System and tab level. The "allow filtering" property in the grid configuration at tab level, in - * the Business Partner tab has been set to "No". So this test checks that the "canFiler: false" - * expression is present in the view. Also, the "allow sorting" property has been set to default, - * so, the taken value is going to be the one set in the grid configuration at system level, which - * is true. The test checks that the "canSort: true" expression is present in the view. + * Having grid configuration at System and tab level. The "allow filtering" property in the grid + * configuration at tab level, in the Business Partner tab has been set to "No". So this test + * checks that the "canFilter: false" expression is present. Also, the "allow sorting" property + * has been set to default, so, the taken value is going to be the one set in the grid + * configuration at system level, which is true. The test checks that the "canSort: true" + * expression is present. */ @Test public void gridConfigurationTabAndSystemLevel() throws Exception { + GCSystem gcsystem = null; + GCTab gctab = null; OBContext.setAdminMode(false); try { - GCSystem gcsystem = OBProvider.getInstance().get(GCSystem.class); + gcsystem = OBProvider.getInstance().get(GCSystem.class); + gctab = OBProvider.getInstance().get(GCTab.class); gcsystem.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gcsystem.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); gcsystem.setSortable(true); OBDal.getInstance().save(gcsystem); - OBDal.getInstance().commitAndClose(); - GCTab gctab = OBProvider.getInstance().get(GCTab.class); + OBDal.getInstance().flush(); + gctab.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gctab.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); gctab.setFilterable("N"); - gctab.setTab(OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID)); + Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID); + tab.getOBUIAPPGCTabList().add(gctab); OBDal.getInstance().save(gctab); - OBDal.getInstance().commitAndClose(); - String theResponse = getViewResponse(); - OBDal.getInstance().remove(gctab); - OBDal.getInstance().commitAndClose(); - OBDal.getInstance().remove(gcsystem); - OBDal.getInstance().commitAndClose(); - boolean existsCanFilter, existsCanSort; - existsCanFilter = theResponse.contains("canFilter: false"); - existsCanSort = theResponse.contains("canSort: true"); - assertThat(existsCanFilter, is(true)); - assertThat(existsCanSort, is(true)); + + JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get( + Tab.class, BUSINESS_PARTNER_TAB_ID)); + JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get( + Field.class, BUSINESS_PARTNER_TAB_CURRENCY_FIELD_ID)); + + assertThat( + "Grid configuration at system level with sorting enabled and grid configuration at tab level with filtering disabled:", + tabConfig.toString(), containsString(CAN_FILTER_FALSE)); + assertThat( + "Grid configuration at field level with sorting diabled for the business partner category field, but enabled at system level for any other field:", + systemConfig.toString(), containsString(CAN_SORT_TRUE)); } finally { - OBDal.getInstance().commitAndClose(); + OBDal.getInstance().rollbackAndClose(); OBContext.restorePreviousMode(); } } /** - * Test to ensure that the the view retrieves the expected values, having only grid configuration - * at field level. The Business Partner category field of business Partner has the property allow - * sorting set to "Yes", so the view must have "canSort: true" expression. + * Having only grid configuration at field level. The Business Partner category field of business + * Partner has the property allow sorting set to "Yes", so the view must have "canSort: true" + * expression. */ @Test public void gridConfigurationFieldLevel() throws Exception { + GCTab gctab = null; + GCField gcfield = null; OBContext.setAdminMode(false); try { - GCTab gctab = OBProvider.getInstance().get(GCTab.class); + gctab = OBProvider.getInstance().get(GCTab.class); + gcfield = OBProvider.getInstance().get(GCField.class); gctab.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gctab.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); - gctab.setTab(OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID)); + Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID); + tab.getOBUIAPPGCTabList().add(gctab); OBDal.getInstance().save(gctab); - OBDal.getInstance().commitAndClose(); - GCField gcfield = OBProvider.getInstance().get(GCField.class); + gcfield.setClient(OBDal.getInstance().get(Client.class, CLIENT_FOR_GC_SYSTEM_FIELD_TAB)); gcfield.setOrganization(OBDal.getInstance().get(Organization.class, ZERO_ORGANIZATION)); gcfield.setField(OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID)); gcfield.setSortable("Y"); - gcfield.setObuiappGcTab(gctab); + gctab.getOBUIAPPGCFieldList().add(gcfield); OBDal.getInstance().save(gcfield); - OBDal.getInstance().commitAndClose(); - String theResponse = getViewResponse(); - OBDal.getInstance().remove(gcfield); - OBDal.getInstance().commitAndClose(); - OBDal.getInstance().remove(gctab); - OBDal.getInstance().commitAndClose(); - boolean existsCanSort; - existsCanSort = theResponse.contains("canSort: true"); - assertThat(existsCanSort, is(true)); + + JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get( + Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID)); + + assertThat( + "Grid configuration at field level with sorting enabled for the business partner category field:", + fieldConfig.toString(), containsString(CAN_SORT_TRUE)); + } finally { - OBDal.getInstance().commitAndClose(); + OBDal.getInstance().rollbackAndClose(); ------------------------------------------------------------------------------ Go from Idea to Many App Stores Faster with Intel(R) XDK Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits