details:   https://code.openbravo.com/erp/devel/pi/rev/b9a5fed6dd96
changeset: 16747:b9a5fed6dd96
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Tue Jun 05 15:08:23 2012 +0200
summary:   Fixes issue 20659: An empty set is returned when an invalid orgid is 
provided

The method getChildOrg of OrganizationStructureProvider now returns and empty 
set instead of null if an invalid orgid is provided.

A test has been added to test this behaviour.: Enter commit message.  Lines 
beginning with 'HG:' are removed.

diffstat:

 src-test/org/openbravo/test/dal/IssuesTest.java                   |  15 
++++++++++
 src/org/openbravo/dal/security/OrganizationStructureProvider.java |   6 +++-
 2 files changed, 20 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r 2c5b66feedf4 -r b9a5fed6dd96 
src-test/org/openbravo/test/dal/IssuesTest.java
--- a/src-test/org/openbravo/test/dal/IssuesTest.java   Tue Jun 05 13:11:45 
2012 +0200
+++ b/src-test/org/openbravo/test/dal/IssuesTest.java   Tue Jun 05 15:08:23 
2012 +0200
@@ -718,4 +718,19 @@
     assertFalse(writableOrganizations2.isEmpty());
   }
 
+  /**
+   * Testing issue 0020659. Tests that if an invalid organization id is 
provided, getChildOrg
+   * returns an empty set instead of null.
+   */
+  public void test20659() {
+    setTestAdminContext();
+    String nonExistentOrg = "-123ZXY";
+
+    final String clientId = 
OBContext.getOBContext().getCurrentClient().getId();
+    final OrganizationStructureProvider osp = OBContext.getOBContext()
+        .getOrganizationStructureProvider(clientId);
+    final Set<String> childOrg = osp.getChildOrg(nonExistentOrg);
+    assertTrue(childOrg.isEmpty());
+  }
+
 }
\ No newline at end of file
diff -r 2c5b66feedf4 -r b9a5fed6dd96 
src/org/openbravo/dal/security/OrganizationStructureProvider.java
--- a/src/org/openbravo/dal/security/OrganizationStructureProvider.java Tue Jun 
05 13:11:45 2012 +0200
+++ b/src/org/openbravo/dal/security/OrganizationStructureProvider.java Tue Jun 
05 15:08:23 2012 +0200
@@ -268,7 +268,11 @@
     if (childByOrganizationID.get(orgId) == null) {
       reInitialize();
     }
-    return new HashSet<String>(childByOrganizationID.get(orgId));
+    if (childByOrganizationID.get(orgId) == null) {
+      return new HashSet<String>();
+    } else {
+      return new HashSet<String>(childByOrganizationID.get(orgId));
+    }
   }
 
   class OrgNode {

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to