Search in sources :

Example 1 with DefaultKeyManagerEventHandlerImpl

use of org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl in project carbon-apimgt by wso2.

the class ApimgtNotificationServiceComponent method activate.

@Activate
protected void activate(ComponentContext ctxt) {
    ctxt.getBundleContext().registerService(KeyManagerEventHandler.class, new DefaultKeyManagerEventHandlerImpl(), null);
    ctxt.getBundleContext().registerService(EventHandler.class, new WebhooksSubscriptionEventHandler(), null);
    ctxt.getBundleContext().registerService(EventHandler.class, new WebhooksDeliveryEventHandler(), null);
    ctxt.getBundleContext().registerService(NotificationEventService.class, new NotificationEventService(), null);
}
Also used : NotificationEventService(org.wso2.carbon.apimgt.notification.NotificationEventService) WebhooksDeliveryEventHandler(org.wso2.carbon.apimgt.notification.WebhooksDeliveryEventHandler) DefaultKeyManagerEventHandlerImpl(org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl) WebhooksSubscriptionEventHandler(org.wso2.carbon.apimgt.notification.WebhooksSubscriptionEventHandler) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with DefaultKeyManagerEventHandlerImpl

use of org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl in project carbon-apimgt by wso2.

the class AbstractKeyManagerEventHandlerTest method handleTokenRevocationEventTest.

@Test
public void handleTokenRevocationEventTest() throws Exception {
    TokenRevocationEvent tokenRevocationEvent = new TokenRevocationEvent();
    Assert.assertTrue(StringUtils.isBlank(tokenRevocationEvent.getTokenType()));
    RevocationRequestPublisher revocationRequestPublisher = Mockito.mock(RevocationRequestPublisher.class);
    PowerMockito.mockStatic(RevocationRequestPublisher.class);
    PowerMockito.when(RevocationRequestPublisher.getInstance()).thenReturn(revocationRequestPublisher);
    doNothing().when(revocationRequestPublisher).publishRevocationEvents(Mockito.anyString(), Mockito.anyLong(), Mockito.anyObject());
    Properties properties = Mockito.mock(Properties.class);
    whenNew(Properties.class).withNoArguments().thenReturn(properties);
    ApiMgtDAO apiMgtDAO = Mockito.mock(ApiMgtDAO.class);
    PowerMockito.mockStatic(ApiMgtDAO.class);
    PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
    DefaultKeyManagerEventHandlerImpl defaultKeyManagerEventHandler = new DefaultKeyManagerEventHandlerImpl();
    Boolean result = defaultKeyManagerEventHandler.handleTokenRevocationEvent(tokenRevocationEvent);
    Assert.assertTrue(result);
    Assert.assertEquals("Default", tokenRevocationEvent.getTokenType());
}
Also used : RevocationRequestPublisher(org.wso2.carbon.apimgt.impl.publishers.RevocationRequestPublisher) TokenRevocationEvent(org.wso2.carbon.apimgt.notification.event.TokenRevocationEvent) ApiMgtDAO(org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO) Properties(java.util.Properties) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Properties (java.util.Properties)1 Test (org.junit.Test)1 Activate (org.osgi.service.component.annotations.Activate)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 ApiMgtDAO (org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO)1 RevocationRequestPublisher (org.wso2.carbon.apimgt.impl.publishers.RevocationRequestPublisher)1 DefaultKeyManagerEventHandlerImpl (org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl)1 NotificationEventService (org.wso2.carbon.apimgt.notification.NotificationEventService)1 WebhooksDeliveryEventHandler (org.wso2.carbon.apimgt.notification.WebhooksDeliveryEventHandler)1 WebhooksSubscriptionEventHandler (org.wso2.carbon.apimgt.notification.WebhooksSubscriptionEventHandler)1 TokenRevocationEvent (org.wso2.carbon.apimgt.notification.event.TokenRevocationEvent)1