[view] don't assume core is in dev to run test
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Aug 2018 10:18:51 +0200
changeset 35069 b3630a7f37c9
parent 35068 87f38633756b
child 35070 084e4c366d84
[view] don't assume core is in dev to run test
src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java
--- a/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Mon Aug 06 09:04:48 2018 +0200
+++ b/src-test/src/org/openbravo/test/views/SortingFilteringGridConfiguration.java	Mon Aug 06 10:18:51 2018 +0200
@@ -29,6 +29,7 @@
 import java.util.Collection;
 
 import org.codehaus.jettison.json.JSONObject;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,6 +42,7 @@
 import org.openbravo.client.application.window.OBViewUtil;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.module.Module;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
@@ -54,6 +56,8 @@
 @RunWith(Parameterized.class)
 public class SortingFilteringGridConfiguration extends GridConfigurationTest {
 
+  private static Boolean coreWasInDevelopment;
+
   /**
    * Execute these test cases only if there is no custom grid config as it could make unstable
    * results
@@ -61,6 +65,34 @@
   @BeforeClass
   public static void shouldExecuteOnlyIfThereIsNoGridConfig() {
     assumeThat("Number of custom grid configs", getNumberOfGridConfigurations(), is(0));
+
+    OBContext.setAdminMode(true);
+    try {
+      Module core = OBDal.getInstance().get(Module.class, "0");
+      coreWasInDevelopment = core.isInDevelopment();
+      if (!coreWasInDevelopment) {
+        core.setInDevelopment(true);
+        OBDal.getInstance().commitAndClose();
+      }
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  @AfterClass
+  public static void cleanUp() {
+    if (coreWasInDevelopment) {
+      return;
+    }
+    OBContext.setAdminMode(true);
+    try {
+      Module core = OBDal.getInstance().get(Module.class, "0");
+      core.setInDevelopment(coreWasInDevelopment);
+      OBDal.getInstance().commitAndClose();
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+
   }
 
   private enum ColumnLevel {