Search in sources :

Example 11 with QualityProfile

use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.

the class QualityProfileEventsStepTest method no_more_used_event_if_qp_is_removed.

@Test
public void no_more_used_event_if_qp_is_removed() {
    QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
    qProfileStatusRepository.register(qp.getQpKey(), REMOVED);
    mockMeasures(treeRootHolder.getRoot(), arrayOf(qp), null);
    Language language = mockLanguageInRepository(LANGUAGE_KEY_1);
    underTest.execute(new TestComputationStepContext());
    verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
    verifyNoMoreInteractions(eventRepository);
    verifyEvent(eventArgumentCaptor.getValue(), "Stop using '" + qp.getQpName() + "' (" + language.getName() + ")", null);
}
Also used : AbstractLanguage(org.sonar.api.resources.AbstractLanguage) Language(org.sonar.api.resources.Language) QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Example 12 with QualityProfile

use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.

the class QualityProfileEventsStepTest method no_event_if_qp_is_unchanged.

@Test
public void no_event_if_qp_is_unchanged() {
    QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
    qProfileStatusRepository.register(qp.getQpKey(), UNCHANGED);
    mockMeasures(treeRootHolder.getRoot(), arrayOf(qp), arrayOf(qp));
    underTest.execute(new TestComputationStepContext());
    verify(eventRepository, never()).add(any(Component.class), any(Event.class));
}
Also used : Event(org.sonar.ce.task.projectanalysis.event.Event) QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Component(org.sonar.ce.task.projectanalysis.component.Component) ReportComponent(org.sonar.ce.task.projectanalysis.component.ReportComponent) Date(java.util.Date) Test(org.junit.Test)

Example 13 with QualityProfile

use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.

the class ComponentActionTest method return_quality_profiles_and_supports_deleted_ones.

@Test
public void return_quality_profiles_and_supports_deleted_ones() {
    ComponentDto project = insertProject();
    QProfileDto qp1 = db.qualityProfiles().insert(t -> t.setKee("qp1").setName("Sonar Way Java").setLanguage("java"));
    QProfileDto qp2 = db.qualityProfiles().insert(t -> t.setKee("qp2").setName("Sonar Way Xoo").setLanguage("xoo"));
    addQualityProfiles(project, new QualityProfile(qp1.getKee(), qp1.getName(), qp1.getLanguage(), new Date()), new QualityProfile(qp2.getKee(), qp2.getName(), qp2.getLanguage(), new Date()));
    userSession.addProjectPermission(UserRole.USER, project);
    init();
    executeAndVerify(project.getDbKey(), "return_quality_profiles.json");
    db.getDbClient().qualityProfileDao().deleteOrgQProfilesByUuids(db.getSession(), ImmutableSet.of(qp1.getKee(), qp2.getKee()));
    db.commit();
    executeAndVerify(project.getDbKey(), "return_deleted_quality_profiles.json");
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ComponentDto(org.sonar.db.component.ComponentDto) QualityProfile(org.sonar.server.qualityprofile.QualityProfile) Date(java.util.Date) Test(org.junit.Test)

Example 14 with QualityProfile

use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.

the class ComputeQProfileMeasureStepTest method fail_if_report_inconsistant.

@Test
public void fail_if_report_inconsistant() throws Exception {
    treeRootHolder.setRoot(MULTI_MODULE_PROJECT);
    QualityProfile qpJava = createQProfile(QP_NAME_1, LANGUAGE_KEY_1);
    analysisMetadataHolder.setQProfilesByLanguage(ImmutableMap.of(LANGUAGE_KEY_1, qpJava));
    try {
        underTest.execute();
        fail("Expected exception");
    } catch (Exception e) {
        assertThat(e).hasCause(new IllegalStateException("Report contains a file with language 'php' but no matching quality profile"));
    }
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 15 with QualityProfile

use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.

the class QualityProfileEventsStepTest method added_event_uses_language_key_in_message_if_language_not_found.

@Test
public void added_event_uses_language_key_in_message_if_language_not_found() {
    QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1);
    mockLanguageNotInRepository(LANGUAGE_KEY_1);
    mockMeasures(treeRootHolder.getRoot(), null, arrayOf(qp));
    underTest.execute();
    verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
    verifyNoMoreInteractions(eventRepository);
    verifyEvent(eventArgumentCaptor.getValue(), "Use '" + qp.getQpName() + "' (" + qp.getLanguageKey() + ")", null);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) Test(org.junit.Test)

Aggregations

QualityProfile (org.sonar.server.qualityprofile.QualityProfile)25 Test (org.junit.Test)22 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)13 Date (java.util.Date)12 AbstractLanguage (org.sonar.api.resources.AbstractLanguage)6 Language (org.sonar.api.resources.Language)6 Component (org.sonar.ce.task.projectanalysis.component.Component)2 Event (org.sonar.ce.task.projectanalysis.event.Event)2 DbSession (org.sonar.db.DbSession)2 Component (org.sonar.server.computation.task.projectanalysis.component.Component)2 HashSet (java.util.HashSet)1 ExpectedException (org.junit.rules.ExpectedException)1 ScannerPlugin (org.sonar.ce.task.projectanalysis.analysis.ScannerPlugin)1 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)1 Metric (org.sonar.ce.task.projectanalysis.metric.Metric)1 ComponentDto (org.sonar.db.component.ComponentDto)1 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)1 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)1 Plugin (org.sonar.scanner.protocol.output.ScannerReport.Metadata.Plugin)1 QProfile (org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile)1