Search in sources :

Example 21 with SearchWsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method map_dates.

@Test
public void map_dates() {
    long time = DateUtils.parseDateTime("2016-12-22T19:10:03+0100").getTime();
    qualityProfileDb.insert(newQualityProfileDto().setLanguage(XOO1.getKey()).setRulesUpdatedAt("2016-12-21T19:10:03+0100").setLastUsed(time).setUserUpdatedAt(time));
    SearchWsResponse result = call(ws.newRequest());
    assertThat(result.getProfilesCount()).isOne();
    assertThat(result.getProfiles(0).getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100");
    assertThat(parseDateTime(result.getProfiles(0).getLastUsed()).getTime()).isEqualTo(time);
    assertThat(parseDateTime(result.getProfiles(0).getUserUpdatedAt()).getTime()).isEqualTo(time);
}
Also used : SearchWsResponse(org.sonarqube.ws.Qualityprofiles.SearchWsResponse) Test(org.junit.Test)

Example 22 with SearchWsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method filter_on_language.

@Test
public void filter_on_language() {
    QProfileDto profile1OnXoo1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    QProfileDto profile2OnXoo1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    QProfileDto profileOnXoo2 = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey()));
    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_LANGUAGE, XOO1.getKey()));
    assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(profile1OnXoo1.getKee(), profile2OnXoo1.getKee()).doesNotContain(profileOnXoo2.getKee());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) QualityProfile(org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile) SearchWsResponse(org.sonarqube.ws.Qualityprofiles.SearchWsResponse) Test(org.junit.Test)

Example 23 with SearchWsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method filter_on_profile_name.

@Test
public void filter_on_profile_name() {
    QProfileDto sonarWayOnXoo1 = db.qualityProfiles().insert(p -> p.setName("Sonar way").setLanguage(XOO1.getKey()));
    QProfileDto sonarWayOnXoo2 = db.qualityProfiles().insert(p -> p.setName("Sonar way").setLanguage(XOO1.getKey()));
    QProfileDto sonarWayInCamelCase = db.qualityProfiles().insert(p -> p.setName("Sonar Way").setLanguage(XOO2.getKey()));
    QProfileDto anotherProfile = db.qualityProfiles().insert(p -> p.setName("Another").setLanguage(XOO2.getKey()));
    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_QUALITY_PROFILE, "Sonar way"));
    assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(sonarWayOnXoo1.getKee(), sonarWayOnXoo2.getKee()).doesNotContain(anotherProfile.getKee(), sonarWayInCamelCase.getKee());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) QualityProfile(org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile) SearchWsResponse(org.sonarqube.ws.Qualityprofiles.SearchWsResponse) Test(org.junit.Test)

Example 24 with SearchWsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method does_not_filter_when_defaults_is_false.

@Test
public void does_not_filter_when_defaults_is_false() {
    QProfileDto defaultProfile1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    QProfileDto defaultProfile2 = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey()));
    QProfileDto nonDefaultProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    db.qualityProfiles().setAsDefault(defaultProfile1, defaultProfile2);
    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_DEFAULTS, "false"));
    assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(defaultProfile1.getKee(), defaultProfile2.getKee(), nonDefaultProfile.getKee());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) SearchWsResponse(org.sonarqube.ws.Qualityprofiles.SearchWsResponse) Test(org.junit.Test)

Example 25 with SearchWsResponse

use of org.sonarqube.ws.Qualityprofiles.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method filter_on_defaults_and_name.

@Test
public void filter_on_defaults_and_name() {
    QProfileDto sonarWayOnXoo1 = db.qualityProfiles().insert(p -> p.setName("Sonar way").setLanguage(XOO1.getKey()));
    QProfileDto sonarWayOnXoo2 = db.qualityProfiles().insert(p -> p.setName("Sonar way").setLanguage(XOO2.getKey()));
    QProfileDto anotherProfile = db.qualityProfiles().insert(p -> p.setName("Another").setLanguage(XOO2.getKey()));
    db.qualityProfiles().setAsDefault(sonarWayOnXoo1, anotherProfile);
    SearchWsResponse result = call(ws.newRequest().setParam(PARAM_DEFAULTS, "true").setParam(PARAM_QUALITY_PROFILE, "Sonar way"));
    assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(sonarWayOnXoo1.getKee()).doesNotContain(sonarWayOnXoo2.getKee(), anotherProfile.getKee());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) QualityProfile(org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile) SearchWsResponse(org.sonarqube.ws.Qualityprofiles.SearchWsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 SearchWsResponse (org.sonarqube.ws.Qualityprofiles.SearchWsResponse)21 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)16 QualityProfile (org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile)14 ProjectDto (org.sonar.db.project.ProjectDto)9 Languages (org.sonar.api.resources.Languages)6 ComponentFinder (org.sonar.server.component.ComponentFinder)6 WsActionTester (org.sonar.server.ws.WsActionTester)6 SearchWsResponse (org.sonarqube.ws.QualityProfiles.SearchWsResponse)6 List (java.util.List)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Assertions.tuple (org.assertj.core.api.Assertions.tuple)5 Rule (org.junit.Rule)5 QualityProfileTesting.newQualityProfileDto (org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto)5 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 IntStream.range (java.util.stream.IntStream.range)4 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)4 Language (org.sonar.api.resources.Language)4 DEPRECATED (org.sonar.api.rule.RuleStatus.DEPRECATED)4