aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-10-02 16:03:03 +0200
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-10-04 13:32:03 +0200
commit489831d3073f67cb838fd607fa90a344125c33f2 (patch)
tree8ed64167a6e586e4510abdd248ced4d3793a664c /tests
parentec5005ad979eb7bc47f277b42992851d8a4fbebc (diff)
downloadsonarqube-489831d3073f67cb838fd607fa90a344125c33f2.tar.gz
sonarqube-489831d3073f67cb838fd607fa90a344125c33f2.zip
SONAR-9498 show correct n. of "more" items in quality profile changelog
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java
index 6047ae1230d..b88ad7121fb 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java
@@ -21,9 +21,12 @@ package org.sonarqube.tests.qualityProfile;
import com.sonar.orchestrator.Orchestrator;
import java.util.function.Predicate;
+import org.json.JSONException;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
import org.sonarqube.tests.Category6Suite;
import org.sonarqube.tests.Tester;
import org.sonarqube.ws.Organizations.Organization;
@@ -35,6 +38,7 @@ import org.sonarqube.ws.QualityProfiles.ShowResponse.QualityProfile;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsResponse;
+import org.sonarqube.ws.client.qualityprofile.ChangelogWsRequest;
import org.sonarqube.ws.client.qualityprofile.SearchWsRequest;
import org.sonarqube.ws.client.qualityprofile.ShowRequest;
@@ -44,6 +48,12 @@ public class QualityProfilesWsTest {
private static final String RULE_ONE_BUG_PER_LINE = "xoo:OneBugIssuePerLine";
private static final String RULE_ONE_ISSUE_PER_LINE = "xoo:OneIssuePerLine";
+ private static final String EXPECTED_CHANGELOG = "{\"total\":2,\"p\":1,\"ps\":50,\"events\":[" +
+ "{\"authorLogin\":\"admin\",\"authorName\":\"Administrator\",\"action\":\"ACTIVATED\",\"ruleKey\":\"xoo:OneIssuePerLine\",\"ruleName\":\"One Issue Per Line\",\"params\":{\"severity\":\"MAJOR\"}}," +
+ "{\"authorLogin\":\"admin\",\"authorName\":\"Administrator\",\"action\":\"ACTIVATED\",\"ruleKey\":\"xoo:OneBugIssuePerLine\",\"ruleName\":\"One Bug Issue Per Line\",\"params\":{\"severity\":\"MAJOR\"}}" +
+ "]}";
+ private static final String EXPECTED_CHANGELOG_EMPTY = "{\"total\":0,\"p\":1,\"ps\":50,\"events\":[]}";
+
@ClassRule
public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR;
@@ -118,6 +128,37 @@ public class QualityProfilesWsTest {
.isEqualTo("xoo -> empty -> 0");
}
+ @Test
+ public void changelog() throws JSONException {
+ Organization org = tester.organizations().generate();
+ CreateWsResponse.QualityProfile profile = tester.qProfiles().createXooProfile(org);
+
+ String changelog = tester.wsClient().qualityProfiles().changelog(ChangelogWsRequest.builder()
+ .setOrganization(org.getKey())
+ .setLanguage(profile.getLanguage())
+ .setQualityProfile(profile.getName())
+ .build());
+ JSONAssert.assertEquals(EXPECTED_CHANGELOG_EMPTY, changelog, JSONCompareMode.STRICT);
+
+ tester.qProfiles().activateRule(profile, RULE_ONE_BUG_PER_LINE);
+ tester.qProfiles().activateRule(profile, RULE_ONE_ISSUE_PER_LINE);
+
+ String changelog2 = tester.wsClient().qualityProfiles().changelog(ChangelogWsRequest.builder()
+ .setOrganization(org.getKey())
+ .setLanguage(profile.getLanguage())
+ .setQualityProfile(profile.getName())
+ .build());
+ JSONAssert.assertEquals(EXPECTED_CHANGELOG, changelog2, JSONCompareMode.LENIENT);
+
+ String changelog3 = tester.wsClient().qualityProfiles().changelog(ChangelogWsRequest.builder()
+ .setOrganization(org.getKey())
+ .setLanguage(profile.getLanguage())
+ .setQualityProfile(profile.getName())
+ .setSince("2999-12-31T23:59:59+0000")
+ .build());
+ JSONAssert.assertEquals(EXPECTED_CHANGELOG_EMPTY, changelog3, JSONCompareMode.STRICT);
+ }
+
private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate<SearchWsResponse.QualityProfile> filter) {
return tester.qProfiles().service().search(new SearchWsRequest()
.setOrganizationKey(organization.getKey())).getProfilesList()