Search in sources :

Example 31 with Language

use of org.sonar.api.resources.Language in project sonarqube by SonarSource.

the class ShowAction method getLanguage.

public Language getLanguage(QProfileDto profile) {
    Language language = languages.get(profile.getLanguage());
    checkFound(language, "Quality Profile with key '%s' does not exist", profile.getKee());
    return language;
}
Also used : Language(org.sonar.api.resources.Language)

Example 32 with Language

use of org.sonar.api.resources.Language in project sonarqube by SonarSource.

the class RuleMapper method setLanguageName.

private void setLanguageName(Rules.Rule.Builder ruleResponse, RuleDefinitionDto ruleDto, Set<String> fieldsToReturn) {
    String languageKey = ruleDto.getLanguage();
    if (shouldReturnField(fieldsToReturn, FIELD_LANGUAGE_NAME) && languageKey != null) {
        Language language = languages.get(languageKey);
        ruleResponse.setLangName(language == null ? languageKey : language.getName());
    }
}
Also used : Language(org.sonar.api.resources.Language)

Example 33 with Language

use of org.sonar.api.resources.Language in project sonarqube by SonarSource.

the class LanguagesProviderTest method should_provide_instance_when_languages.

@Test
public void should_provide_instance_when_languages() {
    Language A = mock(Language.class);
    when(A.getKey()).thenReturn("a");
    Language B = mock(Language.class);
    when(B.getKey()).thenReturn("b");
    LanguagesProvider provider = new LanguagesProvider();
    List<Language> languageList = Arrays.asList(A, B);
    Languages languages = provider.provide(Optional.of(languageList));
    assertThat(languages).isNotNull();
    assertThat(languages.all()).hasSize(2).contains(A, B);
}
Also used : Language(org.sonar.api.resources.Language) Languages(org.sonar.api.resources.Languages) Test(org.junit.Test)

Aggregations

Language (org.sonar.api.resources.Language)33 Test (org.junit.Test)12 AbstractLanguage (org.sonar.api.resources.AbstractLanguage)8 QualityProfile (org.sonar.server.qualityprofile.QualityProfile)6 Languages (org.sonar.api.resources.Languages)4 JsonWriter (org.sonar.api.utils.text.JsonWriter)4 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)3 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)3 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)3 LanguageTesting.newLanguage (org.sonar.server.language.LanguageTesting.newLanguage)3 Date (java.util.Date)2 IntStream.range (java.util.stream.IntStream.range)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)2 Rule (org.junit.Rule)2 DEPRECATED (org.sonar.api.rule.RuleStatus.DEPRECATED)2 WebService (org.sonar.api.server.ws.WebService)2 DateUtils (org.sonar.api.utils.DateUtils)2 DateUtils.parseDateTime (org.sonar.api.utils.DateUtils.parseDateTime)2