details:   https://code.openbravo.com/erp/devel/pi/rev/cf5f7b83f80e
changeset: 35122:cf5f7b83f80e
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Mon Nov 26 19:31:15 2018 +0100
summary:   related to issue 39660: add test case

diffstat:

 src-test/src/org/openbravo/test/dal/OBContextTest.java |  25 +++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r a7bf0aacd4be -r cf5f7b83f80e 
src-test/src/org/openbravo/test/dal/OBContextTest.java
--- a/src-test/src/org/openbravo/test/dal/OBContextTest.java    Mon Nov 26 
17:04:23 2018 +0100
+++ b/src-test/src/org/openbravo/test/dal/OBContextTest.java    Mon Nov 26 
19:31:15 2018 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2018 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -21,6 +21,7 @@
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasItem;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
@@ -37,6 +38,8 @@
 
 import org.junit.Test;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.test.base.OBBaseTest;
 
 /**
@@ -66,6 +69,26 @@
   }
 
   /**
+   * Tests that inactive readable organizations are included in the list of 
readable organization by
+   * the role.
+   */
+  @Test
+  public void testReadableDeactivatedOrg() {
+    try {
+      Organization deactivatedOrg = 
OBDal.getInstance().get(Organization.class, TEST_US_ORG_ID);
+      deactivatedOrg.setActive(false);
+      OBDal.getInstance().flush();
+
+      OBContext.setOBContext("100", "0", TEST_CLIENT_ID, TEST_ORG_ID, "en_US");
+      
assertThat(Arrays.asList(OBContext.getOBContext().getReadableOrganizations()),
+          hasItem(TEST_US_ORG_ID));
+    } finally {
+      // Do not persist change in organization active flag
+      OBDal.getInstance().rollbackAndClose();
+    }
+  }
+
+  /**
    * Tests if the {@link OBContext#setAdminMode()} and {@link 
OBContext#restorePreviousMode()} work
    * correctly if the same OBContext is used by multiple threads. This is 
possible in case of
    * simultaneous ajax requests.


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to