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");
}
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");
}
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();
}
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");
}
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);
}
Aggregations