Related to issue 33650: code review improvements
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Fri, 27 Apr 2018 12:20:39 +0200
changeset 33896 535fbcf42211
parent 33895 d4e39005ae0e
child 33897 ceaf52d36601
Related to issue 33650: code review improvements
Improvements in JUnit tests:
Avoid duplication of code
Remove useless javadoc or comments
Reorganize methods
Remove useless log
Improve asserts
Renamed some classes
Reduced classes and methods visibility where possible
src-test/src/org/openbravo/test/AllAntTaskTests.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoConstants.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoCornerCaseOrg.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoCornerCaseOrgTest.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoSetReadyTest.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoTest.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoTestSuite.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoUtility.java
src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistOrgInfoComplexOrgTreeTest.java
--- a/src-test/src/org/openbravo/test/AllAntTaskTests.java	Fri Apr 27 10:59:04 2018 +0200
+++ b/src-test/src/org/openbravo/test/AllAntTaskTests.java	Fri Apr 27 12:20:39 2018 +0200
@@ -69,7 +69,7 @@
 import org.openbravo.test.db.model.functions.SqlCallableStatement;
 import org.openbravo.test.expression.EvaluationTest;
 import org.openbravo.test.expression.OBBindingsTest;
-import org.openbravo.test.generalsetup.enterprise.organization.ADOrgPersistInfoTest;
+import org.openbravo.test.generalsetup.enterprise.organization.ADOrgPersistInfoTestSuite;
 import org.openbravo.test.inventoryStatus.InventoryStatusTest;
 import org.openbravo.test.materialMgmt.iscompletelyinvoicedshipment.IsCompletelyInvoicedShipment;
 import org.openbravo.test.model.ClassLoaderTest;
@@ -298,7 +298,7 @@
     ReferencedInventoryTestSuite.class,
 
     // AD_Org Persist Information
-    ADOrgPersistInfoTest.class
+    ADOrgPersistInfoTestSuite.class
 
 })
 public class AllAntTaskTests {
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoConstants.java	Fri Apr 27 10:59:04 2018 +0200
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoConstants.java	Fri Apr 27 12:20:39 2018 +0200
@@ -18,103 +18,40 @@
  */
 package org.openbravo.test.generalsetup.enterprise.organization;
 
-public class ADOrgPersistInfoConstants {
-
-  /**
-   * Openbravo user
-   */
+class ADOrgPersistInfoConstants {
   final static String OPENBRAVO_USER_ID = "100";
 
-  /**
-   * F&B International Group Admin Role
-   */
   final static String FB_GROUP_ADMIN_ROLE_ID = "42D0EEB1C66F497A90DD526DC597E6F0";
-
-  /**
-   * QA Admin Role
-   */
   final static String QA_TESTING_ADMIN_ROLE_ID = "4028E6C72959682B01295A071429011E";
 
-  /**
-   * Organization Type: 0 - Organization 2- Generic
-   */
   final static String ORGTYPE_ORGANIZATION = "0";
   final static String ORGTYPE_GENERIC = "2";
   final static String ORGTYPE_LEGALWITHACCOUNTING = "1";
   final static String ORGTYPE_LEGALWITHOUTACCOUNTING = "3";
 
-  /**
-   * System Client *
-   */
-
   final static String CLIENT_0 = "0";
-  /**
-   * All Organization *
-   */
-  final static String ORG_0 = "0";
-  /**
-   * QA Testing Client
-   */
   final static String CLIENT_QA = "4028E6C72959682B01295A070852010D";
-
-  /**
-   * QA Main Organization
-   */
-  final static String ORG_QA_MAIN = "43D590B4814049C6B85C6545E8264E37";
-
-  /**
-   * QA Spain Organization
-   */
-  final static String ORG_QA_SPAIN = "357947E87C284935AD1D783CF6F099A1";
-
-  /**
-   * QA USA Organization
-   */
-  final static String ORG_QA_USA = "5EFF95EB540740A3B10510D9814EFAD5";
-
-  /**
-   * FnB International Group Client
-   */
   final static String CLIENT_FB = "23C59575B9CF467C9620760EB255B389";
 
-  /**
-   * FnB International Group Organization
-   */
+  final static String ORG_0 = "0";
+  final static String ORG_QA_MAIN = "43D590B4814049C6B85C6545E8264E37";
+  final static String ORG_QA_SPAIN = "357947E87C284935AD1D783CF6F099A1";
+  final static String ORG_QA_USA = "5EFF95EB540740A3B10510D9814EFAD5";
   final static String ORG_FB_FBGROUP = "19404EAD144C49A0AF37D54377CF452D";
-
-  /**
-   * FnB US, Inc.
-   */
-  protected static final String ORG_FB_US = "2E60544D37534C0B89E765FE29BC0B43";
-
-  /**
-   * FnB US East Coast
-   */
+  final static String ORG_FB_US = "2E60544D37534C0B89E765FE29BC0B43";
   final static String ORG_FB_EAST = "7BABA5FF80494CAFA54DEBD22EC46F01";
-
-  /**
-   * FnB US West Coast
-   */
   final static String ORG_FB_WEST = "BAE22373FEBE4CCCA24517E23F0C8A48";
-
-  /**
-   * FnB España, S.A.
-   */
   final static String ORG_FB_SPAIN = "B843C30461EA4501935CB1D125C9C25A";
-
-  /**
-   * FnB España - Región Norte
-   */
   final static String ORG_FB_NORTE = "E443A31992CB4635AFCAEABE7183CE85";
-
-  /**
-   * FnB España - Región Sur
-   */
   final static String ORG_FB_SUR = "DC206C91AA6A4897B44DA897936E0EC3";
 
-  /**
-   * Currency ids for EUR, USD
-   */
   final static String CUR_EURO = "102";
   final static String CUR_USD = "100";
+
+  final static String FUNCTION_AD_ORG_GETCALENDAROWNERTN = "ad_org_getcalendarownertn";
+  final static String FUNCTION_AD_ORG_GETCALENDAROWNER = "ad_org_getcalendarowner";
+  final static String FUNCTION_AD_ORG_GETPERIODCONTROLALLOWTN = "ad_org_getperiodcontrolallowtn";
+  final static String FUNCTION_AD_ORG_GETPERIODCONTROLALLOW = "ad_org_getperiodcontrolallow";
+  final static String FUNCTION_AD_ORG_LE_BU_TN = "AD_GET_ORG_LE_BU_TREENODE";
+  final static String FUNCTION_AD_ORG_LE_BU = "AD_GET_ORG_LE_BU";
 }
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoCornerCaseOrg.java	Fri Apr 27 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License.
- * The Original Code is Openbravo ERP.
- * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2018 Openbravo SLU
- * All Rights Reserved.
- * Contributor(s):  ______________________________________.
- *************************************************************************
- */
-package org.openbravo.test.generalsetup.enterprise.organization;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.openbravo.test.base.OBBaseTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ADOrgPersistInfoCornerCaseOrg extends OBBaseTest {
-
-  private static final Logger log = LoggerFactory.getLogger(ADOrgPersistInfoCornerCaseOrg.class);
-
-  /**
-   * Test corner case organization persist information
-   */
-  @Test
-  public void testCornerCaseOrganization() {
-
-    try {
-
-      // * Organization
-
-      assertEquals("Failed AD_Org_GetCalendarOwner for * Organization",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarownertn",
-              ADOrgPersistInfoConstants.ORG_0),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarowner",
-              ADOrgPersistInfoConstants.ORG_0));
-      assertEquals("Failed AD_Org_GetPeriodControlAllow for * Organization",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallowtn",
-              ADOrgPersistInfoConstants.ORG_0),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallow",
-              ADOrgPersistInfoConstants.ORG_0));
-
-      // Null Organization
-
-      assertEquals("Failed AD_Org_GetCalendarOwner for null Organization",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarownertn", null),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarowner", null));
-      assertEquals("Failed AD_Org_GetPeriodControlAllow for null Organization",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallowtn", null),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallow", null));
-
-      // Organizations that does not exists in database
-
-      assertEquals("Failed AD_Org_GetCalendarOwner for organization not in database",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarownertn", "XX"),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getcalendarowner", "XX"));
-      assertEquals("Failed AD_Org_GetPeriodControlAllow for organization not in database",
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallowtn", "XX"),
-          ADOrgPersistInfoUtility.getPersistOrgInfo("ad_org_getperiodcontrolallow", "XX"));
-    } catch (Exception e) {
-      log.error("Error in testCornerCaseOrganization", e);
-    }
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoCornerCaseOrgTest.java	Fri Apr 27 12:20:39 2018 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.test.generalsetup.enterprise.organization;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openbravo.test.base.OBBaseTest;
+
+/**
+ * Test corner cases organization persist information
+ */
+public class ADOrgPersistInfoCornerCaseOrgTest extends OBBaseTest {
+
+  @Test
+  public void testCornerCaseStarOrganization() {
+    runTest(ADOrgPersistInfoConstants.ORG_0);
+  }
+
+  @Test
+  public void testCornerCaseNullOrganization() {
+    runTest(null);
+  }
+
+  @Test
+  public void testCornerCaseNonExistingOrganization() {
+    runTest("XX");
+  }
+
+  private void runTest(String orgId) {
+    assertEquals("AD_Org_GetCalendarOwner for " + orgId + " Organization",
+        ADOrgPersistInfoUtility.runFunction(
+            ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETCALENDAROWNERTN, orgId),
+        ADOrgPersistInfoUtility.runFunction(
+            ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETCALENDAROWNER, orgId));
+
+    assertEquals("AD_Org_GetPeriodControlAllow for " + orgId + " Organization",
+        ADOrgPersistInfoUtility.runFunction(
+            ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETPERIODCONTROLALLOWTN, orgId),
+        ADOrgPersistInfoUtility.runFunction(
+            ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETPERIODCONTROLALLOW, orgId));
+  }
+}
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoSetReadyTest.java	Fri Apr 27 10:59:04 2018 +0200
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoSetReadyTest.java	Fri Apr 27 12:20:39 2018 +0200
@@ -20,29 +20,16 @@
 
 import org.junit.Test;
 import org.openbravo.test.base.OBBaseTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ADOrgPersistInfoSetReadyTest extends OBBaseTest {
 
-  private static final Logger log = LoggerFactory.getLogger(ADOrgPersistInfoSetReadyTest.class);
-
   /**
    * Create a new Organization of type Generic under F&B España, S.A Organization and test persist
    * organization info after the organization is set as ready with Cascade No.
    */
   @Test
-  public void testSetReadyOneGenericOrganization() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String orgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(orgId, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(orgId);
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganization", e);
-    }
+  public void testSetReadyOneGenericOrganizationNoCascade() {
+    testSetReadyOneOrganization(false, ADOrgPersistInfoConstants.ORGTYPE_GENERIC);
   }
 
   /**
@@ -51,16 +38,33 @@
    */
   @Test
   public void testSetReadyOneGenericOrganizationCascade() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String orgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(orgId, "Y");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(orgId);
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganization", e);
-    }
+    testSetReadyOneOrganization(true, ADOrgPersistInfoConstants.ORGTYPE_GENERIC);
+  }
+
+  /**
+   * Create a new Organization of type Organization under * Organization and test persist
+   * organization information after the organization is set as ready cascade as No.
+   */
+  @Test
+  public void testSetReadyOrganizationTypeNoCascade() {
+    testSetReadyOneOrganization(false, ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION);
+  }
+
+  /**
+   * Create a new Organization of type Organization under * Organization and test persist
+   * organization information after the organization is set as ready with cascade as Yes.
+   */
+  @Test
+  public void testSetReadyOrganizationCascade() {
+    testSetReadyOneOrganization(true, ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION);
+  }
+
+  private void testSetReadyOneOrganization(boolean isCascade, final String orgType) {
+    ADOrgPersistInfoUtility.setTestContextFB();
+    String orgId = ADOrgPersistInfoUtility.createOrganization(orgType,
+        ADOrgPersistInfoConstants.ORG_FB_SPAIN, true, ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(orgId, isCascade ? "Y" : "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(orgId);
   }
 
   /**
@@ -69,23 +73,18 @@
    * No.
    */
   @Test
-  public void testSetReadyTwoGenericOrganization() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String firstOrgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      String secondOrgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, firstOrgId, false,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(firstOrgId, "N");
-      ADOrgPersistInfoUtility.setAsReady(secondOrgId, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(firstOrgId);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(secondOrgId);
-
-    } catch (Exception e) {
-      log.error("Error in testSetReadyTwoGenericOrganization", e);
-    }
+  public void testSetReadyTwoGenericOrganizationNoCascade() {
+    ADOrgPersistInfoUtility.setTestContextFB();
+    String firstOrgId = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    String secondOrgId = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, firstOrgId, false,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(firstOrgId, "N");
+    ADOrgPersistInfoUtility.setAsReady(secondOrgId, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(firstOrgId);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(secondOrgId);
   }
 
   /**
@@ -95,56 +94,16 @@
    */
   @Test
   public void testSetReadyTwoGenericOrganizationCascade() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String firstOrgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      String secondOrgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, firstOrgId, false,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(firstOrgId, "Y");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(firstOrgId);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(secondOrgId);
-
-    } catch (Exception e) {
-      log.error("Error in testSetReadyTwoGenericOrganization", e);
-    }
+    ADOrgPersistInfoUtility.setTestContextFB();
+    String firstOrgId = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, ADOrgPersistInfoConstants.ORG_FB_SPAIN, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    String secondOrgId = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, firstOrgId, false,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(firstOrgId, "Y");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(firstOrgId);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(secondOrgId);
   }
 
-  /**
-   * Create a new Organization of type Organization under * Organization and test persist
-   * organization information after the organization is set as ready cascade as No.
-   */
-  @Test
-  public void testSetReadyOrganization() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String orgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_FB_SPAIN,
-          true, ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(orgId, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(orgId);
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganization", e);
-    }
-  }
-
-  /**
-   * Create a new Organization of type Organization under * Organization and test persist
-   * organization information after the organization is set as ready with cascade as Yes.
-   */
-  @Test
-  public void testSetReadyOrganizationCascade() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      String orgId = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_FB_SPAIN,
-          true, ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(orgId, "Y");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(orgId);
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganization", e);
-    }
-  }
 }
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoTest.java	Fri Apr 27 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License.
- * The Original Code is Openbravo ERP.
- * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2018 Openbravo SLU
- * All Rights Reserved.
- * Contributor(s):  ______________________________________.
- *************************************************************************
- */
-package org.openbravo.test.generalsetup.enterprise.organization;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ ADOrgPersistInfoSetReadyTest.class,
-    ADOrgPersistOrgInfoComplexOrgTreeTest.class, ADOrgPersistInfoCornerCaseOrg.class })
-
-public class ADOrgPersistInfoTest {
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoTestSuite.java	Fri Apr 27 12:20:39 2018 +0200
@@ -0,0 +1,28 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2018 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.test.generalsetup.enterprise.organization;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ ADOrgPersistInfoSetReadyTest.class,
+    ADOrgPersistOrgInfoComplexOrgTreeTest.class, ADOrgPersistInfoCornerCaseOrgTest.class })
+public class ADOrgPersistInfoTestSuite {
+}
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoUtility.java	Fri Apr 27 10:59:04 2018 +0200
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistInfoUtility.java	Fri Apr 27 12:20:39 2018 +0200
@@ -44,28 +44,16 @@
 import org.openbravo.model.financialmgmt.calendar.Calendar;
 import org.openbravo.service.db.CallProcess;
 import org.openbravo.service.db.CallStoredProcedure;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-public class ADOrgPersistInfoUtility {
+class ADOrgPersistInfoUtility {
 
-  private static final Logger log = LoggerFactory.getLogger(ADOrgPersistInfoUtility.class);
-
-  /**
-   * Set Context for FnB International Group Client Admin
-   */
-
-  public static void setTestContextFB() {
+  static void setTestContextFB() {
     OBContext.setOBContext(ADOrgPersistInfoConstants.OPENBRAVO_USER_ID,
         ADOrgPersistInfoConstants.FB_GROUP_ADMIN_ROLE_ID, ADOrgPersistInfoConstants.CLIENT_FB,
         ADOrgPersistInfoConstants.ORG_FB_FBGROUP);
   }
 
-  /**
-   * Set Context for QA Testing Client Admin
-   */
-
-  public static void setTestContextQA() {
+  static void setTestContextQA() {
     OBContext.setOBContext(ADOrgPersistInfoConstants.OPENBRAVO_USER_ID,
         ADOrgPersistInfoConstants.QA_TESTING_ADMIN_ROLE_ID, ADOrgPersistInfoConstants.CLIENT_QA,
         ADOrgPersistInfoConstants.ORG_QA_SPAIN);
@@ -73,21 +61,15 @@
 
   /**
    * Create organization with type orgType under strParentOrg
-   * 
-   * @param newOrgType
-   * @param strParentOrg
-   * @param summary
-   * @param currencyId
-   * @return
    */
-  public static String createOrganization(String newOrgType, String strParentOrg, boolean summary,
+  static String createOrganization(String newOrgType, String strParentOrg, boolean summary,
       String currencyId) {
     long number = System.currentTimeMillis();
     Properties properties = OBPropertiesProvider.getInstance().getOpenbravoProperties();
     String strSourcePath = properties.getProperty("source.path");
     InitialOrgSetup initialOrg = new InitialOrgSetup(OBContext.getOBContext().getCurrentClient());
-    initialOrg.createOrganization("Test_" + number, "", newOrgType, strParentOrg, "", "", "", false,
-        null, "", false, false, false, false, false, strSourcePath);
+    initialOrg.createOrganization("Test_" + number, "", newOrgType, strParentOrg, "", "", "",
+        false, null, "", false, false, false, false, false, strSourcePath);
     Organization org = OBDal.getInstance().get(Organization.class, initialOrg.getOrgId());
     org.setSummaryLevel(summary);
     if (StringUtils.equals(newOrgType, ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHACCOUNTING)) {
@@ -101,13 +83,38 @@
     return org.getId();
   }
 
-  /**
-   * Sets organization as ready
-   * 
-   * @param orgId
-   * @param isCascade
-   */
-  public static void setAsReady(final String orgId, final String isCascade) {
+  private static Calendar createCalendar(final Organization org) {
+    Calendar calendar = OBProvider.getInstance().get(Calendar.class);
+    calendar.setName(org.getName() + " Calendar");
+    calendar.setOrganization(org);
+    calendar.setClient(org.getClient());
+    OBDal.getInstance().save(calendar);
+    OBDal.getInstance().flush();
+    return calendar;
+  }
+
+  private static AcctSchema createAcctSchema(final Organization org, final String currencyId) {
+    AcctSchema acctSchema = OBProvider.getInstance().get(AcctSchema.class);
+    acctSchema.setOrganization(org);
+    acctSchema.setName(org.getName() + " GL");
+    acctSchema.setClient(org.getClient());
+    acctSchema.setCurrency(OBDal.getInstance().get(Currency.class, currencyId));
+    OBDal.getInstance().save(acctSchema);
+    OBDal.getInstance().flush();
+    return acctSchema;
+  }
+
+  private static void setAcctSchema(final Organization org) {
+    OrganizationAcctSchema orgAcctSchema = OBProvider.getInstance().get(
+        OrganizationAcctSchema.class);
+    orgAcctSchema.setOrganization(org);
+    orgAcctSchema.setClient(org.getClient());
+    orgAcctSchema.setAccountingSchema(org.getGeneralLedger());
+    OBDal.getInstance().save(orgAcctSchema);
+    OBDal.getInstance().flush();
+  }
+
+  static void setAsReady(final String orgId, final String isCascade) {
     final Map<String, String> parameters = new HashMap<String, String>(1);
     parameters.put("Cascade", isCascade);
     final ProcessInstance pinstance = CallProcess.getInstance().call("AD_Org_Ready", orgId,
@@ -118,88 +125,15 @@
     OBDal.getInstance().commitAndClose();
   }
 
-  public static Organization getCalendarOrganization(String orgId) {
-    Organization calOrg = null;
-    OrganizationStructureProvider osp = OBContext.getOBContext().getOrganizationStructureProvider();
-    for (String org : osp.getParentList(orgId, true)) {
-      calOrg = OBDal.getInstance().get(Organization.class, org);
-      if (calOrg.getCalendar() != null) {
-        break;
-      } else {
-        calOrg = null;
-      }
-    }
-    return calOrg;
-  }
-
-  public static Organization getBusinessUnitOrganization(String orgId) {
-    Organization businessUnitOrg = null;
-    OrganizationStructureProvider osp = OBContext.getOBContext().getOrganizationStructureProvider();
-    for (String org : osp.getParentList(orgId, true)) {
-      businessUnitOrg = OBDal.getInstance().get(Organization.class, org);
-      if (businessUnitOrg.getOrganizationType().isBusinessUnit()) {
-        break;
-      } else {
-        businessUnitOrg = null;
-      }
-    }
-    return businessUnitOrg;
-  }
-
-  public static AcctSchema createAcctSchema(final Organization org, final String currencyId) {
-    AcctSchema acctSchema = null;
-    try {
-      acctSchema = OBProvider.getInstance().get(AcctSchema.class);
-      acctSchema.setOrganization(org);
-      acctSchema.setName(org.getName() + " GL");
-      acctSchema.setClient(org.getClient());
-      acctSchema.setCurrency(OBDal.getInstance().get(Currency.class, currencyId));
-      OBDal.getInstance().save(acctSchema);
-      OBDal.getInstance().flush();
-    } catch (Exception e) {
-      log.error("Error in createAcctSchema", e);
-    }
-    return acctSchema;
-  }
-
-  public static void setAcctSchema(final Organization org) {
-    OrganizationAcctSchema orgAcctSchema = null;
-    try {
-      orgAcctSchema = OBProvider.getInstance().get(OrganizationAcctSchema.class);
-      orgAcctSchema.setOrganization(org);
-      orgAcctSchema.setClient(org.getClient());
-      orgAcctSchema.setAccountingSchema(org.getGeneralLedger());
-      OBDal.getInstance().save(orgAcctSchema);
-      OBDal.getInstance().flush();
-    } catch (Exception e) {
-      log.error("Error in setAcctSchema", e);
-    }
-  }
-
-  public static Calendar createCalendar(final Organization org) {
-    Calendar calendar = null;
-    try {
-      calendar = OBProvider.getInstance().get(Calendar.class);
-      calendar.setName(org.getName() + " Calendar");
-      calendar.setOrganization(org);
-      calendar.setClient(org.getClient());
-      OBDal.getInstance().save(calendar);
-      OBDal.getInstance().flush();
-    } catch (Exception e) {
-      log.error("Error in createCalendar", e);
-    }
-    return calendar;
-  }
-
-  public static String getBusinessUnitOrgType() {
+  static String getBusinessUnitOrgType() {
     String businessUnitOrgType = null;
     try {
       OBContext.setAdminMode(false);
       Client client = OBDal.getInstance().get(Client.class, ADOrgPersistInfoConstants.CLIENT_0);
       Organization org0 = OBDal.getInstance().get(Organization.class,
           ADOrgPersistInfoConstants.ORG_0);
-      final OBCriteria<OrganizationType> criteria = OBDal.getInstance()
-          .createCriteria(OrganizationType.class);
+      final OBCriteria<OrganizationType> criteria = OBDal.getInstance().createCriteria(
+          OrganizationType.class);
       criteria.add(Restrictions.eq(OrganizationType.PROPERTY_BUSINESSUNIT, true));
       criteria.add(Restrictions.eq(OrganizationType.PROPERTY_ACTIVE, true));
       criteria.add(Restrictions.eq(OrganizationType.PROPERTY_CLIENT, client));
@@ -219,27 +153,104 @@
         OBDal.getInstance().commitAndClose();
         businessUnitOrgType = orgType.getId();
       }
-    } catch (Exception e) {
-      log.error("Error in getBusinessUnitOrgType", e);
     } finally {
       OBContext.restorePreviousMode();
     }
     return businessUnitOrgType;
   }
 
-  public static String getPersistOrgInfo(final String functionName, final String orgId) {
-    String returnValue = "";
-    try {
-      final ArrayList<Object> parameters = new ArrayList<Object>();
-      parameters.add(orgId);
-      returnValue = (String) CallStoredProcedure.getInstance().call(functionName, parameters, null);
-    } catch (Exception e) {
-      throw new IllegalStateException(e);
-    }
-    return returnValue;
+  static String runFunction(final String functionName, final String orgId) {
+    final ArrayList<Object> parameters = new ArrayList<Object>();
+    parameters.add(orgId);
+    return (String) CallStoredProcedure.getInstance().call(functionName, parameters, null);
   }
 
-  public static String getLegalEntityOrBusinessUnitOrg(final String functionName,
+  /**
+   * Validates persist organization information set by AD_Org_Ready DB procedure against the
+   * information provided by OrganizationStructureProvider
+   */
+  static void assertPersistOrgInfo(String orgId) {
+    if (StringUtils.isNotEmpty(orgId)) {
+      Organization org = OBDal.getInstance().get(Organization.class, orgId);
+      OrganizationStructureProvider osp = OBContext.getOBContext()
+          .getOrganizationStructureProvider();
+      osp.reInitialize();
+
+      /* Assert Legal Entity */
+      assertEquals("Match Legal Entity of Organization through OrganizationStructureProvider",
+          osp.getLegalEntity(org) == null ? null : osp.getLegalEntity(org).getId(),
+          org.getLegalEntityOrganization() == null ? null : org.getLegalEntityOrganization()
+              .getId());
+      assertEquals(
+          "Match Legal Entity of Organization through AD_GET_ORG_LE_BU",
+          getLegalEntityOrBusinessUnitOrg(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_LE_BU, orgId,
+              "LE"), org.getLegalEntityOrganization() == null ? null : org
+              .getLegalEntityOrganization().getId());
+      assertEquals(
+          "Match Legal Entity of Organization through AD_GET_ORG_LE_BU_TREENODE",
+          getLegalEntityOrBusinessUnitOrg(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_LE_BU_TN,
+              orgId, "LE"), org.getLegalEntityOrganization() == null ? null : org
+              .getLegalEntityOrganization().getId());
+
+      /* Assert Business Unit */
+      assertEquals(
+          "Match Business Unit Organization of Organization through OrganizationStructureProvider",
+          ADOrgPersistInfoUtility.getBusinessUnitOrganization(orgId) == null ? null
+              : ADOrgPersistInfoUtility.getBusinessUnitOrganization(orgId).getId(),
+          org.getBusinessUnitOrganization() == null ? null : org.getBusinessUnitOrganization()
+              .getId());
+      assertEquals(
+          "Match Business Unit Organization of Organization through AD_GET_ORG_LE_BU",
+          getLegalEntityOrBusinessUnitOrg(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_LE_BU, orgId,
+              "BU"), org.getBusinessUnitOrganization() == null ? null : org
+              .getBusinessUnitOrganization().getId());
+      assertEquals(
+          "Match Business Unit Organization of Organization through AD_GET_ORG_LE_BU_TREENODE",
+          getLegalEntityOrBusinessUnitOrg(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_LE_BU_TN,
+              orgId, "BU"), org.getBusinessUnitOrganization() == null ? null : org
+              .getBusinessUnitOrganization().getId());
+
+      /* Assert Period Control Allowed */
+      assertEquals(
+          "Match Period Control Allowed Organization through OrganizationStructureProvider",
+          osp.getPeriodControlAllowedOrganization(org) == null ? null : osp
+              .getPeriodControlAllowedOrganization(org).getId(),
+          org.getPeriodControlAllowedOrganization() == null ? null : org
+              .getPeriodControlAllowedOrganization().getId());
+      assertEquals(
+          "Match Period Control Allowed Organization through ad_org_getperiodcontrolallow",
+          runFunction(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETPERIODCONTROLALLOW, orgId),
+          org.getPeriodControlAllowedOrganization() == null ? null : org
+              .getPeriodControlAllowedOrganization().getId());
+      assertEquals(
+          "Match Period Control Allowed Organization through ad_org_getperiodcontrolallowtn",
+          runFunction(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETPERIODCONTROLALLOWTN, orgId),
+          org.getPeriodControlAllowedOrganization() == null ? null : org
+              .getPeriodControlAllowedOrganization().getId());
+
+      /* Assert Calendar Owner */
+      final Organization calOrg = ADOrgPersistInfoUtility.getCalendarOrganization(orgId);
+      assertEquals("Match Calendar Owner Organization through OrganizationStructureProvider",
+          calOrg == null ? null : calOrg.getId(), org.getCalendarOwnerOrganization() == null ? null
+              : org.getCalendarOwnerOrganization().getId());
+      assertEquals("Match Calendar Owner Organization through ad_org_getcalendarowner",
+          runFunction(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETCALENDAROWNER, orgId),
+          org.getCalendarOwnerOrganization() == null ? null : org.getCalendarOwnerOrganization()
+              .getId());
+      assertEquals("Match Calendar Owner Organization through ad_org_getcalendarownertn",
+          runFunction(ADOrgPersistInfoConstants.FUNCTION_AD_ORG_GETCALENDAROWNERTN, orgId),
+          org.getCalendarOwnerOrganization() == null ? null : org.getCalendarOwnerOrganization()
+              .getId());
+
+      /* Assert Inherited Calendar */
+      if (calOrg != null) {
+        assertEquals("Match Inherited Calendar", calOrg.getCalendar().getId(), org
+            .getInheritedCalendar().getId());
+      }
+    }
+  }
+
+  private static String getLegalEntityOrBusinessUnitOrg(final String functionName,
       final String orgId, final String ptype) {
     String returnValue = "";
     try {
@@ -253,32 +264,31 @@
     return returnValue;
   }
 
-  /**
-   * Validates persist organization information set by AD_Org_Ready DB procedure against the
-   * information provided by OrganizationStructureProvider
-   * 
-   * @param orgId
-   */
-  public static void assertPersistOrgInfo(String orgId) {
-    if (StringUtils.isNotEmpty(orgId)) {
-      Organization org = OBDal.getInstance().get(Organization.class, orgId);
-      OrganizationStructureProvider osp = OBContext.getOBContext()
-          .getOrganizationStructureProvider();
-      osp.reInitialize();
-      assertEquals("Failed to match Legal Entity of Organization", osp.getLegalEntity(org),
-          org.getLegalEntityOrganization());
-      assertEquals("Failed to match Period Control Allowed Organization of Organization",
-          osp.getPeriodControlAllowedOrganization(org), org.getPeriodControlAllowedOrganization());
-      Organization calOrg = ADOrgPersistInfoUtility.getCalendarOrganization(orgId);
-      assertEquals("Failed to match Calendar Owner Organization of organization", calOrg,
-          org.getCalendarOwnerOrganization());
-      if (calOrg != null) {
-        assertEquals("Failed to match Calendar of Organization", calOrg.getCalendar(),
-            org.getInheritedCalendar());
+  private static Organization getCalendarOrganization(String orgId) {
+    Organization calOrg = null;
+    OrganizationStructureProvider osp = OBContext.getOBContext().getOrganizationStructureProvider();
+    for (String org : osp.getParentList(orgId, true)) {
+      calOrg = OBDal.getInstance().get(Organization.class, org);
+      if (calOrg.getCalendar() != null) {
+        break;
+      } else {
+        calOrg = null;
       }
-      assertEquals("Failed to match Business Unit Organization of Organization",
-          ADOrgPersistInfoUtility.getBusinessUnitOrganization(orgId),
-          org.getBusinessUnitOrganization());
     }
+    return calOrg;
+  }
+
+  private static Organization getBusinessUnitOrganization(String orgId) {
+    Organization businessUnitOrg = null;
+    OrganizationStructureProvider osp = OBContext.getOBContext().getOrganizationStructureProvider();
+    for (String org : osp.getParentList(orgId, true)) {
+      businessUnitOrg = OBDal.getInstance().get(Organization.class, org);
+      if (businessUnitOrg.getOrganizationType().isBusinessUnit()) {
+        break;
+      } else {
+        businessUnitOrg = null;
+      }
+    }
+    return businessUnitOrg;
   }
 }
--- a/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistOrgInfoComplexOrgTreeTest.java	Fri Apr 27 10:59:04 2018 +0200
+++ b/src-test/src/org/openbravo/test/generalsetup/enterprise/organization/ADOrgPersistOrgInfoComplexOrgTreeTest.java	Fri Apr 27 12:20:39 2018 +0200
@@ -2,89 +2,78 @@
 
 import org.junit.Test;
 import org.openbravo.test.base.OBBaseTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ADOrgPersistOrgInfoComplexOrgTreeTest extends OBBaseTest {
 
-  private static final Logger log = LoggerFactory
-      .getLogger(ADOrgPersistOrgInfoComplexOrgTreeTest.class);
-
   /**
    * Create a organization tree with different organization types set them ready with cascade No
    * option and validate persist org info for each of them
    */
-
   @Test
   public void testSetReadyOrganizationWithOutCascade() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      // Create a parent organization of type Organization under *
-      String org_0 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_0, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_0, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_0);
+    ADOrgPersistInfoUtility.setTestContextFB();
+    // Create a parent organization of type Organization under *
+    String org_0 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_0, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_0, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_0);
 
-      // Create a parent organization of type Organization under org_0
-      String org_01 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, org_0, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01);
+    // Create a parent organization of type Organization under org_0
+    String org_01 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, org_0, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01);
 
-      // Create a LE with Acct parent organization of type Organization under org_01
-      String org_01_LE1 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHACCOUNTING, org_01, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE1, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1);
+    // Create a LE with Acct parent organization of type Organization under org_01
+    String org_01_LE1 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHACCOUNTING, org_01, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE1, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1);
 
-      // Create a business unit parent organization of type Organization under org_01_LE1
-      String org_01_LE1_BU = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoUtility.getBusinessUnitOrgType(), org_01_LE1, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE1_BU, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU);
+    // Create a business unit parent organization of type Organization under org_01_LE1
+    String org_01_LE1_BU = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoUtility.getBusinessUnitOrgType(), org_01_LE1, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE1_BU, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU);
 
-      // Create a Generic organization of type Organization under org_01_LE1_BU
-      String org_01_LE1_BU_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_BU, false,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE1_BU_GE, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU_GE);
+    // Create a Generic organization of type Organization under org_01_LE1_BU
+    String org_01_LE1_BU_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_BU, false,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE1_BU_GE, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU_GE);
 
-      // Create a Generic parent organization of type Organization under org_01_LE1
-      String org_01_LE1_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE1_GE, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE);
+    // Create a Generic parent organization of type Organization under org_01_LE1
+    String org_01_LE1_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE1_GE, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE);
 
-      // Create a Generic organization of type Organization under org_01_LE1_GE
-      String org_01_LE1_GE_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_GE, false,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE1_GE_GE, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE_GE);
+    // Create a Generic organization of type Organization under org_01_LE1_GE
+    String org_01_LE1_GE_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_GE, false,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE1_GE_GE, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE_GE);
 
-      // Create a LE without Acct parent organization of type Organization under org_01
-      String org_01_LE2 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHOUTACCOUNTING, org_01, true,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE2, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2);
+    // Create a LE without Acct parent organization of type Organization under org_01
+    String org_01_LE2 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHOUTACCOUNTING, org_01, true,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE2, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2);
 
-      // Create a Generic organization of type Organization under org_01_LE2
-      String org_01_LE2_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE2, false,
-          ADOrgPersistInfoConstants.CUR_EURO);
-      ADOrgPersistInfoUtility.setAsReady(org_01_LE2_GE, "N");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2_GE);
-
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganizationWithOutCascade", e);
-    }
+    // Create a Generic organization of type Organization under org_01_LE2
+    String org_01_LE2_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE2, false,
+        ADOrgPersistInfoConstants.CUR_EURO);
+    ADOrgPersistInfoUtility.setAsReady(org_01_LE2_GE, "N");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2_GE);
   }
 
   /**
@@ -93,66 +82,61 @@
    */
   @Test
   public void testSetReadyOrganizationWithCascase() {
-    try {
-      ADOrgPersistInfoUtility.setTestContextFB();
-      // Create a parent organization of type Organization under *
-      String org_0 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_0, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    ADOrgPersistInfoUtility.setTestContextFB();
+    // Create a parent organization of type Organization under *
+    String org_0 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, ADOrgPersistInfoConstants.ORG_0, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a parent organization of type Organization under org_0
-      String org_01 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, org_0, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a parent organization of type Organization under org_0
+    String org_01 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_ORGANIZATION, org_0, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a LE with Acct parent organization of type Organization under org_01
-      String org_01_LE1 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHACCOUNTING, org_01, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a LE with Acct parent organization of type Organization under org_01
+    String org_01_LE1 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHACCOUNTING, org_01, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a business unit parent organization of type Organization under org_01_LE1
-      String org_01_LE1_BU = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoUtility.getBusinessUnitOrgType(), org_01_LE1, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a business unit parent organization of type Organization under org_01_LE1
+    String org_01_LE1_BU = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoUtility.getBusinessUnitOrgType(), org_01_LE1, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a Generic organization of type Organization under org_01_LE1_BU
-      String org_01_LE1_BU_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_BU, false,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a Generic organization of type Organization under org_01_LE1_BU
+    String org_01_LE1_BU_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_BU, false,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a Generic parent organization of type Organization under org_01_LE1
-      String org_01_LE1_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a Generic parent organization of type Organization under org_01_LE1
+    String org_01_LE1_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a Generic organization of type Organization under org_01_LE1_GE
-      String org_01_LE1_GE_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_GE, false,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a Generic organization of type Organization under org_01_LE1_GE
+    String org_01_LE1_GE_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE1_GE, false,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a LE without Acct parent organization of type Organization under org_01
-      String org_01_LE2 = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHOUTACCOUNTING, org_01, true,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a LE without Acct parent organization of type Organization under org_01
+    String org_01_LE2 = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_LEGALWITHOUTACCOUNTING, org_01, true,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      // Create a Generic organization of type Organization under org_01_LE2
-      String org_01_LE2_GE = ADOrgPersistInfoUtility.createOrganization(
-          ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE2, false,
-          ADOrgPersistInfoConstants.CUR_USD);
+    // Create a Generic organization of type Organization under org_01_LE2
+    String org_01_LE2_GE = ADOrgPersistInfoUtility.createOrganization(
+        ADOrgPersistInfoConstants.ORGTYPE_GENERIC, org_01_LE2, false,
+        ADOrgPersistInfoConstants.CUR_USD);
 
-      ADOrgPersistInfoUtility.setAsReady(org_0, "Y");
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_0);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU_GE);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE_GE);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2);
-      ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2_GE);
-
-    } catch (Exception e) {
-      log.error("Error in testSetReadyOrganizationWithCascade", e);
-    }
+    ADOrgPersistInfoUtility.setAsReady(org_0, "Y");
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_0);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_BU_GE);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE1_GE_GE);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2);
+    ADOrgPersistInfoUtility.assertPersistOrgInfo(org_01_LE2_GE);
   }
 }