Search in sources :

Example 26 with QualityProfileDto

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

the class CompareActionMediumTest method compare_nominal.

@Test
public void compare_nominal() throws Exception {
    createRepository("blah", "xoo", "Blah");
    RuleDto rule1 = createRule("xoo", "rule1");
    RuleDto rule2 = createRule("xoo", "rule2");
    RuleDto rule3 = createRule("xoo", "rule3");
    RuleDto rule4 = createRuleWithParam("xoo", "rule4");
    RuleDto rule5 = createRule("xoo", "rule5");
    /*
     * Profile 1:
     * - rule 1 active (on both profiles) => "same"
     * - rule 2 active (only in this profile) => "inLeft"
     * - rule 4 active with different parameters => "modified"
     * - rule 5 active with different severity => "modified"
     */
    QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
    createActiveRule(rule1, profile1);
    createActiveRule(rule2, profile1);
    createActiveRuleWithParam(rule4, profile1, "polop");
    createActiveRuleWithSeverity(rule5, profile1, Severity.MINOR);
    session.commit();
    /*
     * Profile 1:
     * - rule 1 active (on both profiles) => "same"
     * - rule 3 active (only in this profile) => "inRight"
     * - rule 4 active with different parameters => "modified"
     */
    QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
    createActiveRule(rule1, profile2);
    createActiveRule(rule3, profile2);
    createActiveRuleWithParam(rule4, profile2, "palap");
    createActiveRuleWithSeverity(rule5, profile2, Severity.MAJOR);
    session.commit();
    wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_nominal.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 27 with QualityProfileDto

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

the class RuleActivatorMediumTest method assertProfileHasBeenUpdatedManually.

private void assertProfileHasBeenUpdatedManually(String profileKey) {
    QualityProfileDto profile = db.qualityProfileDao().selectByKey(dbSession, profileKey);
    assertThat(profile.getRulesUpdatedAt()).isNotEmpty();
    assertThat(profile.getUserUpdatedAt()).isNotNull();
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 28 with QualityProfileDto

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

the class DeleteActionTest method delete_nominal_with_key.

@Test
public void delete_nominal_with_key() throws Exception {
    String profileKey = "sonar-way-xoo1-12345";
    ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), "polop");
    componentDao.insert(session, project);
    QualityProfileDto qualityProfile = QualityProfileDto.createFor(profileKey).setOrganizationUuid(defaultOrganizationProvider.get().getUuid()).setLanguage(xoo1.getKey()).setName("Sonar way");
    qualityProfileDao.insert(session, qualityProfile);
    qualityProfileDao.insertProjectProfileAssociation(project.uuid(), profileKey, session);
    session.commit();
    logInAsQProfileAdministrator();
    tester.newPostRequest("api/qualityprofiles", "delete").setParam("profileKey", "sonar-way-xoo1-12345").execute().assertNoContent();
    assertThat(qualityProfileDao.selectByKey(session, "sonar-way-xoo1-12345")).isNull();
    assertThat(qualityProfileDao.selectProjects("Sonar way", xoo1.getName(), session)).isEmpty();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 29 with QualityProfileDto

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

the class ExportActionTest method export_with_format.

@Test
public void export_with_format() throws Exception {
    QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
    String result = newWsActionTester(newExporter("polop"), newExporter("palap")).newRequest().setParam("language", profile.getLanguage()).setParam("name", profile.getName()).setParam("exporterKey", "polop").execute().getInput();
    assertThat(result).isEqualTo("Profile " + profile.getName() + " exported by polop");
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Test(org.junit.Test)

Example 30 with QualityProfileDto

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

the class InheritanceActionMediumTest method inheritance_no_family.

@Test
public void inheritance_no_family() throws Exception {
    // Simple profile, no parent, no child
    QualityProfileDto remi = createProfile("xoo", "Nobodys Boy", "xoo-nobody-s-boy-01234");
    wsTester.newGetRequest("api/qualityprofiles", "inheritance").setParam("profileKey", remi.getKee()).execute().assertJson(getClass(), "inheritance-simple.json");
}
Also used : 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