use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.
the class ExternalGatewayNotifier method process.
/**
* Process gateway notifier events related to External gateway deployments
*
* @param event related to deployments
* @throws NotifierException if error occurs when casting event
*/
private void process(Event event) throws NotifierException {
DeployAPIInGatewayEvent deployAPIInGatewayEvent;
deployAPIInGatewayEvent = (DeployAPIInGatewayEvent) event;
if (isExternalGatewayAvailableToDeployment(deployAPIInGatewayEvent))
if (APIConstants.EventType.DEPLOY_API_IN_GATEWAY.name().equals(event.getType())) {
deployApi(deployAPIInGatewayEvent);
} else if (APIConstants.EventType.REMOVE_API_FROM_GATEWAY.name().equals(event.getType())) {
unDeployApi(deployAPIInGatewayEvent);
}
}
use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.
the class NotificationExecutorTest method testShouldSendNotificationWhenConfigurationExists.
@Test
public void testShouldSendNotificationWhenConfigurationExists() throws Exception {
NotificationDTO notificationDTO = new NotificationDTO(new Properties(), NotifierConstants.NOTIFICATION_TYPE_NEW_VERSION);
notificationDTO.setTenantDomain(TENANT_DOMAIN);
notificationDTO.setTenantID(TENANT_ID);
Notifier notifier = Mockito.mock(Notifier.class);
Mockito.doNothing().when(notifier).run();
PowerMockito.when(APIUtil.class, "getTenantConfig", TENANT_DOMAIN).thenReturn(new JSONParser().parse(validNotifierConf));
PowerMockito.when(APIUtil.class, "getClassInstance", "org.wso2.carbon.apimgt.impl.notification" + ".NewAPIVersionEmailNotifier").thenReturn(notifier);
try {
notificationExecutor.sendAsyncNotifications(notificationDTO);
} catch (NotificationException e) {
Assert.fail("Should not throw an exception");
}
}
use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.
the class NotificationExecutorTest method testShouldNotThrowExceptionWhenNotifierNotDefined.
@Test
public void testShouldNotThrowExceptionWhenNotifierNotDefined() throws Exception {
NotificationDTO notificationDTO = new NotificationDTO(new Properties(), NotifierConstants.NOTIFICATION_TYPE_NEW_VERSION);
notificationDTO.setTenantDomain(TENANT_DOMAIN);
notificationDTO.setTenantID(TENANT_ID);
Notifier notifier = Mockito.mock(Notifier.class);
Mockito.doNothing().when(notifier).run();
PowerMockito.when(APIUtil.class, "getTenantConfig", TENANT_DOMAIN).thenReturn(new JSONParser().parse(invalidNotifierConf));
try {
notificationExecutor.sendAsyncNotifications(notificationDTO);
} catch (NotificationException e) {
Assert.fail("Should not throw an exception");
}
}
use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.
the class SolaceApplicationNotifier method process.
/**
* Process Application notifier event related to Solace applications
*
* @param event related to Application handling
* @throws NotifierException if error occurs when casting event
*/
private void process(Event event) throws NotifierException {
ApplicationEvent applicationEvent;
applicationEvent = (ApplicationEvent) event;
if (APIConstants.EventType.APPLICATION_DELETE.name().equals(event.getType())) {
removeSolaceApplication(applicationEvent);
} else if (APIConstants.EventType.APPLICATION_UPDATE.name().equals(event.getType())) {
renameSolaceApplication(applicationEvent);
}
}
use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.
the class SolaceSubscriptionsNotifier method process.
/**
* Process gateway notifier events related to Solace API subscriptions
*
* @param event related to subscription handling
* @throws NotifierException if error occurs when casting event
*/
private void process(Event event) throws NotifierException {
SubscriptionEvent subscriptionEvent;
subscriptionEvent = (SubscriptionEvent) event;
if (APIConstants.EventType.SUBSCRIPTIONS_CREATE.name().equals(event.getType())) {
crateSubscription(subscriptionEvent);
} else if (APIConstants.EventType.SUBSCRIPTIONS_UPDATE.name().equals(event.getType())) {
updateSubscription(subscriptionEvent);
} else if (APIConstants.EventType.SUBSCRIPTIONS_DELETE.name().equals(event.getType())) {
removeSubscription(subscriptionEvent);
}
}
Aggregations