@Test public void testMissingProviders() { SystemMessageAccessor systemMessageAccessor = Mockito.mock(SystemMessageAccessor.class); ConfigurationAccessor configurationAccessor = Mockito.mock(ConfigurationAccessor.class); List<Provider> providers = List.of(); ProviderConfigMissingValidator validator = new ProviderConfigMissingValidator(systemMessageAccessor, providers, configurationAccessor); validator.validate(); Mockito.verify(systemMessageAccessor, Mockito.never()) .addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.any(SystemMessageType.class)); }
public void validate() { removeSystemMessagesByType(SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING); for (Provider provider : providers) { try { List<ConfigurationModel> configurations = configurationAccessor.getConfigurationsByDescriptorKeyAndContext(provider.getKey(), ConfigContextEnum.GLOBAL); boolean emptyConfiguration = isConfigurationsEmpty(configurations); if (emptyConfiguration) { addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } catch (AlertDatabaseConstraintException ex) { logger.debug("Error getting provider configurations", ex); addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } }
ProviderConfigMissingValidator extends BaseSystemValidator { public void validate() { removeSystemMessagesByType(SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING); for (Provider provider : providers) { try { List<ConfigurationModel> configurations = configurationAccessor.getConfigurationsByDescriptorKeyAndContext(provider.getKey(), ConfigContextEnum.GLOBAL); boolean emptyConfiguration = isConfigurationsEmpty(configurations); if (emptyConfiguration) { addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } catch (AlertDatabaseConstraintException ex) { logger.debug("Error getting provider configurations", ex); addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } } }
ProviderConfigMissingValidator extends BaseSystemValidator { public void validate() { removeSystemMessagesByType(SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING); for (Provider provider : providers) { try { List<ConfigurationModel> configurations = configurationAccessor.getConfigurationsByDescriptorKeyAndContext(provider.getKey(), ConfigContextEnum.GLOBAL); boolean emptyConfiguration = isConfigurationsEmpty(configurations); if (emptyConfiguration) { addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } catch (AlertDatabaseConstraintException ex) { logger.debug("Error getting provider configurations", ex); addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } } @Autowired  ProviderConfigMissingValidator(SystemMessageAccessor systemMessageAccessor, List<Provider> providers,
        ConfigurationAccessor configurationAccessor); }
ProviderConfigMissingValidator extends BaseSystemValidator { public void validate() { removeSystemMessagesByType(SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING); for (Provider provider : providers) { try { List<ConfigurationModel> configurations = configurationAccessor.getConfigurationsByDescriptorKeyAndContext(provider.getKey(), ConfigContextEnum.GLOBAL); boolean emptyConfiguration = isConfigurationsEmpty(configurations); if (emptyConfiguration) { addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } catch (AlertDatabaseConstraintException ex) { logger.debug("Error getting provider configurations", ex); addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } } @Autowired  ProviderConfigMissingValidator(SystemMessageAccessor systemMessageAccessor, List<Provider> providers,
        ConfigurationAccessor configurationAccessor); void validate(); }
ProviderConfigMissingValidator extends BaseSystemValidator { public void validate() { removeSystemMessagesByType(SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING); for (Provider provider : providers) { try { List<ConfigurationModel> configurations = configurationAccessor.getConfigurationsByDescriptorKeyAndContext(provider.getKey(), ConfigContextEnum.GLOBAL); boolean emptyConfiguration = isConfigurationsEmpty(configurations); if (emptyConfiguration) { addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } catch (AlertDatabaseConstraintException ex) { logger.debug("Error getting provider configurations", ex); addSystemMessageForError(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, SystemMessageSeverity.WARNING, SystemMessageType.BLACKDUCK_PROVIDER_CONFIGURATION_MISSING, true); } } } @Autowired  ProviderConfigMissingValidator(SystemMessageAccessor systemMessageAccessor, List<Provider> providers,
        ConfigurationAccessor configurationAccessor); void validate(); static final String MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT; }