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