import java.util.HashMap;
import java.util.Map;
import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.utils.MessageException;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.CrawlerDepthLimit;
import org.sonar.server.computation.component.PathAwareCrawler;
@Override
public void visitProject(Component project, Path<QProfiles> path) {
addMeasure(project, path.current());
- Optional<Measure> qProfileMeasure = measureRepository.getRawMeasure(project, qProfilesMetric);
- if (!qProfileMeasure.isPresent() || QPMeasureData.fromJson(qProfileMeasure.get().getData()).getProfiles().isEmpty()) {
- throw MessageException.of(String.format("No quality profiles has been found on project '%s', you probably don't have any language plugin suitable for this analysis.",
- project.getKey()));
- }
}
@Override
// Load base profiles
Optional<Measure> rawMeasure = measureRepository.getRawMeasure(projectComponent, metricRepository.getByKey(CoreMetrics.QUALITY_PROFILES_KEY));
if (!rawMeasure.isPresent()) {
- throw new IllegalStateException("Missing measure " + CoreMetrics.QUALITY_PROFILES + " for component " + projectComponent.getReportAttributes().getRef());
+ // No qualify profile computed on the project
+ return;
}
Map<String, QualityProfile> rawProfiles = QPMeasureData.fromJson(rawMeasure.get().getStringValue()).getProfilesByKey();
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.MessageException;
import org.sonar.server.computation.batch.TreeRootHolderRule;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.ReportComponent;
}
@Test
- public void fail_with_message_exception_when_no_qprofile_computed_on_project() throws Exception {
- thrown.expect(MessageException.class);
- thrown.expectMessage("No quality profiles has been found on project 'PROJECT KEY'");
-
+ public void nothing_to_add_when_no_qprofile_computed_on_project() throws Exception {
treeRootHolder.setRoot(MULTI_MODULE_PROJECT);
underTest.execute();
}
@Test
- public void fail_with_message_exception_when_qprofiles_computed_on_project_are_empty() throws Exception {
- thrown.expect(MessageException.class);
- thrown.expectMessage("No quality profiles has been found on project 'PROJECT KEY', you probably don't have any language plugin suitable for this analysis.");
-
+ public void nothing_to_add_when_qprofiles_computed_on_project_are_empty() throws Exception {
treeRootHolder.setRoot(MULTI_MODULE_PROJECT);
measureRepository.addRawMeasure(PROJECT_REF, QUALITY_PROFILES_KEY, newMeasureBuilder().create(toJson()));
}
@Test
- public void no_effect_if_no_base_measure() {
+ public void no_event_if_no_base_measure() {
when(measureRepository.getBaseMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.<Measure>absent());
underTest.execute();
verifyNoMoreInteractions(eventRepository);
}
- @Test(expected = IllegalStateException.class)
- public void ISE_if_no_raw_measure() {
+ @Test
+ public void no_event_if_no_raw_measure() {
when(measureRepository.getBaseMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.of(newMeasure()));
when(measureRepository.getRawMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.<Measure>absent());
underTest.execute();
+
+ verifyNoMoreInteractions(eventRepository);
}
@Test
- public void no_event_if_no_base_nor_row_QualityProfile_measure() {
+ public void no_event_if_no_base_and_quality_profile_measure_is_empty() {
mockMeasures(treeRootHolder.getRoot(), null, null);
underTest.execute();