Search in sources :

Example 1 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class SlackChannelTestIT method createConnectionFactory.

private ChannelRestConnectionFactory createConnectionFactory() {
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 2 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class BlackDuckNotificationRetrieverFactoryTest method createBlackDuckProperties.

private BlackDuckProperties createBlackDuckProperties(String blackDuckUrl) {
    ConfigurationModel configurationModel = createConfigurationModel(blackDuckUrl);
    ProxyManager proxyManager = new ProxyManager(new MockSettingsUtility());
    return new BlackDuckProperties(1L, new Gson(), BlackDuckServicesFactory.createDefaultObjectMapper(), new MockAlertProperties(), proxyManager, configurationModel);
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) BlackDuckProperties(com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) Gson(com.google.gson.Gson)

Example 3 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class EmailGlobalTestActionTest method createValidEmailChannelMessagingService.

private EmailChannelMessagingService createValidEmailChannelMessagingService(String emailAddress) {
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    EmailAddressGatherer emailAddressGatherer = Mockito.mock(EmailAddressGatherer.class);
    Mockito.when(emailAddressGatherer.gatherEmailAddresses(Mockito.any(), Mockito.any())).thenReturn(Set.of(emailAddress));
    JobEmailAddressValidator emailAddressValidator = Mockito.mock(JobEmailAddressValidator.class);
    Mockito.when(emailAddressValidator.validate(Mockito.any(), Mockito.anyCollection())).thenReturn(new ValidatedEmailAddresses(Set.of(emailAddress), Set.of()));
    Gson gson = new Gson();
    MessageContentGroupCsvCreator messageContentGroupCsvCreator = new MessageContentGroupCsvCreator();
    EmailAttachmentFileCreator emailAttachmentFileCreator = new EmailAttachmentFileCreator(testAlertProperties, messageContentGroupCsvCreator, gson);
    FreemarkerTemplatingService freemarkerTemplatingService = new FreemarkerTemplatingService();
    EmailMessagingService emailMessagingService = new EmailMessagingService(freemarkerTemplatingService);
    return new EmailChannelMessagingService(testAlertProperties, emailMessagingService, emailAttachmentFileCreator);
}
Also used : MessageContentGroupCsvCreator(com.synopsys.integration.alert.channel.email.attachment.MessageContentGroupCsvCreator) FreemarkerTemplatingService(com.synopsys.integration.alert.service.email.template.FreemarkerTemplatingService) EmailMessagingService(com.synopsys.integration.alert.service.email.EmailMessagingService) JobEmailAddressValidator(com.synopsys.integration.alert.channel.email.distribution.address.JobEmailAddressValidator) EmailAttachmentFileCreator(com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) Gson(com.google.gson.Gson) EmailAddressGatherer(com.synopsys.integration.alert.channel.email.distribution.address.EmailAddressGatherer) ValidatedEmailAddresses(com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)

Example 4 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class EmailGlobalTestActionTest method testPermissionConfigMissingDestinationTest.

@Test
public void testPermissionConfigMissingDestinationTest() {
    AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
    EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
    EmailAddressGatherer emailAddressGatherer = Mockito.mock(EmailAddressGatherer.class);
    Mockito.when(emailAddressGatherer.gatherEmailAddresses(Mockito.any(), Mockito.any())).thenReturn(Set.of());
    JobEmailAddressValidator emailAddressValidator = Mockito.mock(JobEmailAddressValidator.class);
    Mockito.when(emailAddressValidator.validate(Mockito.any(), Mockito.anyCollection())).thenReturn(new ValidatedEmailAddresses(Set.of(), Set.of()));
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    MessageContentGroupCsvCreator messageContentGroupCsvCreator = new MessageContentGroupCsvCreator();
    Gson gson = new Gson();
    EmailAttachmentFileCreator emailAttachmentFileCreator = new EmailAttachmentFileCreator(testAlertProperties, messageContentGroupCsvCreator, gson);
    FreemarkerTemplatingService freemarkerTemplatingService = new FreemarkerTemplatingService();
    EmailMessagingService emailMessagingService = new EmailMessagingService(freemarkerTemplatingService);
    EmailChannelMessagingService emailChannelMessagingService = new EmailChannelMessagingService(testAlertProperties, emailMessagingService, emailAttachmentFileCreator);
    JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
    EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, emailChannelMessagingService, javamailPropertiesFactory, configurationAccessor);
    ActionResponse<ValidationResponseModel> response = emailGlobalTestAction.testWithPermissionCheck("", new EmailGlobalConfigModel());
    assertEquals(HttpStatus.OK, response.getHttpStatus());
    assertTrue(response.hasContent());
    assertTrue(response.getContent().get().hasErrors(), "Expected the message result to not have errors");
}
Also used : MessageContentGroupCsvCreator(com.synopsys.integration.alert.channel.email.attachment.MessageContentGroupCsvCreator) EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) EmailMessagingService(com.synopsys.integration.alert.service.email.EmailMessagingService) EmailAttachmentFileCreator(com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator) Gson(com.google.gson.Gson) EmailAddressGatherer(com.synopsys.integration.alert.channel.email.distribution.address.EmailAddressGatherer) ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) EmailGlobalConfigurationValidator(com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator) FreemarkerTemplatingService(com.synopsys.integration.alert.service.email.template.FreemarkerTemplatingService) JobEmailAddressValidator(com.synopsys.integration.alert.channel.email.distribution.address.JobEmailAddressValidator) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ValidatedEmailAddresses(com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) Test(org.junit.jupiter.api.Test)

Example 5 with MockAlertProperties

use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.

the class SettingsEncryptionValidatorTest method validateNotInitializedTest.

@Test
public void validateNotInitializedTest() {
    MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
    alertPropertiesNoEncryption.setEncryptionPassword("");
    alertPropertiesNoEncryption.setEncryptionSalt("");
    FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
    EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
    SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
    settingsEncryptionModel.setEncryptionPassword("password");
    settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertFalse(validationResponseModel.hasErrors());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Aggregations

MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)19 Test (org.junit.jupiter.api.Test)10 Gson (com.google.gson.Gson)9 EmailAttachmentFileCreator (com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator)7 MessageContentGroupCsvCreator (com.synopsys.integration.alert.channel.email.attachment.MessageContentGroupCsvCreator)7 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)7 EmailMessagingService (com.synopsys.integration.alert.service.email.EmailMessagingService)7 JobEmailAddressValidator (com.synopsys.integration.alert.channel.email.distribution.address.JobEmailAddressValidator)6 ValidatedEmailAddresses (com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses)6 FreemarkerTemplatingService (com.synopsys.integration.alert.service.email.template.FreemarkerTemplatingService)6 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)5 FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)5 EmailAddressGatherer (com.synopsys.integration.alert.channel.email.distribution.address.EmailAddressGatherer)4 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)4 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)4 SettingsEncryptionModel (com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel)4 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)4 ChannelRestConnectionFactory (com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory)3 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)3 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)2