use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method task_is_in_queue.
@Test
public void task_is_in_queue() throws Exception {
logInAsRoot();
CeQueueDto queueDto = new CeQueueDto();
queueDto.setTaskType(CeTaskTypes.REPORT);
queueDto.setUuid(SOME_TASK_UUID);
queueDto.setComponentUuid(project.uuid());
queueDto.setStatus(CeQueueDto.Status.PENDING);
queueDto.setSubmitterLogin("john");
persist(queueDto);
TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).execute();
WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
assertThat(taskResponse.getTask().getOrganization()).isEqualTo(organizationDto.getKey());
assertThat(taskResponse.getTask().getId()).isEqualTo(SOME_TASK_UUID);
assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo("john");
assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
assertThat(taskResponse.getTask().getLogs()).isFalse();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ActivityActionTest method support_json_response.
@Test
public void support_json_response() {
logInAsSystemAdministrator();
TestResponse wsResponse = ws.newRequest().setMediaType(MediaTypes.JSON).execute();
JsonAssert.assertJson(wsResponse.getInput()).isSimilarTo("{\"tasks\":[]}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method call.
private void call(String taskUuid) {
TestResponse response = ws.newRequest().setMediaType(PROTOBUF).setParam("id", taskUuid).execute();
WsCe.TaskResponse taskResponse = Protobuf.read(response.getInputStream(), WsCe.TaskResponse.parser());
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(taskUuid);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class RemoveActionTest method remove_a_favorite_project.
@Test
public void remove_a_favorite_project() {
ComponentDto project = insertProjectAndPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project));
db.favorites().add(project, USER_ID);
db.favorites().add(file, USER_ID);
TestResponse result = call(PROJECT_KEY);
assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT);
assertThat(db.favorites().hasFavorite(project, USER_ID)).isFalse();
assertThat(db.favorites().hasFavorite(file, USER_ID)).isTrue();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method do_not_return_module_key_on_single_module_projects.
@Test
public void do_not_return_module_key_on_single_module_projects() throws IOException {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
RuleDto newRule = newRule();
IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
db.issueDao().insert(session, issueInModule, issueInRootModule);
session.commit();
indexIssues();
WsActionTester actionTester = new WsActionTester(tester.get(SearchAction.class));
TestResponse response = actionTester.newRequest().setMediaType(MediaTypes.PROTOBUF).execute();
SearchWsResponse searchResponse = SearchWsResponse.parseFrom(response.getInputStream());
assertThat(searchResponse.getIssuesCount()).isEqualTo(2);
for (Issues.Issue issue : searchResponse.getIssuesList()) {
assertThat(issue.getProject()).isEqualTo("PK1");
if (issue.getKey().equals("ISSUE_IN_MODULE")) {
assertThat(issue.getSubProject()).isEqualTo("MK1");
} else if (issue.getKey().equals("ISSUE_IN_ROOT_MODULE")) {
assertThat(issue.hasSubProject()).isFalse();
}
}
}
Aggregations