use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class QualityProfileEventsStepTest method verify_detection_with_complex_mix_of_qps.
@Test
public void verify_detection_with_complex_mix_of_qps() {
final Set<Event> events = new HashSet<>();
doAnswer(invocationOnMock -> {
events.add((Event) invocationOnMock.getArguments()[1]);
return null;
}).when(eventRepository).add(eq(treeRootHolder.getRoot()), any(Event.class));
Date date = new Date();
QualityProfile qp1 = qp(QP_NAME_2, LANGUAGE_KEY_1, date);
QualityProfile qp2 = qp(QP_NAME_2, LANGUAGE_KEY_2, date);
QualityProfile qp3 = qp(QP_NAME_1, LANGUAGE_KEY_1, parseDateTime("2011-04-25T01:05:13+0100"));
QualityProfile qp3_updated = qp(QP_NAME_1, LANGUAGE_KEY_1, parseDateTime("2011-04-25T01:05:17+0100"));
QualityProfile qp4 = qp(QP_NAME_2, LANGUAGE_KEY_3, date);
mockMeasures(treeRootHolder.getRoot(), arrayOf(qp1, qp2, qp3), arrayOf(qp3_updated, qp2, qp4));
mockNoLanguageInRepository();
qProfileStatusRepository.register(qp1.getQpKey(), REMOVED);
qProfileStatusRepository.register(qp2.getQpKey(), UNCHANGED);
qProfileStatusRepository.register(qp3.getQpKey(), UPDATED);
qProfileStatusRepository.register(qp4.getQpKey(), ADDED);
underTest.execute(new TestComputationStepContext());
assertThat(events).extracting("name").containsOnly("Stop using '" + QP_NAME_2 + "' (" + LANGUAGE_KEY_1 + ")", "Use '" + QP_NAME_2 + "' (" + LANGUAGE_KEY_3 + ")", "Changes in '" + QP_NAME_1 + "' (" + LANGUAGE_KEY_1 + ")");
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class QualityProfileEventsStepTest method no_more_used_event_uses_language_key_in_message_if_language_not_found.
@Test
public void no_more_used_event_uses_language_key_in_message_if_language_not_found() {
QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
qProfileStatusRepository.register(qp.getQpKey(), REMOVED);
mockMeasures(treeRootHolder.getRoot(), arrayOf(qp), null);
mockLanguageNotInRepository(LANGUAGE_KEY_1);
underTest.execute(new TestComputationStepContext());
verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
verifyNoMoreInteractions(eventRepository);
verifyEvent(eventArgumentCaptor.getValue(), "Stop using '" + qp.getQpName() + "' (" + qp.getLanguageKey() + ")", null);
}
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, new Date());
qProfileStatusRepository.register(qp.getQpKey(), ADDED);
mockLanguageNotInRepository(LANGUAGE_KEY_1);
mockMeasures(treeRootHolder.getRoot(), null, arrayOf(qp));
underTest.execute(new TestComputationStepContext());
verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
verifyNoMoreInteractions(eventRepository);
verifyEvent(eventArgumentCaptor.getValue(), "Use '" + qp.getQpName() + "' (" + qp.getLanguageKey() + ")", null);
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class QualityProfileEventsStepTest method added_event_if_qp_is_added.
@Test
public void added_event_if_qp_is_added() {
QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date());
qProfileStatusRepository.register(qp.getQpKey(), ADDED);
Language language = mockLanguageInRepository(LANGUAGE_KEY_1);
mockMeasures(treeRootHolder.getRoot(), null, arrayOf(qp));
underTest.execute(new TestComputationStepContext());
verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
verifyNoMoreInteractions(eventRepository);
verifyEvent(eventArgumentCaptor.getValue(), "Use '" + qp.getQpName() + "' (" + language.getName() + ")", null);
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class RegisterQualityProfileStatusStepTest method register_unchanged_profile.
@Test
public void register_unchanged_profile() {
QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1000L));
mockBaseQPMeasures(treeRootHolder.getRoot(), arrayOf(qp1));
mockRawQProfiles(ImmutableList.of(qp1));
underTest.execute(new TestComputationStepContext());
verify(qProfileStatusRepository).register(qp1.getQpKey(), UNCHANGED);
verifyNoMoreInteractions(qProfileStatusRepository);
}
Aggregations