use of org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE in project sonarqube by SonarSource.
the class SearchActionTest method compare_to_another_profile.
@Test
public void compare_to_another_profile() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(JAVA));
QProfileDto anotherProfile = db.qualityProfiles().insert(p -> p.setLanguage(JAVA));
RuleDefinitionDto commonRule = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
RuleDefinitionDto profileRule1 = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
RuleDefinitionDto profileRule2 = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
RuleDefinitionDto profileRule3 = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
RuleDefinitionDto anotherProfileRule1 = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
RuleDefinitionDto anotherProfileRule2 = db.rules().insertRule(r -> r.setLanguage(JAVA)).getDefinition();
db.qualityProfiles().activateRule(profile, commonRule);
db.qualityProfiles().activateRule(profile, profileRule1);
db.qualityProfiles().activateRule(profile, profileRule2);
db.qualityProfiles().activateRule(profile, profileRule3);
db.qualityProfiles().activateRule(anotherProfile, commonRule);
db.qualityProfiles().activateRule(anotherProfile, anotherProfileRule1);
db.qualityProfiles().activateRule(anotherProfile, anotherProfileRule2);
indexRules();
indexActiveRules();
SearchResponse result = ws.newRequest().setParam(PARAM_QPROFILE, profile.getKee()).setParam(PARAM_ACTIVATION, "false").setParam(PARAM_COMPARE_TO_PROFILE, anotherProfile.getKee()).executeProtobuf(SearchResponse.class);
assertThat(result.getRulesList()).extracting(Rule::getKey).containsExactlyInAnyOrder(anotherProfileRule1.getKey().toString(), anotherProfileRule2.getKey().toString());
}
Aggregations