Search in sources :

Example 6 with NotificationManager

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

the class DailyItemReaderTest method testRead.

@Test
public void testRead() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    final DailyItemReader dailyItemReader = new DailyItemReader(notificationManager, globalProperties);
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList(new NotificationModel(null, null)));
    final List<NotificationModel> notificationList = dailyItemReader.read();
    assertTrue(!notificationList.isEmpty());
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList());
    final List<NotificationModel> hasReadNotificationList = dailyItemReader.read();
    assertNull(hasReadNotificationList);
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 7 with NotificationManager

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

the class DailyItemReaderTest method testUnknownVersionPhoneHome.

@Test
public void testUnknownVersionPhoneHome() throws Exception {
    globalProperties.setProductVersionOverride(GlobalProperties.PRODUCT_VERSION_UNKNOWN);
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    final DailyItemReader dailyItemReader = new DailyItemReader(notificationManager, globalProperties);
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList(new NotificationModel(null, null)));
    final List<NotificationModel> notificationList = dailyItemReader.read();
    assertTrue(!notificationList.isEmpty());
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList());
    final List<NotificationModel> hasReadNotificationList = dailyItemReader.read();
    assertNull(hasReadNotificationList);
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 8 with NotificationManager

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

the class DailyItemReaderTest method testReadNull.

@Test
public void testReadNull() throws Exception {
    final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    Mockito.when(notificationManager.findByCreatedAtBetween(Mockito.any(), Mockito.any())).thenReturn(Arrays.asList());
    final DailyItemReader dailyItemReaderNull = new DailyItemReader(notificationManager, globalProperties);
    final List<NotificationModel> nullNotificationList = dailyItemReaderNull.read();
    assertNull(nullNotificationList);
}
Also used : NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) Test(org.junit.Test)

Example 9 with NotificationManager

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

the class AuditEntryActionsTest method testResendNotificationException.

@Test
public void testResendNotificationException() {
    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 MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
    final MockNotificationEntity mockNotificationEntity = new MockNotificationEntity();
    Mockito.when(auditEntryRepository.findOne(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEmptyEntity());
    Mockito.when(commonDistributionRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(null);
    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, null, null, null, null);
    List<AuditEntryRestModel> restModel = null;
    try {
        restModel = auditEntryActions.resendNotification(1L);
        fail();
    } catch (final IllegalArgumentException e) {
        assertTrue(true);
    } catch (final IntegrationException e) {
        fail();
    }
    assertNull(restModel);
}
Also used : AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper) MockAuditEntryEntity(com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity) Test(org.junit.Test)

Aggregations

NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)9 Test (org.junit.Test)7 NotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper)4 VulnerabilityRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)4 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)4 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)3 MockAuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity)2 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)2 AuditNotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper)2 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 CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)2 MockNotificationEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity)2 GlobalSchedulingRepositoryWrapper (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper)2 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 DBStoreEvent (com.blackducksoftware.integration.hub.alert.event.DBStoreEvent)1 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)1