Search in sources :

Example 1 with IdentityEventConfigBuilder

use of org.wso2.carbon.identity.event.IdentityEventConfigBuilder in project carbon-identity-framework by wso2.

the class AbstractEventHandlerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    String home = IdentityEventConfigBuilder.class.getResource("/").getFile();
    String config = IdentityEventConfigBuilder.class.getResource("/").getFile();
    System.setProperty("carbon.home", home);
    System.setProperty("carbon.config.dir.path", config);
    subscriptionList = new ArrayList<>();
    moduleConfiguration = Mockito.mock(ModuleConfiguration.class);
    Mockito.doReturn(subscriptionList).when(moduleConfiguration).getSubscriptions();
    IdentityEventConfigBuilder identityEventConfigBuilder = Mockito.mock(IdentityEventConfigBuilder.class);
    Field field = IdentityEventConfigBuilder.class.getDeclaredField("notificationMgtConfigBuilder");
    field.setAccessible(true);
    field.set(null, identityEventConfigBuilder);
    Mockito.doReturn(moduleConfiguration).when(identityEventConfigBuilder).getModuleConfigurations(moduleName);
    moduleConfigurationMap = new HashMap<>();
    Mockito.doReturn(moduleConfigurationMap).when(identityEventConfigBuilder).getModuleConfiguration();
    Mockito.doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return moduleConfigurationMap.get(invocationOnMock.getArguments()[0]);
        }
    }).when(identityEventConfigBuilder).getModuleConfigurations(Matchers.anyString());
    ModuleConfiguration moduleConfiguration2 = new ModuleConfiguration(new Properties(), subscriptionList);
    moduleConfigurationMap.put("TestEventHandler", moduleConfiguration2);
}
Also used : Field(java.lang.reflect.Field) Answer(org.mockito.stubbing.Answer) ModuleConfiguration(org.wso2.carbon.identity.event.bean.ModuleConfiguration) IdentityEventConfigBuilder(org.wso2.carbon.identity.event.IdentityEventConfigBuilder) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Properties(java.util.Properties) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Field (java.lang.reflect.Field)1 Properties (java.util.Properties)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 IdentityEventConfigBuilder (org.wso2.carbon.identity.event.IdentityEventConfigBuilder)1 ModuleConfiguration (org.wso2.carbon.identity.event.bean.ModuleConfiguration)1