Skip to content

Commit

Permalink
Improving unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashi1993 committed Jan 24, 2025
1 parent f9bfb6c commit 4f90776
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMClientException;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMServerException;
import org.wso2.carbon.identity.oauth.dcr.handler.AdditionalAttributeFilter;
import org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder;
import org.wso2.carbon.identity.oauth.dcr.util.DCRConstants;
import org.wso2.carbon.identity.oauth.dcr.util.ErrorCodes;
Expand Down Expand Up @@ -132,6 +133,7 @@ public void setUp() throws Exception {
mockOAuthAdminService = mock(OAuthAdminService.class);
applicationRegistrationRequest = new ApplicationRegistrationRequest();
applicationRegistrationRequest.setClientName(dummyClientName);
applicationRegistrationRequest.setAdditionalAttributes(new HashMap<>());
dcrmService = new DCRMService();
mockApplicationManagementService = mock(ApplicationManagementService.class);
DCRDataHolder dcrDataHolder = DCRDataHolder.getInstance();
Expand All @@ -148,6 +150,17 @@ public void setUp() throws Exception {
mockedUserStoreManager = mock(AbstractUserStoreManager.class);
mockConfigurationManager = mock(ConfigurationManager.class);
DCRDataHolder.getInstance().setConfigurationManager(mockConfigurationManager);

List<String> responseKeys = new ArrayList<>();
Map<String, Object> processedAttributes = new HashMap<>();
AdditionalAttributeFilter additionalAttributeFilter = mock(AdditionalAttributeFilter.class);
lenient().when(additionalAttributeFilter.filterDCRRegisterAttributes(any(), any()))
.thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.filterDCRUpdateAttributes(any(), any(), any()))
.thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.processDCRGetAttributes(any())).thenReturn(processedAttributes);
lenient().when(additionalAttributeFilter.getResponseAttributeKeys()).thenReturn(responseKeys);
DCRDataHolder.getInstance().setAdditionalAttributeFilter(additionalAttributeFilter);
}

@AfterMethod
Expand Down Expand Up @@ -1104,6 +1117,8 @@ private OAuthConsumerAppDTO updateApplication()
applicationUpdateRequest.setGrantTypes(dummyGrantTypes);
applicationUpdateRequest.setTokenType(dummyTokenType);
applicationUpdateRequest.setBackchannelLogoutUri(dummyBackchannelLogoutUri);
applicationUpdateRequest.setAdditionalAttributes(new HashMap<>());


OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
dto.setApplicationName(dummyClientName);
Expand Down

0 comments on commit 4f90776

Please sign in to comment.