use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class StartupLogTest method testLogConfiguration.
@Test
void testLogConfiguration() throws Exception {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setProxyHost("google.com");
settingsProxyModel.setProxyPort(3218);
settingsProxyModel.setProxyUsername("AUser");
settingsProxyModel.setIsProxyPasswordSet(true);
settingsProxyModel.setProxyPassword("aPassword");
SettingsUtility mockSettingsUtility = Mockito.mock(SettingsUtility.class);
Mockito.when(mockSettingsUtility.getConfiguration()).thenReturn(Optional.of(settingsProxyModel));
ProxyManager proxyManager = new ProxyManager(mockSettingsUtility);
MockAlertProperties testAlertProperties = new MockAlertProperties();
ConfigurationLogger configurationLogger = new ConfigurationLogger(proxyManager, testAlertProperties);
configurationLogger.initializeComponent();
assertTrue(outputLogger.isLineContainingText("Alert Proxy Authenticated: true"));
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class EmailChannelMessagingServiceTest method initializeEmailChannelMessagingService.
@BeforeEach
public void initializeEmailChannelMessagingService() {
MockAlertProperties alertProperties = new MockAlertProperties();
// For a unit test we don't want to actually send emails -- rotte SEPT 2021
EmailMessagingService emailMessagingService = Mockito.mock(EmailMessagingService.class);
Mockito.doCallRealMethod().when(emailMessagingService).addTemplateImage(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
//
Gson gson = new Gson();
MessageContentGroupCsvCreator messageContentGroupCsvCreator = new MessageContentGroupCsvCreator();
EmailAttachmentFileCreator emailAttachmentFileCreator = new EmailAttachmentFileCreator(alertProperties, messageContentGroupCsvCreator, gson);
emailChannelMessagingService = new EmailChannelMessagingService(alertProperties, emailMessagingService, emailAttachmentFileCreator);
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class EmailGlobalTestActionTest method testConfigMissingDestinationTest.
@Test
public void testConfigMissingDestinationTest() {
AuthorizationManager authorizationManager = createAuthorizationManager(255);
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);
ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent("", new EmailGlobalConfigModel());
assertFalse(testResult.isSuccess());
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class EmailGlobalFieldModelTestActionTest method testConfigMissingDestinationTest.
@Test
public void testConfigMissingDestinationTest() {
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();
EmailGlobalFieldModelTestAction emailGlobalFieldModelTestAction = new EmailGlobalFieldModelTestAction(emailChannelMessagingService, javamailPropertiesFactory);
FieldModel validFieldModel = createFieldModelToTest("");
try {
emailGlobalFieldModelTestAction.testConfig("0", validFieldModel, new FieldUtility(Map.of()));
fail("Expected an exception to be thrown");
} catch (AlertException e) {
// Pass
}
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class SlackDistributionEventHandlerTest 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);
}
Aggregations