Search in sources :

Example 21 with RulesProfileDto

use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.

the class RegisterQualityProfilesNotificationTest method notification_contains_send_start_and_end_date.

@Test
public void notification_contains_send_start_and_end_date() {
    String language = newLanguageKey();
    RuleDefinitionDto existingRule = db.rules().insert(r -> r.setLanguage(language));
    RulesProfileDto dbProfile = insertBuiltInProfile(language);
    activateRuleInDb(dbProfile, existingRule, MAJOR);
    RuleDefinitionDto newRule = db.rules().insert(r -> r.setLanguage(language));
    addPluginProfile(dbProfile, existingRule, newRule);
    builtInQProfileRepositoryRule.initialize();
    long startDate = RANDOM.nextInt(5000);
    long endDate = startDate + RANDOM.nextInt(5000);
    when(system2.now()).thenReturn(startDate, endDate);
    underTest.start();
    verify(builtInQualityProfilesNotification).onChange(any(), eq(startDate), eq(endDate));
}
Also used : RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) RulesProfileDto(org.sonar.db.qualityprofile.RulesProfileDto) Test(org.junit.Test)

Example 22 with RulesProfileDto

use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.

the class BuiltInQProfileUpdateImplTest method assertThatProfileIsMarkedAsUpdated.

private void assertThatProfileIsMarkedAsUpdated(RulesProfileDto dto) {
    RulesProfileDto reloaded = db.getDbClient().qualityProfileDao().selectBuiltInRuleProfiles(db.getSession()).stream().filter(p -> p.getUuid().equals(dto.getUuid())).findFirst().get();
    assertThat(reloaded.getRulesUpdatedAt()).isNotEmpty();
}
Also used : RulesProfileDto(org.sonar.db.qualityprofile.RulesProfileDto)

Aggregations

RulesProfileDto (org.sonar.db.qualityprofile.RulesProfileDto)22 Test (org.junit.Test)10 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)9 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)7 Map (java.util.Map)6 BuiltInQProfile (org.sonar.server.qualityprofile.builtin.BuiltInQProfile)6 List (java.util.List)5 Multimap (com.google.common.collect.Multimap)4 RuleKey (org.sonar.api.rule.RuleKey)4 BuiltInQualityProfilesDefinition (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition)4 System2 (org.sonar.api.utils.System2)4 MoreCollectors (org.sonar.core.util.stream.MoreCollectors)4 DbClient (org.sonar.db.DbClient)4 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)4 QProfileName (org.sonar.server.qualityprofile.builtin.QProfileName)4 Preconditions.checkState (com.google.common.base.Preconditions.checkState)3 SecureRandom (java.security.SecureRandom)3 Arrays (java.util.Arrays)3 Collections.singleton (java.util.Collections.singleton)3 Random (java.util.Random)3