use of org.sonar.server.plugins.ServerPluginRepository in project sonarqube by SonarSource.
the class RegisterRulesTest method execute.
private void execute(RulesDefinition... defs) {
ServerPluginRepository pluginRepository = mock(ServerPluginRepository.class);
when(pluginRepository.getPluginKey(any(RulesDefinition.class))).thenReturn(FAKE_PLUGIN_KEY);
RuleDefinitionsLoader loader = new RuleDefinitionsLoader(mock(CommonRuleDefinitionsImpl.class), pluginRepository, defs);
Languages languages = mock(Languages.class);
when(languages.get(any())).thenReturn(mock(Language.class));
reset(webServerRuleFinder);
RegisterRules task = new RegisterRules(loader, qProfileRules, dbClient, ruleIndexer, activeRuleIndexer, languages, system, webServerRuleFinder, uuidFactory, metadataIndex);
task.start();
// Execute a commit to refresh session state as the task is using its own session
db.getSession().commit();
verify(webServerRuleFinder).startCaching();
}
use of org.sonar.server.plugins.ServerPluginRepository in project sonarqube by SonarSource.
the class LanguageValidationTest method succeed_if_no_language.
@Test
public void succeed_if_no_language() {
ServerPluginRepository repo = mock(ServerPluginRepository.class);
LanguageValidation languageValidation = new LanguageValidation(repo);
languageValidation.start();
languageValidation.stop();
}
use of org.sonar.server.plugins.ServerPluginRepository in project sonarqube by SonarSource.
the class LanguageValidationTest method succeed_if_no_duplicated_language.
@Test
public void succeed_if_no_duplicated_language() {
Language lang1 = mock(Language.class);
Language lang2 = mock(Language.class);
when(lang1.getKey()).thenReturn("key1");
when(lang2.getKey()).thenReturn("key2");
ServerPluginRepository repo = mock(ServerPluginRepository.class);
when(repo.getPluginKey(lang1)).thenReturn("plugin1");
when(repo.getPluginKey(lang2)).thenReturn("plugin2");
LanguageValidation languageValidation = new LanguageValidation(repo);
languageValidation.start();
languageValidation.stop();
}
use of org.sonar.server.plugins.ServerPluginRepository in project sonarqube by SonarSource.
the class LanguageValidationTest method fail_if_conflicting_languages.
@Test
public void fail_if_conflicting_languages() {
Language lang1 = mock(Language.class);
Language lang2 = mock(Language.class);
when(lang1.getKey()).thenReturn("key");
when(lang2.getKey()).thenReturn("key");
ServerPluginRepository repo = mock(ServerPluginRepository.class);
when(repo.getPluginKey(lang1)).thenReturn("plugin1");
when(repo.getPluginKey(lang2)).thenReturn("plugin2");
LanguageValidation languageValidation = new LanguageValidation(repo, lang1, lang2);
assertThatThrownBy(languageValidation::start).isInstanceOf(IllegalStateException.class).hasMessage("There are two languages declared with the same key 'key' declared by the plugins 'plugin1' and 'plugin2'. " + "Please uninstall one of the conflicting plugins.");
}
Aggregations