use of com.blackducksoftware.integration.hub.alert.NotificationManager in project hub-alert by blackducksoftware.
the class AuditEntryActionsTest method testGetException.
@Test
public void testGetException() throws AlertException, IOException {
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
final AuditNotificationRepositoryWrapper auditNotificationRepository = Mockito.mock(AuditNotificationRepositoryWrapper.class);
final CommonDistributionRepositoryWrapper commonDistributionRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
final ObjectTransformer objectTransformer = new ObjectTransformer();
final ObjectTransformer spyObjectTransformer = Mockito.spy(objectTransformer);
final MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
final MockNotificationEntity mockNotificationEntity = new MockNotificationEntity();
final MockCommonDistributionEntity mockCommonDistributionEntity = new MockCommonDistributionEntity();
Mockito.when(auditEntryRepository.findOne(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEmptyEntity());
Mockito.when(commonDistributionRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(mockCommonDistributionEntity.createEntity());
Mockito.doThrow(new AlertException()).when(spyObjectTransformer).databaseEntityToConfigRestModel(Mockito.any(), Mockito.any());
Mockito.when(notificationRepository.findAll(Mockito.any())).thenReturn(Arrays.asList(mockNotificationEntity.createEntity()));
final AuditEntryActions auditEntryActions = new AuditEntryActions(auditEntryRepository, new NotificationManager(notificationRepository, vulnerabilityRepository, auditEntryRepository, auditNotificationRepository), auditNotificationRepository, commonDistributionRepositoryWrapper, spyObjectTransformer, null, null, null);
auditEntryActions.get(1L);
assertTrue(outputLogger.isLineContainingText("Problem converting audit entry"));
}
use of com.blackducksoftware.integration.hub.alert.NotificationManager in project hub-alert by blackducksoftware.
the class DailyItemReaderTest method testReadException.
@Test
public void testReadException() throws Exception {
final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(null);
final DailyItemReader dailyItemReaderException = new DailyItemReader(notificationManager, globalProperties);
final List<NotificationModel> nullNotificationList = dailyItemReaderException.read();
assertNull(nullNotificationList);
}
use of com.blackducksoftware.integration.hub.alert.NotificationManager 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());
}
use of com.blackducksoftware.integration.hub.alert.NotificationManager 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;
}
use of com.blackducksoftware.integration.hub.alert.NotificationManager in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method testConfigurationChangeTriggers.
@Override
public void testConfigurationChangeTriggers() {
final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
Mockito.when(globalSchedulingRepository.findAll()).thenReturn(Arrays.asList(getGlobalEntityMockUtil().createGlobalEntity()));
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, new ObjectTransformer(), globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
configActions.configurationChangeTriggers(null);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.reset(mockedAccumulatorConfig);
Mockito.reset(mockedDailyDigestBatchConfig);
Mockito.reset(mockedPurgeConfig);
final GlobalSchedulingConfigRestModel restModel = getGlobalRestModelMockUtil().createGlobalRestModel();
configActions.configurationChangeTriggers(restModel);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
}
Aggregations