use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method task_is_archived.
@Test
public void task_is_archived() throws Exception {
logInAsRoot();
CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID);
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.getOrganization()).isEqualTo(organizationDto.getKey());
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
assertThat(task.getComponentId()).isEqualTo(project.uuid());
assertThat(task.getComponentKey()).isEqualTo(project.key());
assertThat(task.getComponentName()).isEqualTo(project.name());
assertThat(task.getAnalysisId()).isEqualTo(activityDto.getAnalysisUuid());
assertThat(task.getExecutionTimeMs()).isEqualTo(500L);
assertThat(task.getLogs()).isFalse();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ProjectActionTest method do_not_fail_when_a_path_is_null.
/**
* SONAR-7084
*/
@Test
public void do_not_fail_when_a_path_is_null() throws Exception {
String projectKey = "org.codehaus.sonar:sonar";
ProjectRepositories projectRepositories = new ProjectRepositories().addFileData("module-1", null, new FileData(null, null));
when(projectDataLoader.load(any(ProjectDataQuery.class))).thenReturn(projectRepositories);
TestResponse result = ws.newRequest().setMediaType(MediaTypes.PROTOBUF).setParam("key", projectKey).setParam("profile", "Default").execute();
WsProjectResponse wsProjectResponse = WsProjectResponse.parseFrom(result.getInputStream());
assertThat(wsProjectResponse.getFileDataByModuleAndPath()).isEmpty();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method return_scannerContext_of_activity_with_scannerContext_when_additionalField_is_set.
@Test
public void return_scannerContext_of_activity_with_scannerContext_when_additionalField_is_set() {
logInAsRoot();
String scannerContext = "this is some scanner context, yeah!";
persist(createActivityDto(SOME_TASK_UUID));
persistScannerContext(SOME_TASK_UUID, scannerContext);
TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).setParam("additionalFields", "scannerContext").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.getScannerContext()).isEqualTo(scannerContext);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method do_not_return_stacktrace_of_failed_activity_without_stacktrace.
@Test
public void do_not_return_stacktrace_of_failed_activity_without_stacktrace() {
logInAsRoot();
CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID).setErrorMessage("error msg");
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();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class AddActionTest method add_a_project.
@Test
public void add_a_project() {
ComponentDto project = insertProjectAndPermissions();
TestResponse result = call(PROJECT_KEY);
assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT);
List<PropertyDto> favorites = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder().setUserId(USER_ID).setKey("favourite").build(), dbSession);
assertThat(favorites).hasSize(1);
PropertyDto favorite = favorites.get(0);
assertThat(favorite).extracting(PropertyDto::getResourceId, PropertyDto::getUserId, PropertyDto::getKey).containsOnly(project.getId(), USER_ID, "favourite");
}
Aggregations