Search in sources :

Example 21 with QualityProfileDto

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

the class ProjectDataLoaderMediumTest method addDefaultProfile.

private void addDefaultProfile() {
    QualityProfileDto profileDto = newQProfileDto("org-123", QProfileName.createFor(ServerTester.Xoo.KEY, "SonarQube way"), "abcd").setRulesUpdatedAt(formatDateTime(new Date())).setDefault(true);
    dbClient.qualityProfileDao().insert(dbSession, profileDto);
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Date(java.util.Date)

Example 22 with QualityProfileDto

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

the class UpdateQualityProfilesLastUsedDateStepTest method ancestor_profiles_are_updated.

@Test
public void ancestor_profiles_are_updated() throws Exception {
    // Parent profiles should be updated
    QualityProfileDto rootProfile = newQualityProfileDto().setKey("root");
    QualityProfileDto parentProfile = newQualityProfileDto().setKey("parent").setParentKee(rootProfile.getKey());
    // Current profile => should be updated
    QualityProfileDto currentProfile = newQualityProfileDto().setKey("current").setParentKee(parentProfile.getKey());
    // Child of current profile => should not be updated
    QualityProfileDto childProfile = newQualityProfileDto().setKey("child").setParentKee(currentProfile.getKey());
    qualityProfileDb.insertQualityProfiles(rootProfile, parentProfile, currentProfile, childProfile);
    measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create(toJson(currentProfile.getKey())));
    underTest.execute();
    assertQualityProfileIsUpdated(rootProfile);
    assertQualityProfileIsUpdated(parentProfile);
    assertQualityProfileIsUpdated(currentProfile);
    assertQualityProfileIsTheSame(childProfile);
}
Also used : QualityProfileTesting.newQualityProfileDto(org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 23 with QualityProfileDto

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

the class CompareActionMediumTest method createProfile.

private QualityProfileDto createProfile(String lang, String name, String key) {
    QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, name), key);
    db.qualityProfileDao().insert(session, profile);
    session.commit();
    return profile;
}
Also used : QProfileName(org.sonar.server.qualityprofile.QProfileName) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 24 with QualityProfileDto

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

the class CompareActionMediumTest method compare_param_on_right.

@Test
public void compare_param_on_right() throws Exception {
    RuleDto rule1 = createRuleWithParam("xoo", "rule1");
    createRepository("blah", "xoo", "Blah");
    QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
    createActiveRule(rule1, profile1);
    QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
    createActiveRuleWithParam(rule1, profile2, "polop");
    session.commit();
    wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_param_on_right.json");
}
Also used : ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 25 with QualityProfileDto

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

the class CompareActionMediumTest method compare_param_on_left.

@Test
public void compare_param_on_left() throws Exception {
    RuleDto rule1 = createRuleWithParam("xoo", "rule1");
    createRepository("blah", "xoo", "Blah");
    QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
    createActiveRuleWithParam(rule1, profile1, "polop");
    QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
    createActiveRule(rule1, profile2);
    session.commit();
    wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_param_on_left.json");
}
Also used : ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) 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