details:   https://code.openbravo.com/erp/devel/pi/rev/ad665ee3f59e
changeset: 33779:ad665ee3f59e
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Tue Apr 10 19:48:23 2018 +0200
summary:   Fixed 38319. Auto-skip grid config junit test if other grid config 
present.

That test creates a specially crated grid config entry and verifies expected
behavior. That indirectly requires no other conflicting grid config present
for the same object (i.e. Business Partner tab). So auto-skip this testcase
if any non-core grid config is found similar to what the other 2 grid config
related tests already do.

diffstat:

 src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java |  30 
++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diffs (56 lines):

diff -r 83a89e5a2543 -r ad665ee3f59e 
src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java
--- a/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java  Fri Apr 
06 09:47:12 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java  Tue Apr 
10 19:48:23 2018 +0200
@@ -19,15 +19,25 @@
 
 package org.openbravo.test.views;
 
+import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.Matchers.containsString;
+import static org.hibernate.criterion.Restrictions.in;
+import static org.hibernate.criterion.Restrictions.not;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
+
+import java.util.Arrays;
+import java.util.List;
 
 import org.codehaus.jettison.json.JSONObject;
+import org.junit.Before;
 import org.junit.Test;
 import org.openbravo.base.provider.OBProvider;
+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.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.ui.Tab;
@@ -52,6 +62,26 @@
   private static final String NO = "N";
   private static final long LOW_SEQUENCE_NUMBER = 10;
   private static final long HIGH_SEQUENCE_NUMBER = 20;
+  private static final List<String> CORE_DEFAULT_GRID_CONFIGS = Arrays.asList(
+      "4701BC23719C41FAA422305FCDBBAF85", "FDA9AFD8D7504E18A220EFC01F5D28D3");
+
+  /**
+   * Execute these test cases only if there is no custom grid config as it 
could make unstable
+   * results
+   */
+  @Before
+  public void shouldExecuteOnlyIfThereIsNoGridConfig() {
+    OBContext.setAdminMode(false);
+    try {
+      OBCriteria<GCSystem> systemGridConfig = 
OBDal.getInstance().createCriteria(GCSystem.class);
+      OBCriteria<GCTab> tabGridConfig = 
OBDal.getInstance().createCriteria(GCTab.class);
+      tabGridConfig.add(not(in(GCTab.PROPERTY_ID, CORE_DEFAULT_GRID_CONFIGS)));
+      assumeThat("Number of custom grid configs", systemGridConfig.count() + 
tabGridConfig.count(),
+          is(0));
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
 
   /**
    * If different sequence number is set for the same tab, the expected 
behavior is that the

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to