Search in sources :

Example 46 with TestRequest

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();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 47 with TestRequest

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"));
}
Also used : DbSession(org.sonar.db.DbSession) CoveredFileDoc(org.sonar.server.test.index.CoveredFileDoc) TestDoc(org.sonar.server.test.index.TestDoc) OrganizationDto(org.sonar.db.organization.OrganizationDto) TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test)

Example 48 with TestRequest

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");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Aggregations

TestRequest (org.sonar.server.ws.TestRequest)48 IOException (java.io.IOException)19 Test (org.junit.Test)4 InputStream (java.io.InputStream)3 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 AddRequest (org.sonarqube.ws.client.notification.AddRequest)2 DbSession (org.sonar.db.DbSession)1 CoveredFileDoc (org.sonar.server.test.index.CoveredFileDoc)1 TestDoc (org.sonar.server.test.index.TestDoc)1 TestResponse (org.sonar.server.ws.TestResponse)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 SearchProjectsRequest (org.sonarqube.ws.client.component.SearchProjectsRequest)1 SearchHistoryRequest (org.sonarqube.ws.client.measure.SearchHistoryRequest)1 CreateEventRequest (org.sonarqube.ws.client.projectanalysis.CreateEventRequest)1