Search in sources :

Example 1 with NotificationEventManager

use of com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager in project hub-alert by blackducksoftware.

the class RealTimeListenerTest method testReceiveMessageException.

@SuppressWarnings("unchecked")
@Test
public void testReceiveMessageException() throws IOException, Exception {
    try (OutputLogger outputLogger = new OutputLogger()) {
        final Gson gson = new Gson();
        final MockNotificationEntity notificationEntity = new MockNotificationEntity();
        final NotificationModel model = new NotificationModel(notificationEntity.createEntity(), Collections.emptyList());
        final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
        final ProjectDataFactory projectDataFactory = Mockito.mock(ProjectDataFactory.class);
        final NotificationEventManager eventManager = Mockito.mock(NotificationEventManager.class);
        Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.any());
        Mockito.doThrow(new NullPointerException("null error")).when(projectDataFactory).createProjectDataCollection(Mockito.anyCollection(), Mockito.any());
        final RealTimeListener realTimeListener = new RealTimeListener(gson, channelTemplateManager, projectDataFactory, eventManager);
        final RealTimeEvent realTimeEvent = new RealTimeEvent(Arrays.asList(model));
        final String realTimeEventString = gson.toJson(realTimeEvent);
        realTimeListener.receiveMessage(realTimeEventString);
        assertTrue(outputLogger.isLineContainingText("null"));
    }
}
Also used : MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationEventManager(com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager) OutputLogger(com.blackducksoftware.integration.hub.alert.OutputLogger) Gson(com.google.gson.Gson) RealTimeEvent(com.blackducksoftware.integration.hub.alert.event.RealTimeEvent) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) ProjectDataFactory(com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory) Test(org.junit.Test)

Example 2 with NotificationEventManager

use of com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager in project hub-alert by blackducksoftware.

the class RealTimeListenerTest method testReceiveMessage.

@Test
public void testReceiveMessage() {
    final Gson gson = new Gson();
    final MockNotificationEntity notificationEntity = new MockNotificationEntity();
    final NotificationModel model = new NotificationModel(notificationEntity.createEntity(), Collections.emptyList());
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    final ProjectDataFactory projectDataFactory = Mockito.mock(ProjectDataFactory.class);
    final NotificationEventManager eventManager = Mockito.mock(NotificationEventManager.class);
    final RealTimeListener realTimeListener = new RealTimeListener(gson, channelTemplateManager, projectDataFactory, eventManager);
    final RealTimeEvent realTimeEvent = new RealTimeEvent(Arrays.asList(model));
    final String realTimeEventString = gson.toJson(realTimeEvent);
    realTimeListener.receiveMessage(realTimeEventString);
    Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.any());
    Mockito.verify(channelTemplateManager).sendEvents(Mockito.any());
}
Also used : MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationEventManager(com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager) Gson(com.google.gson.Gson) RealTimeEvent(com.blackducksoftware.integration.hub.alert.event.RealTimeEvent) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) ProjectDataFactory(com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory) Test(org.junit.Test)

Aggregations

ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)2 NotificationEventManager (com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager)2 ProjectDataFactory (com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory)2 RealTimeEvent (com.blackducksoftware.integration.hub.alert.event.RealTimeEvent)2 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)2 MockNotificationEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity)2 Gson (com.google.gson.Gson)2 Test (org.junit.Test)2 OutputLogger (com.blackducksoftware.integration.hub.alert.OutputLogger)1