From 7e59dac3b1a5eeace8f543e8ff9cdf8f1e211725 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 8 Feb 2017 17:55:19 +0100 Subject: [PATCH] SONAR-8756 add guarded flag to response of api/organizations/search --- .../ws/OrganizationsWsSupport.java | 3 ++- .../server/organization/ws/example-create.json | 3 ++- .../server/organization/ws/example-search.json | 6 ++++-- .../organization/ws/SearchActionTest.java | 18 ++++++++++-------- .../src/main/protobuf/ws-organizations.proto | 1 + 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsSupport.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsSupport.java index bdbc004de86..394c7934b12 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsSupport.java +++ b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsSupport.java @@ -119,7 +119,8 @@ public class OrganizationsWsSupport { builder .clear() .setName(dto.getName()) - .setKey(dto.getKey()); + .setKey(dto.getKey()) + .setGuarded(dto.isGuarded()); setNullable(dto.getDescription(), builder::setDescription); setNullable(dto.getUrl(), builder::setUrl); setNullable(dto.getAvatarUrl(), builder::setAvatar); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-create.json b/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-create.json index a350af2f7a4..3acbecf4148 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-create.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-create.json @@ -4,6 +4,7 @@ "name": "Foo Company", "description": "The Foo company produces quality software for Bar.", "url": "https://www.foo.com", - "avatar": "https://www.foo.com/foo.png" + "avatar": "https://www.foo.com/foo.png", + "guarded": false } } diff --git a/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-search.json b/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-search.json index ef0b9d84d24..81566290cf1 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-search.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/example-search.json @@ -2,14 +2,16 @@ "organizations": [ { "key": "foo-company", - "name": "Foo Company" + "name": "Foo Company", + "guarded": true }, { "key": "bar-company", "name": "Bar Company", "description": "The Bar company produces quality software too.", "url": "https://www.bar.com", - "avatar": "https://www.bar.com/logo.png" + "avatar": "https://www.bar.com/logo.png", + "guarded": false } ] } diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java index d3e9ba208b0..6b064c813b6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java @@ -107,11 +107,13 @@ public class SearchActionTest { .setName("Bar Company") .setDescription("The Bar company produces quality software too.") .setUrl("https://www.bar.com") - .setAvatarUrl("https://www.bar.com/logo.png")); + .setAvatarUrl("https://www.bar.com/logo.png") + .setGuarded(false)); insertOrganization(new OrganizationDto() .setUuid(Uuids.UUID_EXAMPLE_01) .setKey("foo-company") - .setName("Foo Company")); + .setName("Foo Company") + .setGuarded(true)); String response = executeJsonRequest(null, null); @@ -199,14 +201,14 @@ public class SearchActionTest { // verify paging assertThat(executeRequest(1, 1, "key-1", "key-3", "key-5")) - .extracting(Organization::getKey) - .containsExactly("key-5"); + .extracting(Organization::getKey) + .containsExactly("key-5"); assertThat(executeRequest(1, 2, "key-1", "key-3", "key-5")) - .extracting(Organization::getKey) - .containsExactly("key-5", "key-1"); + .extracting(Organization::getKey) + .containsExactly("key-5", "key-1"); assertThat(executeRequest(2, 2, "key-1", "key-3", "key-5")) - .extracting(Organization::getKey) - .containsExactly("key-3"); + .extracting(Organization::getKey) + .containsExactly("key-3"); } @Test diff --git a/sonar-ws/src/main/protobuf/ws-organizations.proto b/sonar-ws/src/main/protobuf/ws-organizations.proto index e4087f6c91b..fa0251a9549 100644 --- a/sonar-ws/src/main/protobuf/ws-organizations.proto +++ b/sonar-ws/src/main/protobuf/ws-organizations.proto @@ -45,4 +45,5 @@ message Organization { optional string description = 3; optional string url = 4; optional string avatar = 5; + optional bool guarded = 6; } -- 2.39.5