Search in sources :

Example 31 with TestResponse

use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.

the class GhostsActionTest method ghost_projects_with_partial_query_on_name.

@Test
public void ghost_projects_with_partial_query_on_name() throws Exception {
    OrganizationDto organization = db.organizations().insert();
    insertGhostProject(organization, dto -> dto.setName("ghost-name-10"));
    insertGhostProject(organization, dto -> dto.setName("ghost-name-11"));
    insertGhostProject(organization, dto -> dto.setName("ghost-name-20"));
    userSessionRule.logIn().addPermission(ADMINISTER, organization);
    TestResponse result = underTest.newRequest().setParam("organization", organization.getKey()).setParam(Param.TEXT_QUERY, "name-1").execute();
    assertThat(result.getInput()).contains("ghost-name-10", "ghost-name-11").doesNotContain("ghost-name-2");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 32 with TestResponse

use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.

the class CreateActionTest method test_json.

@Test
public void test_json() throws Exception {
    logInAsQProfileAdministrator();
    TestResponse response = wsTester.newRequest().setMethod("POST").setMediaType(MediaTypes.JSON).setParam("language", XOO_LANGUAGE).setParam("name", "Yeehaw!").execute();
    JsonAssert.assertJson(response.getInput()).isSimilarTo(getClass().getResource("CreateActionTest/test_json.json"));
    assertThat(response.getMediaType()).isEqualTo(MediaTypes.JSON);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 33 with TestResponse

use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.

the class RestoreBuiltInActionTest method return_empty_result_when_no_info_or_warning.

@Test
public void return_empty_result_when_no_info_or_warning() {
    logInAsQProfileAdministrator();
    TestResponse response = tester.newRequest().setParam("language", "xoo").execute();
    verify(reset).resetLanguage("xoo");
    assertThat(response.getStatus()).isEqualTo(204);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 34 with TestResponse

use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.

the class SearchActionTest method test_response_example.

@Test
public void test_response_example() {
    logInAsRoot();
    UserDto user = UserTesting.newUserDto().setLogin("daniel").setName("Daniel").setEmail("daniel@corp.com");
    UserDto rootDto = userDao.insert(dbSession, user);
    userDao.setRoot(dbSession, rootDto.getLogin(), true);
    dbSession.commit();
    TestResponse response = wsTester.newRequest().setMediaType(MediaTypes.JSON).execute();
    assertJson(response.getInput()).isSimilarTo(wsTester.getDef().responseExampleAsString());
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) UserDto(org.sonar.db.user.UserDto) Test(org.junit.Test)

Example 35 with TestResponse

use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.

the class SetActionTest method empty_204_response.

@Test
public void empty_204_response() {
    TestResponse result = ws.newRequest().setParam("key", "my.key").setParam("value", "my value").execute();
    assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
    assertThat(result.getInput()).isEmpty();
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Aggregations

TestResponse (org.sonar.server.ws.TestResponse)67 Test (org.junit.Test)64 OrganizationDto (org.sonar.db.organization.OrganizationDto)18 WsCe (org.sonarqube.ws.WsCe)13 ComponentDto (org.sonar.db.component.ComponentDto)9 CeActivityDto (org.sonar.db.ce.CeActivityDto)4 InputStream (java.io.InputStream)2 Date (java.util.Date)2 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)2 UserDto (org.sonar.db.user.UserDto)2 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)2 File (java.io.File)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 CeQueueDto (org.sonar.db.ce.CeQueueDto)1 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)1 IssueDto (org.sonar.db.issue.IssueDto)1 PropertyDto (org.sonar.db.property.PropertyDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 FileData (org.sonar.scanner.protocol.input.FileData)1