// part of client import:
// 8509: References in the database without using foreign keys can go wrong in import
// https://issues.openbravo.com/view.php?id=8509
private void testMantis8509(String clientId) {
setUserContext("0");
final OrganizationStructureProvider osp = new OrganizationStructureProvider();
osp.setClientId(clientId);
final Client client = OBDal.getInstance().get(Client.class, clientId);
final OBCriteria<Organization> os = OBDal.getInstance().createCriteria(Organization.class);
os.setFilterOnReadableClients(false);
os.setFilterOnReadableOrganization(false);
os.setFilterOnActive(false);
os.add(Expression.eq("client", client));
for (Organization o : os.list()) {
final Set<String> naturalTree = osp.getNaturalTree(o.getId());
// all the organizations should at least have a tree of size 2
if (naturalTree.size() <= 1) {
fail("Naturaltree computation fails for organization " + o.getId() + " in imported client "
+ clientId);
}