Search in sources :

Example 6 with QualityProfile

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

the class ComputeQProfileMeasureStepTest method add_quality_profile_measure_on_project.

@Test
public void add_quality_profile_measure_on_project() {
    treeRootHolder.setRoot(MULTI_MODULE_PROJECT);
    QualityProfile qpJava = createQProfile(QP_NAME_1, LANGUAGE_KEY_1);
    QualityProfile qpPhp = createQProfile(QP_NAME_2, LANGUAGE_KEY_2);
    analysisMetadataHolder.setQProfilesByLanguage(ImmutableMap.of(LANGUAGE_KEY_1, qpJava, LANGUAGE_KEY_2, qpPhp));
    underTest.execute(new TestComputationStepContext());
    assertThat(measureRepository.getAddedRawMeasures(PROJECT_REF).get(QUALITY_PROFILES_KEY)).extracting("data").isEqualTo(toJson(qpJava, qpPhp));
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 7 with QualityProfile

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

the class RegisterQualityProfileStatusStepTest method register_added_profile.

@Test
public void register_added_profile() {
    QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1000L));
    QualityProfile qp2 = qp(QP_NAME_2, LANGUAGE_KEY_2, new Date(1000L));
    mockBaseQPMeasures(treeRootHolder.getRoot(), arrayOf(qp1));
    mockRawQProfiles(ImmutableList.of(qp1, qp2));
    underTest.execute(new TestComputationStepContext());
    verify(qProfileStatusRepository).register(qp1.getQpKey(), UNCHANGED);
    verify(qProfileStatusRepository).register(qp2.getQpKey(), ADDED);
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Example 8 with QualityProfile

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

the class RegisterQualityProfileStatusStepTest method register_removed_profile.

@Test
public void register_removed_profile() {
    QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
    mockBaseQPMeasures(treeRootHolder.getRoot(), new QualityProfile[] { qp });
    underTest.execute(new TestComputationStepContext());
    verify(qProfileStatusRepository).register(qp.getQpKey(), REMOVED);
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Example 9 with QualityProfile

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

the class RegisterQualityProfileStatusStepTest method register_updated_profile.

@Test
public void register_updated_profile() {
    QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1000L));
    QualityProfile qp2 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1200L));
    mockBaseQPMeasures(treeRootHolder.getRoot(), arrayOf(qp1));
    mockRawQProfiles(ImmutableList.of(qp2));
    underTest.execute(new TestComputationStepContext());
    verify(qProfileStatusRepository).register(qp2.getQpKey(), UPDATED);
    verifyNoMoreInteractions(qProfileStatusRepository);
}
Also used : QualityProfile(org.sonar.server.qualityprofile.QualityProfile) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Date(java.util.Date) Test(org.junit.Test)

Example 10 with QualityProfile

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

the class QualityProfileEventsStepTest method changed_event_if_qp_has_been_updated.

@Test
public void changed_event_if_qp_has_been_updated() {
    QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, parseDateTime("2011-04-25T01:05:13+0100"));
    QualityProfile qp2 = qp(QP_NAME_1, LANGUAGE_KEY_1, parseDateTime("2011-04-25T01:05:17+0100"));
    qProfileStatusRepository.register(qp2.getQpKey(), UPDATED);
    mockMeasures(treeRootHolder.getRoot(), arrayOf(qp1), arrayOf(qp2));
    Language language = mockLanguageInRepository(LANGUAGE_KEY_1);
    underTest.execute(new TestComputationStepContext());
    verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
    verifyNoMoreInteractions(eventRepository);
    verifyEvent(eventArgumentCaptor.getValue(), "Changes in '" + qp2.getQpName() + "' (" + language.getName() + ")", "from=" + UtcDateUtils.formatDateTime(parseDateTime("2011-04-25T01:05:14+0100")) + ";key=" + qp1.getQpKey() + ";to=" + UtcDateUtils.formatDateTime(parseDateTime("2011-04-25T01:05:18+0100")));
}
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) 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