]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9356 add "showOnboardingTutorial" in api/user/current
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 12 Jun 2017 08:53:04 +0000 (10:53 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 20 Jun 2017 11:10:53 +0000 (04:10 -0700)
server/sonar-server/src/main/java/org/sonar/server/user/ws/CurrentAction.java
server/sonar-server/src/main/resources/org/sonar/server/user/ws/current-example.json
server/sonar-server/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java
sonar-ws/src/main/protobuf/ws-users.proto

index 36a208ca8ce348ce1067be5b42cce4c5ca5ef5b0..6d06d380fc89f6c9d2f57edbf36b91cbcab17d30 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.user.ws;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
+import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService.NewController;
@@ -59,7 +60,8 @@ public class CurrentAction implements UsersWsAction {
       .setHandler(this)
       .setInternal(true)
       .setResponseExample(getClass().getResource("current-example.json"))
-      .setSince("5.2");
+      .setSince("5.2")
+    .setChangelog(new Change("6.5", "showOnboardingTutorial is now returned in the response"));
   }
 
   @Override
@@ -89,7 +91,8 @@ public class CurrentAction implements UsersWsAction {
       .setLocal(user.isLocal())
       .addAllGroups(groups)
       .addAllScmAccounts(user.getScmAccountsAsList())
-      .setPermissions(Permissions.newBuilder().addAllGlobal(getGlobalPermissions()).build());
+      .setPermissions(Permissions.newBuilder().addAllGlobal(getGlobalPermissions()).build())
+      .setShowOnboardingTutorial(!user.isOnboarded());
     setNullable(emptyToNull(user.getEmail()), builder::setEmail);
     setNullable(user.getExternalIdentity(), builder::setExternalIdentity);
     setNullable(user.getExternalIdentityProvider(), builder::setExternalProvider);
index 9237b50fe0e0ef5ee53acf54b9b6a4516cd4ad16..77420e5fe9c75d741a394f84257cb4f41b4a85a1 100644 (file)
@@ -6,6 +6,7 @@
   "local": true,
   "externalIdentity": "obiwan.kenobi",
   "externalProvider": "sonarqube",
+  "showOnboardingTutorial": false,
   "scmAccounts": [
     "obiwan:github",
     "obiwan:bitbucket"
index fe623c05cce48227727f370be120a9ba253b7b7d..a5b9f4b3f1007fb8356fe92e764c231988b3f83a 100644 (file)
@@ -63,16 +63,17 @@ public class CurrentActionTest {
       .setLocal(true)
       .setExternalIdentity("obiwan")
       .setExternalIdentityProvider("sonarqube")
-      .setScmAccounts(newArrayList("obiwan:github", "obiwan:bitbucket")));
+      .setScmAccounts(newArrayList("obiwan:github", "obiwan:bitbucket"))
+      .setOnboarded(false));
     userSessionRule.logIn("obiwan.kenobi");
 
     CurrentWsResponse response = call();
 
     assertThat(response)
       .extracting(CurrentWsResponse::getIsLoggedIn, CurrentWsResponse::getLogin, CurrentWsResponse::getName, CurrentWsResponse::getEmail, CurrentWsResponse::getLocal,
-        CurrentWsResponse::getExternalIdentity, CurrentWsResponse::getExternalProvider, CurrentWsResponse::getScmAccountsList)
+        CurrentWsResponse::getExternalIdentity, CurrentWsResponse::getExternalProvider, CurrentWsResponse::getScmAccountsList, CurrentWsResponse::getShowOnboardingTutorial)
       .containsExactly(true, "obiwan.kenobi", "Obiwan Kenobi", "obiwan.kenobi@starwars.com", true, "obiwan", "sonarqube",
-        newArrayList("obiwan:github", "obiwan:bitbucket"));
+        newArrayList("obiwan:github", "obiwan:bitbucket"), true);
   }
 
   @Test
@@ -182,7 +183,8 @@ public class CurrentActionTest {
       .setLocal(true)
       .setExternalIdentity("obiwan.kenobi")
       .setExternalIdentityProvider("sonarqube")
-      .setScmAccounts(newArrayList("obiwan:github", "obiwan:bitbucket")));
+      .setScmAccounts(newArrayList("obiwan:github", "obiwan:bitbucket"))
+      .setOnboarded(true));
     db.users().insertMember(db.users().insertGroup(newGroupDto().setName("Jedi")), obiwan);
     db.users().insertMember(db.users().insertGroup(newGroupDto().setName("Rebel")), obiwan);
 
@@ -201,7 +203,7 @@ public class CurrentActionTest {
     assertThat(definition.isInternal()).isTrue();
     assertThat(definition.responseExampleAsString()).isNotEmpty();
     assertThat(definition.params()).isEmpty();
-    assertThat(definition.changelog()).isEmpty();
+    assertThat(definition.changelog()).hasSize(1);
   }
 
   private CurrentWsResponse call() {
index 0eddebed9400e103149732dc48918de011368b5b..c71a3395f2dad490ed7be3719a89b017bb42e6f1 100644 (file)
@@ -105,6 +105,7 @@ message CurrentWsResponse {
   repeated string scmAccounts = 8;
   repeated string groups = 9;
   optional Permissions permissions = 10;
+  optional bool showOnboardingTutorial = 11;
 
   message Permissions {
     repeated string global = 1;