src-test/src/org/openbravo/test/views/GCSequenceNumberTests.java
changeset 33779 ad665ee3f59e
parent 28222 ec1d815ecbe2
child 33788 d28ede862e61
equal deleted inserted replaced
33778:83a89e5a2543 33779:ad665ee3f59e
    17  ************************************************************************
    17  ************************************************************************
    18  */
    18  */
    19 
    19 
    20 package org.openbravo.test.views;
    20 package org.openbravo.test.views;
    21 
    21 
       
    22 import static org.hamcrest.CoreMatchers.is;
    22 import static org.hamcrest.Matchers.containsString;
    23 import static org.hamcrest.Matchers.containsString;
       
    24 import static org.hibernate.criterion.Restrictions.in;
       
    25 import static org.hibernate.criterion.Restrictions.not;
    23 import static org.junit.Assert.assertThat;
    26 import static org.junit.Assert.assertThat;
       
    27 import static org.junit.Assume.assumeThat;
       
    28 
       
    29 import java.util.Arrays;
       
    30 import java.util.List;
    24 
    31 
    25 import org.codehaus.jettison.json.JSONObject;
    32 import org.codehaus.jettison.json.JSONObject;
       
    33 import org.junit.Before;
    26 import org.junit.Test;
    34 import org.junit.Test;
    27 import org.openbravo.base.provider.OBProvider;
    35 import org.openbravo.base.provider.OBProvider;
       
    36 import org.openbravo.client.application.GCSystem;
    28 import org.openbravo.client.application.GCTab;
    37 import org.openbravo.client.application.GCTab;
    29 import org.openbravo.client.application.window.OBViewUtil;
    38 import org.openbravo.client.application.window.OBViewUtil;
    30 import org.openbravo.dal.core.OBContext;
    39 import org.openbravo.dal.core.OBContext;
       
    40 import org.openbravo.dal.service.OBCriteria;
    31 import org.openbravo.dal.service.OBDal;
    41 import org.openbravo.dal.service.OBDal;
    32 import org.openbravo.model.ad.system.Client;
    42 import org.openbravo.model.ad.system.Client;
    33 import org.openbravo.model.ad.ui.Tab;
    43 import org.openbravo.model.ad.ui.Tab;
    34 import org.openbravo.model.common.enterprise.Organization;
    44 import org.openbravo.model.common.enterprise.Organization;
    35 import org.openbravo.test.base.OBBaseTest;
    45 import org.openbravo.test.base.OBBaseTest;
    50   private static final String CAN_FILTER_TRUE = "\"canFilter\":true";
    60   private static final String CAN_FILTER_TRUE = "\"canFilter\":true";
    51   private static final String YES = "Y";
    61   private static final String YES = "Y";
    52   private static final String NO = "N";
    62   private static final String NO = "N";
    53   private static final long LOW_SEQUENCE_NUMBER = 10;
    63   private static final long LOW_SEQUENCE_NUMBER = 10;
    54   private static final long HIGH_SEQUENCE_NUMBER = 20;
    64   private static final long HIGH_SEQUENCE_NUMBER = 20;
       
    65   private static final List<String> CORE_DEFAULT_GRID_CONFIGS = Arrays.asList(
       
    66       "4701BC23719C41FAA422305FCDBBAF85", "FDA9AFD8D7504E18A220EFC01F5D28D3");
       
    67 
       
    68   /**
       
    69    * Execute these test cases only if there is no custom grid config as it could make unstable
       
    70    * results
       
    71    */
       
    72   @Before
       
    73   public void shouldExecuteOnlyIfThereIsNoGridConfig() {
       
    74     OBContext.setAdminMode(false);
       
    75     try {
       
    76       OBCriteria<GCSystem> systemGridConfig = OBDal.getInstance().createCriteria(GCSystem.class);
       
    77       OBCriteria<GCTab> tabGridConfig = OBDal.getInstance().createCriteria(GCTab.class);
       
    78       tabGridConfig.add(not(in(GCTab.PROPERTY_ID, CORE_DEFAULT_GRID_CONFIGS)));
       
    79       assumeThat("Number of custom grid configs", systemGridConfig.count() + tabGridConfig.count(),
       
    80           is(0));
       
    81     } finally {
       
    82       OBContext.restorePreviousMode();
       
    83     }
       
    84   }
    55 
    85 
    56   /**
    86   /**
    57    * If different sequence number is set for the same tab, the expected behavior is that the
    87    * If different sequence number is set for the same tab, the expected behavior is that the
    58    * configuration set in the record with the highest sequence number be applied.
    88    * configuration set in the record with the highest sequence number be applied.
    59    */
    89    */