Search in sources :

Example 26 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 27 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 28 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 29 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)

Example 30 with TestResponse

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

the class OrganizationActionTest method returns_admin_and_canDelete_true_when_user_logged_in_and_admin_and_key_is_the_default_organization.

@Test
public void returns_admin_and_canDelete_true_when_user_logged_in_and_admin_and_key_is_the_default_organization() {
    OrganizationDto defaultOrganization = dbTester.getDefaultOrganization();
    userSession.logIn().addPermission(ADMINISTER, defaultOrganization);
    TestResponse response = executeRequest(defaultOrganization);
    verifyResponse(response, true, false, true);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) 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