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);
}
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);
}
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);
}
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);
}
Aggregations