[view] fixed GC test cases
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Aug 2018 11:35:02 +0200
changeset 35070 084e4c366d84
parent 35069 b3630a7f37c9
child 35071 813f68aaf192
[view] fixed GC test cases

Properly handle HB session
src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java
src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java
--- a/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java	Mon Aug 06 10:18:51 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java	Mon Aug 06 11:35:02 2018 +0200
@@ -118,6 +118,7 @@
     GCTab gctabSecondRecord = null;
     OBContext.setAdminMode(false);
     try {
+      Tab firstTab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
       gctabFirstRecord = OBProvider.getInstance().get(GCTab.class);
       gctabSecondRecord = OBProvider.getInstance().get(GCTab.class);
       gctabFirstRecord.setClient(OBDal.getInstance().get(Client.class,
@@ -126,20 +127,23 @@
           ZERO_ORGANIZATION));
       gctabFirstRecord.setFilterable(YES);
       gctabFirstRecord.setSeqno(LOW_SEQUENCE_NUMBER);
-      Tab firstTab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      gctabFirstRecord.setTab(firstTab);
       firstTab.getOBUIAPPGCTabList().add(gctabFirstRecord);
       OBDal.getInstance().save(gctabFirstRecord);
 
+      Tab secondTab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
       gctabSecondRecord.setClient(OBDal.getInstance().get(Client.class,
           CLIENT_FOR_GC_SYSTEM_FIELD_TAB));
       gctabSecondRecord.setOrganization(OBDal.getInstance().get(Organization.class,
           ZERO_ORGANIZATION));
       gctabSecondRecord.setFilterable(NO);
       gctabSecondRecord.setSeqno(LOW_SEQUENCE_NUMBER);
-      Tab secondTab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
+      gctabSecondRecord.setTab(secondTab);
       secondTab.getOBUIAPPGCTabList().add(gctabSecondRecord);
       OBDal.getInstance().save(gctabSecondRecord);
 
+      OBDal.getInstance().flush();
+
       Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
       JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
           getTabGridConfig(tab));
@@ -169,6 +173,7 @@
     GCTab gctabSecondRecord = null;
     OBContext.setAdminMode(false);
     try {
+      Tab firstTab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
       gctabFirstRecord = OBProvider.getInstance().get(GCTab.class);
       gctabSecondRecord = OBProvider.getInstance().get(GCTab.class);
       gctabFirstRecord.setClient(OBDal.getInstance().get(Client.class,
@@ -177,20 +182,23 @@
           ZERO_ORGANIZATION));
       gctabFirstRecord.setFilterable(YES);
       gctabFirstRecord.setSeqno(HIGH_SEQUENCE_NUMBER);
-      Tab firstTab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
+      gctabFirstRecord.setTab(firstTab);
       firstTab.getOBUIAPPGCTabList().add(gctabFirstRecord);
       OBDal.getInstance().save(gctabFirstRecord);
 
+      Tab secondTab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
       gctabSecondRecord.setClient(OBDal.getInstance().get(Client.class,
           CLIENT_FOR_GC_SYSTEM_FIELD_TAB));
       gctabSecondRecord.setOrganization(OBDal.getInstance().get(Organization.class,
           ZERO_ORGANIZATION));
       gctabSecondRecord.setFilterable(NO);
       gctabSecondRecord.setSeqno(LOW_SEQUENCE_NUMBER);
-      Tab secondTab = OBDal.getInstance().get(Tab.class, PRODUCT_TAB_ID);
+      gctabSecondRecord.setTab(secondTab);
       secondTab.getOBUIAPPGCTabList().add(gctabSecondRecord);
       OBDal.getInstance().save(gctabSecondRecord);
 
+      OBDal.getInstance().flush();
+
       Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
       JSONObject bpTabConfig = OBViewUtil.getGridConfigurationSettings(tab, getSystemGridConfig(),
           getTabGridConfig(tab));
--- a/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Mon Aug 06 10:18:51 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Mon Aug 06 11:35:02 2018 +0200
@@ -243,17 +243,16 @@
           gcsystem.setSortable(sysLevel.sort);
           gcsystem.setSeqno(10L);
           OBDal.getInstance().save(gcsystem);
-          OBDal.getInstance().flush();
         }
         if (tabLevel != TabLevel.NULL) {
+          Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
           gctab = OBProvider.getInstance().get(GCTab.class);
           gctab.setClient(OBDal.getInstance().get(Client.class, "0"));
           gctab.setOrganization(OBDal.getInstance().get(Organization.class, "0"));
           gctab.setFilterable(tabLevel.filter);
           gctab.setSortable(tabLevel.sort);
           gctab.setSeqno(10L);
-          Tab tab = OBDal.getInstance().get(Tab.class, BUSINESS_PARTNER_TAB_ID);
-          tab.getOBUIAPPGCTabList().add(gctab);
+          gctab.setTab(tab);
           OBDal.getInstance().save(gctab);
         }
         if (fieldLevel != FieldLevel.NULL) {
@@ -264,9 +263,11 @@
           gcfield.setField(field);
           gcfield.setFilterable(fieldLevel.filter);
           gcfield.setSortable(fieldLevel.sort);
+          gcfield.setObuiappGcTab(gctab);
           gctab.getOBUIAPPGCFieldList().add(gcfield);
           OBDal.getInstance().save(gcfield);
         }
+        OBDal.getInstance().flush();
         field = OBDal.getInstance().get(Field.class, BUSINESS_PARTNER_CATEGORY_FIELD_ID);
         fieldConfig = OBViewUtil.getGridConfigurationSettings(field, getSystemGridConfig(),
             getTabGridConfig(field.getTab()));