diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-19 14:46:58 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-20 11:07:24 +0100 |
commit | 88219ea163c159be7d16203be32d8f0b3d7e7d0a (patch) | |
tree | ef96d6c0860ebac6b53ff6f39d521a733c14c25b /server | |
parent | 1af9a73913f04992e8a9033b29980dd74c6f0a22 (diff) | |
download | sonarqube-88219ea163c159be7d16203be32d8f0b3d7e7d0a.tar.gz sonarqube-88219ea163c159be7d16203be32d8f0b3d7e7d0a.zip |
Replace lib org.skyscreamer.jsonassert by org.sonar.test.JsonAssert.
This class supports lenient comparison of datetime values.
Diffstat (limited to 'server')
28 files changed, 243 insertions, 240 deletions
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index da5049e8286..bc6768f29a9 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -216,11 +216,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.skyscreamer</groupId> - <artifactId>jsonassert</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>xmlunit</groupId> <artifactId>xmlunit</artifactId> <scope>test</scope> diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java index 36f91833e9f..8c8e4670c71 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java @@ -88,7 +88,7 @@ public class SearchActionTest { MockUserSession.set().setLogin("john").addProjectUuidPermissions(UserRole.USER, "EFGH"); WsTester.TestRequest request = tester.newGetRequest("api/components", "search").setParam("componentUuid", "EFGH").setParam("q", "st").setParam("p", "2").setParam("ps", "1"); - request.execute().assertJson(getClass(), "return_paged_result.json", false); + request.execute().assertJson(getClass(), "return_paged_result.json"); } @Test @@ -97,7 +97,7 @@ public class SearchActionTest { MockUserSession.set().setLogin("john").addProjectUuidPermissions(UserRole.USER, "EFGH"); WsTester.TestRequest request = tester.newGetRequest("api/components", "search").setParam("componentUuid", "EFGH").setParam("q", "st").setParam("p", "1").setParam("ps", "1"); - request.execute().assertJson(getClass(), "return_only_first_page.json", false); + request.execute().assertJson(getClass(), "return_only_first_page.json"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/HistoryWsActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/HistoryWsActionMediumTest.java index 26fe86462b3..d04c2c21cf7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/HistoryWsActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/HistoryWsActionMediumTest.java @@ -77,7 +77,7 @@ public class HistoryWsActionMediumTest { MockUserSession.set().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); WsTester.TestRequest request = tester.wsTester().newGetRequest("api/computation", "history"); - request.execute().assertJson(getClass(), "list_history_reports.json", false); + request.execute().assertJson(getClass(), "list_history_reports.json"); } @Test(expected = ForbiddenException.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java index 846f8d095b3..ebf3bf043f4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java @@ -60,7 +60,7 @@ public class QueueWsActionTest { when(queue.all()).thenReturn(reports); WsTester.TestRequest request = tester.newGetRequest(ComputationWebService.API_ENDPOINT, "queue"); - request.execute().assertJson(getClass(), "list_queue_reports.json", false); + request.execute().assertJson(getClass(), "list_queue_reports.json"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java index 73df3a7c827..18fd62b7fec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsJsonWriterTest.java @@ -20,18 +20,17 @@ package org.sonar.server.duplication.ws; -import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.utils.text.JsonWriter; import org.sonar.core.component.ComponentDto; import org.sonar.core.persistence.DbSession; import org.sonar.server.component.ComponentTesting; import org.sonar.server.component.db.ComponentDao; +import org.sonar.test.JsonAssert; import java.io.StringWriter; import java.util.Collections; @@ -40,9 +39,7 @@ import java.util.List; import static com.google.common.collect.Lists.newArrayList; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) public class DuplicationsJsonWriterTest { @@ -77,14 +74,15 @@ public class DuplicationsJsonWriterTest { when(componentDao.getNullableByKey(session, key1)).thenReturn(file1); when(componentDao.getNullableByKey(session, key2)).thenReturn(file2); - when(componentDao.getNullableById(5L, session)).thenReturn(new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client")); + when(componentDao.getNullableById(5L, session)).thenReturn( + new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client")); when(componentDao.getNullableByUuid(session, project.uuid())).thenReturn(project); List<DuplicationsParser.Block> blocks = newArrayList(); blocks.add(new DuplicationsParser.Block(newArrayList( new DuplicationsParser.Duplication(file1, 57, 12), new DuplicationsParser.Duplication(file2, 73, 12) - ))); + ))); test(blocks, "{\n" + @@ -118,8 +116,7 @@ public class DuplicationsJsonWriterTest { " \"subProjectName\": \"SonarQube :: Web Service Client\"\n" + " }\n" + " }" + - "}" - ); + "}"); verify(componentDao, times(2)).getNullableByKey(eq(session), anyString()); // Verify call to dao is cached when searching for project / sub project @@ -142,7 +139,7 @@ public class DuplicationsJsonWriterTest { blocks.add(new DuplicationsParser.Block(newArrayList( new DuplicationsParser.Duplication(file1, 57, 12), new DuplicationsParser.Duplication(file2, 73, 12) - ))); + ))); test(blocks, "{\n" + @@ -172,8 +169,7 @@ public class DuplicationsJsonWriterTest { " \"projectName\": \"SonarQube\"\n" + " }\n" + " }" + - "}" - ); + "}"); } @Test @@ -190,7 +186,7 @@ public class DuplicationsJsonWriterTest { new DuplicationsParser.Duplication(file1, 57, 12), // Duplication on a removed file new DuplicationsParser.Duplication(null, 73, 12) - ))); + ))); test(blocks, "{\n" + @@ -214,8 +210,7 @@ public class DuplicationsJsonWriterTest { " \"projectName\": \"SonarQube\"\n" + " }\n" + " }" + - "}" - ); + "}"); } @Test @@ -223,13 +218,13 @@ public class DuplicationsJsonWriterTest { test(Collections.<DuplicationsParser.Block>emptyList(), "{\"duplications\": [], \"files\": {}}"); } - private void test(List<DuplicationsParser.Block> blocks, String expected) throws JSONException { + private void test(List<DuplicationsParser.Block> blocks, String expected) { StringWriter output = new StringWriter(); JsonWriter jsonWriter = JsonWriter.of(output); jsonWriter.beginObject(); writer.write(blocks, jsonWriter, session); jsonWriter.endObject(); - JSONAssert.assertEquals(expected, output.toString(), false); + JsonAssert.assertJson(output.toString()).isSimilarTo(expected); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java index 8eea2257555..6c1db01f582 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java @@ -20,9 +20,9 @@ package org.sonar.server.es; import org.junit.Test; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.utils.text.JsonWriter; import org.sonar.server.search.QueryContext; +import org.sonar.test.JsonAssert; import java.io.StringWriter; @@ -129,7 +129,7 @@ public class SearchOptionsTest { options.writeJson(jsonWriter, 42L); jsonWriter.endObject().close(); - JSONAssert.assertEquals("{\"total\": 42, \"p\": 3, \"ps\": 10}", json.toString(), true); + JsonAssert.assertJson(json.toString()).isSimilarTo("{\"total\": 42, \"p\": 3, \"ps\": 10}"); } @Test @@ -140,7 +140,7 @@ public class SearchOptionsTest { options.writeDeprecatedJson(jsonWriter, 42L); jsonWriter.endObject().close(); - JSONAssert.assertEquals("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 42, \"fTotal\": \"42\", \"pages\": 5}}", json.toString(), true); + JsonAssert.assertJson(json.toString()).isSimilarTo("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 42, \"fTotal\": \"42\", \"pages\": 5}}"); } @Test @@ -151,6 +151,6 @@ public class SearchOptionsTest { options.writeDeprecatedJson(jsonWriter, 30L); jsonWriter.endObject().close(); - JSONAssert.assertEquals("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 30, \"fTotal\": \"30\", \"pages\": 3}}", json.toString(), true); + JsonAssert.assertJson(json.toString()).isSimilarTo("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 30, \"fTotal\": \"30\", \"pages\": 3}}"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/filter/FavoritesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/filter/FavoritesActionTest.java index 8ab06092016..35bce350817 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/filter/FavoritesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/filter/FavoritesActionTest.java @@ -58,7 +58,7 @@ public class FavoritesActionTest { MockUserSession.set(); tester.newGetRequest("api/issue_filters", "favorites").execute() - .assertJson("{'favoriteFilters': []}"); + .assertJson("{\"favoriteFilters\": []}"); } @Test @@ -69,7 +69,7 @@ public class FavoritesActionTest { )); tester.newGetRequest("api/issue_filters", "favorites").execute() - .assertJson("{'favoriteFilters': [{'id': 13, 'name': 'Blocker issues', 'user': 'simon', 'shared': true}]}"); + .assertJson("{\"favoriteFilters\": [{\"id\": 13, \"name\": \"Blocker issues\", \"user\": \"simon\", \"shared\": true}]}"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/filter/IssueFilterWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/filter/IssueFilterWriterTest.java index d9e71d91800..a468eeb70ad 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/filter/IssueFilterWriterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/filter/IssueFilterWriterTest.java @@ -20,9 +20,7 @@ package org.sonar.server.issue.filter; -import org.json.JSONException; import org.junit.Test; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.utils.text.JsonWriter; import org.sonar.core.issue.db.IssueFilterDto; import org.sonar.core.permission.GlobalPermissions; @@ -31,6 +29,8 @@ import org.sonar.server.user.UserSession; import java.io.StringWriter; +import static org.sonar.test.JsonAssert.assertJson; + public class IssueFilterWriterTest { IssueFilterWriter writer = new IssueFilterWriter(); @@ -54,8 +54,7 @@ public class IssueFilterWriterTest { " \"query\":\"severity=BLOCKER\",\n" + " \"user\":\"simon\",\n" + " \"canModify\":false\n" + - " }}" - ); + " }}"); } @Test @@ -77,8 +76,7 @@ public class IssueFilterWriterTest { " \"query\":\"severity=BLOCKER\",\n" + " \"user\":\"simon\",\n" + " \"canModify\":true\n" + - " }}" - ); + " }}"); } @Test @@ -100,16 +98,15 @@ public class IssueFilterWriterTest { " \"query\":\"severity=BLOCKER\",\n" + " \"user\":\"julien\",\n" + " \"canModify\":true\n" + - " }}" - ); + " }}"); } - private void test(UserSession userSession, IssueFilterDto filter, String expected) throws JSONException { + private void test(UserSession userSession, IssueFilterDto filter, String expected) { StringWriter output = new StringWriter(); JsonWriter jsonWriter = JsonWriter.of(output); jsonWriter.beginObject(); writer.write(userSession, filter, jsonWriter); jsonWriter.endObject(); - JSONAssert.assertEquals(output.toString(), expected, true); + assertJson(output.toString()).isSimilarTo(expected); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java index fe6472b390c..4dd53d9bf0f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java @@ -86,7 +86,7 @@ public class ComponentTagsActionTest { @Test public void should_return_empty_list() throws Exception { - tester.newGetRequest("api/issues", "component_tags").setParam("componentUuid", "polop").execute().assertJson("{tags:[]}"); + tester.newGetRequest("api/issues", "component_tags").setParam("componentUuid", "polop").execute().assertJson("{\"tags\":[]}"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueActionsWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueActionsWriterTest.java index 73f0d301ff3..d4f10786a6a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueActionsWriterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueActionsWriterTest.java @@ -20,13 +20,11 @@ package org.sonar.server.issue.ws; -import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.issue.Issue; import org.sonar.api.issue.action.Action; import org.sonar.api.issue.internal.DefaultIssue; @@ -37,6 +35,7 @@ import org.sonar.core.issue.workflow.Transition; import org.sonar.server.issue.ActionService; import org.sonar.server.issue.IssueService; import org.sonar.server.user.MockUserSession; +import org.sonar.test.JsonAssert; import java.io.StringWriter; @@ -181,22 +180,22 @@ public class IssueActionsWriterTest { "{\"transitions\": []}"); } - private void testActions(Issue issue, String expected) throws JSONException { + private void testActions(Issue issue, String expected) { StringWriter output = new StringWriter(); JsonWriter jsonWriter = JsonWriter.of(output); jsonWriter.beginObject(); writer.writeActions(issue, jsonWriter); jsonWriter.endObject(); - JSONAssert.assertEquals(output.toString(), expected, true); + JsonAssert.assertJson(output.toString()).isSimilarTo(expected); } - private void testTransitions(Issue issue, String expected) throws JSONException { + private void testTransitions(Issue issue, String expected) { StringWriter output = new StringWriter(); JsonWriter jsonWriter = JsonWriter.of(output); jsonWriter.beginObject(); writer.writeTransitions(issue, jsonWriter); jsonWriter.endObject(); - JSONAssert.assertEquals(output.toString(), expected, true); + JsonAssert.assertJson(output.toString()).isSimilarTo(expected); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueTagsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueTagsActionTest.java index 9519396292b..3bdf5a1c37b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueTagsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/IssueTagsActionTest.java @@ -73,14 +73,14 @@ public class IssueTagsActionTest { @Test public void should_return_empty_list() throws Exception { - tester.newGetRequest("api/issues", "tags").execute().assertJson("{tags:[]}"); + tester.newGetRequest("api/issues", "tags").execute().assertJson("{\"tags\":[]}"); } @Test public void should_return_tag_list() throws Exception { when(service.listTags("polop", 5)).thenReturn(Lists.newArrayList("tag1", "tag2", "tag3", "tag4", "tag5")); tester.newGetRequest("api/issues", "tags").setParam("q", "polop").setParam("ps", "5").execute() - .assertJson("{tags:[\"tag1\", \"tag2\", \"tag3\", \"tag4\", \"tag5\"]}"); + .assertJson("{\"tags\":[\"tag1\", \"tag2\", \"tag3\", \"tag4\", \"tag5\"]}"); verify(service).listTags("polop", 5); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java index b8d6c393b92..6d6759b1575 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java @@ -105,7 +105,7 @@ public class SearchActionComponentsMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "issues_on_different_projects.json", false); + result.assertJson(this.getClass(), "issues_on_different_projects.json"); } @Test @@ -121,22 +121,22 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.PROJECT_UUIDS, project.uuid()) .execute() - .assertJson(this.getClass(), "search_by_project_uuid.json", false); + .assertJson(this.getClass(), "search_by_project_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.PROJECT_UUIDS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, project.uuid()) .execute() - .assertJson(this.getClass(), "search_by_project_uuid.json", false); + .assertJson(this.getClass(), "search_by_project_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @Test @@ -162,7 +162,7 @@ public class SearchActionComponentsMediumTest { .setParam(IssueFilterParameters.PROJECT_UUIDS, project1.uuid()) .setParam(WebService.Param.FACETS, "projectUuids") .execute() - .assertJson(this.getClass(), "display_sticky_project_facet.json", false); + .assertJson(this.getClass(), "display_sticky_project_facet.json"); } @Test @@ -178,22 +178,22 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.FILE_UUIDS, file.uuid()) .execute() - .assertJson(this.getClass(), "search_by_file_uuid.json", false); + .assertJson(this.getClass(), "search_by_file_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.FILE_UUIDS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, file.uuid()) .execute() - .assertJson(this.getClass(), "search_by_file_uuid.json", false); + .assertJson(this.getClass(), "search_by_file_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @Test @@ -212,12 +212,12 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENTS, file.key()) .execute() - .assertJson(this.getClass(), "search_by_file_key.json", false); + .assertJson(this.getClass(), "search_by_file_key.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENTS, unitTest.key()) .execute() - .assertJson(this.getClass(), "search_by_test_key.json", false); + .assertJson(this.getClass(), "search_by_test_key.json"); } @@ -240,7 +240,7 @@ public class SearchActionComponentsMediumTest { .setParam(IssueFilterParameters.FILE_UUIDS, file1.uuid() + "," + file3.uuid()) .setParam(WebService.Param.FACETS, "fileUuids") .execute() - .assertJson(this.getClass(), "display_file_facet.json", false); + .assertJson(this.getClass(), "display_file_facet.json"); } @Test @@ -257,22 +257,22 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, directory.uuid()) .execute() - .assertJson(this.getClass(), "search_by_file_uuid.json", false); + .assertJson(this.getClass(), "search_by_file_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java/dir") .execute() - .assertJson(this.getClass(), "search_by_file_uuid.json", false); + .assertJson(this.getClass(), "search_by_file_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @Test @@ -295,34 +295,34 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, directory1.uuid()) .execute() - .assertJson(this.getClass(), "search_by_directory_uuid.json", false); + .assertJson(this.getClass(), "search_by_directory_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, directory2.uuid()) .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.MODULE_UUIDS, module1.uuid()) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java/dir") .execute() - .assertJson(this.getClass(), "search_by_directory_uuid.json", false); + .assertJson(this.getClass(), "search_by_directory_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.MODULE_UUIDS, module2.uuid()) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java/dir") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java/dir") .execute() - .assertJson(this.getClass(), "search_by_directory_uuid.json", false); + .assertJson(this.getClass(), "search_by_directory_uuid.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.DIRECTORIES, "src/main/java") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @Test @@ -347,7 +347,7 @@ public class SearchActionComponentsMediumTest { .setParam(IssueFilterParameters.MODULE_UUIDS, subModule1.uuid() + "," + subModule3.uuid()) .setParam(WebService.Param.FACETS, "moduleUuids") .execute() - .assertJson(this.getClass(), "display_module_facet.json", false); + .assertJson(this.getClass(), "display_module_facet.json"); } @Test @@ -366,7 +366,7 @@ public class SearchActionComponentsMediumTest { .setParam("resolved", "false") .setParam(WebService.Param.FACETS, "directories") .execute(); - result.assertJson(this.getClass(), "display_directory_facet.json", false); + result.assertJson(this.getClass(), "display_directory_facet.json"); } @Test @@ -385,7 +385,7 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, view.uuid()) .execute() - .assertJson(this.getClass(), "search_by_view_uuid.json", false); + .assertJson(this.getClass(), "search_by_view_uuid.json"); } @Test @@ -405,7 +405,7 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, view.uuid()) .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @Test @@ -426,7 +426,7 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, subView.uuid()) .execute() - .assertJson(this.getClass(), "search_by_view_uuid.json", false); + .assertJson(this.getClass(), "search_by_view_uuid.json"); } @Test @@ -448,7 +448,7 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, subView.uuid()) .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } public void search_by_author() throws Exception { @@ -467,12 +467,12 @@ public class SearchActionComponentsMediumTest { .setParam(IssueFilterParameters.AUTHORS, "leia") .setParam(WebService.Param.FACETS, "authors") .execute() - .assertJson(this.getClass(), "search_by_authors.json", false); + .assertJson(this.getClass(), "search_by_authors.json"); wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.AUTHORS, "unknown") .execute() - .assertJson(this.getClass(), "no_issue.json", false); + .assertJson(this.getClass(), "no_issue.json"); } @@ -496,7 +496,7 @@ public class SearchActionComponentsMediumTest { wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam(IssueFilterParameters.COMPONENT_UUIDS, developer.uuid()) .execute() - .assertJson(this.getClass(), "search_by_developer.json", false); + .assertJson(this.getClass(), "search_by_developer.json"); } @Test @@ -530,7 +530,7 @@ public class SearchActionComponentsMediumTest { .execute(); System.out.println(result.outputAsString()); result - .assertJson(this.getClass(), "search_by_developer.json", false); + .assertJson(this.getClass(), "search_by_developer.json"); } private RuleDto newRule() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java index 1132c428782..174005a2ccf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java @@ -97,7 +97,7 @@ public class SearchActionMediumTest { WsTester.Result result = request.execute(); assertThat(result).isNotNull(); - result.assertJson(this.getClass(), "empty_result.json", false); + result.assertJson(this.getClass(), "empty_result.json"); } @Test @@ -125,7 +125,7 @@ public class SearchActionMediumTest { WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); // TODO date assertion is complex to test, and components id are not predictable, that's why strict boolean is set to false - result.assertJson(this.getClass(), "issue.json", false); + result.assertJson(this.getClass(), "issue.json"); } @Test @@ -159,7 +159,7 @@ public class SearchActionMediumTest { MockUserSession.set().setLogin("john"); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "issue_with_comment.json", false); + result.assertJson(this.getClass(), "issue_with_comment.json"); } @Test @@ -193,7 +193,7 @@ public class SearchActionMediumTest { MockUserSession.set().setLogin("john"); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.HIDE_COMMENTS, "true").execute(); - result.assertJson(this.getClass(), "issue_with_comment_hidden.json", false); + result.assertJson(this.getClass(), "issue_with_comment_hidden.json"); assertThat(result.outputAsString()).doesNotContain("fabrice"); } @@ -221,7 +221,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "issue_with_action_plan.json", false); + result.assertJson(this.getClass(), "issue_with_action_plan.json"); } @Test @@ -237,7 +237,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "issue_with_attributes.json", false); + result.assertJson(this.getClass(), "issue_with_attributes.json"); } @Test @@ -268,7 +268,7 @@ public class SearchActionMediumTest { MockUserSession.set().setLogin("john"); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION) .setParam("extra_fields", "actions,transitions,assigneeName,reporterName,actionPlanName").execute(); - result.assertJson(this.getClass(), "issue_with_extra_fields.json", false); + result.assertJson(this.getClass(), "issue_with_extra_fields.json"); } @Test @@ -292,7 +292,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "issue_linked_on_removed_file.json", false); + result.assertJson(this.getClass(), "issue_linked_on_removed_file.json"); } @Test @@ -326,7 +326,7 @@ public class SearchActionMediumTest { .setParam(IssueFilterParameters.COMPONENTS, file.getKey()) .setParam(IssueFilterParameters.IGNORE_PAGING, "true") .execute(); - result.assertJson(this.getClass(), "ignore_paging_with_one_component.json", false); + result.assertJson(this.getClass(), "ignore_paging_with_one_component.json"); } @Test @@ -348,7 +348,7 @@ public class SearchActionMediumTest { .setParam(IssueFilterParameters.COMPONENTS, file.getKey() + "," + otherFile.getKey()) .setParam(IssueFilterParameters.IGNORE_PAGING, "true") .execute(); - result.assertJson(this.getClass(), "apply_paging_with_multiple_components.json", false); + result.assertJson(this.getClass(), "apply_paging_with_multiple_components.json"); } @Test @@ -365,7 +365,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.COMPONENTS, file.getKey()).execute(); - result.assertJson(this.getClass(), "apply_paging_with_one_component.json", false); + result.assertJson(this.getClass(), "apply_paging_with_one_component.json"); } @Test @@ -380,7 +380,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).execute(); - result.assertJson(this.getClass(), "components_contains_sub_projects.json", false); + result.assertJson(this.getClass(), "components_contains_sub_projects.json"); } @Test @@ -404,7 +404,7 @@ public class SearchActionMediumTest { .setParam("resolved", "false") .setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,languages,actionPlans") .execute(); - result.assertJson(this.getClass(), "display_facets.json", false); + result.assertJson(this.getClass(), "display_facets.json"); } @Test @@ -430,7 +430,7 @@ public class SearchActionMediumTest { .setParam("languages", "xoo,polop,palap") .setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,assigned_to_me,languages,actionPlans") .execute(); - result.assertJson(this.getClass(), "display_zero_facets.json", false); + result.assertJson(this.getClass(), "display_zero_facets.json"); } @Test @@ -472,7 +472,7 @@ public class SearchActionMediumTest { .setParam("assignees", "__me__") .setParam(WebService.Param.FACETS, "assignees,assigned_to_me") .execute() - .assertJson(this.getClass(), "filter_by_assigned_to_me.json", false); + .assertJson(this.getClass(), "filter_by_assigned_to_me.json"); } @Test @@ -502,7 +502,7 @@ public class SearchActionMediumTest { .setParam("resolved", "false") .setParam("assignees", "__me__") .execute() - .assertJson(this.getClass(), "empty_result.json", false); + .assertJson(this.getClass(), "empty_result.json"); } @Test @@ -544,7 +544,7 @@ public class SearchActionMediumTest { .setParam("assignees", "alice") .setParam(WebService.Param.FACETS, "assignees,assigned_to_me") .execute() - .assertJson(this.getClass(), "assigned_to_me_facet_sticky.json", false); + .assertJson(this.getClass(), "assigned_to_me_facet_sticky.json"); } @Test @@ -564,7 +564,7 @@ public class SearchActionMediumTest { tester.get(IssueIndexer.class).indexAll(); WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION).setParam(IssueFilterParameters.HIDE_RULES, "true").execute(); - result.assertJson(this.getClass(), "hide_rules.json", false); + result.assertJson(this.getClass(), "hide_rules.json"); } @Test @@ -583,7 +583,7 @@ public class SearchActionMediumTest { .setParam("sort", IssueQuery.SORT_BY_UPDATE_DATE) .setParam("asc", "false") .execute(); - result.assertJson(this.getClass(), "sort_by_updated_at.json", false); + result.assertJson(this.getClass(), "sort_by_updated_at.json"); } @Test @@ -604,7 +604,7 @@ public class SearchActionMediumTest { request.setParam(WebService.Param.PAGE_SIZE, "9"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "paging.json", false); + result.assertJson(this.getClass(), "paging.json"); } @Test @@ -625,7 +625,7 @@ public class SearchActionMediumTest { request.setParam(WebService.Param.PAGE_SIZE, "-1"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "paging_with_page_size_to_minus_one.json", false); + result.assertJson(this.getClass(), "paging_with_page_size_to_minus_one.json"); } @Test @@ -646,7 +646,7 @@ public class SearchActionMediumTest { request.setParam(IssueFilterParameters.PAGE_SIZE, "9"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "deprecated_paging.json", false); + result.assertJson(this.getClass(), "deprecated_paging.json"); } @Test @@ -654,7 +654,7 @@ public class SearchActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "default_page_size_is_100.json", false); + result.assertJson(this.getClass(), "default_page_size_is_100.json"); } private RuleDto newRule() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/L10nWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/L10nWsTest.java index 810f325b827..1c5dd04158f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/L10nWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/L10nWsTest.java @@ -87,7 +87,7 @@ public class L10nWsTest { verify(i18n).message(locale, key2, key2); verify(i18n).message(locale, key3, key3); - result.assertJson("{key1:'key1',key2:'key2',key3:'key3'}"); + result.assertJson("{\"key1\":\"key1\",\"key2\":\"key2\",\"key3\":\"key3\"}"); } @Test @@ -111,6 +111,6 @@ public class L10nWsTest { verify(i18n).message(override, key2, key2); verify(i18n).message(override, key3, key3); - result.assertJson("{key1:'key1',key2:'key2',key3:'key3'}"); + result.assertJson("{\"key1\":\"key1\",\"key2\":\"key2\",\"key3\":\"key3\"}"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java index d36da7bfd60..6e531cac71c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QGatesWsTest.java @@ -189,7 +189,7 @@ public class QGatesWsTest { String name = "New QG"; when(qGates.create(name)).thenReturn(new QualityGateDto().setId(42L).setName(name)); tester.newGetRequest("api/qualitygates", "create").setParam("name", name).execute() - .assertJson("{'id':42,'name':'New QG'}"); + .assertJson("{\"id\":42,\"name\":\"New QG\"}"); } @Test @@ -197,7 +197,7 @@ public class QGatesWsTest { String name = "Copied QG"; when(qGates.copy(24L, name)).thenReturn(new QualityGateDto().setId(42L).setName(name)); tester.newGetRequest("api/qualitygates", "copy").setParam("id", "24").setParam("name", name).execute() - .assertJson("{'id':42,'name':'Copied QG'}"); + .assertJson("{\"id\":42,\"name\":\"Copied QG\"}"); } @Test(expected = IllegalArgumentException.class) @@ -218,7 +218,7 @@ public class QGatesWsTest { String name = "New QG"; when(qGates.rename(id, name)).thenReturn(new QualityGateDto().setId(id).setName(name)); tester.newPostRequest("api/qualitygates", "rename").setParam("id", id.toString()).setParam("name", name).execute() - .assertJson("{'id':42,'name':'New QG'}"); + .assertJson("{\"id\":42,\"name\":\"New QG\"}"); ; } @@ -263,7 +263,7 @@ public class QGatesWsTest { )); when(qGates.currentUserHasWritePermission()).thenReturn(false); tester.newGetRequest("api/qualitygates", "list").execute().assertJson( - "{'qualitygates':[{'id':42,'name':'Golden'},{'id':43,'name':'Star'},{'id':666,'name':'Ninth'}]}"); + "{\"qualitygates\":[{\"id\":42,\"name\":\"Golden\"},{\"id\":43,\"name\":\"Star\"},{\"id\":666,\"name\":\"Ninth\"}]}"); } @Test @@ -276,7 +276,7 @@ public class QGatesWsTest { )); when(qGates.getDefault()).thenReturn(defaultQgate); tester.newGetRequest("api/qualitygates", "list").execute().assertJson( - "{'qualitygates':[{'id':42,'name':'Golden'},{'id':43,'name':'Star'},{'id':666,'name':'Ninth'}],'default':42}"); + "{\"qualitygates\":[{\"id\":42,\"name\":\"Golden\"},{\"id\":43,\"name\":\"Star\"},{\"id\":666,\"name\":\"Ninth\"}],\"default\":42}"); } @Test @@ -284,7 +284,7 @@ public class QGatesWsTest { long gateId = 12345L; when(qGates.get(gateId)).thenReturn(new QualityGateDto().setId(gateId).setName("Golden")); tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson( - "{'id':12345,'name':'Golden'}"); + "{\"id\":12345,\"name\":\"Golden\"}"); } @Test @@ -296,9 +296,9 @@ public class QGatesWsTest { new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3) )); tester.newGetRequest("api/qualitygates", "show").setParam("id", Long.toString(gateId)).execute().assertJson( - "{'id':12345,'name':'Golden','conditions':[" - + "{'id':1,'metric':'ncloc','op':'GT','error':'10000'}," - + "{'id':2,'metric':'new_coverage','op':'LT','warning':'90','period':3}" + "{\"id\":12345,\"name\":\"Golden\",\"conditions\":[" + + "{\"id\":1,\"metric\":\"ncloc\",\"op\":\"GT\",\"error\":\"10000\"}," + + "{\"id\":2,\"metric\":\"new_coverage\",\"op\":\"LT\",\"warning\":\"90\",\"period\":3}" + "]}" ); } @@ -313,9 +313,9 @@ public class QGatesWsTest { new QualityGateConditionDto().setId(2L).setMetricKey("new_coverage").setOperator("LT").setWarningThreshold("90").setPeriod(3) )); tester.newGetRequest("api/qualitygates", "show").setParam("name", gateName).execute().assertJson( - "{'id':12345,'name':'Golden','conditions':[" - + "{'id':1,'metric':'ncloc','op':'GT','error':'10000'}," - + "{'id':2,'metric':'new_coverage','op':'LT','warning':'90','period':3}" + "{\"id\":12345,\"name\":\"Golden\",\"conditions\":[" + + "{\"id\":1,\"metric\":\"ncloc\",\"op\":\"GT\",\"error\":\"10000\"}," + + "{\"id\":2,\"metric\":\"new_coverage\",\"op\":\"LT\",\"warning\":\"90\",\"period\":3}" + "]}" ); } @@ -347,7 +347,7 @@ public class QGatesWsTest { .setParam("warning", warningThreshold) .setParam("error", errorThreshold) .execute() - .assertJson("{'id':12345,'metric':'coverage','op':'LT','warning':'80','error':'75'}"); + .assertJson("{\"id\":12345,\"metric\":\"coverage\",\"op\":\"LT\",\"warning\":\"80\",\"error\":\"75\"}"); } @Test @@ -367,7 +367,7 @@ public class QGatesWsTest { .setParam("warning", warningThreshold) .setParam("error", errorThreshold) .execute() - .assertJson("{'id':12345,'metric':'coverage','op':'LT','warning':'80','error':'75'}"); + .assertJson("{\"id\":12345,\"metric\":\"coverage\",\"op\":\"LT\",\"warning\":\"80\",\"error\":\"75\"}"); } @Test @@ -395,9 +395,9 @@ public class QGatesWsTest { .setParam("gateId", Long.toString(gateId)) .setParam("query", "Project") .execute() - .assertJson("{'more':true,'results':[" - + "{'id':42,'name':'Project One','selected':false}," - + "{'id':24,'name':'Project Two','selected':true}" + .assertJson("{\"more\":true,\"results\":[" + + "{\"id\":42,\"name\":\"Project One\",\"selected\":false}," + + "{\"id\":24,\"name\":\"Project Two\",\"selected\":true}" + "]}"); ArgumentCaptor<ProjectQgateAssociationQuery> queryCaptor = ArgumentCaptor.forClass(ProjectQgateAssociationQuery.class); verify(projectFinder).find(queryCaptor.capture()); @@ -419,8 +419,8 @@ public class QGatesWsTest { tester.newGetRequest("api/qualitygates", "search") .setParam("gateId", Long.toString(gateId)) .execute() - .assertJson("{'more':true,'results':[" - + "{'id':24,'name':'Project Two','selected':true}" + .assertJson("{\"more\":true,\"results\":[" + + "{\"id\":24,\"name\":\"Project Two\",\"selected\":true}" + "]}"); ArgumentCaptor<ProjectQgateAssociationQuery> queryCaptor = ArgumentCaptor.forClass(ProjectQgateAssociationQuery.class); verify(projectFinder).find(queryCaptor.capture()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java index 8ba84ec7e23..3e432a78d2f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java @@ -87,7 +87,7 @@ public class CreateActionMediumTest { .setParam("severity", "MAJOR") .setParam("status", "BETA") .setParam("params", "regex=a.*"); - request.execute().assertJson(getClass(), "create_custom_rule.json", false); + request.execute().assertJson(getClass(), "create_custom_rule.json"); } @Test @@ -101,7 +101,7 @@ public class CreateActionMediumTest { .setParam("name", "My manual rule") .setParam("markdown_description", "Description") .setParam("severity", "MAJOR"); - request.execute().assertJson(getClass(), "create_manual_rule.json", false); + request.execute().assertJson(getClass(), "create_manual_rule.json"); } @Test @@ -114,7 +114,7 @@ public class CreateActionMediumTest { .setParam("manual_key", "MY_MANUAL") .setParam("name", "My manual rule") .setParam("markdown_description", "Description"); - request.execute().assertJson(getClass(), "create_manual_rule_without_severity.json", false); + request.execute().assertJson(getClass(), "create_manual_rule_without_severity.json"); } @Test @@ -161,7 +161,7 @@ public class CreateActionMediumTest { .setParam("severity", "MAJOR") .setParam("prevent_reactivation", "true"); request.execute() - .assertJson(getClass(), "create_rule_with_prevent_reactivation_param_to_true.json", false) + .assertJson(getClass(), "create_rule_with_prevent_reactivation_param_to_true.json") .assertStatus(409); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWebServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWebServiceMediumTest.java index 4a97bf50e68..9a45b332a79 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWebServiceMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWebServiceMediumTest.java @@ -126,13 +126,13 @@ public class RulesWebServiceMediumTest { request.setParam(ShowAction.PARAM_KEY, rule.getKey().toString()); request.setParam(ShowAction.PARAM_ACTIVES, "true"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "show_rule_active.json", false); + result.assertJson(this.getClass(), "show_rule_active.json"); // 1. Default Activation (defaults to false) request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SHOW_METHOD); request.setParam(ShowAction.PARAM_KEY, rule.getKey().toString()); result = request.execute(); - result.assertJson(this.getClass(), "show_rule_no_active.json", false); + result.assertJson(this.getClass(), "show_rule_no_active.json"); } @Test @@ -156,13 +156,13 @@ public class RulesWebServiceMediumTest { request.setParam(SearchAction.PARAM_KEY, RuleTesting.XOO_X1.toString()); request.setParam(SearchOptions.PARAM_FIELDS, "actives"); WsTester.Result result = request.execute(); - result.assertJson("{\"total\":1,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x1\"}]}", false); + result.assertJson("{\"total\":1,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x1\"}]}"); request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(SearchAction.PARAM_KEY, RuleKey.of("xoo", "unknown").toString()); request.setParam(SearchOptions.PARAM_FIELDS, "actives"); result = request.execute(); - result.assertJson("{\"total\":0,\"p\":1,\"ps\":100,\"rules\":[],\"actives\":{}}", false); + result.assertJson("{\"total\":0,\"p\":1,\"ps\":100,\"rules\":[],\"actives\":{}}"); } @@ -176,7 +176,7 @@ public class RulesWebServiceMediumTest { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); WsTester.Result result = request.execute(); - result.assertJson(getClass(), "search_2_rules.json", false); + result.assertJson(getClass(), "search_2_rules.json"); } @Test @@ -189,7 +189,7 @@ public class RulesWebServiceMediumTest { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD).setParam(SearchOptions.PARAM_FIELDS, "name,htmlDesc,mdDesc"); WsTester.Result result = request.execute(); - result.assertJson(getClass(), "search_2_rules_fields.json", false); + result.assertJson(getClass(), "search_2_rules_fields.json"); } @Test @@ -214,7 +214,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchOptions.PARAM_FIELDS, "debtChar,debtCharName,debtSubChar,debtSubCharName,debtRemFn,debtOverloaded,defaultDebtChar,defaultDebtSubChar,defaultDebtRemFn"); request.setParam(SearchAction.PARAM_FACETS, "debt_characteristics"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "search_debt_rule.json", false); + result.assertJson(this.getClass(), "search_debt_rule.json"); } @Test @@ -345,7 +345,7 @@ public class RulesWebServiceMediumTest { .setParam("debt_characteristics", "SOFT_RELIABILITY") .setParam(SearchAction.PARAM_FACETS, "debt_characteristics") .execute(); - result.assertJson(this.getClass(), "search_debt_rules_sticky.json", false); + result.assertJson(this.getClass(), "search_debt_rules_sticky.json"); } @Test @@ -397,7 +397,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchOptions.PARAM_FIELDS, ""); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "search_active_rules.json", false); + result.assertJson(this.getClass(), "search_active_rules.json"); } @Test @@ -427,14 +427,14 @@ public class RulesWebServiceMediumTest { request.setParam(SearchAction.PARAM_QPROFILE, profile2.getKey()); request.setParam(SearchOptions.PARAM_FIELDS, "actives"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "search_profile_active_rules.json", false); + result.assertJson(this.getClass(), "search_profile_active_rules.json"); tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD) .setParam(SearchAction.PARAM_ACTIVATION, "true") .setParam(SearchAction.PARAM_QPROFILE, "unknown_profile") .setParam(SearchOptions.PARAM_FIELDS, "actives") .execute() - .assertJson(this.getClass(), "search_no_rules.json", false); + .assertJson(this.getClass(), "search_no_rules.json"); } @Test @@ -464,7 +464,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchAction.PARAM_QPROFILE, profile2.getKey()); request.setParam(SearchOptions.PARAM_FIELDS, "actives"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "search_profile_active_rules_inheritance.json", false); + result.assertJson(this.getClass(), "search_profile_active_rules_inheritance.json"); } @Test @@ -508,7 +508,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchOptions.PARAM_FIELDS, "params"); WsTester.Result result = request.execute(); - result.assertJson(this.getClass(), "search_active_rules_params.json", false); + result.assertJson(this.getClass(), "search_active_rules_params.json"); } @Test @@ -528,11 +528,11 @@ public class RulesWebServiceMediumTest { session.commit(); MockUserSession.set(); - tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD).execute().assertJson(this.getClass(), "get_tags.json", false); + tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD).execute().assertJson(this.getClass(), "get_tags.json"); tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD) - .setParam("ps", "1").execute().assertJson(this.getClass(), "get_tags_limited.json", false); + .setParam("ps", "1").execute().assertJson(this.getClass(), "get_tags_limited.json"); tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD) - .setParam("q", "ll").execute().assertJson(this.getClass(), "get_tags_filtered.json", false); + .setParam("q", "ll").execute().assertJson(this.getClass(), "get_tags_filtered.json"); } @Test @@ -573,14 +573,14 @@ public class RulesWebServiceMediumTest { public void severities_facet_should_have_all_severities() throws Exception { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(SearchAction.PARAM_FACETS, "severities"); - request.execute().assertJson(this.getClass(), "severities_facet.json", false); + request.execute().assertJson(this.getClass(), "severities_facet.json"); } @Test public void statuses_facet_should_have_all_statuses_except_removed() throws Exception { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(SearchAction.PARAM_FACETS, "statuses"); - request.execute().assertJson(this.getClass(), "statuses_facet.json", false); + request.execute().assertJson(this.getClass(), "statuses_facet.json"); } @Test @@ -593,7 +593,7 @@ public class RulesWebServiceMediumTest { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(SearchAction.PARAM_STATUSES, "DEPRECATED"); request.setParam(SearchAction.PARAM_FACETS, "statuses"); - request.execute().assertJson(this.getClass(), "statuses_facet_sticky.json", false); + request.execute().assertJson(this.getClass(), "statuses_facet_sticky.json"); } @Test @@ -611,7 +611,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchOptions.PARAM_ASCENDING, "true"); WsTester.Result result = request.execute(); - result.assertJson("{\"total\":3,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x2\"},{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x3\"}]}", false); + result.assertJson("{\"total\":3,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x2\"},{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x3\"}]}"); // 2. Sort Name DESC request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); @@ -620,7 +620,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchOptions.PARAM_ASCENDING, "false"); result = request.execute(); - result.assertJson("{\"total\":3,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x3\"},{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x2\"}]}", false); + result.assertJson("{\"total\":3,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x3\"},{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x2\"}]}"); } @@ -640,7 +640,7 @@ public class RulesWebServiceMediumTest { request.setParam(SearchAction.PARAM_AVAILABLE_SINCE, DateUtils.formatDate(since)); request.setParam(SearchOptions.PARAM_SORT, RuleNormalizer.RuleField.KEY.field()); WsTester.Result result = request.execute(); - result.assertJson("{\"total\":2,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x2\"}]}", false); + result.assertJson("{\"total\":2,\"p\":1,\"ps\":100,\"rules\":[{\"key\":\"xoo:x1\"},{\"key\":\"xoo:x2\"}]}"); Calendar c = Calendar.getInstance(); c.setTime(since); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java index cc4819a9a58..779487d4e4b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java @@ -95,7 +95,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", ruleDto.getKey().toString()); - request.execute().assertJson(getClass(), "show_rule.json", false); + request.execute().assertJson(getClass(), "show_rule.json"); } @Test @@ -133,7 +133,7 @@ public class ShowActionMediumTest { .setParam("key", ruleDto.getKey().toString()); WsTester.Result response = request.execute(); - response.assertJson(getClass(), "show_rule_with_default_debt_infos.json", false); + response.assertJson(getClass(), "show_rule_with_default_debt_infos.json"); } @Test @@ -169,7 +169,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", ruleDto.getKey().toString()); - request.execute().assertJson(getClass(), "show_rule_with_overridden_debt_infos.json", false); + request.execute().assertJson(getClass(), "show_rule_with_overridden_debt_infos.json"); } @Test @@ -210,7 +210,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", ruleDto.getKey().toString()); - request.execute().assertJson(getClass(), "show_rule_with_default_and_overridden_debt_infos.json", false); + request.execute().assertJson(getClass(), "show_rule_with_default_and_overridden_debt_infos.json"); } @Test @@ -242,7 +242,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", ruleDto.getKey().toString()); - request.execute().assertJson(getClass(), "show_rule_with_no_default_and_no_overridden_debt.json", false); + request.execute().assertJson(getClass(), "show_rule_with_no_default_and_no_overridden_debt.json"); } @Test @@ -273,7 +273,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", ruleDto.getKey().toString()); - request.execute().assertJson(getClass(), "show_rule_with_overridden_disable_debt.json", false); + request.execute().assertJson(getClass(), "show_rule_with_overridden_disable_debt.json"); } @Test @@ -297,7 +297,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", customRuleKey.toString()); - request.execute().assertJson(getClass(), "encode_html_description_of_custom_rule.json", false); + request.execute().assertJson(getClass(), "encode_html_description_of_custom_rule.json"); } @Test @@ -316,7 +316,7 @@ public class ShowActionMediumTest { WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show") .setParam("key", customRuleKey.toString()); - request.execute().assertJson(getClass(), "encode_html_description_of_manual_rule.json", false); + request.execute().assertJson(getClass(), "encode_html_description_of_manual_rule.json"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java index 68b64822c2e..7ce82055083 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java @@ -98,7 +98,7 @@ public class UpdateActionMediumTest { .setParam("severity", "MAJOR") .setParam("status", "BETA") .setParam("params", "regex=a.*"); - request.execute().assertJson(getClass(), "update_custom_rule.json", false); + request.execute().assertJson(getClass(), "update_custom_rule.json"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java index d4bcee11a82..e69e22ee157 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java @@ -21,13 +21,13 @@ package org.sonar.server.search.ws; import com.google.common.collect.Lists; import org.junit.Test; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.server.ws.RequestHandler; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.internal.SimpleGetRequest; import org.sonar.api.utils.text.JsonWriter; import org.sonar.server.search.QueryContext; import org.sonar.server.search.Result; +import org.sonar.test.JsonAssert; import java.io.StringWriter; @@ -101,7 +101,7 @@ public class SearchOptionsTest { options.writeStatistics(jsonWriter, result); jsonWriter.endObject().close(); - JSONAssert.assertEquals("{\"total\": 42, \"p\": 3, \"ps\": 10}", json.toString(), true); + JsonAssert.assertJson(json.toString()).isSimilarTo("{\"total\": 42, \"p\": 3, \"ps\": 10}"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java index acfc1527b63..bcd67c877c1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java @@ -163,7 +163,7 @@ public class LinesActionTest { WsTester.TestRequest request = tester.newGetRequest("api/sources", "lines").setParam("uuid", componentUuid); // Using non-strict match b/c of dates - request.execute().assertJson(getClass(), "show_source.json", false); + request.execute().assertJson(getClass(), "show_source.json"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmWriterTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmWriterTest.java index bec891ff22c..cf05251cf34 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmWriterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/ScmWriterTest.java @@ -19,10 +19,9 @@ */ package org.sonar.server.source.ws; -import org.json.JSONException; import org.junit.Test; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.utils.text.JsonWriter; +import org.sonar.test.JsonAssert; import java.io.StringWriter; @@ -63,13 +62,12 @@ public class ScmWriterTest { test(authors, dates, 10, 20, false, "{\"scm\": []}"); } - - private void test(String authors, String dates, int from, int to, boolean group, String expected) throws JSONException { + private void test(String authors, String dates, int from, int to, boolean group, String expected) { StringWriter output = new StringWriter(); JsonWriter jsonWriter = JsonWriter.of(output); jsonWriter.beginObject(); writer.write(authors, dates, from, to, group, jsonWriter); jsonWriter.endObject(); - JSONAssert.assertEquals(output.toString(), expected, true); + JsonAssert.assertJson(output.toString()).isSimilarTo(expected); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/ws/WsTester.java b/server/sonar-server/src/test/java/org/sonar/server/ws/WsTester.java index b0e4e7264dd..1be9064a188 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ws/WsTester.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ws/WsTester.java @@ -22,13 +22,13 @@ package org.sonar.server.ws; import com.google.common.collect.Maps; import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; -import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.internal.ValidatingRequest; import org.sonar.api.utils.text.JsonWriter; import org.sonar.api.utils.text.XmlWriter; import org.sonar.server.ws.WsTester.TestResponse.TestStream; +import org.sonar.test.JsonAssert; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -185,12 +185,8 @@ public class WsTester { } public Result assertJson(String expectedJson) throws Exception { - return assertJson(expectedJson, true); - } - - public Result assertJson(String expectedJson, boolean strict) throws Exception { String json = outputAsString(); - JSONAssert.assertEquals(expectedJson, json, strict); + JsonAssert.assertJson(json).isSimilarTo(expectedJson); return this; } @@ -203,17 +199,13 @@ public class WsTester { * @param expectedJsonFilename name of the file containing the expected JSON */ public Result assertJson(Class clazz, String expectedJsonFilename) throws Exception { - return assertJson(clazz, expectedJsonFilename, true); - } - - public Result assertJson(Class clazz, String expectedJsonFilename, boolean strict) throws Exception { String path = clazz.getSimpleName() + "/" + expectedJsonFilename; URL url = clazz.getResource(path); if (url == null) { throw new IllegalStateException("Cannot find " + path); } String json = outputAsString(); - JSONAssert.assertEquals(IOUtils.toString(url), json, strict); + JsonAssert.assertJson(json).isSimilarTo(url); return this; } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/ComponentTagsActionTest/component-tags.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/ComponentTagsActionTest/component-tags.json index 38e018c645b..e3afc9a2dc4 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/ComponentTagsActionTest/component-tags.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/ComponentTagsActionTest/component-tags.json @@ -1,9 +1,9 @@ { - tags: [ - { key: "convention", value: 2771 }, - { key: "brain-overload", value: 998 }, - { key: "cwe", value: 89 }, - { key: "bug", value: 32 }, - { key: "cert", value: 2 } + "tags": [ + { "key": "convention", "value": 2771 }, + { "key": "brain-overload", "value": 998 }, + { "key": "cwe", "value": 89 }, + { "key": "bug", "value": 32 }, + { "key": "cert", "value": 2 } ] -}
\ No newline at end of file +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/get_tags.json b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/get_tags.json index 14764b48180..c9a14f30cd0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/get_tags.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/get_tags.json @@ -1 +1,8 @@ -{"tags": ["hello", "sys1", "java", "world"]}
\ No newline at end of file +{ + "tags": [ + "sys1", + "java", + "world", + "hello" + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_2_rules.json b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_2_rules.json index bd84f45871e..a3da4d33ff2 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_2_rules.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_2_rules.json @@ -1,5 +1,7 @@ { - "total": 2, "p": 1, "ps": 100, + "total": 2, + "p": 1, + "ps": 100, "rules": [ { "key": "xoo:x2", @@ -10,8 +12,14 @@ "status": "READY", "internalKey": "InternalKeyx2", "isTemplate": false, - "tags": ["tag1", "tag2"], - "sysTags": ["systag1", "systag2"], + "tags": [ + "tag1", + "tag2" + ], + "sysTags": [ + "systag1", + "systag2" + ], "debtRemFnType": "LINEAR", "debtRemFnCoeff": "1h", "debtRemFnOffset": "5min", @@ -27,12 +35,19 @@ "status": "READY", "internalKey": "InternalKeyx1", "isTemplate": false, - "tags": ["tag1", "tag2"], - "sysTags": ["systag1", "systag2"], + "tags": [ + "tag1", + "tag2" + ], + "sysTags": [ + "systag1", + "systag2" + ], "debtRemFnType": "LINEAR", "debtRemFnCoeff": "1h", "debtRemFnOffset": "5min", "lang": "xoo", "params": [] } - ]} + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_debt_rules_sticky.json b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_debt_rules_sticky.json index a7cba30b88e..59441d3015d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_debt_rules_sticky.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_debt_rules_sticky.json @@ -1,41 +1,46 @@ -{"total": 1, "p": 1, "ps": 100, "rules": [ - { - "key": "xoo:x2", - "debtChar": "RELIABILITY", - "debtCharName": "Reliability", - "debtSubChar": "SOFT_RELIABILITY", - "debtSubCharName": "Soft Reliability", - "debtRemFnType": "LINEAR_OFFSET", - "debtRemFnCoeff": "30min", - "debtRemFnOffset": "5min", - "debtOverloaded": true, - "defaultDebtChar": "RELIABILITY", - "defaultDebtSubChar": "HARD_RELIABILITY", - "defaultDebtRemFnType": "LINEAR_OFFSET", - "defaultDebtRemFnCoeff": "1h", - "defaultDebtRemFnOffset": "15min" - } -], -"facets": [ - { - "property": "debt_characteristics", - "values": [ - { - "val": "RELIABILITY", - "count": 2 - }, - { - "val": "SOFT_RELIABILITY", - "count": 1 - }, - { - "val": "HARD_RELIABILITY", - "count": 1 - }, - { - "val": "NONE", - "count": 2 - } - ] - } -]} +{ + "total": 1, + "p": 1, + "ps": 100, + "rules": [ + { + "key": "xoo:x2", + "debtSubCharName": "Soft Reliability", + "defaultDebtRemFnType": "LINEAR_OFFSET", + "defaultDebtRemFnCoeff": "1h", + "defaultDebtRemFnOffset": "15min", + "debtChar": "RELIABILITY", + "debtOverloaded": true, + "debtCharName": "Reliability", + "debtRemFnType": "LINEAR_OFFSET", + "debtRemFnCoeff": "30min", + "debtRemFnOffset": "5min", + "debtSubChar": "SOFT_RELIABILITY", + "defaultDebtSubChar": "HARD_RELIABILITY", + "defaultDebtChar": "RELIABILITY" + } + ], + "facets": [ + { + "property": "debt_characteristics", + "values": [ + { + "val": "HARD_RELIABILITY", + "count": 1 + }, + { + "val": "SOFT_RELIABILITY", + "count": 1 + }, + { + "val": "RELIABILITY", + "count": 2 + }, + { + "val": "NONE", + "count": 2 + } + ] + } + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_profile_active_rules_inheritance.json b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_profile_active_rules_inheritance.json index 80d049d4442..adc48218f3e 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_profile_active_rules_inheritance.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/ws/RulesWebServiceMediumTest/search_profile_active_rules_inheritance.json @@ -1,7 +1,7 @@ { - "total":1, - "p":1, - "ps":100, + "total": 1, + "p": 1, + "ps": 100, "rules": [ { "key": "xoo:x1" |