related to bug 36628: can't update organization if entity has computed columns
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 09 Aug 2017 15:24:46 +0200
changeset 32551 e6738814dcbe
parent 32550 31583e78ae29
child 32552 79642582d449
related to bug 36628: can't update organization if entity has computed columns

Added test case
src-test/src/org/openbravo/test/security/EntityAccessTest.java
--- a/src-test/src/org/openbravo/test/security/EntityAccessTest.java	Wed Aug 09 11:02:37 2017 +0530
+++ b/src-test/src/org/openbravo/test/security/EntityAccessTest.java	Wed Aug 09 15:24:46 2017 +0200
@@ -38,9 +38,12 @@
 import org.openbravo.dal.security.EntityAccessChecker;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.currency.CurrencyTrl;
-import org.openbravo.test.base.OBBaseTest;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.enterprise.Warehouse;
+import org.openbravo.model.common.order.Order;
 
 /**
  * Tests access on the basis of window and table definitions. Also tests derived read access.
@@ -54,7 +57,7 @@
  */
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class EntityAccessTest extends OBBaseTest {
+public class EntityAccessTest extends CrossOrganizationReference {
 
   private static final Logger log = Logger.getLogger(EntityAccessTest.class);
 
@@ -212,4 +215,21 @@
     assertEquals(1, cs.size());
     OBDal.getInstance().remove(cs.get(0));
   }
+
+  /** Covers issue #36628: it was not possible to update organization if entity had computed columns */
+  @Test
+  public void changeOrgIsAllowedHavingComputedColumns() {
+    setTestAdminContext();
+    Order order = createOrder(SPAIN_ORG);
+    String orderId = order.getId();
+
+    // reload it from DB so that computed columns property is not null
+    OBDal.getInstance().getSession().evict(order);
+    order = OBDal.getInstance().get(Order.class, orderId);
+
+    order.setOrganization(OBDal.getInstance().getProxy(Organization.class, USA_ORG));
+    order.setWarehouse(OBDal.getInstance().getProxy(Warehouse.class, USA_WAREHOUSE));
+    order.setBusinessPartner(OBDal.getInstance().getProxy(BusinessPartner.class, USA_BP));
+    OBDal.getInstance().flush();
+  }
 }
\ No newline at end of file