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;
}
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());
}
}
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);
}
Aggregations