use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ProjectActionTest method project_referentials.
@Test
public void project_referentials() throws Exception {
String projectKey = "org.codehaus.sonar:sonar";
ProjectRepositories projectReferentials = mock(ProjectRepositories.class);
when(projectReferentials.toJson()).thenReturn("{\"settingsByModule\": {}}");
ArgumentCaptor<ProjectDataQuery> queryArgumentCaptor = ArgumentCaptor.forClass(ProjectDataQuery.class);
when(projectDataLoader.load(queryArgumentCaptor.capture())).thenReturn(projectReferentials);
TestResponse response = ws.newRequest().setParam("key", projectKey).setParam("profile", "Default").setParam("preview", "false").execute();
assertJson(response.getInput()).isSimilarTo("{\"settingsByModule\": {}}");
assertThat(queryArgumentCaptor.getValue().getModuleKey()).isEqualTo(projectKey);
assertThat(queryArgumentCaptor.getValue().getProfileName()).isEqualTo("Default");
assertThat(queryArgumentCaptor.getValue().isIssuesMode()).isFalse();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ComponentActionTest method project_tasks.
@Test
public void project_tasks() {
OrganizationDto organizationDto = dbTester.organizations().insert();
dbTester.components().insertComponent(newProjectDto(organizationDto, "PROJECT_1"));
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
insertActivity("T3", "PROJECT_1", CeActivityDto.Status.FAILED);
insertQueue("T4", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
insertQueue("T5", "PROJECT_1", CeQueueDto.Status.PENDING);
TestResponse wsResponse = ws.newRequest().setParam("componentId", "PROJECT_1").setMediaType(MediaTypes.PROTOBUF).execute();
WsCe.ProjectResponse response = Protobuf.read(wsResponse.getInputStream(), WsCe.ProjectResponse.parser());
assertThat(response.getQueueCount()).isEqualTo(2);
assertThat(response.getQueue(0).getId()).isEqualTo("T4");
assertThat(response.getQueue(1).getId()).isEqualTo("T5");
// T3 is the latest task executed on PROJECT_1
assertThat(response.hasCurrent()).isTrue();
assertThat(response.getCurrent().getId()).isEqualTo("T3");
assertThat(response.getQueueList()).extracting(WsCe.Task::getOrganization).containsOnly(organizationDto.getKey());
assertThat(response.getCurrent().getOrganization()).isEqualTo(organizationDto.getKey());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ComponentActionTest method search_tasks_by_component_key.
@Test
public void search_tasks_by_component_key() {
ComponentDto project = dbTester.components().insertProject();
logInWithBrowsePermission(project);
insertActivity("T1", project.uuid(), CeActivityDto.Status.SUCCESS);
TestResponse wsResponse = ws.newRequest().setParam(PARAM_COMPONENT_KEY, project.key()).setMediaType(MediaTypes.PROTOBUF).execute();
WsCe.ProjectResponse response = Protobuf.read(wsResponse.getInputStream(), WsCe.ProjectResponse.parser());
assertThat(response.hasCurrent()).isTrue();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method return_stacktrace_of_failed_activity_with_stacktrace_when_additionalField_is_set.
@Test
public void return_stacktrace_of_failed_activity_with_stacktrace_when_additionalField_is_set() {
logInAsRoot();
CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID).setErrorMessage("error msg").setErrorStacktrace("error stack");
persist(activityDto);
TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).setParam("additionalFields", "stacktrace").execute();
WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
assertThat(task.hasErrorStacktrace()).isTrue();
assertThat(task.getErrorStacktrace()).isEqualTo(activityDto.getErrorStacktrace());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method do_not_return_stacktrace_of_failed_activity_with_stacktrace_when_additionalField_is_not_set.
@Test
public void do_not_return_stacktrace_of_failed_activity_with_stacktrace_when_additionalField_is_not_set() {
logInAsRoot();
CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID).setErrorMessage("error msg").setErrorStacktrace("error stack");
persist(activityDto);
TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).execute();
WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
assertThat(task.hasErrorStacktrace()).isFalse();
}
Aggregations