Search in sources :

Example 16 with ProjectData

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;
}
Also used : CategoryData(com.blackducksoftware.integration.hub.alert.digest.model.CategoryData) HashMap(java.util.HashMap) NotificationCategoryEnum(com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)

Example 17 with 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());
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) MockEmailEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailEntity) GlobalHubConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 18 with ProjectData

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());
}
Also used : ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) Test(org.junit.Test)

Example 19 with ProjectData

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));
}
Also used : CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) DistributionNotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) DatabaseConnectionTest(com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest) Test(org.junit.Test)

Aggregations

ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)19 Test (org.junit.Test)14 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)7 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)6 HashMap (java.util.HashMap)6 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)5 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)5 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)4 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)4 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)4 ChannelRequestHelper (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRequestHelper)3 DistributionChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity)3 GlobalChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity)3 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)3 CategoryData (com.blackducksoftware.integration.hub.alert.digest.model.CategoryData)3 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)2 AuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryEntity)2 HipChatDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity)2 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)2 MockSlackEntity (com.blackducksoftware.integration.hub.alert.channel.slack.mock.MockSlackEntity)2