aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java15
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java15
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java7
3 files changed, 31 insertions, 6 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java
index 4b21fe35839..9c1d7cbcb85 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java
@@ -23,6 +23,7 @@ import org.json.simple.JSONValue;
import org.sonar.wsclient.internal.HttpRequestFactory;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -35,7 +36,7 @@ public class DefaultUserClient implements UserClient {
private static final String SEARCH_URL = BASE_URL + "search";
private static final String CREATE_URL = BASE_URL + "create";
private static final String UPDATE_URL = BASE_URL + "update";
- private static final String DELETE_URL = BASE_URL + "delete";
+ private static final String DEACTIVATE_URL = BASE_URL + "deactivate";
private final HttpRequestFactory requestFactory;
@@ -76,8 +77,18 @@ public class DefaultUserClient implements UserClient {
return new User(jsonUser);
}
+ /**
+ * TODO to be removed
+ */
@Override
public void delete(UserParameters userParameters) {
- requestFactory.post(DELETE_URL, userParameters.urlParams());
+ requestFactory.post(DEACTIVATE_URL, userParameters.urlParams());
+ }
+
+ @Override
+ public void deactivate(String login) {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("login", login);
+ requestFactory.post(DEACTIVATE_URL, params);
}
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java
index fe0e620f5c7..762bc8cdaf1 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java
@@ -28,9 +28,24 @@ public interface UserClient {
List<User> find(UserQuery query);
+ /**
+ * @since 3.7
+ */
User create(UserParameters userParameters);
+ /**
+ * @since 3.7
+ */
User update(UserParameters userParameters);
+ /**
+ * TODO to remove
+ */
+ @Deprecated
void delete(UserParameters userParameters);
+
+ /**
+ * @since 3.7
+ */
+ void deactivate(String login);
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
index 2a7ea302491..90e6865f28b 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
@@ -89,13 +89,12 @@ public class DefaultUserClientTest {
}
@Test
- public void should_delete_user() throws Exception {
+ public void should_deactivate_user() throws Exception {
httpServer.stubStatusCode(200);
- UserParameters params = UserParameters.create().login("daveloper");
- client.delete(params);
+ client.deactivate("daveloper");
- assertThatRequestUrlContains("/api/users/delete?", "login=daveloper");
+ assertThatRequestUrlContains("/api/users/deactivate?", "login=daveloper");
}
private void assertThatRequestUrlContains(String baseUrl, String... parameters) {