use of org.sonarqube.ws.client.PostRequest in project sonarqube by SonarSource.
the class IssueNotificationsTest method prepare.
@Before
public void prepare() {
ORCHESTRATOR.resetData();
// Create test user
userRule.createUser(USER_LOGIN, "Tester", USER_EMAIL, USER_LOGIN);
smtpServer.getMessages().clear();
issueClient = ORCHESTRATOR.getServer().adminWsClient().issueClient();
issuesService = newAdminWsClient(ORCHESTRATOR).issues();
setServerProperty(ORCHESTRATOR, "sonar.issues.defaultAssigneeLogin", null);
ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/one-issue-per-line-profile.xml"));
ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Sample");
ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "one-issue-per-line-profile");
// Add notifications to the test user
WsClient wsClient = newUserWsClient(ORCHESTRATOR, USER_LOGIN, USER_PASSWORD);
wsClient.wsConnector().call(new PostRequest("api/notifications/add").setParam("type", "NewIssues").setParam("channel", "EmailNotificationChannel")).failIfNotSuccessful();
wsClient.wsConnector().call(new PostRequest("api/notifications/add").setParam("type", "ChangesOnMyIssue").setParam("channel", "EmailNotificationChannel")).failIfNotSuccessful();
wsClient.wsConnector().call(new PostRequest("api/notifications/add").setParam("type", "SQ-MyNewIssues").setParam("channel", "EmailNotificationChannel")).failIfNotSuccessful();
}
use of org.sonarqube.ws.client.PostRequest in project sonarqube by SonarSource.
the class AutoAssignTest method createUser.
private void createUser(String login, String password) {
WsResponse response = newAdminWsClient(ORCHESTRATOR).wsConnector().call(new PostRequest("api/users/create").setParam("login", login).setParam("name", login).setParam("password", password));
assertThat(response.code()).isEqualTo(200);
}
use of org.sonarqube.ws.client.PostRequest in project sonarqube by SonarSource.
the class ReportPublisher method upload.
/**
* Uploads the report file to server and returns the generated task id
*/
@VisibleForTesting
String upload(File report) {
LOG.debug("Upload report");
long startTime = System.currentTimeMillis();
ProjectDefinition projectDefinition = projectReactor.getRoot();
PostRequest.Part filePart = new PostRequest.Part(MediaTypes.ZIP, report);
PostRequest post = new PostRequest("api/ce/submit").setMediaType(MediaTypes.PROTOBUF).setParam("organization", settings.getString(CoreProperties.PROJECT_ORGANIZATION_PROPERTY)).setParam("projectKey", projectDefinition.getKey()).setParam("projectName", projectDefinition.getOriginalName()).setParam("projectBranch", projectDefinition.getBranch()).setPart("report", filePart);
WsResponse response;
try {
response = wsClient.call(post).failIfNotSuccessful();
} catch (HttpException e) {
throw MessageException.of(String.format("Failed to upload report - %d: %s", e.code(), ScannerWsClient.tryParseAsJsonError(e.content())));
}
try (InputStream protobuf = response.contentStream()) {
return WsCe.SubmitResponse.parser().parseFrom(protobuf).getTaskId();
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
long stopTime = System.currentTimeMillis();
LOG.info("Analysis report uploaded in " + (stopTime - startTime) + "ms");
}
}
use of org.sonarqube.ws.client.PostRequest in project sonarqube by SonarSource.
the class ProjectsService method updateKey.
public void updateKey(UpdateKeyWsRequest request) {
PostRequest post = new PostRequest(path(ACTION_UPDATE_KEY)).setParam(PARAM_PROJECT_ID, request.getId()).setParam(PARAM_FROM, request.getKey()).setParam(PARAM_TO, request.getNewKey());
call(post);
}
use of org.sonarqube.ws.client.PostRequest in project sonarqube by SonarSource.
the class RootsService method setRoot.
public void setRoot(String login) {
PostRequest post = new PostRequest(path("set_root")).setParam("login", login);
call(post);
}
Aggregations