@@ -23,9 +23,9 @@ import java.util.Arrays; | |||
import org.sonar.api.server.ws.WebService; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.CONTROLLER; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.CONTROLLER; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class BranchesWs implements WebService { | |||
private final BranchWsAction[] actions; |
@@ -36,9 +36,9 @@ import org.sonar.server.user.UserSession; | |||
import static org.sonar.server.branch.ws.BranchesWs.addBranchParam; | |||
import static org.sonar.server.branch.ws.BranchesWs.addProjectParam; | |||
import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_DELETE; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.ACTION_DELETE; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class DeleteAction implements BranchWsAction { | |||
private final DbClient dbClient; |
@@ -58,8 +58,8 @@ import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; | |||
import static org.sonar.db.component.BranchType.LONG; | |||
import static org.sonar.db.component.BranchType.SHORT; | |||
import static org.sonar.server.branch.ws.BranchesWs.addProjectParam; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_LIST; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.ACTION_LIST; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class ListAction implements BranchWsAction { | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectbranches; | |||
package org.sonar.server.branch.ws; | |||
public class ProjectBranchesParameters { | |||
@@ -25,7 +25,6 @@ public class ProjectBranchesParameters { | |||
// actions | |||
public static final String ACTION_LIST = "list"; | |||
public static final String ACTION_SHOW = "show"; | |||
public static final String ACTION_DELETE = "delete"; | |||
public static final String ACTION_RENAME = "rename"; | |||
@@ -34,9 +34,9 @@ import org.sonar.server.user.UserSession; | |||
import static com.google.common.base.Preconditions.checkArgument; | |||
import static org.sonar.server.branch.ws.BranchesWs.addProjectParam; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_RENAME; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.ACTION_RENAME; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_NAME; | |||
import static org.sonar.server.branch.ws.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class RenameAction implements BranchWsAction { | |||
private final ComponentFinder componentFinder; |
@@ -64,13 +64,13 @@ import static org.sonar.db.Pagination.forPage; | |||
import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_QUERY; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MIN_SUBMITTED_AT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_ONLY_CURRENTS; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_STATUS; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_QUERY; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_MAX_EXECUTED_AT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_MIN_SUBMITTED_AT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_ONLY_CURRENTS; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_STATUS; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_TYPE; | |||
public class ActivityAction implements CeWsAction { | |||
private static final int MAX_PAGE_SIZE = 1000; |
@@ -39,8 +39,8 @@ import org.sonarqube.ws.client.ce.ActivityStatusRequest; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
public class ActivityStatusAction implements CeWsAction { | |||
private final UserSession userSession; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.ce; | |||
package org.sonar.server.ce.ws; | |||
public class CeWsParameters { | |||
@@ -41,8 +41,8 @@ import org.sonarqube.ws.Ce.ComponentResponse; | |||
import static org.sonar.db.Pagination.forPage; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_COMPONENT; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
public class ComponentAction implements CeWsAction { | |||
@@ -28,7 +28,7 @@ import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.Ce.WorkerCountResponse; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.ACTION_WORKER_COUNT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.ACTION_WORKER_COUNT; | |||
public class WorkerCountAction implements CeWsAction { | |||
@@ -32,7 +32,7 @@ import org.sonar.server.favorite.FavoriteUpdater; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.KeyExamples; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.favorite.ws.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class AddAction implements FavoritesWsAction { | |||
private final UserSession userSession; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.favorite; | |||
package org.sonar.server.favorite.ws; | |||
public class FavoritesWsParameters { | |||
public static final String CONTROLLER_FAVORITES = "api/favorites"; |
@@ -31,7 +31,7 @@ import org.sonar.server.favorite.FavoriteUpdater; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.KeyExamples; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.favorite.ws.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class RemoveAction implements FavoritesWsAction { | |||
private final UserSession userSession; |
@@ -38,15 +38,16 @@ import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.Common; | |||
import org.sonarqube.ws.Favorites.Favorite; | |||
import org.sonarqube.ws.Favorites.SearchResponse; | |||
import org.sonarqube.ws.client.favorite.SearchRequest; | |||
import org.sonarqube.ws.client.favorites.SearchRequest; | |||
import static com.google.common.base.Preconditions.checkArgument; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.favorite.SearchRequest.MAX_PAGE_SIZE; | |||
import static org.sonar.server.favorite.ws.FavoritesWsParameters.ACTION_SEARCH; | |||
public class SearchAction implements FavoritesWsAction { | |||
private static final int MAX_PAGE_SIZE = 500; | |||
private final FavoriteFinder favoriteFinder; | |||
private final DbClient dbClient; | |||
private final UserSession userSession; | |||
@@ -79,15 +80,15 @@ public class SearchAction implements FavoritesWsAction { | |||
private static SearchRequest toWsRequest(Request request) { | |||
return new SearchRequest() | |||
.setPage(request.mandatoryParamAsInt(Param.PAGE)) | |||
.setPageSize(request.mandatoryParamAsInt(Param.PAGE_SIZE)); | |||
.setP(request.mandatoryParam(Param.PAGE)) | |||
.setPs(request.mandatoryParam(Param.PAGE_SIZE)); | |||
} | |||
private SearchResults toSearchResults(SearchRequest request) { | |||
userSession.checkLoggedIn(); | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
List<ComponentDto> authorizedFavorites = getAuthorizedFavorites(); | |||
Paging paging = Paging.forPageIndex(request.getPage()).withPageSize(request.getPageSize()).andTotal(authorizedFavorites.size()); | |||
Paging paging = Paging.forPageIndex(Integer.parseInt(request.getP())).withPageSize(Integer.parseInt(request.getPs())).andTotal(authorizedFavorites.size()); | |||
List<ComponentDto> displayedFavorites = authorizedFavorites.stream() | |||
.skip(paging.offset()) | |||
.limit(paging.pageSize()) |
@@ -39,7 +39,7 @@ import org.sonar.server.notification.NotificationUpdater; | |||
import org.sonar.server.notification.email.EmailNotificationChannel; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.KeyExamples; | |||
import org.sonarqube.ws.client.notification.AddRequest; | |||
import org.sonarqube.ws.client.notifications.AddRequest; | |||
import static java.util.Optional.empty; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
@@ -48,11 +48,11 @@ import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBA | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; | |||
import static org.sonar.server.ws.WsUtils.checkFound; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.ACTION_ADD; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.ACTION_ADD; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_TYPE; | |||
public class AddAction implements NotificationsWsAction { | |||
private final NotificationCenter notificationCenter; | |||
@@ -152,25 +152,24 @@ public class AddAction implements NotificationsWsAction { | |||
} | |||
private AddRequest toWsRequest(Request request) { | |||
AddRequest.Builder requestBuilder = AddRequest.builder() | |||
AddRequest add = new AddRequest() | |||
.setType(request.mandatoryParam(PARAM_TYPE)) | |||
.setChannel(request.mandatoryParam(PARAM_CHANNEL)); | |||
setNullable(request.param(PARAM_PROJECT), requestBuilder::setProject); | |||
setNullable(request.param(PARAM_LOGIN), requestBuilder::setLogin); | |||
AddRequest wsRequest = requestBuilder.build(); | |||
setNullable(request.param(PARAM_PROJECT), add::setProject); | |||
setNullable(request.param(PARAM_LOGIN), add::setLogin); | |||
if (wsRequest.getProject() == null) { | |||
checkRequest(globalDispatchers.contains(wsRequest.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
if (add.getProject() == null) { | |||
checkRequest(globalDispatchers.contains(add.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
PARAM_TYPE, | |||
wsRequest.getType(), | |||
add.getType(), | |||
globalDispatchers); | |||
} else { | |||
checkRequest(projectDispatchers.contains(wsRequest.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
checkRequest(projectDispatchers.contains(add.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
PARAM_TYPE, | |||
wsRequest.getType(), | |||
add.getType(), | |||
projectDispatchers); | |||
} | |||
return wsRequest; | |||
return add; | |||
} | |||
} |
@@ -57,8 +57,8 @@ import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBA | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; | |||
import static org.sonar.server.ws.WsUtils.checkFound; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.ACTION_LIST; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.ACTION_LIST; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_LOGIN; | |||
public class ListAction implements NotificationsWsAction { | |||
private static final Splitter PROPERTY_KEY_SPLITTER = Splitter.on("."); |
@@ -21,7 +21,7 @@ package org.sonar.server.notification.ws; | |||
import org.sonar.api.server.ws.WebService; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.CONTROLLER; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.CONTROLLER; | |||
public class NotificationsWs implements WebService { | |||
private final NotificationsWsAction[] actions; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.notification; | |||
package org.sonar.server.notification.ws; | |||
public class NotificationsWsParameters { | |||
public static final String CONTROLLER = "api/notifications"; |
@@ -39,7 +39,7 @@ import org.sonar.server.notification.NotificationUpdater; | |||
import org.sonar.server.notification.email.EmailNotificationChannel; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.KeyExamples; | |||
import org.sonarqube.ws.client.notification.RemoveRequest; | |||
import org.sonarqube.ws.client.notifications.RemoveRequest; | |||
import static java.util.Optional.empty; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
@@ -47,11 +47,11 @@ import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBA | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; | |||
import static org.sonar.server.ws.WsUtils.checkFound; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.ACTION_REMOVE; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.ACTION_REMOVE; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_TYPE; | |||
public class RemoveAction implements NotificationsWsAction { | |||
private final NotificationCenter notificationCenter; | |||
@@ -150,25 +150,24 @@ public class RemoveAction implements NotificationsWsAction { | |||
} | |||
private RemoveRequest toWsRequest(Request request) { | |||
RemoveRequest.Builder requestBuilder = RemoveRequest.builder() | |||
RemoveRequest remove = new RemoveRequest() | |||
.setType(request.mandatoryParam(PARAM_TYPE)) | |||
.setChannel(request.mandatoryParam(PARAM_CHANNEL)); | |||
setNullable(request.param(PARAM_PROJECT), requestBuilder::setProject); | |||
setNullable(request.param(PARAM_LOGIN), requestBuilder::setLogin); | |||
RemoveRequest wsRequest = requestBuilder.build(); | |||
setNullable(request.param(PARAM_PROJECT), remove::setProject); | |||
setNullable(request.param(PARAM_LOGIN), remove::setLogin); | |||
if (wsRequest.getProject() == null) { | |||
checkRequest(globalDispatchers.contains(wsRequest.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
if (remove.getProject() == null) { | |||
checkRequest(globalDispatchers.contains(remove.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
PARAM_TYPE, | |||
wsRequest.getType(), | |||
remove.getType(), | |||
globalDispatchers); | |||
} else { | |||
checkRequest(projectDispatchers.contains(wsRequest.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
checkRequest(projectDispatchers.contains(remove.getType()), "Value of parameter '%s' (%s) must be one of: %s", | |||
PARAM_TYPE, | |||
wsRequest.getType(), | |||
remove.getType(), | |||
projectDispatchers); | |||
} | |||
return wsRequest; | |||
return remove; | |||
} | |||
} |
@@ -31,17 +31,17 @@ import org.sonar.server.component.ComponentFinder; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.ProjectLinks; | |||
import org.sonarqube.ws.ProjectLinks.CreateWsResponse; | |||
import org.sonarqube.ws.client.projectlinks.CreateWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.CreateRequest; | |||
import static org.sonar.core.util.Slug.slugify; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_CREATE; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_URL; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.ACTION_CREATE; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_URL; | |||
public class CreateAction implements ProjectLinksWsAction { | |||
private final DbClient dbClient; | |||
@@ -92,12 +92,12 @@ public class CreateAction implements ProjectLinksWsAction { | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
CreateWsRequest searchWsRequest = toCreateWsRequest(request); | |||
CreateRequest searchWsRequest = toCreateWsRequest(request); | |||
CreateWsResponse createWsResponse = doHandle(searchWsRequest); | |||
writeProtobuf(createWsResponse, request, response); | |||
} | |||
private CreateWsResponse doHandle(CreateWsRequest createWsRequest) { | |||
private CreateWsResponse doHandle(CreateRequest createWsRequest) { | |||
String name = createWsRequest.getName(); | |||
String url = createWsRequest.getUrl(); | |||
@@ -127,7 +127,7 @@ public class CreateAction implements ProjectLinksWsAction { | |||
.build(); | |||
} | |||
private ComponentDto getComponentByUuidOrKey(DbSession dbSession, CreateWsRequest request) { | |||
private ComponentDto getComponentByUuidOrKey(DbSession dbSession, CreateRequest request) { | |||
return componentFinder.getRootComponentByUuidOrKey( | |||
dbSession, | |||
request.getProjectId(), | |||
@@ -135,8 +135,8 @@ public class CreateAction implements ProjectLinksWsAction { | |||
ComponentFinder.ParamNames.PROJECT_ID_AND_KEY); | |||
} | |||
private static CreateWsRequest toCreateWsRequest(Request request) { | |||
return new CreateWsRequest() | |||
private static CreateRequest toCreateWsRequest(Request request) { | |||
return new CreateRequest() | |||
.setProjectId(request.param(PARAM_PROJECT_ID)) | |||
.setProjectKey(request.param(PARAM_PROJECT_KEY)) | |||
.setName(request.mandatoryParam(PARAM_NAME)) |
@@ -28,11 +28,11 @@ import org.sonar.db.DbSession; | |||
import org.sonar.db.component.ComponentLinkDto; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.WsUtils; | |||
import org.sonarqube.ws.client.projectlinks.DeleteWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.DeleteRequest; | |||
import static org.sonar.db.component.ComponentLinkDto.PROVIDED_TYPES; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_DELETE; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.ACTION_DELETE; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_ID; | |||
public class DeleteAction implements ProjectLinksWsAction { | |||
private final DbClient dbClient; | |||
@@ -61,19 +61,19 @@ public class DeleteAction implements ProjectLinksWsAction { | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
DeleteWsRequest deleteWsRequest = toDeleteWsRequest(request); | |||
DeleteRequest deleteWsRequest = toDeleteWsRequest(request); | |||
doHandle(deleteWsRequest); | |||
response.noContent(); | |||
} | |||
private static DeleteWsRequest toDeleteWsRequest(Request request) { | |||
return new DeleteWsRequest() | |||
.setId(request.mandatoryParamAsLong(PARAM_ID)); | |||
private static DeleteRequest toDeleteWsRequest(Request request) { | |||
return new DeleteRequest() | |||
.setId(request.mandatoryParam(PARAM_ID)); | |||
} | |||
private void doHandle(DeleteWsRequest request) { | |||
private void doHandle(DeleteRequest request) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
long id = request.getId(); | |||
long id = Long.parseLong(request.getId()); | |||
ComponentLinkDto link = dbClient.componentLinkDao().selectById(dbSession, id); | |||
link = WsUtils.checkFound(link, "Link with id '%s' not found", id); |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
package org.sonar.server.projectlink.ws; | |||
public class ProjectLinksWsParameters { | |||
@@ -33,16 +33,16 @@ import org.sonar.server.component.ComponentFinder; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.ProjectLinks.Link; | |||
import org.sonarqube.ws.ProjectLinks.SearchWsResponse; | |||
import org.sonarqube.ws.client.projectlinks.SearchWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.SearchRequest; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.ACTION_SEARCH; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
public class SearchAction implements ProjectLinksWsAction { | |||
private final DbClient dbClient; | |||
@@ -82,13 +82,13 @@ public class SearchAction implements ProjectLinksWsAction { | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
SearchWsRequest searchWsRequest = toSearchWsRequest(request); | |||
SearchRequest searchWsRequest = toSearchWsRequest(request); | |||
SearchWsResponse searchWsResponse = doHandle(searchWsRequest); | |||
writeProtobuf(searchWsResponse, request, response); | |||
} | |||
private SearchWsResponse doHandle(SearchWsRequest searchWsRequest) { | |||
private SearchWsResponse doHandle(SearchRequest searchWsRequest) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
ComponentDto component = getComponentByUuidOrKey(dbSession, searchWsRequest); | |||
List<ComponentLinkDto> links = dbClient.componentLinkDao() | |||
@@ -114,7 +114,7 @@ public class SearchAction implements ProjectLinksWsAction { | |||
return builder.build(); | |||
} | |||
private ComponentDto getComponentByUuidOrKey(DbSession dbSession, SearchWsRequest request) { | |||
private ComponentDto getComponentByUuidOrKey(DbSession dbSession, SearchRequest request) { | |||
ComponentDto component = componentFinder.getRootComponentByUuidOrKey( | |||
dbSession, | |||
request.getProjectId(), | |||
@@ -129,8 +129,8 @@ public class SearchAction implements ProjectLinksWsAction { | |||
return component; | |||
} | |||
private static SearchWsRequest toSearchWsRequest(Request request) { | |||
return new SearchWsRequest() | |||
private static SearchRequest toSearchWsRequest(Request request) { | |||
return new SearchRequest() | |||
.setProjectId(request.param(PARAM_PROJECT_ID)) | |||
.setProjectKey(request.param(PARAM_PROJECT_KEY)); | |||
} |
@@ -26,8 +26,8 @@ import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.db.qualitygate.QualityGateDto; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; | |||
public class CopyAction implements QualityGatesWsAction { | |||
@@ -32,8 +32,8 @@ import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.Qualitygates.CreateWsResponse; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_CREATE; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_CREATE; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; | |||
public class CreateAction implements QualityGatesWsAction { | |||
@@ -34,13 +34,13 @@ import org.sonarqube.ws.Qualitygates.CreateConditionWsResponse; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWs.addConditionParams; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_CREATE_CONDITION; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_WARNING; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_CREATE_CONDITION; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_WARNING; | |||
public class CreateConditionAction implements QualityGatesWsAction { | |||
@@ -28,7 +28,7 @@ import org.sonar.db.organization.OrganizationDto; | |||
import org.sonar.server.user.UserSession; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
public class DeleteConditionAction implements QualityGatesWsAction { | |||
@@ -33,8 +33,8 @@ import org.sonar.server.component.ComponentFinder; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
public class DeselectAction implements QualityGatesWsAction { | |||
@@ -23,7 +23,6 @@ import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters; | |||
public class DestroyAction implements QualityGatesWsAction { | |||
@@ -38,7 +38,7 @@ import org.sonarqube.ws.Qualitygates.GetByProjectWsResponse; | |||
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_GET_BY_PROJECT; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_GET_BY_PROJECT; | |||
public class GetByProjectAction implements QualityGatesWsAction { | |||
private static final String PARAM_PROJECT = "project"; |
@@ -50,10 +50,10 @@ import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesEx | |||
import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_PROJECT_STATUS; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ANALYSIS_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_PROJECT_STATUS; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ANALYSIS_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
public class ProjectStatusAction implements QualityGatesWsAction { | |||
private static final String QG_STATUSES_ONE_LINE = Arrays.stream(ProjectStatusWsResponse.Status.values()) |
@@ -26,14 +26,14 @@ import org.sonar.db.qualitygate.QualityGateConditionDto; | |||
import org.sonar.db.qualitygate.QualityGateDto; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.CONTROLLER_QUALITY_GATES; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_WARNING; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.CONTROLLER_QUALITY_GATES; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_WARNING; | |||
public class QualityGatesWs implements WebService { | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.qualitygate; | |||
package org.sonar.server.qualitygate.ws; | |||
public class QualityGatesWsParameters { | |||
@@ -27,8 +27,8 @@ import org.sonar.db.qualitygate.QualityGateDto; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import static org.sonar.server.qualitygate.ws.CreateAction.NAME_MAXIMUM_LENGTH; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; | |||
public class RenameAction implements QualityGatesWsAction { | |||
@@ -28,7 +28,6 @@ import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.db.qualitygate.ProjectQgateAssociation; | |||
import org.sonar.db.qualitygate.ProjectQgateAssociationQuery; | |||
import org.sonar.server.qualitygate.QgateProjectFinder; | |||
import org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters; | |||
public class SearchAction implements QualityGatesWsAction { | |||
@@ -39,10 +39,10 @@ import static org.sonar.server.qualitygate.QualityGates.SONAR_QUALITYGATE_PROPER | |||
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.WsUtils.checkFound; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_SELECT; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_SELECT; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
public class SelectAction implements QualityGatesWsAction { | |||
private final DbClient dbClient; |
@@ -23,7 +23,6 @@ import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters; | |||
public class SetAsDefaultAction implements QualityGatesWsAction { | |||
@@ -31,8 +31,8 @@ import org.sonar.db.qualitygate.QualityGateDto; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; | |||
public class ShowAction implements QualityGatesWsAction { | |||
@@ -23,7 +23,6 @@ import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters; | |||
public class UnsetDefaultAction implements QualityGatesWsAction { | |||
@@ -34,13 +34,13 @@ import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWs.addConditionParams; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.ACTION_UPDATE_CONDITION; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_WARNING; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_UPDATE_CONDITION; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_WARNING; | |||
public class UpdateConditionAction implements QualityGatesWsAction { | |||
@@ -33,15 +33,15 @@ import org.sonar.server.user.UserSession; | |||
import org.sonar.server.usertoken.TokenGenerator; | |||
import org.sonarqube.ws.UserTokens; | |||
import org.sonarqube.ws.UserTokens.GenerateWsResponse; | |||
import org.sonarqube.ws.client.usertoken.GenerateWsRequest; | |||
import org.sonarqube.ws.client.usertokens.GenerateRequest; | |||
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; | |||
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_GENERATE; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.ACTION_GENERATE; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_NAME; | |||
public class GenerateAction implements UserTokensWsAction { | |||
private static final int MAX_TOKEN_NAME_LENGTH = 100; | |||
@@ -85,7 +85,7 @@ public class GenerateAction implements UserTokensWsAction { | |||
writeProtobuf(generateWsResponse, request, response); | |||
} | |||
private UserTokens.GenerateWsResponse doHandle(GenerateWsRequest request) { | |||
private UserTokens.GenerateWsResponse doHandle(GenerateRequest request) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
checkWsRequest(dbSession, request); | |||
TokenPermissionsValidator.validate(userSession, request.getLogin()); | |||
@@ -109,21 +109,21 @@ public class GenerateAction implements UserTokensWsAction { | |||
return tokenHash; | |||
} | |||
private void checkWsRequest(DbSession dbSession, GenerateWsRequest request) { | |||
private void checkWsRequest(DbSession dbSession, GenerateRequest request) { | |||
checkLoginExists(dbSession, request); | |||
Optional<UserTokenDto> userTokenDto = dbClient.userTokenDao().selectByLoginAndName(dbSession, request.getLogin(), request.getName()); | |||
checkRequest(!userTokenDto.isPresent(), "A user token with login '%s' and name '%s' already exists", request.getLogin(), request.getName()); | |||
} | |||
private void checkLoginExists(DbSession dbSession, GenerateWsRequest request) { | |||
private void checkLoginExists(DbSession dbSession, GenerateRequest request) { | |||
UserDto user = dbClient.userDao().selectByLogin(dbSession, request.getLogin()); | |||
if (user == null) { | |||
throw insufficientPrivilegesException(); | |||
} | |||
} | |||
private UserTokenDto insertTokenInDb(DbSession dbSession, GenerateWsRequest request, String tokenHash) { | |||
private UserTokenDto insertTokenInDb(DbSession dbSession, GenerateRequest request, String tokenHash) { | |||
UserTokenDto userTokenDto = new UserTokenDto() | |||
.setLogin(request.getLogin()) | |||
.setName(request.getName()) | |||
@@ -135,8 +135,8 @@ public class GenerateAction implements UserTokensWsAction { | |||
return userTokenDto; | |||
} | |||
private GenerateWsRequest toCreateWsRequest(Request request) { | |||
GenerateWsRequest generateWsRequest = new GenerateWsRequest() | |||
private GenerateRequest toCreateWsRequest(Request request) { | |||
GenerateRequest generateWsRequest = new GenerateRequest() | |||
.setLogin(request.param(PARAM_LOGIN)) | |||
.setName(request.mandatoryParam(PARAM_NAME).trim()); | |||
if (generateWsRequest.getLogin() == null) { |
@@ -25,11 +25,11 @@ import org.sonar.api.server.ws.WebService; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.client.usertoken.RevokeWsRequest; | |||
import org.sonarqube.ws.client.usertokens.RevokeRequest; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_REVOKE; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.ACTION_REVOKE; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_NAME; | |||
public class RevokeAction implements UserTokensWsAction { | |||
private final DbClient dbClient; | |||
@@ -61,11 +61,11 @@ public class RevokeAction implements UserTokensWsAction { | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
doHandle(toRevokeWsRequest(request)); | |||
doHandle(toRevokeRequest(request)); | |||
response.noContent(); | |||
} | |||
private void doHandle(RevokeWsRequest request) { | |||
private void doHandle(RevokeRequest request) { | |||
TokenPermissionsValidator.validate(userSession, request.getLogin()); | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
@@ -74,13 +74,13 @@ public class RevokeAction implements UserTokensWsAction { | |||
} | |||
} | |||
private RevokeWsRequest toRevokeWsRequest(Request request) { | |||
RevokeWsRequest revokeWsRequest = new RevokeWsRequest() | |||
private RevokeRequest toRevokeRequest(Request request) { | |||
RevokeRequest RevokeRequest = new RevokeRequest() | |||
.setLogin(request.param(PARAM_LOGIN)) | |||
.setName(request.mandatoryParam(PARAM_NAME)); | |||
if (revokeWsRequest.getLogin() == null) { | |||
revokeWsRequest.setLogin(userSession.getLogin()); | |||
if (RevokeRequest.getLogin() == null) { | |||
RevokeRequest.setLogin(userSession.getLogin()); | |||
} | |||
return revokeWsRequest; | |||
return RevokeRequest; | |||
} | |||
} |
@@ -29,13 +29,13 @@ import org.sonar.db.DbSession; | |||
import org.sonar.db.user.UserTokenDto; | |||
import org.sonar.server.user.UserSession; | |||
import org.sonarqube.ws.UserTokens.SearchWsResponse; | |||
import org.sonarqube.ws.client.usertoken.SearchWsRequest; | |||
import org.sonarqube.ws.client.usertokens.SearchRequest; | |||
import static org.sonar.api.utils.DateUtils.formatDateTime; | |||
import static org.sonar.server.ws.WsUtils.checkFound; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.ACTION_SEARCH; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
public class SearchAction implements UserTokensWsAction { | |||
private final DbClient dbClient; | |||
@@ -63,11 +63,11 @@ public class SearchAction implements UserTokensWsAction { | |||
@Override | |||
public void handle(Request request, Response response) throws Exception { | |||
SearchWsResponse searchWsResponse = doHandle(toSearchWsRequest(request)); | |||
SearchWsResponse searchWsResponse = doHandle(toSearchRequest(request)); | |||
writeProtobuf(searchWsResponse, request, response); | |||
} | |||
private SearchWsResponse doHandle(SearchWsRequest request) { | |||
private SearchWsResponse doHandle(SearchRequest request) { | |||
TokenPermissionsValidator.validate(userSession, request.getLogin()); | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
@@ -78,12 +78,12 @@ public class SearchAction implements UserTokensWsAction { | |||
} | |||
} | |||
private SearchWsRequest toSearchWsRequest(Request request) { | |||
SearchWsRequest searchWsRequest = new SearchWsRequest().setLogin(request.param(PARAM_LOGIN)); | |||
if (searchWsRequest.getLogin() == null) { | |||
searchWsRequest.setLogin(userSession.getLogin()); | |||
private SearchRequest toSearchRequest(Request request) { | |||
SearchRequest SearchRequest = new SearchRequest().setLogin(request.param(PARAM_LOGIN)); | |||
if (SearchRequest.getLogin() == null) { | |||
SearchRequest.setLogin(userSession.getLogin()); | |||
} | |||
return searchWsRequest; | |||
return SearchRequest; | |||
} | |||
private static SearchWsResponse buildResponse(String login, List<UserTokenDto> userTokensDto) { |
@@ -21,7 +21,7 @@ package org.sonar.server.usertoken.ws; | |||
import org.sonar.api.server.ws.WebService; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.CONTROLLER; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.CONTROLLER; | |||
public class UserTokensWs implements WebService { | |||
private final UserTokensWsAction[] actions; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.usertoken; | |||
package org.sonar.server.usertoken.ws; | |||
public class UserTokensWsParameters { | |||
public static final String CONTROLLER = "api/user_tokens"; |
@@ -53,7 +53,6 @@ import org.sonar.test.JsonAssert; | |||
import org.sonarqube.ws.Ce; | |||
import org.sonarqube.ws.Common; | |||
import org.sonarqube.ws.MediaTypes; | |||
import org.sonarqube.ws.Ce; | |||
import org.sonarqube.ws.Ce.ActivityResponse; | |||
import org.sonarqube.ws.Ce.Task; | |||
@@ -70,12 +69,12 @@ import static org.sonar.db.ce.CeQueueDto.Status.PENDING; | |||
import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_KEY; | |||
import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_TYPE_KEY; | |||
import static org.sonar.db.component.BranchType.LONG; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_QUERY; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MIN_SUBMITTED_AT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_STATUS; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_QUERY; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_MAX_EXECUTED_AT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_MIN_SUBMITTED_AT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_STATUS; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_TYPE; | |||
public class ActivityActionTest { | |||
@@ -41,14 +41,13 @@ import org.sonar.server.tester.UserSessionRule; | |||
import org.sonar.server.ws.TestRequest; | |||
import org.sonar.server.ws.WsActionTester; | |||
import org.sonarqube.ws.Ce; | |||
import org.sonarqube.ws.Ce; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.ce.CeQueueTesting.newCeQueueDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
public class ActivityStatusActionTest { | |||
@@ -53,8 +53,8 @@ import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_KEY; | |||
import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_TYPE_KEY; | |||
import static org.sonar.db.component.BranchType.LONG; | |||
import static org.sonar.db.component.BranchType.SHORT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT; | |||
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
public class ComponentActionTest { | |||
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.favorite.ws.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class AddActionTest { | |||
private static final String PROJECT_KEY = "project-key"; |
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newFileDto; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
import static org.sonar.server.favorite.ws.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class RemoveActionTest { | |||
private static final String PROJECT_KEY = "project-key"; |
@@ -42,7 +42,7 @@ import org.sonar.server.tester.UserSessionRule; | |||
import org.sonar.server.ws.TestRequest; | |||
import org.sonar.server.ws.TestResponse; | |||
import org.sonar.server.ws.WsActionTester; | |||
import org.sonarqube.ws.client.notification.AddRequest; | |||
import org.sonarqube.ws.client.notifications.AddRequest; | |||
import static java.lang.String.format; | |||
import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | |||
@@ -51,10 +51,10 @@ import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_TYPE; | |||
public class AddActionTest { | |||
private static final String NOTIF_MY_NEW_ISSUES = "Dispatcher1"; | |||
@@ -82,8 +82,7 @@ public class AddActionTest { | |||
private AddAction underTest; | |||
private WsActionTester ws; | |||
private AddRequest.Builder request = AddRequest.builder() | |||
.setType(NOTIF_MY_NEW_ISSUES); | |||
private AddRequest request = new AddRequest().setType(NOTIF_MY_NEW_ISSUES); | |||
@Before | |||
public void setUp() { | |||
@@ -313,13 +312,12 @@ public class AddActionTest { | |||
.setLogin(userSession.getLogin())); | |||
} | |||
private TestResponse call(AddRequest.Builder wsRequestBuilder) { | |||
AddRequest wsRequest = wsRequestBuilder.build(); | |||
private TestResponse call(AddRequest add) { | |||
TestRequest request = ws.newRequest(); | |||
request.setParam(PARAM_TYPE, wsRequest.getType()); | |||
setNullable(wsRequest.getChannel(), channel -> request.setParam(PARAM_CHANNEL, channel)); | |||
setNullable(wsRequest.getProject(), project -> request.setParam(PARAM_PROJECT, project)); | |||
setNullable(wsRequest.getLogin(), login -> request.setParam(PARAM_LOGIN, login)); | |||
request.setParam(PARAM_TYPE, add.getType()); | |||
setNullable(add.getChannel(), channel -> request.setParam(PARAM_CHANNEL, channel)); | |||
setNullable(add.getProject(), project -> request.setParam(PARAM_PROJECT, project)); | |||
setNullable(add.getLogin(), login -> request.setParam(PARAM_LOGIN, login)); | |||
return request.execute(); | |||
} | |||
@@ -42,7 +42,7 @@ import org.sonar.server.tester.UserSessionRule; | |||
import org.sonar.server.ws.TestRequest; | |||
import org.sonar.server.ws.TestResponse; | |||
import org.sonar.server.ws.WsActionTester; | |||
import org.sonarqube.ws.client.notification.RemoveRequest; | |||
import org.sonarqube.ws.client.notifications.RemoveRequest; | |||
import static java.lang.String.format; | |||
import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | |||
@@ -51,10 +51,10 @@ import static org.sonar.core.util.Protobuf.setNullable; | |||
import static org.sonar.db.component.ComponentTesting.newView; | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; | |||
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.notification.NotificationsWsParameters.PARAM_TYPE; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_CHANNEL; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_PROJECT; | |||
import static org.sonar.server.notification.ws.NotificationsWsParameters.PARAM_TYPE; | |||
public class RemoveActionTest { | |||
private static final String NOTIF_MY_NEW_ISSUES = "Dispatcher1"; | |||
@@ -79,7 +79,7 @@ public class RemoveActionTest { | |||
private RemoveAction underTest; | |||
private WsActionTester ws; | |||
private RemoveRequest.Builder request = RemoveRequest.builder().setType(NOTIF_MY_NEW_ISSUES); | |||
private RemoveRequest request = new RemoveRequest().setType(NOTIF_MY_NEW_ISSUES); | |||
private UserDto user; | |||
@@ -280,14 +280,12 @@ public class RemoveActionTest { | |||
call(request.setProject(branch.getDbKey())); | |||
} | |||
private TestResponse call(RemoveRequest.Builder wsRequestBuilder) { | |||
RemoveRequest wsRequest = wsRequestBuilder.build(); | |||
private TestResponse call(RemoveRequest remove) { | |||
TestRequest request = ws.newRequest(); | |||
request.setParam(PARAM_TYPE, wsRequest.getType()); | |||
setNullable(wsRequest.getChannel(), channel -> request.setParam(PARAM_CHANNEL, channel)); | |||
setNullable(wsRequest.getProject(), project -> request.setParam(PARAM_PROJECT, project)); | |||
setNullable(wsRequest.getLogin(), login -> request.setParam(PARAM_LOGIN, login)); | |||
request.setParam(PARAM_TYPE, remove.getType()); | |||
setNullable(remove.getChannel(), channel -> request.setParam(PARAM_CHANNEL, channel)); | |||
setNullable(remove.getProject(), project -> request.setParam(PARAM_PROJECT, project)); | |||
setNullable(remove.getLogin(), login -> request.setParam(PARAM_LOGIN, login)); | |||
return request.execute(); | |||
} | |||
@@ -50,10 +50,10 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_URL; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_URL; | |||
public class CreateActionTest { | |||
@@ -41,7 +41,7 @@ import org.sonar.server.ws.WsActionTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_ID; | |||
public class DeleteActionTest { | |||
@@ -53,8 +53,8 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.projectlink.ws.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
public class SearchActionTest { | |||
@@ -48,12 +48,12 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.metric.MetricTesting.newMetricDto; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES; | |||
import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.PERCENT; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_WARNING; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_GATE_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_WARNING; | |||
public class CreateConditionActionTest { | |||
@@ -41,7 +41,7 @@ import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
public class DeleteConditionActionTest { | |||
@@ -54,9 +54,9 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis; | |||
import static org.sonar.db.measure.MeasureTesting.newMeasureDto; | |||
import static org.sonar.db.metric.MetricTesting.newMetricDto; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ANALYSIS_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ANALYSIS_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_KEY; | |||
public class ProjectStatusActionTest { | |||
private static final String ANALYSIS_ID = "task-uuid"; |
@@ -48,12 +48,12 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.metric.MetricTesting.newMetricDto; | |||
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES; | |||
import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.PERCENT; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_WARNING; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ERROR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_ID; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_METRIC; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_OPERATOR; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PERIOD; | |||
import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_WARNING; | |||
public class UpdateConditionActionTest { | |||
@@ -44,8 +44,8 @@ import static org.mockito.Mockito.when; | |||
import static org.sonar.db.user.UserTesting.newUserDto; | |||
import static org.sonar.db.user.UserTokenTesting.newUserToken; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_NAME; | |||
public class GenerateActionTest { | |||
private static final String GRACE_HOPPER = "grace.hopper"; |
@@ -37,8 +37,8 @@ import org.sonar.server.ws.WsActionTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.user.UserTokenTesting.newUserToken; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_NAME; | |||
public class RevokeActionTest { |
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.sonar.db.user.UserTesting.newUserDto; | |||
import static org.sonar.db.user.UserTokenTesting.newUserToken; | |||
import static org.sonar.test.JsonAssert.assertJson; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonar.server.usertoken.ws.UserTokensWsParameters.PARAM_LOGIN; | |||
public class SearchActionTest { | |||
private static final String GRACE_HOPPER = "grace.hopper"; |
@@ -21,25 +21,26 @@ package org.sonarqube.ws.client; | |||
import org.sonarqube.ws.client.ce.CeService; | |||
import org.sonarqube.ws.client.component.ComponentsService; | |||
import org.sonarqube.ws.client.favorite.FavoritesService; | |||
import org.sonarqube.ws.client.favorites.FavoritesService; | |||
import org.sonarqube.ws.client.issue.IssuesService; | |||
import org.sonarqube.ws.client.measure.MeasuresService; | |||
import org.sonarqube.ws.client.notifications.NotificationsService; | |||
import org.sonarqube.ws.client.organization.OrganizationService; | |||
import org.sonarqube.ws.client.permission.PermissionsService; | |||
import org.sonarqube.ws.client.project.ProjectsService; | |||
import org.sonarqube.ws.client.projectanalysis.ProjectAnalysisService; | |||
import org.sonarqube.ws.client.projectbranches.ProjectBranchesServiceOld; | |||
import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; | |||
import org.sonarqube.ws.client.projectlinks.ProjectLinksService; | |||
import org.sonarqube.ws.client.qualitygates.QualitygatesService; | |||
import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; | |||
import org.sonarqube.ws.client.root.RootsService; | |||
import org.sonarqube.ws.client.rule.RulesService; | |||
import org.sonarqube.ws.client.setting.SettingsService; | |||
import org.sonarqube.ws.client.system.SystemServiceOld; | |||
import org.sonarqube.ws.client.system.SystemService; | |||
import org.sonarqube.ws.client.user.UsersService; | |||
import org.sonarqube.ws.client.usergroup.UserGroupsService; | |||
import org.sonarqube.ws.client.usertoken.UserTokensService; | |||
import org.sonarqube.ws.client.webhook.WebhooksService; | |||
import org.sonarqube.ws.client.usertokens.UserTokensService; | |||
import org.sonarqube.ws.client.webhooks.WebhooksService; | |||
/** | |||
* This class is not public anymore since version 5.5. It is | |||
@@ -61,7 +62,7 @@ class DefaultWsClient implements WsClient { | |||
private final UserTokensService userTokensService; | |||
private final QualitygatesService qualityGatesService; | |||
private final MeasuresService measuresService; | |||
private final SystemServiceOld systemService; | |||
private final SystemService systemService; | |||
private final CeService ceService; | |||
private final RulesService rulesService; | |||
private final ProjectsService projectsService; | |||
@@ -70,7 +71,8 @@ class DefaultWsClient implements WsClient { | |||
private final RootsService rootsService; | |||
private final WebhooksService webhooksService; | |||
private final ProjectAnalysisService projectAnalysisService; | |||
private final ProjectBranchesServiceOld projectBranchesService; | |||
private final NotificationsService notificationsService; | |||
private final ProjectBranchesService projectBranchesService; | |||
DefaultWsClient(WsConnector wsConnector) { | |||
this.wsConnector = wsConnector; | |||
@@ -85,7 +87,7 @@ class DefaultWsClient implements WsClient { | |||
this.userTokensService = new UserTokensService(wsConnector); | |||
this.qualityGatesService = new QualitygatesService(wsConnector); | |||
this.measuresService = new MeasuresService(wsConnector); | |||
this.systemService = new SystemServiceOld(wsConnector); | |||
this.systemService = new SystemService(wsConnector); | |||
this.ceService = new CeService(wsConnector); | |||
this.rulesService = new RulesService(wsConnector); | |||
this.projectsService = new ProjectsService(wsConnector); | |||
@@ -94,7 +96,8 @@ class DefaultWsClient implements WsClient { | |||
this.rootsService = new RootsService(wsConnector); | |||
this.webhooksService = new WebhooksService(wsConnector); | |||
this.projectAnalysisService = new ProjectAnalysisService(wsConnector); | |||
this.projectBranchesService = new ProjectBranchesServiceOld(wsConnector); | |||
this.projectBranchesService = new ProjectBranchesService(wsConnector); | |||
this.notificationsService = new NotificationsService(wsConnector); | |||
} | |||
@Override | |||
@@ -158,7 +161,7 @@ class DefaultWsClient implements WsClient { | |||
} | |||
@Override | |||
public SystemServiceOld system() { | |||
public SystemService system() { | |||
return systemService; | |||
} | |||
@@ -203,7 +206,12 @@ class DefaultWsClient implements WsClient { | |||
} | |||
@Override | |||
public ProjectBranchesServiceOld projectBranches() { | |||
public ProjectBranchesService projectBranches() { | |||
return projectBranchesService; | |||
} | |||
@Override | |||
public NotificationsService notifications() { | |||
return notificationsService; | |||
} | |||
} |
@@ -21,25 +21,26 @@ package org.sonarqube.ws.client; | |||
import org.sonarqube.ws.client.ce.CeService; | |||
import org.sonarqube.ws.client.component.ComponentsService; | |||
import org.sonarqube.ws.client.favorite.FavoritesService; | |||
import org.sonarqube.ws.client.favorites.FavoritesService; | |||
import org.sonarqube.ws.client.issue.IssuesService; | |||
import org.sonarqube.ws.client.measure.MeasuresService; | |||
import org.sonarqube.ws.client.notifications.NotificationsService; | |||
import org.sonarqube.ws.client.organization.OrganizationService; | |||
import org.sonarqube.ws.client.permission.PermissionsService; | |||
import org.sonarqube.ws.client.project.ProjectsService; | |||
import org.sonarqube.ws.client.projectanalysis.ProjectAnalysisService; | |||
import org.sonarqube.ws.client.projectbranches.ProjectBranchesServiceOld; | |||
import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; | |||
import org.sonarqube.ws.client.projectlinks.ProjectLinksService; | |||
import org.sonarqube.ws.client.qualitygates.QualitygatesService; | |||
import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; | |||
import org.sonarqube.ws.client.root.RootsService; | |||
import org.sonarqube.ws.client.rule.RulesService; | |||
import org.sonarqube.ws.client.setting.SettingsService; | |||
import org.sonarqube.ws.client.system.SystemServiceOld; | |||
import org.sonarqube.ws.client.system.SystemService; | |||
import org.sonarqube.ws.client.user.UsersService; | |||
import org.sonarqube.ws.client.usergroup.UserGroupsService; | |||
import org.sonarqube.ws.client.usertoken.UserTokensService; | |||
import org.sonarqube.ws.client.webhook.WebhooksService; | |||
import org.sonarqube.ws.client.usertokens.UserTokensService; | |||
import org.sonarqube.ws.client.webhooks.WebhooksService; | |||
/** | |||
* Allows to request the web services of SonarQube server. Instance is provided by | |||
@@ -68,6 +69,8 @@ public interface WsClient { | |||
IssuesService issues(); | |||
NotificationsService notifications(); | |||
PermissionsService permissions(); | |||
QualityProfilesService qualityProfiles(); | |||
@@ -82,7 +85,7 @@ public interface WsClient { | |||
MeasuresService measures(); | |||
SystemServiceOld system(); | |||
SystemService system(); | |||
CeService ce(); | |||
@@ -123,5 +126,5 @@ public interface WsClient { | |||
/** | |||
* @since 6.6> | |||
*/ | |||
ProjectBranchesServiceOld projectBranches(); | |||
ProjectBranchesService projectBranches(); | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.ce; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,63 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.favorite; | |||
import org.sonar.api.server.ws.WebService.Param; | |||
import org.sonarqube.ws.Favorites.SearchResponse; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_ADD; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_REMOVE; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.CONTROLLER_FAVORITES; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class FavoritesService extends BaseService { | |||
public FavoritesService(WsConnector wsConnector) { | |||
super(wsConnector, CONTROLLER_FAVORITES); | |||
} | |||
public void add(String component) { | |||
PostRequest post = new PostRequest(path(ACTION_ADD)).setParam(PARAM_COMPONENT, component); | |||
call(post); | |||
} | |||
public void remove(String component) { | |||
PostRequest post = new PostRequest(path(ACTION_REMOVE)).setParam(PARAM_COMPONENT, component); | |||
call(post); | |||
} | |||
public SearchResponse search(SearchRequest request) { | |||
GetRequest get = new GetRequest(path(ACTION_SEARCH)); | |||
if (request.getPage() != null) { | |||
get.setParam(Param.PAGE, request.getPage()); | |||
} | |||
if (request.getPageSize() != null) { | |||
get.setParam(Param.PAGE_SIZE, request.getPageSize()); | |||
} | |||
return call(get, SearchResponse.parser()); | |||
} | |||
} |
@@ -1,53 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.favorite; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class SearchRequest { | |||
public static final int MAX_PAGE_SIZE = 500; | |||
private Integer page; | |||
private Integer pageSize; | |||
@CheckForNull | |||
public Integer getPage() { | |||
return page; | |||
} | |||
public SearchRequest setPage(@Nullable Integer page) { | |||
this.page = page; | |||
return this; | |||
} | |||
@CheckForNull | |||
public Integer getPageSize() { | |||
return pageSize; | |||
} | |||
public SearchRequest setPageSize(@Nullable Integer pageSize) { | |||
if (pageSize != null && pageSize > MAX_PAGE_SIZE) { | |||
throw new IllegalArgumentException("Page size must be lower than or equals to " + MAX_PAGE_SIZE); | |||
} | |||
this.pageSize = pageSize; | |||
return this; | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.favorite; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,98 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.notification; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import static java.util.Objects.requireNonNull; | |||
public class AddRequest { | |||
private final String type; | |||
private final String channel; | |||
private final String project; | |||
private final String login; | |||
private AddRequest(Builder builder) { | |||
this.channel = builder.channel; | |||
this.type = builder.type; | |||
this.project = builder.project; | |||
this.login = builder.login; | |||
} | |||
public String getType() { | |||
return type; | |||
} | |||
@CheckForNull | |||
public String getChannel() { | |||
return channel; | |||
} | |||
@CheckForNull | |||
public String getProject() { | |||
return project; | |||
} | |||
@CheckForNull | |||
public String getLogin() { | |||
return login; | |||
} | |||
public static Builder builder() { | |||
return new Builder(); | |||
} | |||
public static class Builder { | |||
private String type; | |||
private String channel; | |||
private String project; | |||
private String login; | |||
private Builder() { | |||
// enforce factory method | |||
} | |||
public Builder setType(String type) { | |||
this.type = type; | |||
return this; | |||
} | |||
public Builder setChannel(@Nullable String channel) { | |||
this.channel = channel; | |||
return this; | |||
} | |||
public Builder setProject(@Nullable String project) { | |||
this.project = project; | |||
return this; | |||
} | |||
public Builder setLogin(@Nullable String login) { | |||
this.login = login; | |||
return this; | |||
} | |||
public AddRequest build() { | |||
requireNonNull(type, "Notification is required"); | |||
return new AddRequest(this); | |||
} | |||
} | |||
} |
@@ -1,98 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.notification; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import static java.util.Objects.requireNonNull; | |||
public class RemoveRequest { | |||
private final String type; | |||
private final String channel; | |||
private final String project; | |||
private final String login; | |||
private RemoveRequest(Builder builder) { | |||
this.channel = builder.channel; | |||
this.type = builder.type; | |||
this.project = builder.project; | |||
this.login = builder.login; | |||
} | |||
public String getType() { | |||
return type; | |||
} | |||
@CheckForNull | |||
public String getChannel() { | |||
return channel; | |||
} | |||
@CheckForNull | |||
public String getProject() { | |||
return project; | |||
} | |||
@CheckForNull | |||
public String getLogin() { | |||
return login; | |||
} | |||
public static Builder builder() { | |||
return new Builder(); | |||
} | |||
public static class Builder { | |||
private String type; | |||
private String channel; | |||
private String project; | |||
private String login; | |||
private Builder() { | |||
// enforce factory method | |||
} | |||
public Builder setType(String type) { | |||
this.type = type; | |||
return this; | |||
} | |||
public Builder setChannel(@Nullable String channel) { | |||
this.channel = channel; | |||
return this; | |||
} | |||
public Builder setProject(@Nullable String project) { | |||
this.project = project; | |||
return this; | |||
} | |||
public Builder setLogin(@Nullable String login) { | |||
this.login = login; | |||
return this; | |||
} | |||
public RemoveRequest build() { | |||
requireNonNull(type, "Notification is required"); | |||
return new RemoveRequest(this); | |||
} | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.notification; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,71 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectbranches; | |||
import org.sonarqube.ws.ProjectBranches.ListWsResponse; | |||
import org.sonarqube.ws.ProjectBranches.ShowWsResponse; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_DELETE; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_LIST; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_RENAME; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_SHOW; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.CONTROLLER; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class ProjectBranchesServiceOld extends BaseService { | |||
public ProjectBranchesServiceOld(WsConnector wsConnector) { | |||
super(wsConnector, CONTROLLER); | |||
} | |||
public ListWsResponse list(String project) { | |||
GetRequest get = new GetRequest(path(ACTION_LIST)) | |||
.setParam(PARAM_PROJECT, project); | |||
return call(get, ListWsResponse.parser()); | |||
} | |||
public ShowWsResponse show(String project, String branch) { | |||
GetRequest get = new GetRequest(path(ACTION_SHOW)) | |||
.setParam(PARAM_PROJECT, project) | |||
.setParam(PARAM_BRANCH, branch); | |||
return call(get, ShowWsResponse.parser()); | |||
} | |||
public void delete(String project, String branch) { | |||
PostRequest post = new PostRequest(path(ACTION_DELETE)) | |||
.setParam(PARAM_PROJECT, project) | |||
.setParam(PARAM_BRANCH, branch); | |||
call(post); | |||
} | |||
public void rename(String project, String name) { | |||
PostRequest post = new PostRequest(path(ACTION_RENAME)) | |||
.setParam(PARAM_PROJECT, project) | |||
.setParam(PARAM_NAME, name); | |||
call(post); | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.projectbranches; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,68 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class CreateWsRequest { | |||
private String projectId; | |||
private String projectKey; | |||
private String name; | |||
private String url; | |||
@CheckForNull | |||
public String getProjectId() { | |||
return projectId; | |||
} | |||
public CreateWsRequest setProjectId(@Nullable String projectId) { | |||
this.projectId = projectId; | |||
return this; | |||
} | |||
@CheckForNull | |||
public String getProjectKey() { | |||
return projectKey; | |||
} | |||
public CreateWsRequest setProjectKey(@Nullable String projectKey) { | |||
this.projectKey = projectKey; | |||
return this; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public CreateWsRequest setName(String name) { | |||
this.name = name; | |||
return this; | |||
} | |||
public String getUrl() { | |||
return url; | |||
} | |||
public CreateWsRequest setUrl(String url) { | |||
this.url = url; | |||
return this; | |||
} | |||
} |
@@ -1,33 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
public class DeleteWsRequest { | |||
private Long id; | |||
public Long getId() { | |||
return id; | |||
} | |||
public DeleteWsRequest setId(Long id) { | |||
this.id = id; | |||
return this; | |||
} | |||
} |
@@ -1,64 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
import org.sonarqube.ws.ProjectLinks.CreateWsResponse; | |||
import org.sonarqube.ws.ProjectLinks.SearchWsResponse; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_CREATE; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_DELETE; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_URL; | |||
public class ProjectLinksService extends BaseService { | |||
public ProjectLinksService(WsConnector wsConnector) { | |||
super(wsConnector, "api/project_links"); | |||
} | |||
public SearchWsResponse search(SearchWsRequest request) { | |||
return call(new GetRequest(path(ACTION_SEARCH)) | |||
.setParam(PARAM_PROJECT_KEY, request.getProjectKey()) | |||
.setParam(PARAM_PROJECT_ID, request.getProjectId()), | |||
SearchWsResponse.parser()); | |||
} | |||
public CreateWsResponse create(CreateWsRequest request) { | |||
return call(new PostRequest(path(ACTION_CREATE)) | |||
.setParam(PARAM_PROJECT_KEY, request.getProjectKey()) | |||
.setParam(PARAM_PROJECT_ID, request.getProjectId()) | |||
.setParam(PARAM_NAME, request.getName()) | |||
.setParam(PARAM_URL, request.getUrl()), | |||
CreateWsResponse.parser()); | |||
} | |||
public void delete(DeleteWsRequest request) { | |||
call(new PostRequest(path(ACTION_DELETE)) | |||
.setParam(PARAM_ID, request.getId())); | |||
} | |||
} |
@@ -1,50 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class SearchWsRequest { | |||
@CheckForNull | |||
private String projectId; | |||
@CheckForNull | |||
private String projectKey; | |||
@CheckForNull | |||
public String getProjectId() { | |||
return projectId; | |||
} | |||
public SearchWsRequest setProjectId(@Nullable String projectId) { | |||
this.projectId = projectId; | |||
return this; | |||
} | |||
@CheckForNull | |||
public String getProjectKey() { | |||
return projectKey; | |||
} | |||
public SearchWsRequest setProjectKey(@Nullable String projectKey) { | |||
this.projectKey = projectKey; | |||
return this; | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.projectlinks; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.qualitygate; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,53 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.system; | |||
import org.sonarqube.ws.System; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import org.sonarqube.ws.client.WsResponse; | |||
public class SystemServiceOld extends BaseService { | |||
public SystemServiceOld(WsConnector wsConnector) { | |||
super(wsConnector, "api/system"); | |||
} | |||
public System.HealthResponse health() { | |||
return call(new GetRequest(path("health")), System.HealthResponse.parser()); | |||
} | |||
public void restart() { | |||
call(new PostRequest(path("restart"))); | |||
} | |||
public System.StatusResponse status() { | |||
return call(new GetRequest(path("status")), System.StatusResponse.parser()); | |||
} | |||
public void changeLogLevel(String level) { | |||
call(new PostRequest(path("change_log_level")).setParam("level", level)); | |||
} | |||
public WsResponse info() { | |||
return call(new GetRequest(path("info"))); | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.system; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,47 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.usertoken; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class GenerateWsRequest { | |||
private String login; | |||
private String name; | |||
@CheckForNull | |||
public String getLogin() { | |||
return login; | |||
} | |||
public GenerateWsRequest setLogin(@Nullable String login) { | |||
this.login = login; | |||
return this; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public GenerateWsRequest setName(String name) { | |||
this.name = name; | |||
return this; | |||
} | |||
} |
@@ -1,47 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.usertoken; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class RevokeWsRequest { | |||
private String login; | |||
private String name; | |||
@CheckForNull | |||
public String getLogin() { | |||
return login; | |||
} | |||
public RevokeWsRequest setLogin(@Nullable String login) { | |||
this.login = login; | |||
return this; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public RevokeWsRequest setName(String name) { | |||
this.name = name; | |||
return this; | |||
} | |||
} |
@@ -1,37 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.usertoken; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
public class SearchWsRequest { | |||
private String login; | |||
@CheckForNull | |||
public String getLogin() { | |||
return login; | |||
} | |||
public SearchWsRequest setLogin(@Nullable String login) { | |||
this.login = login; | |||
return this; | |||
} | |||
} |
@@ -1,63 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.usertoken; | |||
import org.sonarqube.ws.UserTokens.GenerateWsResponse; | |||
import org.sonarqube.ws.UserTokens.SearchWsResponse; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_GENERATE; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_REVOKE; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.ACTION_SEARCH; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.CONTROLLER; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_LOGIN; | |||
import static org.sonarqube.ws.client.usertoken.UserTokensWsParameters.PARAM_NAME; | |||
public class UserTokensService extends BaseService { | |||
public UserTokensService(WsConnector wsConnector) { | |||
super(wsConnector, CONTROLLER); | |||
} | |||
public GenerateWsResponse generate(GenerateWsRequest request) { | |||
return call( | |||
new PostRequest(path(ACTION_GENERATE)) | |||
.setParam(PARAM_LOGIN, request.getLogin()) | |||
.setParam(PARAM_NAME, request.getName()), | |||
GenerateWsResponse.parser()); | |||
} | |||
public SearchWsResponse search(SearchWsRequest request) { | |||
return call( | |||
new GetRequest(path(ACTION_SEARCH)).setParam(PARAM_LOGIN, request.getLogin()), | |||
SearchWsResponse.parser()); | |||
} | |||
public void revoke(RevokeWsRequest request) { | |||
call( | |||
new PostRequest(path(ACTION_REVOKE)) | |||
.setParam(PARAM_LOGIN, request.getLogin()) | |||
.setParam(PARAM_NAME, request.getName())); | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.usertoken; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,75 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.webhook; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import javax.annotation.concurrent.Immutable; | |||
@Immutable | |||
public class DeliveriesRequest { | |||
private final String componentKey; | |||
private final String ceTaskId; | |||
private DeliveriesRequest(Builder builder) { | |||
this.componentKey = builder.componentKey; | |||
this.ceTaskId = builder.ceTaskId; | |||
} | |||
@CheckForNull | |||
public String getComponentKey() { | |||
return componentKey; | |||
} | |||
@CheckForNull | |||
public String getCeTaskId() { | |||
return ceTaskId; | |||
} | |||
public static Builder builder() { | |||
return new Builder(); | |||
} | |||
public static class Builder { | |||
private String componentKey; | |||
private String ceTaskId; | |||
/** | |||
* @see #builder() | |||
*/ | |||
private Builder() { | |||
} | |||
public Builder setComponentKey(@Nullable String s) { | |||
this.componentKey = s; | |||
return this; | |||
} | |||
public Builder setCeTaskId(@Nullable String s) { | |||
this.ceTaskId = s; | |||
return this; | |||
} | |||
public DeliveriesRequest build() { | |||
return new DeliveriesRequest(this); | |||
} | |||
} | |||
} |
@@ -1,51 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.webhook; | |||
import org.sonarqube.ws.Webhooks; | |||
import org.sonarqube.ws.client.BaseService; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.WsConnector; | |||
/** | |||
* @since 6.2 | |||
*/ | |||
public class WebhooksService extends BaseService { | |||
public WebhooksService(WsConnector wsConnector) { | |||
super(wsConnector, "api/webhooks"); | |||
} | |||
public Webhooks.DeliveryWsResponse delivery(String deliveryId) { | |||
GetRequest httpRequest = new GetRequest(path("delivery")) | |||
.setParam("deliveryId", deliveryId); | |||
return call(httpRequest, Webhooks.DeliveryWsResponse.parser()); | |||
} | |||
/** | |||
* @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx. | |||
*/ | |||
public Webhooks.DeliveriesWsResponse deliveries(DeliveriesRequest request) { | |||
GetRequest httpRequest = new GetRequest(path("deliveries")) | |||
.setParam("componentKey", request.getComponentKey()) | |||
.setParam("ceTaskId", request.getCeTaskId()); | |||
return call(httpRequest, Webhooks.DeliveriesWsResponse.parser()); | |||
} | |||
} |
@@ -1,24 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonarqube.ws.client.webhook; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -1,67 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.favorite; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.server.ws.WebService.Param; | |||
import org.sonarqube.ws.client.ServiceTester; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT; | |||
public class FavoritesServiceTest { | |||
@Rule | |||
public ServiceTester<FavoritesService> serviceTester = new ServiceTester<>(new FavoritesService(mock(WsConnector.class))); | |||
private FavoritesService underTest = serviceTester.getInstanceUnderTest(); | |||
@Test | |||
public void add() { | |||
underTest.add("my_project"); | |||
serviceTester.assertThat(serviceTester.getPostRequest()) | |||
.hasPath("add") | |||
.hasParam(PARAM_COMPONENT, "my_project") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void remove() { | |||
underTest.remove("my_project"); | |||
serviceTester.assertThat(serviceTester.getPostRequest()) | |||
.hasPath("remove") | |||
.hasParam(PARAM_COMPONENT, "my_project") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void search() { | |||
underTest.search(new SearchRequest().setPage(42).setPageSize(255)); | |||
serviceTester.assertThat(serviceTester.getGetRequest()) | |||
.hasPath("search") | |||
.hasParam(Param.PAGE, 42) | |||
.hasParam(Param.PAGE_SIZE, 255) | |||
.andNoOtherParam(); | |||
} | |||
} |
@@ -1,39 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.favorite; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
public class SearchRequestTest { | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
private SearchRequest underTest = new SearchRequest(); | |||
@Test | |||
public void fail_if_page_size_greater_than_500() { | |||
expectedException.expect(IllegalArgumentException.class); | |||
expectedException.expectMessage("Page size must be lower than or equals to 500"); | |||
underTest.setPageSize(501); | |||
} | |||
} |
@@ -1,96 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectbranches; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonarqube.ws.ProjectBranches.ListWsResponse; | |||
import org.sonarqube.ws.ProjectBranches.ShowWsResponse; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.ServiceTester; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; | |||
public class ProjectBranchesServiceTest { | |||
@Rule | |||
public ServiceTester<ProjectBranchesServiceOld> serviceTester = new ServiceTester<>(new ProjectBranchesServiceOld(mock(WsConnector.class))); | |||
private ProjectBranchesServiceOld underTest = serviceTester.getInstanceUnderTest(); | |||
@Test | |||
public void list() { | |||
underTest.list("projectKey"); | |||
assertThat(serviceTester.getGetParser()).isSameAs(ListWsResponse.parser()); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("list") | |||
.hasParam(PARAM_PROJECT, "projectKey") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void show() { | |||
underTest.show("projectKey", "my_branch"); | |||
assertThat(serviceTester.getGetParser()).isSameAs(ShowWsResponse.parser()); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("show") | |||
.hasParam(PARAM_PROJECT, "projectKey") | |||
.hasParam(PARAM_BRANCH, "my_branch") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void delete() { | |||
underTest.delete("projectKey", "my_branch"); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("delete") | |||
.hasParam(PARAM_PROJECT, "projectKey") | |||
.hasParam(PARAM_BRANCH, "my_branch") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void rename() { | |||
underTest.rename("projectKey", "my_branch"); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("rename") | |||
.hasParam(PARAM_PROJECT, "projectKey") | |||
.hasParam(PARAM_NAME, "my_branch") | |||
.andNoOtherParam(); | |||
} | |||
} |
@@ -1,102 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.projectlinks; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonarqube.ws.ProjectLinks.CreateWsResponse; | |||
import org.sonarqube.ws.ProjectLinks.SearchWsResponse; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.ServiceTester; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY; | |||
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_URL; | |||
public class ProjectLinksServiceTest { | |||
private static final String PROJECT_ID_VALUE = "project_id_value"; | |||
private static final String PROJECT_KEY_VALUE = "project_key_value"; | |||
private static final String NAME_VALUE = "name_value"; | |||
private static final String URL_VALUE = "url_value"; | |||
private static final long ID_VALUE = 175; | |||
@Rule | |||
public ServiceTester<ProjectLinksService> serviceTester = new ServiceTester<>(new ProjectLinksService(mock(WsConnector.class))); | |||
private ProjectLinksService underTest = serviceTester.getInstanceUnderTest(); | |||
@Test | |||
public void search_does_GET_request() { | |||
underTest.search(new SearchWsRequest() | |||
.setProjectId(PROJECT_ID_VALUE) | |||
.setProjectKey(PROJECT_KEY_VALUE)); | |||
assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("search") | |||
.hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE) | |||
.hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE) | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void create_does_POST_request() { | |||
underTest.create(new CreateWsRequest() | |||
.setProjectId(PROJECT_ID_VALUE) | |||
.setProjectKey(PROJECT_KEY_VALUE) | |||
.setName(NAME_VALUE) | |||
.setUrl(URL_VALUE)); | |||
assertThat(serviceTester.getPostParser()).isSameAs(CreateWsResponse.parser()); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("create") | |||
.hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE) | |||
.hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE) | |||
.hasParam(PARAM_NAME, NAME_VALUE) | |||
.hasParam(PARAM_URL, URL_VALUE) | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void delete_does_POST_request() { | |||
underTest.delete(new DeleteWsRequest().setId(ID_VALUE)); | |||
assertThat(serviceTester.getPostParser()).isNull(); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("delete") | |||
.hasParam(PARAM_ID, String.valueOf(ID_VALUE)) | |||
.andNoOtherParam(); | |||
} | |||
} |
@@ -1,88 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonarqube.ws.client.system; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.PostRequest; | |||
import org.sonarqube.ws.client.ServiceTester; | |||
import org.sonarqube.ws.client.WsConnector; | |||
import static org.mockito.Mockito.mock; | |||
public class SystemServiceTest { | |||
@Rule | |||
public ServiceTester<SystemServiceOld> serviceTester = new ServiceTester<>(new SystemServiceOld(mock(WsConnector.class))); | |||
private SystemServiceOld underTest = serviceTester.getInstanceUnderTest(); | |||
@Test | |||
public void test_health() throws Exception { | |||
underTest.health(); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("health") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void test_status() throws Exception { | |||
underTest.status(); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("status") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void test_restart() throws Exception { | |||
underTest.restart(); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("restart") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void test_changeLogLevel() throws Exception { | |||
underTest.changeLogLevel("TRACE"); | |||
PostRequest postRequest = serviceTester.getPostRequest(); | |||
serviceTester.assertThat(postRequest) | |||
.hasPath("change_log_level") | |||
.hasParam("level", "TRACE") | |||
.andNoOtherParam(); | |||
} | |||
@Test | |||
public void test_info() throws Exception { | |||
underTest.info(); | |||
GetRequest getRequest = serviceTester.getGetRequest(); | |||
serviceTester.assertThat(getRequest) | |||
.hasPath("info") | |||
.andNoOtherParam(); | |||
} | |||
} |
@@ -31,7 +31,7 @@ import org.sonarqube.ws.Favorites; | |||
import org.sonarqube.ws.Favorites.Favorite; | |||
import org.sonarqube.ws.Permissions; | |||
import org.sonarqube.ws.client.WsClient; | |||
import org.sonarqube.ws.client.favorite.SearchRequest; | |||
import org.sonarqube.ws.client.favorites.SearchRequest; | |||
import org.sonarqube.ws.client.permission.AddProjectCreatorToTemplateWsRequest; | |||
import org.sonarqube.ws.client.permission.RemoveProjectCreatorFromTemplateWsRequest; | |||
import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest; |
@@ -23,15 +23,15 @@ import com.google.common.collect.ImmutableMap; | |||
import com.sonar.orchestrator.Orchestrator; | |||
import com.sonar.orchestrator.build.MavenBuild; | |||
import com.sonar.orchestrator.build.SonarScanner; | |||
import org.sonarqube.tests.Category3Suite; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import org.junit.After; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.sonarqube.tests.Category3Suite; | |||
import org.sonarqube.ws.ProjectLinks; | |||
import org.sonarqube.ws.client.WsClient; | |||
import org.sonarqube.ws.client.projectlinks.SearchWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.SearchRequest; | |||
import util.ItUtils; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -75,7 +75,7 @@ public class LinksTest { | |||
private void verifyLinks() { | |||
WsClient wsClient = ItUtils.newWsClient(orchestrator); | |||
List<ProjectLinks.Link> links = wsClient.projectLinks().search(new SearchWsRequest().setProjectKey(PROJECT_KEY)).getLinksList(); | |||
List<ProjectLinks.Link> links = wsClient.projectLinks().search(new SearchRequest().setProjectKey(PROJECT_KEY)).getLinksList(); | |||
verifyLink(links, "homepage", "http://www.simplesample.org_OVERRIDDEN"); | |||
verifyLink(links, "ci", "http://bamboo.ci.codehaus.org/browse/SIMPLESAMPLE"); | |||
verifyLink(links, "issue", "http://jira.codehaus.org/browse/SIMPLESAMPLE"); |
@@ -32,9 +32,9 @@ import org.junit.Test; | |||
import org.sonarqube.ws.UserTokens; | |||
import org.sonarqube.ws.client.WsClient; | |||
import org.sonarqube.ws.client.permission.AddUserWsRequest; | |||
import org.sonarqube.ws.client.usertoken.GenerateWsRequest; | |||
import org.sonarqube.ws.client.usertoken.RevokeWsRequest; | |||
import org.sonarqube.ws.client.usertoken.UserTokensService; | |||
import org.sonarqube.ws.client.usertokens.GenerateRequest; | |||
import org.sonarqube.ws.client.usertokens.RevokeRequest; | |||
import org.sonarqube.ws.client.usertokens.UserTokensService; | |||
import util.user.UserRule; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -79,7 +79,7 @@ public class PermissionTest { | |||
createUserWithProvisioningAndScanPermissions(); | |||
String tokenName = "For test"; | |||
UserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateWsRequest() | |||
UserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateRequest() | |||
.setLogin(A_LOGIN) | |||
.setName(tokenName)); | |||
SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample")); | |||
@@ -90,7 +90,7 @@ public class PermissionTest { | |||
BuildResult buildResult = orchestrator.executeBuild(sampleProject); | |||
assertThat(buildResult.isSuccess()).isTrue(); | |||
userTokensWsClient.revoke(new RevokeWsRequest().setLogin(A_LOGIN).setName(tokenName)); | |||
userTokensWsClient.revoke(new RevokeRequest().setLogin(A_LOGIN).setName(tokenName)); | |||
} | |||
@Test |
@@ -30,6 +30,7 @@ import org.sonarqube.ws.Common; | |||
import org.sonarqube.ws.ProjectBranches; | |||
import org.sonarqube.ws.client.GetRequest; | |||
import org.sonarqube.ws.client.WsResponse; | |||
import org.sonarqube.ws.client.projectbranches.ListRequest; | |||
import util.ItUtils; | |||
import static org.assertj.core.api.Java6Assertions.assertThat; | |||
@@ -47,7 +48,7 @@ public class BranchTest { | |||
public void list_branches_contains_main_branch() { | |||
runProjectAnalysis(orchestrator, "shared/xoo-sample"); | |||
ProjectBranches.ListWsResponse result = tester.wsClient().projectBranches().list("sample"); | |||
ProjectBranches.ListWsResponse result = tester.wsClient().projectBranches().list(new ListRequest().setProject("sample")); | |||
assertThat(result.getBranchesList()) | |||
.extracting(ProjectBranches.Branch::getName, ProjectBranches.Branch::getType, ProjectBranches.Branch::getIsMain) |
@@ -33,8 +33,8 @@ import org.sonarqube.qa.util.Tester; | |||
import org.sonarqube.qa.util.pageobjects.ProjectLinkItem; | |||
import org.sonarqube.qa.util.pageobjects.ProjectLinksPage; | |||
import org.sonarqube.ws.ProjectLinks.CreateWsResponse; | |||
import org.sonarqube.ws.client.projectlinks.CreateWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.DeleteWsRequest; | |||
import org.sonarqube.ws.client.projectlinks.CreateRequest; | |||
import org.sonarqube.ws.client.projectlinks.DeleteRequest; | |||
import static com.codeborne.selenide.Condition.text; | |||
import static com.codeborne.selenide.Selenide.$; | |||
@@ -131,7 +131,7 @@ public class ProjectLinksTest { | |||
} | |||
private CreateWsResponse createCustomLink() { | |||
return tester.wsClient().projectLinks().create(new CreateWsRequest() | |||
return tester.wsClient().projectLinks().create(new CreateRequest() | |||
.setProjectKey("sample") | |||
.setName("Custom") | |||
.setUrl("http://example.org/custom")); | |||
@@ -139,7 +139,7 @@ public class ProjectLinksTest { | |||
private void deleteLink(long id) { | |||
try { | |||
tester.wsClient().projectLinks().delete(new DeleteWsRequest().setId(id)); | |||
tester.wsClient().projectLinks().delete(new DeleteRequest().setId("" + id)); | |||
} catch (Exception e) { | |||
// fail silently | |||
} |