use of org.sonar.ce.task.log.CeTaskMessages in project sonarqube by SonarSource.
the class PersistAnalysisWarningsStepTest method execute_persists_warnings_from_reportReader.
@Test
public void execute_persists_warnings_from_reportReader() {
ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
reportReader.setAnalysisWarnings(warnings);
underTest.execute(new TestComputationStepContext());
verify(ceTaskMessages, times(1)).addAll(argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).extracting(CeTaskMessages.Message::getText, CeTaskMessages.Message::getType).containsExactly(tuple("warning 1", CeTaskMessageType.GENERIC), tuple("warning 2", CeTaskMessageType.GENERIC));
}
use of org.sonar.ce.task.log.CeTaskMessages in project sonarqube by SonarSource.
the class HandleUnanalyzedLanguagesStepTest method adds_warning_and_measures_in_SQ_community_edition_if_there_are_c_files.
@Test
public void adds_warning_and_measures_in_SQ_community_edition_if_there_are_c_files() {
when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().putNotAnalyzedFilesByLanguage("C", 10).build());
underTest.execute(new TestComputationStepContext());
verify(ceTaskMessages, times(1)).add(argumentCaptor.capture());
List<CeTaskMessages.Message> messages = argumentCaptor.getAllValues();
assertThat(messages).extracting(CeTaskMessages.Message::getText).containsExactly("10 unanalyzed C files were detected in this project during the last analysis. C cannot be analyzed with your current SonarQube edition. Please" + " consider <a target=\"_blank\" href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to Developer" + " Edition</a> to find Bugs, Code Smells, Vulnerabilities and Security Hotspots in this file.");
assertThat(measureRepository.getAddedRawMeasure(PROJECT_REF, UNANALYZED_C_KEY).get().getIntValue()).isEqualTo(10);
assertThat(measureRepository.getAddedRawMeasure(PROJECT_REF, UNANALYZED_CPP_KEY)).isEmpty();
}
use of org.sonar.ce.task.log.CeTaskMessages in project sonarqube by SonarSource.
the class HandleUnanalyzedLanguagesStepTest method adds_warning_in_SQ_community_edition_if_there_are_cpp_files.
@Test
public void adds_warning_in_SQ_community_edition_if_there_are_cpp_files() {
when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().putNotAnalyzedFilesByLanguage("C++", 1).build());
underTest.execute(new TestComputationStepContext());
verify(ceTaskMessages, times(1)).add(argumentCaptor.capture());
List<CeTaskMessages.Message> messages = argumentCaptor.getAllValues();
assertThat(messages).extracting(CeTaskMessages.Message::getText).containsExactly("1 unanalyzed C++ file was detected in this project during the last analysis. C++ cannot be analyzed with your current SonarQube edition. Please" + " consider <a target=\"_blank\" href=\"https://www.sonarqube.org/trial-request/developer-edition/?referrer=sonarqube-cpp\">upgrading to Developer" + " Edition</a> to find Bugs, Code Smells, Vulnerabilities and Security Hotspots in this file.");
assertThat(measureRepository.getAddedRawMeasure(PROJECT_REF, UNANALYZED_CPP_KEY).get().getIntValue()).isOne();
assertThat(measureRepository.getAddedRawMeasure(PROJECT_REF, UNANALYZED_C_KEY)).isEmpty();
}
Aggregations