From 5fc36b646db595d5ae376b6d5fc16753d03d1f8e Mon Sep 17 00:00:00 2001 From: dhaura Date: Wed, 11 Dec 2024 12:46:52 +0530 Subject: [PATCH] Fix root org template resolving issue. --- .../service/strategy/FirstFoundAggregationStrategy.java | 6 ++++-- .../service/strategy/MergeAllAggregationStrategy.java | 6 ++++-- .../traverse/service/OrgResourceResolverServiceTest.java | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/FirstFoundAggregationStrategy.java b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/FirstFoundAggregationStrategy.java index efede0cb7..4bae6e922 100644 --- a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/FirstFoundAggregationStrategy.java +++ b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/FirstFoundAggregationStrategy.java @@ -46,7 +46,8 @@ public T aggregate(List organizationHierarchy, Function organizationHierarchy, Map appli } for (String orgId : organizationHierarchy) { - if (OrgResourceHierarchyTraverseUtil.isMinOrgHierarchyDepthReached(orgId)) { + if (organizationHierarchy.size() != 1 && + OrgResourceHierarchyTraverseUtil.isMinOrgHierarchyDepthReached(orgId)) { break; } diff --git a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/MergeAllAggregationStrategy.java b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/MergeAllAggregationStrategy.java index 2d1ad9372..497a96eda 100644 --- a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/MergeAllAggregationStrategy.java +++ b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/MergeAllAggregationStrategy.java @@ -63,7 +63,8 @@ public T aggregate(List organizationHierarchy, Function organizationHierarchy, Map appli } for (String orgId : organizationHierarchy) { - if (OrgResourceHierarchyTraverseUtil.isMinOrgHierarchyDepthReached(orgId)) { + if (organizationHierarchy.size() != 1 && + OrgResourceHierarchyTraverseUtil.isMinOrgHierarchyDepthReached(orgId)) { break; } diff --git a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java index 311ed269c..37948b5d8 100644 --- a/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java +++ b/components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java @@ -491,8 +491,6 @@ public void testGetOrgLevelResourcesFromOrgHierarchyWhenServerErrorOccurs( when(organizationManager.getOrganizationDepthInHierarchy(anyString())) .thenThrow(OrganizationManagementServerException.class); - assertThrows(OrgResourceHierarchyTraverseServerException.class, - () -> invokeOrgLevelResourceResolver(aggregationStrategy, ROOT_ORG_ID)); assertThrows(OrgResourceHierarchyTraverseServerException.class, () -> invokeOrgLevelResourceResolver(aggregationStrategy, L1_ORG_ID)); assertThrows(OrgResourceHierarchyTraverseServerException.class,