use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ComponentActionTest method empty_queue_and_empty_activity.
@Test
public void empty_queue_and_empty_activity() {
dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
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(0);
assertThat(response.hasCurrent()).isFalse();
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ComponentActionTest method canceled_tasks_must_not_be_picked_as_current_analysis.
@Test
public void canceled_tasks_must_not_be_picked_as_current_analysis() {
dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization(), "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.SUCCESS);
insertActivity("T4", "PROJECT_1", CeActivityDto.Status.CANCELED);
insertActivity("T5", "PROJECT_1", CeActivityDto.Status.CANCELED);
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(0);
// T3 is the latest task executed on PROJECT_1 ignoring Canceled ones
assertThat(response.hasCurrent()).isTrue();
assertThat(response.getCurrent().getId()).isEqualTo("T3");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SubmitActionTest method test_example_json_response.
@Test
public void test_example_json_response() {
when(reportSubmitter.submit(eq(organizationKey), eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(A_CE_TASK);
TestResponse wsResponse = tester.newRequest().setParam("projectKey", "my_project").setParam("projectName", "My Project").setParam("report", "{binary}").setMediaType(MediaTypes.JSON).setMethod("POST").execute();
JsonAssert.assertJson(tester.getDef().responseExampleAsString()).isSimilarTo(wsResponse.getInput());
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SubmitActionTest method submit_task_to_the_queue_and_ask_for_immediate_processing.
@Test
public void submit_task_to_the_queue_and_ask_for_immediate_processing() {
when(reportSubmitter.submit(eq(organizationKey), eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(A_CE_TASK);
TestResponse wsResponse = tester.newRequest().setParam("projectKey", "my_project").setParam("projectName", "My Project").setParam("report", "{binary}").setMediaType(MediaTypes.PROTOBUF).setMethod("POST").execute();
verify(reportSubmitter).submit(eq(organizationKey), eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class));
WsCe.SubmitResponse submitResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.SubmitResponse.PARSER);
assertThat(submitResponse.getTaskId()).isEqualTo("TASK_1");
assertThat(submitResponse.getProjectId()).isEqualTo("PROJECT_1");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class TaskActionTest method do_not_return_scannerContext_of_activity_with_scannerContext_when_additionalField_is_not_set.
@Test
public void do_not_return_scannerContext_of_activity_with_scannerContext_when_additionalField_is_not_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", "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.hasScannerContext()).isFalse();
}
Aggregations