From: Teryk Bellahsene Date: Tue, 3 Oct 2017 15:48:12 +0000 (+0200) Subject: SONAR-9289 Remove id field from response of api/components/search_projects X-Git-Tag: 6.6-RC1~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=928332d7ffdbcae1c28495fe1b0c0d49a0b2d1ee;p=sonarqube.git SONAR-9289 Remove id field from response of api/components/search_projects --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java index d6faf28ef75..3aabfa94b70 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java @@ -115,7 +115,8 @@ public class SearchProjectsAction implements ComponentsWsAction { new Change("6.4", "The 'visibility' field is added"), new Change("6.5", "The 'filter' parameter now allows 'NO_DATA' as value for numeric metrics"), new Change("6.5", "Added the option 'analysisDate' for the 'sort' parameter"), - new Change("6.5", format("Value '%s' is added to parameter '%s'", LEAK_PERIOD_DATE, FIELDS))) + new Change("6.5", format("Value '%s' is added to parameter '%s'", LEAK_PERIOD_DATE, FIELDS)), + new Change("6.6", "The 'id' field is removed from the response")) .setHandler(this); action.createFieldsParam(POSSIBLE_FIELDS) @@ -423,7 +424,6 @@ public class SearchProjectsAction implements ComponentsWsAction { wsComponent .clear() .setOrganization(organizationDto.getKey()) - .setId(dbComponent.uuid()) .setKey(dbComponent.getDbKey()) .setName(dbComponent.name()) .setVisibility(Visibility.getLabel(dbComponent.isPrivate())); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/search_projects-example.json b/server/sonar-server/src/main/resources/org/sonar/server/component/ws/search_projects-example.json index 785c4e50c94..ddb458d04ac 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/component/ws/search_projects-example.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/component/ws/search_projects-example.json @@ -7,7 +7,6 @@ "components": [ { "organization": "my-org-key-1", - "id": "AU-Tpxb--iU5OvuD2FLy", "key": "my_project", "name": "My Project 1", "isFavorite": true, @@ -19,7 +18,6 @@ }, { "organization": "my-org-key-1", - "id": "AU-TpxcA-iU5OvuD2FLz", "key": "another_project", "name": "My Project 2", "isFavorite": false, @@ -28,7 +26,6 @@ }, { "organization": "my-org-key-2", - "id": "AU-TpxcA-iU5OvuD2FL0", "key": "third_project", "name": "My Project 3", "isFavorite": false, @@ -39,5 +36,36 @@ ], "visibility": "public" } + ], + "facets": [ + { + "property": "coverage", + "values": [ + { + "val": "NO_DATA", + "count": 0 + }, + { + "val": "*-30.0", + "count": 1 + }, + { + "val": "30.0-50.0", + "count": 0 + }, + { + "val": "50.0-70.0", + "count": 0 + }, + { + "val": "70.0-80.0", + "count": 0 + }, + { + "val": "80.0-*", + "count": 2 + } + ] + } ] } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java index cc27c3fedc7..0f1c5e3989c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java @@ -151,7 +151,8 @@ public class SearchProjectsActionTest { tuple("6.4", "The 'visibility' field is added"), tuple("6.5", "The 'filter' parameter now allows 'NO_DATA' as value for numeric metrics"), tuple("6.5", "Added the option 'analysisDate' for the 'sort' parameter"), - tuple("6.5", "Value 'leakPeriodDate' is added to parameter 'f'")); + tuple("6.5", "Value 'leakPeriodDate' is added to parameter 'f'"), + tuple("6.6", "The 'id' field is removed from the response")); Param organization = def.param("organization"); assertThat(organization.isRequired()).isFalse(); @@ -198,22 +199,29 @@ public class SearchProjectsActionTest { userSession.logIn(); OrganizationDto organization1Dto = db.organizations().insertForKey("my-org-key-1"); OrganizationDto organization2Dto = db.organizations().insertForKey("my-org-key-2"); + MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType(PERCENT.name())); ComponentDto project1 = insertProject(organization1Dto, c -> c .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_001) .setName("My Project 1") - .setTagsString("finance, java")); + .setTagsString("finance, java"), + new Measure(coverage, c -> c.setValue(80d))); insertProject(organization1Dto, c -> c .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_002) - .setName("My Project 2")); + .setName("My Project 2"), + new Measure(coverage, c -> c.setValue(90d))); insertProject(organization2Dto, c -> c .setDbKey(KeyExamples.KEY_PROJECT_EXAMPLE_003) .setName("My Project 3") - .setTagsString("sales, offshore, java")); + .setTagsString("sales, offshore, java"), + new Measure(coverage, c -> c.setValue(20d))); addFavourite(project1); - String result = ws.newRequest().execute().getInput(); + String result = ws.newRequest() + .setParam(Param.FACETS, COVERAGE) + .execute().getInput(); - assertJson(result).withStrictArrayOrder().ignoreFields("id").isSimilarTo(ws.getDef().responseExampleAsString()); + assertJson(result).withStrictArrayOrder().isSimilarTo(ws.getDef().responseExampleAsString()); + assertJson(ws.getDef().responseExampleAsString()).withStrictArrayOrder().isSimilarTo(result); } @Test