Search in sources :

Example 1 with ServerPluginRepository

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();
}
Also used : RulesDefinition(org.sonar.api.server.rule.RulesDefinition) Language(org.sonar.api.resources.Language) ServerPluginRepository(org.sonar.server.plugins.ServerPluginRepository) Languages(org.sonar.api.resources.Languages)

Example 2 with ServerPluginRepository

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();
}
Also used : ServerPluginRepository(org.sonar.server.plugins.ServerPluginRepository) Test(org.junit.Test)

Example 3 with ServerPluginRepository

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();
}
Also used : Language(org.sonar.api.resources.Language) ServerPluginRepository(org.sonar.server.plugins.ServerPluginRepository) Test(org.junit.Test)

Example 4 with ServerPluginRepository

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.");
}
Also used : Language(org.sonar.api.resources.Language) ServerPluginRepository(org.sonar.server.plugins.ServerPluginRepository) Test(org.junit.Test)

Aggregations

ServerPluginRepository (org.sonar.server.plugins.ServerPluginRepository)4 Test (org.junit.Test)3 Language (org.sonar.api.resources.Language)3 Languages (org.sonar.api.resources.Languages)1 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)1