Search in sources :

Example 1 with ChannelTemplateManager

use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager 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 ChannelTemplateManager

use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.

the class DigestItemWriterTest method testWrite.

@Test
public void testWrite() throws Exception {
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.anyListOf(AbstractChannelEvent.class));
    final DigestItemWriter digestItemWriter = new DigestItemWriter(channelTemplateManager);
    final AbstractChannelEvent abstractChannelEvent = Mockito.mock(AbstractChannelEvent.class);
    final List<AbstractChannelEvent> channelList = Arrays.asList(abstractChannelEvent);
    digestItemWriter.write(Arrays.asList(channelList));
    Mockito.verify(channelTemplateManager).sendEvents(Mockito.anyListOf(AbstractChannelEvent.class));
}
Also used : ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) AbstractChannelEvent(com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent) Test(org.junit.Test)

Example 3 with ChannelTemplateManager

use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.

the class AccumulatorWriterTest method testWrite.

@Test
public void testWrite() throws Exception {
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    final AccumulatorWriter accumulatorWriter = new AccumulatorWriter(notificationManager, channelTemplateManager);
    final String eventKey = "_event_key_";
    final NotificationCategoryEnum categoryType = NotificationCategoryEnum.HIGH_VULNERABILITY;
    final NotificationEvent notificationEvent = new NotificationEvent(eventKey, categoryType, generateDataSet());
    final DBStoreEvent storeEvent = new DBStoreEvent(Arrays.asList(notificationEvent));
    accumulatorWriter.write(Arrays.asList(storeEvent));
    Mockito.verify(channelTemplateManager).sendEvent(Mockito.any());
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationCategoryEnum(com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum) NotificationEvent(com.blackducksoftware.integration.hub.notification.NotificationEvent) DBStoreEvent(com.blackducksoftware.integration.hub.alert.event.DBStoreEvent) Test(org.junit.Test)

Example 4 with ChannelTemplateManager

use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager 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)

Example 5 with ChannelTemplateManager

use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.

the class GlobalSchedulingConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.

@Override
public GlobalSchedulingConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
    final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
    Mockito.when(mockedAccumulatorConfig.getMillisecondsToNextRun()).thenReturn(33000l);
    final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
    Mockito.when(mockedDailyDigestBatchConfig.getFormatedNextRunTime()).thenReturn("01/19/2018 02:00 AM UTC");
    final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
    Mockito.when(mockedPurgeConfig.getFormatedNextRunTime()).thenReturn("01/21/2018 12:00 AM UTC");
    final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
    final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
    final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
    final GlobalSchedulingConfigActions configActions = new GlobalSchedulingConfigActions(mockedAccumulatorConfig, mockedDailyDigestBatchConfig, mockedPurgeConfig, globalSchedulingRepository, objectTransformer, globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
    return configActions;
}
Also used : NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) AccumulatorConfig(com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig) GlobalSchedulingRepositoryWrapper(com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) PurgeConfig(com.blackducksoftware.integration.hub.alert.config.PurgeConfig) DailyDigestBatchConfig(com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)

Aggregations

ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)7 Test (org.junit.Test)5 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)3 AccumulatorConfig (com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig)2 DailyDigestBatchConfig (com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig)2 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)2 PurgeConfig (com.blackducksoftware.integration.hub.alert.config.PurgeConfig)2 NotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper)2 VulnerabilityRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)2 NotificationEventManager (com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager)2 ProjectDataFactory (com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory)2 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)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 GlobalSchedulingRepositoryWrapper (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper)2 Gson (com.google.gson.Gson)2 OutputLogger (com.blackducksoftware.integration.hub.alert.OutputLogger)1 DBStoreEvent (com.blackducksoftware.integration.hub.alert.event.DBStoreEvent)1 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)1