Search in sources :

Example 1 with SystemMessageAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor in project hub-alert by blackducksoftware.

the class ProviderConfigMissingValidatorTest method testValidConfigurations.

@Test
public void testValidConfigurations() {
    SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    List<Provider> providers = List.of(Mockito.mock(Provider.class));
    ConfigurationModel model = Mockito.mock(ConfigurationModel.class);
    Mockito.when(model.getCopyOfFieldList()).thenReturn(List.of(Mockito.mock(ConfigurationFieldModel.class)));
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(), Mockito.any())).thenReturn(List.of(model));
    ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationModelConfigurationAccessor);
    validator.validate();
    Mockito.verify(systemMessageAccessor, Mockito.never()).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.anyString());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) SystemMessageSeverity(com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) SystemMessageAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor) Test(org.junit.jupiter.api.Test)

Example 2 with SystemMessageAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor in project hub-alert by blackducksoftware.

the class ProviderConfigMissingValidatorTest method testEmptyConfigurationsList.

@Test
public void testEmptyConfigurationsList() {
    SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    List<Provider> providers = List.of(Mockito.mock(Provider.class));
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(ProviderKey.class), Mockito.any(ConfigContextEnum.class))).thenReturn(List.of());
    ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationModelConfigurationAccessor);
    validator.validate();
    Mockito.verify(systemMessageAccessor).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.anyString());
}
Also used : ProviderKey(com.synopsys.integration.alert.descriptor.api.model.ProviderKey) SystemMessageSeverity(com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) SystemMessageAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor) Test(org.junit.jupiter.api.Test)

Example 3 with SystemMessageAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor in project hub-alert by blackducksoftware.

the class SystemValidatorTest method testValidate.

@Test
public void testValidate() {
    BlackDuckProperties blackDuckProperties = Mockito.mock(BlackDuckProperties.class);
    Mockito.when(blackDuckProperties.getBlackDuckUrl()).thenReturn(Optional.of("Black Duck URL"));
    Mockito.when(blackDuckProperties.getApiToken()).thenReturn("Black Duck API Token");
    Mockito.when(blackDuckProperties.getBlackDuckTimeout()).thenReturn(BlackDuckProperties.DEFAULT_TIMEOUT);
    SettingsSystemValidator settingsSystemValidator = Mockito.mock(SettingsSystemValidator.class);
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    UserSystemValidator userSystemValidator = Mockito.mock(UserSystemValidator.class);
    SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
    SystemMessageInitializer systemValidator = new SystemMessageInitializer(List.of(), settingsSystemValidator, configurationModelConfigurationAccessor, userSystemValidator, systemMessageAccessor);
    systemValidator.validate();
}
Also used : BlackDuckProperties(com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties) SettingsSystemValidator(com.synopsys.integration.alert.component.settings.validator.SettingsSystemValidator) UserSystemValidator(com.synopsys.integration.alert.component.users.UserSystemValidator) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) SystemMessageAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor) DefaultSystemMessageAccessor(com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor) Test(org.junit.jupiter.api.Test)

Example 4 with SystemMessageAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor in project hub-alert by blackducksoftware.

the class ProviderConfigMissingValidatorTest method testMissingProviders.

@Test
public void testMissingProviders() {
    SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    List<Provider> providers = List.of();
    ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationModelConfigurationAccessor);
    validator.validate();
    Mockito.verify(systemMessageAccessor, Mockito.never()).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.any(SystemMessageType.class));
}
Also used : SystemMessageSeverity(com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity) SystemMessageType(com.synopsys.integration.alert.common.enumeration.SystemMessageType) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) SystemMessageAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor) Test(org.junit.jupiter.api.Test)

Example 5 with SystemMessageAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor in project hub-alert by blackducksoftware.

the class ProviderConfigMissingValidatorTest method testEmptyConfigurations.

@Test
public void testEmptyConfigurations() {
    SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class);
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    List<Provider> providers = List.of(Mockito.mock(Provider.class));
    ConfigurationModel model = Mockito.mock(ConfigurationModel.class);
    Mockito.when(model.getCopyOfFieldList()).thenReturn(List.of());
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(ProviderKey.class), Mockito.any(ConfigContextEnum.class))).thenReturn(List.of(model));
    ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationModelConfigurationAccessor);
    validator.validate();
    Mockito.verify(systemMessageAccessor).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.anyString());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ProviderKey(com.synopsys.integration.alert.descriptor.api.model.ProviderKey) SystemMessageSeverity(com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) SystemMessageAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)6 SystemMessageAccessor (com.synopsys.integration.alert.common.persistence.accessor.SystemMessageAccessor)6 Test (org.junit.jupiter.api.Test)6 SystemMessageSeverity (com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity)4 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)2 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 SettingsSystemValidator (com.synopsys.integration.alert.component.settings.validator.SettingsSystemValidator)2 UserSystemValidator (com.synopsys.integration.alert.component.users.UserSystemValidator)2 DefaultSystemMessageAccessor (com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor)2 ProviderKey (com.synopsys.integration.alert.descriptor.api.model.ProviderKey)2 BlackDuckProperties (com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties)2 SystemMessageType (com.synopsys.integration.alert.common.enumeration.SystemMessageType)1