Search in sources :

Example 1 with ConsentManagerComponentDataHolder

use of org.wso2.carbon.consent.mgt.core.internal.ConsentManagerComponentDataHolder in project carbon-identity-framework by wso2.

the class SSOConsentServiceImplTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    initiateH2Base();
    DataSource dataSource = mock(DataSource.class);
    mockStatic(ConsentManagerComponentDataHolder.class);
    ConsentManagerComponentDataHolder componentDataHolder = mock(ConsentManagerComponentDataHolder.class);
    when(ConsentManagerComponentDataHolder.getInstance()).thenReturn(componentDataHolder);
    when(componentDataHolder.getDataSource()).thenReturn(dataSource);
    connection = getConnection();
    Connection spyConnection = spyConnection(connection);
    when(dataSource.getConnection()).thenReturn(spyConnection);
    mockStatic(IdentityConfigParser.class);
    mockStatic(OMElement.class);
    when(IdentityConfigParser.getInstance()).thenReturn(mockConfigParser);
    when(IdentityConfigParser.getInstance().getConfigElement(CONFIG_ELEM_CONSENT)).thenReturn(consentElement);
    ssoConsentService = new SSOConsentServiceImpl();
    String carbonHome = Paths.get(System.getProperty("user.dir"), "target", "test-classes").toString();
    System.setProperty(CarbonBaseConstants.CARBON_HOME, carbonHome);
    System.setProperty(CarbonBaseConstants.CARBON_CONFIG_DIR_PATH, Paths.get(carbonHome, "conf").toString());
}
Also used : Connection(java.sql.Connection) ConsentManagerComponentDataHolder(org.wso2.carbon.consent.mgt.core.internal.ConsentManagerComponentDataHolder) Matchers.anyString(org.mockito.Matchers.anyString) DataSource(javax.sql.DataSource) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Connection (java.sql.Connection)1 DataSource (javax.sql.DataSource)1 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 Matchers.anyString (org.mockito.Matchers.anyString)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 ConsentManagerComponentDataHolder (org.wso2.carbon.consent.mgt.core.internal.ConsentManagerComponentDataHolder)1