Search in sources :

Example 86 with QualityProfileDto

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

the class QProfileFactoryMediumTest method ignore_renaming_if_same_name.

@Test
public void ignore_renaming_if_same_name() {
    QualityProfileDto dto = factory.create(dbSession, new QProfileName("xoo", "P1"));
    dbSession.commit();
    dbSession.clearCache();
    String key = dto.getKey();
    assertThat(factory.rename(key, "P1")).isFalse();
    dbSession.clearCache();
    QualityProfileDto reloaded = db.qualityProfileDao().selectByKey(dbSession, dto.getKee());
    assertThat(reloaded.getKey()).isEqualTo(key);
    assertThat(reloaded.getName()).isEqualTo("P1");
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 87 with QualityProfileDto

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

the class QProfileFactoryMediumTest method rename.

@Test
public void rename() {
    QualityProfileDto dto = factory.create(dbSession, new QProfileName("xoo", "P1"));
    dbSession.commit();
    dbSession.clearCache();
    String key = dto.getKey();
    assertThat(factory.rename(key, "the new name")).isTrue();
    dbSession.clearCache();
    QualityProfileDto reloaded = db.qualityProfileDao().selectByKey(dbSession, dto.getKee());
    assertThat(reloaded.getKey()).isEqualTo(key);
    assertThat(reloaded.getName()).isEqualTo("the new name");
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 88 with QualityProfileDto

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

the class QProfileFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    QualityProfileDto dto = QualityProfileTesting.newQualityProfileDto().setKey("sw").setName("Sonar way").setLanguage("js");
    dbTester.getDbClient().qualityProfileDao().insert(dbSession, dto);
    dbTester.commit();
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Before(org.junit.Before)

Example 89 with QualityProfileDto

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

the class RegisterQualityProfilesMediumTest method do_not_reset_default_profile_if_still_valid.

@Test
public void do_not_reset_default_profile_if_still_valid() {
    tester = new ServerTester().withEsIndexes().withStartupTasks().addXoo().addComponents(new SimpleProfileDefinition("one", true), new SimpleProfileDefinition("two", false));
    tester.start();
    QualityProfileDao profileDao = dbClient().qualityProfileDao();
    dbSession = dbClient().openSession(false);
    QualityProfileDto profileTwo = profileDao.selectByNameAndLanguage("two", "xoo", dbSession);
    tester.get(QProfileFactory.class).setDefault(dbSession, profileTwo.getKee());
    dbSession.commit();
    verifyDefaultProfile("xoo", "two");
    tester.get(Platform.class).restart();
    // restart must keep "two" as default profile, even if "one" is marked as it
    verifyDefaultProfile("xoo", "two");
}
Also used : QualityProfileDao(org.sonar.db.qualityprofile.QualityProfileDao) Platform(org.sonar.server.platform.Platform) ServerTester(org.sonar.server.tester.ServerTester) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 90 with QualityProfileDto

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

the class CreateActionTest method create_profile_from_backup_xml.

@Test
public void create_profile_from_backup_xml() {
    logInAsQProfileAdministrator();
    insertRule(RULE);
    executeRequest("New Profile", XOO_LANGUAGE, ImmutableMap.of("xoo_lint", "<xml/>"));
    QualityProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage("New Profile", XOO_LANGUAGE, dbSession);
    assertThat(dto.getKey()).isNotNull();
    assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, dto.getKey())).hasSize(1);
    assertThat(ruleIndex.searchAll(new RuleQuery().setQProfileKey(dto.getKey()).setActivation(true))).hasSize(1);
}
Also used : RuleQuery(org.sonar.server.rule.index.RuleQuery) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Aggregations

QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)126 Test (org.junit.Test)76 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)37 RuleDto (org.sonar.db.rule.RuleDto)29 WsTester (org.sonar.server.ws.WsTester)21 RuleQuery (org.sonar.server.rule.index.RuleQuery)14 QualityProfileDao (org.sonar.db.qualityprofile.QualityProfileDao)13 ActiveRuleDao (org.sonar.db.qualityprofile.ActiveRuleDao)12 DbSession (org.sonar.db.DbSession)11 ActiveRuleParamDto (org.sonar.db.qualityprofile.ActiveRuleParamDto)9 SearchOptions (org.sonar.server.es.SearchOptions)9 ComponentDto (org.sonar.db.component.ComponentDto)8 OrganizationDto (org.sonar.db.organization.OrganizationDto)7 ActiveRuleKey (org.sonar.db.qualityprofile.ActiveRuleKey)6 Date (java.util.Date)5 QualityProfileTesting.newQualityProfileDto (org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto)5 RuleParamDto (org.sonar.db.rule.RuleParamDto)5 RulesProfile (org.sonar.api.profiles.RulesProfile)4 Language (org.sonar.api.resources.Language)4 RuleKey (org.sonar.api.rule.RuleKey)4