[view] fixed GC test compilation
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 03 Aug 2018 16:29:18 +0200
changeset 35065 81d914aee0e4
parent 35064 293e7b1d09b5
child 35066 ca52c98e1149
[view] fixed GC test compilation
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java
src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java
src-test/src/org/openbravo/test/views/GridConfigurationTest.java
src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java
src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Fri Aug 03 16:06:26 2018 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Fri Aug 03 16:29:18 2018 +0200
@@ -217,7 +217,7 @@
     return processViews;
   }
 
-  static Optional<GCSystem> getSystemGridConfig() {
+  public static Optional<GCSystem> getSystemGridConfig() {
     OBCriteria<GCSystem> gcSystemCriteria = OBDal.getInstance().createCriteria(GCSystem.class);
     gcSystemCriteria.addOrder(Order.desc(GCTab.PROPERTY_SEQNO));
     gcSystemCriteria.addOrder(Order.desc(GCTab.PROPERTY_ID));
@@ -225,7 +225,7 @@
     return Optional.ofNullable((GCSystem) gcSystemCriteria.uniqueResult());
   }
 
-  static Map<String, Optional<GCTab>> getTabsGridConfig(Window window) {
+  public static Map<String, Optional<GCTab>> getTabsGridConfig(Window window) {
     // window comes from ADCS, we need to retrieve GC from DB as it might have changed
     OBQuery<GCTab> qGCTab = OBDal.getInstance().createQuery(GCTab.class,
         "as g where g.tab.window = :window");
--- a/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java	Fri Aug 03 16:06:26 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java	Fri Aug 03 16:29:18 2018 +0200
@@ -95,8 +95,9 @@
       firstTab.getOBUIAPPGCTabList().add(gctabSecondRecord);
       OBDal.getInstance().save(gctabSecondRecord);
 
-      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Tab.class, BUSINESS_PARTNER_TAB_ID));
+      Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
 
       assertThat("Grid configuration in business partner tab with filtering enabled:",
           tabConfig.toString(), containsString(CAN_FILTER_TRUE));
@@ -139,10 +140,13 @@
       secondTab.getOBUIAPPGCTabList().add(gctabSecondRecord);
       OBDal.getInstance().save(gctabSecondRecord);
 
-      JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Tab.class, BUSINESS_PARTNER_TAB_ID));
-      JSONObject productTabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance()
-          .get(Tab.class, PRODUCT_TAB_ID));
+      Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
+
+      tab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
+      JSONObject productTabConfig = OBViewUtil.getGridConfigurationSettings(tab,
+          getSystemGridConfig(), getTabGridConfig(tab));
 
       assertThat("Grid configuration in business partner tab with filtering enabled:",
           bpTabConfig.toString(), containsString(CAN_FILTER_TRUE));
@@ -187,10 +191,13 @@
       secondTab.getOBUIAPPGCTabList().add(gctabSecondRecord);
       OBDal.getInstance().save(gctabSecondRecord);
 
-      JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Tab.class, BUSINESS_PARTNER_TAB_ID));
-      JSONObject productTabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance()
-          .get(Tab.class, PRODUCT_TAB_ID));
+      Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
+
+      tab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
+      JSONObject productTabConfig = OBViewUtil.getGridConfigurationSettings(tab,
+          getSystemGridConfig(), getTabGridConfig(tab));
 
       assertThat("Grid configuration in business partner tab with filtering enabled:",
           bpTabConfig.toString(), containsString(CAN_FILTER_TRUE));
--- a/src-test/src/org/openbravo/test/views/GridConfigurationTest.java	Fri Aug 03 16:06:26 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/GridConfigurationTest.java	Fri Aug 03 16:29:18 2018 +0200
@@ -24,12 +24,15 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 
 import org.openbravo.client.application.GCSystem;
 import org.openbravo.client.application.GCTab;
+import org.openbravo.client.application.window.StandardWindowComponent;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.test.base.OBBaseTest;
 
 public class GridConfigurationTest extends OBBaseTest {
@@ -54,4 +57,12 @@
       OBContext.restorePreviousMode();
     }
   }
+
+  protected static Optional<GCSystem> getSystemGridConfig() {
+    return StandardWindowComponent.getSystemGridConfig();
+  }
+
+  protected static Optional<GCTab> getTabGridConfig(Tab tab) {
+    return StandardWindowComponent.getTabsGridConfig(tab.getWindow()).get(tab.getId());
+  }
 }
--- a/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Fri Aug 03 16:06:26 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Fri Aug 03 16:29:18 2018 +0200
@@ -235,8 +235,9 @@
           gctab.getOBUIAPPGCFieldList().add(gcfield);
           OBDal.getInstance().save(gcfield);
         }
-        fieldConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(Field.class,
-            BUSINESS_PARTNER_CATEGORY_FIELD_ID));
+        field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
+        fieldConfig = OBViewUtil.getGridConfigurationSettings(field, getSystemGridConfig(),
+            getTabGridConfig(field.getTab()));
         return fieldConfig.toString();
       } finally {
         OBDal.getInstance().rollbackAndClose();
--- a/src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java	Fri Aug 03 16:06:26 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/ViewGenerationWithDifferentConfigLevelTest.java	Fri Aug 03 16:29:18 2018 +0200
@@ -85,8 +85,9 @@
       OBDal.getInstance().save(gcsystem);
       OBDal.getInstance().flush();
 
-      JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID));
+      Field field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
+      JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
 
       assertThat("Grid configuration at system level with filtering enabled:",
           systemConfig.toString(), containsString(CAN_FILTER_TRUE));
@@ -115,8 +116,9 @@
       tab.getOBUIAPPGCTabList().add(gctab);
       OBDal.getInstance().save(gctab);
 
-      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Tab.class, BUSINESS_PARTNER_TAB_ID));
+      tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
 
       assertThat("Grid configuration at tab level with filtering disabled:", tabConfig.toString(),
           containsString(CAN_FILTER_FALSE));
@@ -157,10 +159,14 @@
       tab.getOBUIAPPGCTabList().add(gctab);
       OBDal.getInstance().save(gctab);
 
-      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));
+      tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+
+      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
+
+      Field field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_TAB_CURRENCY_FIELD_ID);
+      JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
 
       assertThat(
           "Grid configuration at system level with sorting enabled and grid configuration at tab level with filtering disabled:",
@@ -201,8 +207,9 @@
       gctab.getOBUIAPPGCFieldList().add(gcfield);
       OBDal.getInstance().save(gcfield);
 
-      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID));
+      Field field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
+      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
 
       assertThat(
           "Grid configuration at field level with sorting enabled for the business partner category field:",
@@ -252,10 +259,13 @@
       gctab.getOBUIAPPGCFieldList().add(gcfield);
       OBDal.getInstance().save(gcfield);
 
-      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID));
-      JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Field.class, BUSINESS_PARTNER_TAB_CURRENCY_FIELD_ID));
+      Field field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
+      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
+
+      field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_TAB_CURRENCY_FIELD_ID);
+      JSONObject systemConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
 
       assertThat(
           "Grid configuration at field level with sorting diabled for the business partner category field, but enabled at system level for any other field:",
@@ -299,10 +309,13 @@
       gctab.getOBUIAPPGCFieldList().add(gcfield);
       OBDal.getInstance().save(gcfield);
 
-      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Tab.class, BUSINESS_PARTNER_TAB_ID));
-      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(OBDal.getInstance().get(
-          Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID));
+      tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      JSONObject tabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
+          getTabGridConfig(tab));
+
+      Field field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
+      JSONObject fieldConfig = OBViewUtil.getGridConfigurationSettings(field,
+          getSystemGridConfig(), getTabGridConfig(field.getTab()));
 
       assertThat(
           "Grid configuration at tab level with filtering disabled for the business partner tab:",