diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2023-12-19 10:13:02 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-01-04 20:02:48 +0000 |
commit | cd59a269218256fbd43e3e1573d0319b4253e245 (patch) | |
tree | 1c3692b40d686ae7e28e3f3078fffd051f71b22d /sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest | |
parent | 7839d6e3c8fd4045efca1b4cb76db0709189965f (diff) | |
download | sonarqube-cd59a269218256fbd43e3e1573d0319b4253e245.tar.gz sonarqube-cd59a269218256fbd43e3e1573d0319b4253e245.zip |
SONAR-21195 Make DefaultLanguagesRepository more suitable for tests
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesLoader.java (renamed from sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesRepository.java) | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesRepository.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesLoader.java index 7443db29fa3..d7b481a1113 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesRepository.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakeLanguagesLoader.java @@ -1,6 +1,6 @@ /* * SonarQube - * Copyright (C) 2009-2023 SonarSource SA + * Copyright (C) 2009-2024 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or @@ -19,43 +19,31 @@ */ package org.sonar.scanner.mediumtest; -import java.util.Collection; -import java.util.Comparator; import java.util.HashMap; import java.util.Map; import javax.annotation.Priority; -import org.jetbrains.annotations.Nullable; import org.sonar.api.resources.Languages; import org.sonar.scanner.repository.language.Language; -import org.sonar.scanner.repository.language.LanguagesRepository; +import org.sonar.scanner.repository.language.LanguagesLoader; import org.sonar.scanner.repository.language.SupportedLanguageDto; @Priority(1) -public class FakeLanguagesRepository implements LanguagesRepository { +public class FakeLanguagesLoader implements LanguagesLoader { private final Map<String, Language> languageMap = new HashMap<>(); - public FakeLanguagesRepository() { + public FakeLanguagesLoader() { languageMap.put("xoo", new Language(new FakeLanguage("xoo", "xoo", new String[] { ".xoo" }, new String[0], true))); } - public FakeLanguagesRepository(Languages languages) { + public FakeLanguagesLoader(Languages languages) { for (org.sonar.api.resources.Language language : languages.all()) { languageMap.put(language.getKey(), new Language(new FakeLanguage(language.getKey(), language.getName(), language.getFileSuffixes(), language.filenamePatterns(), true))); } } - - @Nullable - @Override - public Language get(String languageKey) { - return languageMap.get(languageKey); - } - @Override - public Collection<Language> all() { - return languageMap.values().stream() - // sorted for test consistency - .sorted(Comparator.comparing(Language::key)).toList(); + public Map<String, Language> load() { + return languageMap; } public void addLanguage(String key, String name, String[] suffixes, String[] filenamePatterns) { |