Repository: wso2-extensions/identity-organization-management
Pull request #497: Update organization discovery to call overloaded method by default
Author: login: AmshikaH
Created: 2025-03-27T08:25:57Z | Merged: 2025-03-31T06:54:45Z

## Purpose

$subject

## Related Issues

- https://github.com/wso2/product-is/issues/23390
- https://github.com/wso2/product-is/issues/23605


Diff:
diff --git a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/AttributeBasedOrganizationDiscoveryHandler.java b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/AttributeBasedOrganizationDiscoveryHandler.java
index eadc849c7..2d58fc9b0 100644
--- a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/AttributeBasedOrganizationDiscoveryHandler.java
+++ b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/AttributeBasedOrganizationDiscoveryHandler.java
@@ -18,7 +18,6 @@
 
 package org.wso2.carbon.identity.organization.discovery.service;
 
-import org.apache.commons.lang.NotImplementedException;
 import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext;
 import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
 
@@ -64,7 +63,7 @@ boolean isDiscoveryConfigurationEnabled(String organizationId)
      */
     default String extractAttributeValue(String discoveryInput, AuthenticationContext context) {
 
-        throw new NotImplementedException("extractAttributeValue method is not implemented");
+        return extractAttributeValue(discoveryInput);
     }
 
     /**
diff --git a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
index fc6bbce6b..9c982d816 100644
--- a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
+++ b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
@@ -20,6 +20,7 @@
 
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
+import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext;
 import org.wso2.carbon.identity.core.util.IdentityUtil;
 import org.wso2.carbon.identity.organization.discovery.service.dao.OrganizationDiscoveryDAO;
 import org.wso2.carbon.identity.organization.discovery.service.dao.OrganizationDiscoveryDAOImpl;
@@ -181,6 +182,21 @@ public String getOrganizationIdByDiscoveryAttribute(String attributeType, String
         return null;
     }
 
+    @Override
+    public String getOrganizationIdByDiscoveryAttribute(String attributeType, String discoveryInput,
+                                                        String rootOrganizationId, AuthenticationContext context)
+            throws OrganizationManagementException {
+
+        AttributeBasedOrganizationDiscoveryHandler handler = getAttributeBasedOrganizationDiscoveryHandlers()
+                .get(attributeType);
+        String attributeValue = handler.extractAttributeValue(discoveryInput, context);
+        if (StringUtils.isNotBlank(attributeValue)) {
+            return organizationDiscoveryDAO.getOrganizationIdByDiscoveryAttribute(attributeType, attributeValue,
+                    rootOrganizationId);
+        }
+        return null;
+    }
+
     private void validateRootOrganization(String rootOrganizationId, String organizationId)
             throws OrganizationManagementClientException {
 
diff --git a/components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java b/components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
index 548b7111e..243a8e498 100644
--- a/components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
+++ b/components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
@@ -18,7 +18,7 @@
 
 package org.wso2.carbon.identity.organization.discovery.service;
 
-import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang.StringUtils;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
@@ -46,16 +46,20 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.SUPER_ORG_ID;
 
 public class OrganizationDiscoveryManagerImplTest {
 
     private static final String DISCOVERY_ATTRIBUTE_TYPE = "emailDomain";
+    private static final String DISCOVERY_ATTRIBUTE_VALUE = "wso2.lk";
+    private static final String DISCOVERY_INPUT = "dewni@wso2.lk";
     private static final String WSO2_ORG_ID = "20084a8d-113f-4211-a0d5-efe36b082212";
     private static final String ABC_ORG_ID = "30084a8d-113f-4211-a0d5-efe36b082213";
     private static final String XYZ_ORG_ID = "40084a8d-113f-4211-a0d5-efe36b082214";
     private final OrganizationDiscoveryDAO organizationDiscoveryDAO = new OrganizationDiscoveryDAOImpl();
+    private AuthenticationContext mockAuthenticationContext;
 
     @InjectMocks
     private OrganizationDiscoveryManagerImpl organizationDiscoveryManager;
@@ -73,6 +77,7 @@ public class OrganizationDiscoveryManagerImplTest {
     public void setUp() throws Exception {
 
         MockitoAnnotations.openMocks(this);
+        mockAuthenticationContext = mock(AuthenticationContext.class);
 
         TestUtils.initiateH2Base();
         TestUtils.mockDataSource();
@@ -381,14 +386,30 @@ public void testGetOrganizationIdByDiscoveryAttribute() throws Exception {
         when(attributeBasedOrganizationDiscoveryHandler.isDiscoveryConfigurationEnabled(SUPER_ORG_ID)).thenReturn(true);
         when(attributeBasedOrganizationDiscoveryHandler.getType()).thenReturn(DISCOVERY_ATTRIBUTE_TYPE);
         when(attributeBasedOrganizationDiscoveryHandler.areAttributeValuesInValidFormat(anyList())).thenReturn(true);
-        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("wso2.lk");
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+                thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
         when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
-                any(AuthenticationContext.class)))
-                .thenThrow(new NotImplementedException("extractAttributeValue method is not implemented"));
+                any(AuthenticationContext.class))).thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
 
         String organizationId =
                 organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
-                        "dewni@wso2.lk", SUPER_ORG_ID);
+                        DISCOVERY_INPUT, SUPER_ORG_ID);
         Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+        thenReturn(StringUtils.EMPTY);
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID);
+        Assert.assertNull(organizationId);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
+                any(AuthenticationContext.class))).thenReturn(StringUtils.EMPTY);
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertNull(organizationId);
     }
 }


Reviews:
user: login: jenkins-is-staging
body: Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/14122114584
state: APPROVED
author_association: NONE
submitted_at: 2025-03-28T06:23:17Z
user: login: SujanSanjula96
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T08:45:06Z
user: login: AmshikaH
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T08:50:04Z
user: login: AmshikaH
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T12:02:31Z
user: login: AnuradhaSK
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T16:18:21Z
user: login: AnuradhaSK
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T16:18:37Z
user: login: AmshikaH
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-31T05:01:18Z
user: login: AmshikaH
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-31T05:05:06Z
user: login: AnuradhaSK
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-31T05:23:58Z
user: login: jenkins-is-staging
body: Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/14164488332
state: APPROVED
author_association: NONE
submitted_at: 2025-03-31T06:49:06Z

Review comments:
diff_hunk: @@ -181,6 +183,26 @@ public String getOrganizationIdByDiscoveryAttribute(String attributeType, String
         return null;
     }
 
+    @Override
+    public String getOrganizationIdByDiscoveryAttribute(String attributeType, String discoveryInput,
+                                                        String rootOrganizationId, AuthenticationContext context)
+            throws OrganizationManagementException {
+
+        AttributeBasedOrganizationDiscoveryHandler handler = getAttributeBasedOrganizationDiscoveryHandlers()
+                .get(attributeType);
+        String attributeValue;
+        try {
+            attributeValue = handler.extractAttributeValue(discoveryInput, context);
+        } catch (NotImplementedException e) {
+            attributeValue = handler.extractAttributeValue(discoveryInput);
+        }
path: components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
user: login: SujanSanjula96
body: Instead of this, we can call `extractAttributeValue(discoveryInput)` inside of default method of `extractAttributeValue(discoveryInput, context)`. WDYT @AnuradhaSK @ShanChathusanda93 ?
created_at: 2025-03-28T08:45:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -181,6 +183,26 @@ public String getOrganizationIdByDiscoveryAttribute(String attributeType, String
         return null;
     }
 
+    @Override
+    public String getOrganizationIdByDiscoveryAttribute(String attributeType, String discoveryInput,
+                                                        String rootOrganizationId, AuthenticationContext context)
+            throws OrganizationManagementException {
+
+        AttributeBasedOrganizationDiscoveryHandler handler = getAttributeBasedOrganizationDiscoveryHandlers()
+                .get(attributeType);
+        String attributeValue;
+        try {
+            attributeValue = handler.extractAttributeValue(discoveryInput, context);
+        } catch (NotImplementedException e) {
+            attributeValue = handler.extractAttributeValue(discoveryInput);
+        }
path: components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
user: login: AmshikaH
body: The default approach is the original approach that was sent in this PR's first commit: https://github.com/wso2-extensions/identity-organization-management/pull/497/commits/e68722597fc4fdddbd7f771cbfe5942341b71b18

We could revert to that if it's better.
created_at: 2025-03-28T08:50:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -181,6 +183,26 @@ public String getOrganizationIdByDiscoveryAttribute(String attributeType, String
         return null;
     }
 
+    @Override
+    public String getOrganizationIdByDiscoveryAttribute(String attributeType, String discoveryInput,
+                                                        String rootOrganizationId, AuthenticationContext context)
+            throws OrganizationManagementException {
+
+        AttributeBasedOrganizationDiscoveryHandler handler = getAttributeBasedOrganizationDiscoveryHandlers()
+                .get(attributeType);
+        String attributeValue;
+        try {
+            attributeValue = handler.extractAttributeValue(discoveryInput, context);
+        } catch (NotImplementedException e) {
+            attributeValue = handler.extractAttributeValue(discoveryInput);
+        }
path: components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/OrganizationDiscoveryManagerImpl.java
user: login: AmshikaH
body: Fixed with [fca97b1](https://github.com/wso2-extensions/identity-organization-management/pull/497/commits/fca97b1d9157b9ad54225099cd722ba1a6df940e).
created_at: 2025-03-28T12:02:31Z
author_association: CONTRIBUTOR
diff_hunk: @@ -381,14 +385,29 @@ public void testGetOrganizationIdByDiscoveryAttribute() throws Exception {
         when(attributeBasedOrganizationDiscoveryHandler.isDiscoveryConfigurationEnabled(SUPER_ORG_ID)).thenReturn(true);
         when(attributeBasedOrganizationDiscoveryHandler.getType()).thenReturn(DISCOVERY_ATTRIBUTE_TYPE);
         when(attributeBasedOrganizationDiscoveryHandler.areAttributeValuesInValidFormat(anyList())).thenReturn(true);
-        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("wso2.lk");
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+                thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
         when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
-                any(AuthenticationContext.class)))
-                .thenThrow(new NotImplementedException("extractAttributeValue method is not implemented"));
+                any(AuthenticationContext.class))).thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
 
         String organizationId =
                 organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
-                        "dewni@wso2.lk", SUPER_ORG_ID);
+                        DISCOVERY_INPUT, SUPER_ORG_ID);
         Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("");
path: components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
user: login: AnuradhaSK
body: ```suggestion
        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn(StringUtils.Empty);
```
created_at: 2025-03-28T16:18:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -381,14 +385,29 @@ public void testGetOrganizationIdByDiscoveryAttribute() throws Exception {
         when(attributeBasedOrganizationDiscoveryHandler.isDiscoveryConfigurationEnabled(SUPER_ORG_ID)).thenReturn(true);
         when(attributeBasedOrganizationDiscoveryHandler.getType()).thenReturn(DISCOVERY_ATTRIBUTE_TYPE);
         when(attributeBasedOrganizationDiscoveryHandler.areAttributeValuesInValidFormat(anyList())).thenReturn(true);
-        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("wso2.lk");
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+                thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
         when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
-                any(AuthenticationContext.class)))
-                .thenThrow(new NotImplementedException("extractAttributeValue method is not implemented"));
+                any(AuthenticationContext.class))).thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
 
         String organizationId =
                 organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
-                        "dewni@wso2.lk", SUPER_ORG_ID);
+                        DISCOVERY_INPUT, SUPER_ORG_ID);
         Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("");
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID);
+        Assert.assertNull(organizationId);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
+                any(AuthenticationContext.class))).thenReturn("");
path: components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
user: login: AnuradhaSK
body: ```suggestion
                any(AuthenticationContext.class))).thenReturn(StringUtils.Empty);
```
created_at: 2025-03-28T16:18:37Z
author_association: CONTRIBUTOR
diff_hunk: @@ -381,14 +385,29 @@ public void testGetOrganizationIdByDiscoveryAttribute() throws Exception {
         when(attributeBasedOrganizationDiscoveryHandler.isDiscoveryConfigurationEnabled(SUPER_ORG_ID)).thenReturn(true);
         when(attributeBasedOrganizationDiscoveryHandler.getType()).thenReturn(DISCOVERY_ATTRIBUTE_TYPE);
         when(attributeBasedOrganizationDiscoveryHandler.areAttributeValuesInValidFormat(anyList())).thenReturn(true);
-        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("wso2.lk");
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+                thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
         when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
-                any(AuthenticationContext.class)))
-                .thenThrow(new NotImplementedException("extractAttributeValue method is not implemented"));
+                any(AuthenticationContext.class))).thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
 
         String organizationId =
                 organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
-                        "dewni@wso2.lk", SUPER_ORG_ID);
+                        DISCOVERY_INPUT, SUPER_ORG_ID);
         Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("");
path: components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
user: login: AmshikaH
body: Fixed with [be63eeb](https://github.com/wso2-extensions/identity-organization-management/pull/497/commits/be63eeb4f0f7042d7f783507bc880b7019e6f5d7).
created_at: 2025-03-31T05:01:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -381,14 +385,29 @@ public void testGetOrganizationIdByDiscoveryAttribute() throws Exception {
         when(attributeBasedOrganizationDiscoveryHandler.isDiscoveryConfigurationEnabled(SUPER_ORG_ID)).thenReturn(true);
         when(attributeBasedOrganizationDiscoveryHandler.getType()).thenReturn(DISCOVERY_ATTRIBUTE_TYPE);
         when(attributeBasedOrganizationDiscoveryHandler.areAttributeValuesInValidFormat(anyList())).thenReturn(true);
-        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("wso2.lk");
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).
+                thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
         when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
-                any(AuthenticationContext.class)))
-                .thenThrow(new NotImplementedException("extractAttributeValue method is not implemented"));
+                any(AuthenticationContext.class))).thenReturn(DISCOVERY_ATTRIBUTE_VALUE);
 
         String organizationId =
                 organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
-                        "dewni@wso2.lk", SUPER_ORG_ID);
+                        DISCOVERY_INPUT, SUPER_ORG_ID);
         Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID, mockAuthenticationContext);
+        Assert.assertEquals(organizationId, WSO2_ORG_ID);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString())).thenReturn("");
+        organizationId = organizationDiscoveryManager.getOrganizationIdByDiscoveryAttribute(DISCOVERY_ATTRIBUTE_TYPE,
+                DISCOVERY_INPUT, SUPER_ORG_ID);
+        Assert.assertNull(organizationId);
+
+        when(attributeBasedOrganizationDiscoveryHandler.extractAttributeValue(anyString(),
+                any(AuthenticationContext.class))).thenReturn("");
path: components/org.wso2.carbon.identity.organization.discovery.service/src/test/java/org.wso2.carbon.identity.organization.discovery.service/OrganizationDiscoveryManagerImplTest.java
user: login: AmshikaH
body: Fixed with [be63eeb](https://github.com/wso2-extensions/identity-organization-management/pull/497/commits/be63eeb4f0f7042d7f783507bc880b7019e6f5d7).
created_at: 2025-03-31T05:05:06Z
author_association: CONTRIBUTOR

PR comments:
user: login: codecov[bot]
created_at: 2025-03-27T10:55:32Z
body: ## [Codecov](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) Report
Attention: Patch coverage is `85.71429%` with `1 line` in your changes missing coverage. Please review.
> Project coverage is 57.60%. Comparing base [(`9146bd1`)](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/commit/9146bd1ccbb26a0642d7538a765875af557351b3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) to head [(`be63eeb`)](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/commit/be63eeb4f0f7042d7f783507bc880b7019e6f5d7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions).
> Report is 6 commits behind head on main.

| [Files with missing lines](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) | Patch % | Lines |
|---|---|---|
| [...ce/AttributeBasedOrganizationDiscoveryHandler.java](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497?src=pr&el=tree&filepath=components%2Forg.wso2.carbon.identity.organization.discovery.service%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fidentity%2Forganization%2Fdiscovery%2Fservice%2FAttributeBasedOrganizationDiscoveryHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions#diff-Y29tcG9uZW50cy9vcmcud3NvMi5jYXJib24uaWRlbnRpdHkub3JnYW5pemF0aW9uLmRpc2NvdmVyeS5zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL3dzbzIvY2FyYm9uL2lkZW50aXR5L29yZ2FuaXphdGlvbi9kaXNjb3Zlcnkvc2VydmljZS9BdHRyaWJ1dGVCYXNlZE9yZ2FuaXphdGlvbkRpc2NvdmVyeUhhbmRsZXIuamF2YQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) |

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##               main     #497      +/-   ##
============================================
+ Coverage     57.58%   57.60%   +0.01%     
- Complexity     1740     1742       +2     
============================================
  Files           177      177              
  Lines          9688     9694       +6     
  Branches       1357     1358       +1     
============================================
+ Hits           5579     5584       +5     
- Misses         3642     3644       +2     
+ Partials        467      466       -1     
```

| [Flag](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) | Coverage Δ | |
|---|---|---|
| [unit](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions) | `37.98% <85.71%> (+0.02%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/wso2-extensions/identity-organization-management/pull/497?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wso2-extensions).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-03-28T04:40:34Z
body: PR builder started 
Link: https://github.com/wso2/product-is/actions/runs/14122114584
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-03-28T06:23:17Z
body: PR builder completed 
Link: https://github.com/wso2/product-is/actions/runs/14122114584 
Status: **success**
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-03-31T05:06:49Z
body: PR builder started 
Link: https://github.com/wso2/product-is/actions/runs/14164488332
author_association: NONE
user: login: jenkins-is-staging
created_at: 2025-03-31T06:49:05Z
body: PR builder completed 
Link: https://github.com/wso2/product-is/actions/runs/14164488332 
Status: **success**
author_association: NONE