Search in sources :

Example 1 with GlobalEmailConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity in project hub-alert by blackducksoftware.

the class DistributionChannelTest method getGlobalConfigEntityTest.

@Test
public void getGlobalConfigEntityTest() {
    final GlobalEmailRepositoryWrapper globalEmailRepositoryWrapper = Mockito.mock(GlobalEmailRepositoryWrapper.class);
    final EmailGroupChannel channel = new EmailGroupChannel(null, null, null, globalEmailRepositoryWrapper, null, null);
    final MockEmailGlobalEntity mockEntity = new MockEmailGlobalEntity();
    final GlobalEmailConfigEntity entity = mockEntity.createGlobalEntity();
    Mockito.when(globalEmailRepositoryWrapper.findAll()).thenReturn(Arrays.asList(entity));
    final GlobalEmailConfigEntity globalEntity = channel.getGlobalConfigEntity();
    assertEquals(entity, globalEntity);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) EmailGroupChannel(com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel) MockEmailGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity) GlobalEmailRepositoryWrapper(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailRepositoryWrapper) Test(org.junit.Test)

Example 2 with GlobalEmailConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity in project hub-alert by blackducksoftware.

the class ObjectTransformerTest method testTransformNullModels.

@Test
public void testTransformNullModels() throws Exception {
    final MockEmailGlobalRestModel restGlobalEmailMockUtil = new MockEmailGlobalRestModel();
    final MockEmailGlobalEntity mockEmailGlobalEntity = new MockEmailGlobalEntity();
    final ObjectTransformer objectTransformer = new ObjectTransformer();
    GlobalEmailConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(null, GlobalEmailConfigEntity.class);
    GlobalEmailConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(null, GlobalEmailConfigRestModel.class);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
    transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restGlobalEmailMockUtil.createGlobalRestModel(), null);
    transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(mockEmailGlobalEntity.createGlobalEntity(), null);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
    transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(null, null);
    transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(null, null);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) MockEmailGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel) MockEmailGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity) GlobalEmailConfigRestModel(com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel) Test(org.junit.Test)

Example 3 with GlobalEmailConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity in project hub-alert by blackducksoftware.

the class EmailPropertiesTest method updateFromConfigTest.

@Test
public void updateFromConfigTest() {
    final String mailSmtpUser = "guy";
    final String mailSmtpPassword = "xxxxx";
    final Integer mailSmtpPort = 99999;
    final Boolean mailSmtpSendPartial = Boolean.TRUE;
    final GlobalEmailConfigEntity emailConfigEntity = new GlobalEmailConfigEntity(null, mailSmtpUser, mailSmtpPassword, mailSmtpPort, null, null, null, null, null, null, null, null, null, mailSmtpSendPartial);
    final EmailProperties emailProperties = new EmailProperties(emailConfigEntity);
    emailProperties.updateFromConfig(emailConfigEntity);
    assertEquals(mailSmtpUser, emailProperties.getJavamailOption(EmailProperties.JAVAMAIL_USER_KEY));
    assertEquals(mailSmtpPort.toString(), emailProperties.getJavamailOption(EmailProperties.JAVAMAIL_PORT_KEY));
    assertEquals(mailSmtpSendPartial.toString(), emailProperties.getJavamailOption(EmailProperties.JAVAMAIL_SEND_PARTIAL_KEY));
    assertEquals(mailSmtpPassword, emailProperties.getMailSmtpPassword());
    assertNotNull(emailProperties.getJavamailConfigProperties());
    IllegalArgumentException caughtException = null;
    try {
        new EmailProperties(null);
    } catch (final IllegalArgumentException e) {
        caughtException = e;
    }
    assertNotNull(caughtException);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) Test(org.junit.Test)

Example 4 with GlobalEmailConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity in project hub-alert by blackducksoftware.

the class MockEmailGlobalEntity method createGlobalEntity.

@Override
public GlobalEmailConfigEntity createGlobalEntity() {
    final GlobalEmailConfigEntity entity = new GlobalEmailConfigEntity(mailSmtpHost, mailSmtpUser, mailSmtpPassword, Integer.valueOf(mailSmtpPort), Integer.valueOf(mailSmtpConnectionTimeout), Integer.valueOf(mailSmtpTimeout), mailSmtpFrom, mailSmtpLocalhost, Boolean.valueOf(mailSmtpEhlo), Boolean.valueOf(mailSmtpAuth), mailSmtpDnsNotify, mailSmtpDnsRet, Boolean.valueOf(mailSmtpAllow8bitmime), Boolean.valueOf(mailSmtpSendPartial));
    entity.setId(id);
    return entity;
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity)

Example 5 with GlobalEmailConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity 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)

Aggregations

GlobalEmailConfigEntity (com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity)7 Test (org.junit.Test)6 MockEmailGlobalEntity (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity)4 GlobalEmailConfigRestModel (com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel)3 MockEmailGlobalRestModel (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel)3 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)1 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)1 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)1 EmailGroupChannel (com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel)1 MockEmailEntity (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailEntity)1 GlobalEmailRepositoryWrapper (com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailRepositoryWrapper)1 GlobalHubConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)1 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)1 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)1 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)1 Category (org.junit.experimental.categories.Category)1