Search in sources :

Example 6 with ShowResponse

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

the class ShowActionTest method profile_info.

@Test
public void profile_info() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
    assertThat(result.getProfile()).extracting(QualityProfile::getKey, QualityProfile::getName, QualityProfile::getIsBuiltIn, QualityProfile::getLanguage, QualityProfile::getLanguageName, QualityProfile::getIsInherited).containsExactly(profile.getKee(), profile.getName(), profile.isBuiltIn(), profile.getLanguage(), XOO1.getName(), false);
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ShowResponse(org.sonarqube.ws.Qualityprofiles.ShowResponse) Test(org.junit.Test)

Example 7 with ShowResponse

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

the class ShowActionTest method default_profile.

@Test
public void default_profile() {
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    db.qualityProfiles().setAsDefault(profile);
    ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
    assertThat(result.getProfile().getIsDefault()).isTrue();
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ShowResponse(org.sonarqube.ws.Qualityprofiles.ShowResponse) Test(org.junit.Test)

Example 8 with ShowResponse

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

the class ShowActionTest method show.

@Test
public void show() {
    QProfileDto qualityProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    UserDto user = db.users().insertUser();
    userSession.logIn(user);
    ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, qualityProfile.getKee()));
    assertThat(result.getProfile()).extracting(QualityProfile::getKey).isEqualTo(qualityProfile.getKee());
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ShowResponse(org.sonarqube.ws.Qualityprofiles.ShowResponse) UserDto(org.sonar.db.user.UserDto) Test(org.junit.Test)

Example 9 with ShowResponse

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

the class ShowActionTest method map_dates.

@Test
public void map_dates() {
    long time = DateUtils.parseDateTime("2016-12-22T19:10:03+0100").getTime();
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()).setRulesUpdatedAt("2016-12-21T19:10:03+0100").setLastUsed(time).setUserUpdatedAt(time));
    ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
    assertThat(result.getProfile().getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100");
    assertThat(parseDateTime(result.getProfile().getLastUsed()).getTime()).isEqualTo(time);
    assertThat(parseDateTime(result.getProfile().getUserUpdatedAt()).getTime()).isEqualTo(time);
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ShowResponse(org.sonarqube.ws.Qualityprofiles.ShowResponse) Test(org.junit.Test)

Example 10 with ShowResponse

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

the class ShowActionTest method no_comparison_when_sonar_way_does_not_exist.

@Test
public void no_comparison_when_sonar_way_does_not_exist() {
    QProfileDto anotherSonarWayProfile = db.qualityProfiles().insert(p -> p.setIsBuiltIn(true).setName("Another Sonar way").setLanguage(XOO1.getKey()));
    QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
    ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()).setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"));
    assertThat(result.hasCompareToSonarWay()).isFalse();
}
Also used : QProfileDto(org.sonar.db.qualityprofile.QProfileDto) ShowResponse(org.sonarqube.ws.Qualityprofiles.ShowResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)10 ShowResponse (org.sonarqube.ws.Qualityprofiles.ShowResponse)10 UserDto (org.sonar.db.user.UserDto)2 IntStream.range (java.util.stream.IntStream.range)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Rule (org.junit.Rule)1 Language (org.sonar.api.resources.Language)1 Languages (org.sonar.api.resources.Languages)1 DEPRECATED (org.sonar.api.rule.RuleStatus.DEPRECATED)1 WebService (org.sonar.api.server.ws.WebService)1 DateUtils (org.sonar.api.utils.DateUtils)1 DateUtils.parseDateTime (org.sonar.api.utils.DateUtils.parseDateTime)1 System2 (org.sonar.api.utils.System2)1 DbTester (org.sonar.db.DbTester)1 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)1 EsTester (org.sonar.server.es.EsTester)1 NotFoundException (org.sonar.server.exceptions.NotFoundException)1 LanguageTesting.newLanguage (org.sonar.server.language.LanguageTesting.newLanguage)1