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