Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
madurangasiriwardena committed May 10, 2024
1 parent f56094c commit cbd7033
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="org.wso2.carbon.identity.api.resource.collection.mgt.test" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="org.wso2.carbon.identity.api.resource.collection.mgt.test">
<test name="api-resource-collection-mgt-tests" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManagerTest"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="org.wso2.carbon.identity.api.resource.mgt.dao" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="org.wso2.carbon.identity.api.resource.mgt.dao">
<test name="api-resource-mgt-tests" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.carbon.identity.api.resource.mgt.dao.APIResourceManagementDAOImplTest"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="AuthenticationEndpointUtilTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="AuthenticationEndpointUtilTestSuite">

<test name="AuthenticationEndpointUtilTests-with-info-logs" preserve-order="true" parallel="false">
<parameter name="log-level" value="info"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="IdentityFrameworkTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="IdentityFrameworkTestSuite">
<test name="IdentityFrameworkTestsWithDebugEnabled" preserve-order="true" parallel="false">
<!--<parameter name="log-level" value="debug"/>-->
<classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Identity-suite-initializer" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="Identity-suite-initializer">
<parameter name="log-level" value="info"/>

<test name="is-tests-initialize" preserve-order="true" parallel="classes" group-by-instances="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="ConfigurationManagementCoreTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="ConfigurationManagementCoreTestSuite">

<test name="ConfigurationManagementCoreTests" preserve-order="true" parallel="false">
<classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="ConfigurationManagementServerTestSuite"
object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="ConfigurationManagementServerTestSuite">

<test name="ConfigurationManagementServerTests" preserve-order="true" parallel="false">
<classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="ConfigurationManagementServerTestSuite"
object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="ConfigurationManagementServerTestSuite">
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.utils</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class BaseCacheTest {

MockedStatic<IdentityTenantUtil> identityTenantUtil;
private MockedStatic<IdentityTenantUtil> identityTenantUtil;

@BeforeMethod
public void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,25 +460,28 @@ public void testRemoveEmptyServiceProvider() throws Exception {

@Test
public void testGetServiceProvider() throws Exception {
mockStatic(IdentityTenantUtil.class);
RealmService mockRealmService = mock(RealmService.class);
TenantManager mockTenantManager = mock(TenantManager.class);
when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");

Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);

String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(path)).thenReturn(true);
when(mockRegistry.get(path)).thenReturn(dummyResource);

SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch");
try (MockedStatic<IdentityTenantUtil> identityTenantUtil = mockStatic(IdentityTenantUtil.class)) {
RealmService mockRealmService = mock(RealmService.class);
TenantManager mockTenantManager = mock(TenantManager.class);
identityTenantUtil.when(IdentityTenantUtil::getRealmService).thenReturn(mockRealmService);
when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");

Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);

String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(path)).thenReturn(true);
when(mockRegistry.get(path)).thenReturn(dummyResource);

SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
assertEquals(serviceProviderDO.getTenantDomain(), "test.com",
"Retrieved resource's tenant domain mismatch");
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public class DefaultServiceURLBuilderTest {

private final String HTTPS = "https";

MockedStatic<CarbonUtils> carbonUtils;
MockedStatic<ServerConfiguration> serverConfiguration;
MockedStatic<NetworkUtils> networkUtils;
MockedStatic<IdentityCoreServiceComponent> identityCoreServiceComponent;
MockedStatic<IdentityTenantUtil> identityTenantUtil;
MockedStatic<PrivilegedCarbonContext> privilegedCarbonContext;
private MockedStatic<CarbonUtils> carbonUtils;
private MockedStatic<ServerConfiguration> serverConfiguration;
private MockedStatic<NetworkUtils> networkUtils;
private MockedStatic<IdentityCoreServiceComponent> identityCoreServiceComponent;
private MockedStatic<IdentityTenantUtil> identityTenantUtil;
private MockedStatic<PrivilegedCarbonContext> privilegedCarbonContext;

@BeforeMethod
public void setUp() throws Exception {
Expand Down Expand Up @@ -479,8 +479,8 @@ public void testGetRelativePublicURL(String protocol, String hostName, int port,
carbonUtils.when(() -> CarbonUtils.getTransportProxyPort(mockAxisConfiguration, protocol)).thenReturn(port);
when(ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants
.PROXY_CONTEXT_PATH)).thenReturn(proxyContextPath);
when(IdentityTenantUtil.isTenantQualifiedUrlsEnabled()).thenReturn(enableTenantURLSupport);
when(IdentityTenantUtil.getTenantDomainFromContext()).thenReturn(tenantNameFromContext);
identityTenantUtil.when(IdentityTenantUtil::isTenantQualifiedUrlsEnabled).thenReturn(enableTenantURLSupport);
identityTenantUtil.when(IdentityTenantUtil::getTenantDomainFromContext).thenReturn(tenantNameFromContext);
lenient().when(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()).thenReturn("carbon.super");

String relativePublicUrl = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="identity-core-test-suite" parallel="false">
<suite name="identity-core-test-suite" parallel="false">
<test name="identity-core-test-all">
<classes>
<class name="org.wso2.carbon.identity.core.util.IdentityUtilTest"/>
<!-- <class name="org.wso2.carbon.identity.core.util.IdentityConfigParserTest"/>-->
<!-- <class name="org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderDAOTest"/>-->
<!-- <class name="org.wso2.carbon.identity.core.internal.DefaultServiceURLBuilderTest"/>-->
<!-- <class name="org.wso2.carbon.identity.core.cache.BaseCacheTest"/>-->
<class name="org.wso2.carbon.identity.core.util.IdentityConfigParserTest"/>
<class name="org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderDAOTest"/>
<class name="org.wso2.carbon.identity.core.internal.DefaultServiceURLBuilderTest"/>
<class name="org.wso2.carbon.identity.core.cache.BaseCacheTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="org.wso2.carbon.identity.mgt.policy.password" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="org.wso2.carbon.identity.mgt.policy.password">
<test name="org.wso2.carbon.identity.mgt.policy.password" preserve-order="false" parallel="false">
<!--<parameter name="log-level" value="debug"/>-->
<classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="org.wso2.carbon.idp.mgt.suite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="org.wso2.carbon.idp.mgt.suite">
<test name="org.wso2.carbon.idp.mgt.test" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.carbon.idp.mgt.util.IdPManagementUtilTest"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="SecretManagementCoreTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="SecretManagementCoreTestSuite">

<test name="SecretManagementCoreTests" preserve-order="true" parallel="false">
<classes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="TemplateManagementTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="TemplateManagementTestSuite">
<!--<suite thread-count="1" verbose="0" name="Surefire suite">-->

<test name="TemplateManagementTests" preserve-order="true" parallel="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="UserFunctionalityManagementTestSuite" object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
<suite name="UserFunctionalityManagementTestSuite">
<!--<suite thread-count="1" verbose="0" name="Surefire suite">-->

<test name="UserFunctionalityManagementTests" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.carbon.identity.user.functionality.mgt.model.FunctionalityLockStatusTest"/>
<class name="org.wso2.carbon.identity.user.functionality.mgt.UserFunctionalityManagerImplTest"/>
<class name="org.wso2.carbon.identity.user.functionality.mgt.dao.impl.UserFunctionalityManagerDAOImplTest"/>
<class name="org.wso2.carbon.identity.user.functionality.mgt.dao.impl.UserFunctionalityPropertyDAOImplTest"></class>
<class name="org.wso2.carbon.identity.user.functionality.mgt.dao.impl.UserFunctionalityPropertyDAOImplTest"/>
</classes>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public void testGetAllRolesNames() throws Exception {
Mockito.when(realm.getUserStoreManager()).thenReturn(userStoreManagerWithAb);
HybridRoleManager hybridRoleManager = mock(HybridRoleManager.class);
String[] test = {"role3x", "role4x"};
Mockito.when(hybridRoleManager.getHybridRoles("role")).thenReturn(test);
Mockito.when(((AbstractUserStoreManager)userStoreManagerWithAb).getHybridRoles("role")).thenReturn(test);
Mockito.when(((AbstractUserStoreManager) userStoreManagerWithAb).getHybridRoles("role")).thenReturn(test);
Mockito.when(((AbstractUserStoreManager) userStoreManagerWithAb)
.getSharedRoleNames("role", 10)).thenReturn(new String[]{"role1", "role2"});
Mockito.when(((AbstractUserStoreManager) userStoreManagerWithAb)
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ public void onBeforeClass(ITestClass iTestClass) {
WithKeyStore withKeyStore = (WithKeyStore) annotation;
createKeyStore(realClass, withKeyStore);
}
//TODO check this
// Field[] fields = realClass.getDeclaredFields();
// processFields(fields, iMethodInstance.getInstance());
}

private boolean microserviceServerInitialized(Object instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
* Some White-Box utilities, to call/set internal states with reflection.
* Mockito and PowerMockito has Witebox class. But seems not quite simple.
* Mockito has Whitebox class. But seems not quite simple.
*/
public class Whitebox {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import org.apache.logging.log4j.core.Logger;

/**
* This utility class is used to configure log Appenders and log levels by IdentityBaseTest and
* PowerMockIdentityBaseTest classes.
* This utility class is used to configure log Appenders and log levels by IdentityBaseTest class.
*/
public class LogUtil {

Expand Down

0 comments on commit cbd7033

Please sign in to comment.