Search in sources :

Example 51 with EmailGlobalConfigModel

use of com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel in project hub-alert by blackducksoftware.

the class JavamailPropertiesFactoryTest method testCreateFromEmailGlobalConfigModel.

@Test
public void testCreateFromEmailGlobalConfigModel() {
    EmailGlobalConfigModel emailGlobalConfigModel = new EmailGlobalConfigModel();
    emailGlobalConfigModel.setSmtpFrom(EXPECTED_FROM_VALUE);
    emailGlobalConfigModel.setSmtpHost(EXPECTED_HOST_VALUE);
    emailGlobalConfigModel.setSmtpPort(EXPECTED_PORT_VALUE);
    emailGlobalConfigModel.setSmtpAuth(EXPECTED_AUTH_VALUE);
    emailGlobalConfigModel.setSmtpUsername(EXPECTED_USERNAME_VALUE);
    emailGlobalConfigModel.setSmtpPassword(EXPECTED_PASSWORD_VALUE);
    emailGlobalConfigModel.setAdditionalJavaMailProperties(Map.of(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey(), EXPECTED_EHLO_VALUE));
    JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
    Properties properties = javamailPropertiesFactory.createJavaMailProperties(emailGlobalConfigModel);
    assertEquals(EXPECTED_FROM_VALUE, properties.getProperty(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey()));
    assertEquals(EXPECTED_HOST_VALUE, properties.getProperty(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey()));
    assertEquals(EXPECTED_PORT_VALUE_STRING, properties.getProperty(EmailPropertyKeys.JAVAMAIL_PORT_KEY.getPropertyKey()));
    assertEquals(EXPECTED_AUTH_VALUE_STRING, properties.getProperty(EmailPropertyKeys.JAVAMAIL_AUTH_KEY.getPropertyKey()));
    assertEquals(EXPECTED_USERNAME_VALUE, properties.getProperty(EmailPropertyKeys.JAVAMAIL_USER_KEY.getPropertyKey()));
    assertEquals(EXPECTED_EHLO_VALUE, properties.getProperty(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey()));
    assertNull(properties.getProperty(EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey()));
}
Also used : EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Aggregations

EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)51 Test (org.junit.jupiter.api.Test)41 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)27 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)26 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)15 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)15 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)15 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)15 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)15 EmailGlobalConfigAccessor (com.synopsys.integration.alert.channel.email.database.accessor.EmailGlobalConfigAccessor)14 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)10 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)9 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)8 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)6 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)6 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)5 UUID (java.util.UUID)5 EmailGlobalCrudActions (com.synopsys.integration.alert.channel.email.action.EmailGlobalCrudActions)4 ValidatedEmailAddresses (com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses)4 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)4