use of com.blackducksoftware.integration.hub.alert.digest.model.ProjectData in project hub-alert by blackducksoftware.
the class ChannelTest method createProjectData.
public ProjectData createProjectData(final String testName) {
final HashMap<NotificationCategoryEnum, CategoryData> categoryMap = new HashMap<>();
categoryMap.put(NotificationCategoryEnum.POLICY_VIOLATION, createMockPolicyViolation());
categoryMap.put(NotificationCategoryEnum.MEDIUM_VULNERABILITY, createMockVulnerability());
final ProjectData projectData = new ProjectData(DigestTypeEnum.REAL_TIME, testName, testName + " Version", Collections.emptyList(), categoryMap);
return projectData;
}
use of com.blackducksoftware.integration.hub.alert.digest.model.ProjectData in project hub-alert by blackducksoftware.
the class EmailChannelTestIT method sendEmailTest.
@Test
@Category(ExternalConnectionTest.class)
public void sendEmailTest() throws Exception {
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final GlobalHubRepositoryWrapper globalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final GlobalHubConfigEntity globalConfig = new GlobalHubConfigEntity(300, properties.getProperty(TestPropertyKey.TEST_HUB_API_KEY));
Mockito.when(globalRepository.findAll()).thenReturn(Arrays.asList(globalConfig));
final TestGlobalProperties globalProperties = new TestGlobalProperties(globalRepository);
globalProperties.setHubUrl(properties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
final String trustCert = properties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT);
if (trustCert != null) {
globalProperties.setHubTrustCertificate(Boolean.valueOf(trustCert));
}
EmailGroupChannel emailChannel = new EmailGroupChannel(globalProperties, gson, auditEntryRepository, null, null, null);
final ProjectData projectData = createProjectData("Manual test project");
final EmailGroupEvent event = new EmailGroupEvent(projectData, 1L);
final String smtpHost = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_HOST);
final String smtpFrom = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_FROM);
final GlobalEmailConfigEntity emailGlobalConfigEntity = new GlobalEmailConfigEntity(smtpHost, null, null, null, null, null, smtpFrom, null, null, null, null, null, null, null);
emailChannel = Mockito.spy(emailChannel);
Mockito.doReturn(emailGlobalConfigEntity).when(emailChannel).getGlobalConfigEntity();
final MockEmailEntity mockEmailEntity = new MockEmailEntity();
mockEmailEntity.setGroupName("IntegrationTest");
emailChannel.sendAuditedMessage(event, mockEmailEntity.createEntity());
}
use of com.blackducksoftware.integration.hub.alert.digest.model.ProjectData in project hub-alert by blackducksoftware.
the class ChannelManagerTest method testCreateChannelEvent.
@Test
public void testCreateChannelEvent() {
final CM channelManager = getChannelManager();
final ProjectData projectData = new ProjectData(DigestTypeEnum.DAILY, "Test project", "1", Arrays.asList(), new HashMap<>());
final CE channelEvent = channelManager.createChannelEvent(projectData, 1L);
assertEquals(Long.valueOf(1L), channelEvent.getCommonDistributionConfigId());
assertEquals(36, channelEvent.getEventId().length());
assertEquals(channelTopic(), channelEvent.getTopic());
}
use of com.blackducksoftware.integration.hub.alert.digest.model.ProjectData in project hub-alert by blackducksoftware.
the class NotificationPostProcessorTestIT method doNotificationTypesMatchWithNoneConfiguredTest.
@Test
public void doNotificationTypesMatchWithNoneConfiguredTest() {
final DistributionNotificationTypeRepositoryWrapper distributionNotificationTypeRepository = Mockito.mock(DistributionNotificationTypeRepositoryWrapper.class);
final NotificationPostProcessor postProcessor = new NotificationPostProcessor(distributionProjectRepository, configuredProjectsRepository, distributionNotificationTypeRepository, notificationTypeRepository);
Mockito.when(distributionNotificationTypeRepository.findByCommonDistributionConfigId(Mockito.anyLong())).thenReturn(Collections.emptyList());
final ProjectData projectData = new ProjectData(null, null, null, null, null);
final CommonDistributionConfigEntity config = new CommonDistributionConfigEntity(13L, SupportedChannels.EMAIL_GROUP, "Config 1", DigestTypeEnum.DAILY, true);
config.setId(13L);
assertFalse(postProcessor.doNotificationTypesMatch(config, projectData));
}
Aggregations