use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SetActionTest method call.
private void call(@Nullable String key, @Nullable String value, @Nullable List<String> values, @Nullable List<String> fieldValues, @Nullable String componentKey) {
TestRequest request = ws.newRequest();
if (key != null) {
request.setParam("key", key);
}
if (value != null) {
request.setParam("value", value);
}
if (values != null) {
request.setMultiParam("values", values);
}
if (fieldValues != null) {
request.setMultiParam("fieldValues", fieldValues);
}
if (componentKey != null) {
request.setParam("component", componentKey);
}
request.execute();
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class CoveredFilesActionTest method covered_files.
@Test
public void covered_files() {
userSessionRule.addComponentUuidPermission(UserRole.CODEVIEWER, "SonarQube", "test-file-uuid");
when(testIndex.getNullableByTestUuid(anyString())).thenReturn(Optional.of(new TestDoc().setFileUuid("test-file-uuid")));
when(testIndex.coveredFiles("test-uuid")).thenReturn(Arrays.asList(new CoveredFileDoc().setFileUuid(FILE_1_ID).setCoveredLines(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), new CoveredFileDoc().setFileUuid(FILE_2_ID).setCoveredLines(Arrays.asList(1, 2, 3))));
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
when(dbClient.componentDao().selectByUuids(any(DbSession.class), anyList())).thenReturn(Arrays.asList(newFileDto(newProjectDto(organizationDto), null, FILE_1_ID).setKey("org.foo.Bar.java").setLongName("src/main/java/org/foo/Bar.java"), newFileDto(newProjectDto(organizationDto), null, FILE_2_ID).setKey("org.foo.File.java").setLongName("src/main/java/org/foo/File.java")));
TestRequest request = ws.newRequest().setParam(TEST_ID, "test-uuid");
assertJson(request.execute().getInput()).isSimilarTo(getClass().getResource("CoveredFilesActionTest/tests-covered-files.json"));
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method newRequest.
private SearchWsResponse newRequest(@Nullable String login) {
TestRequest testRequest = ws.newRequest().setMediaType(MediaTypes.PROTOBUF);
if (login != null) {
testRequest.setParam(PARAM_LOGIN, login);
}
TestResponse response = testRequest.execute();
try {
return SearchWsResponse.parseFrom(response.getInputStream());
} catch (IOException e) {
Throwables.propagate(e);
}
throw new IllegalStateException("unreachable");
}
Aggregations