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);
}
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);
}
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());
}
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();
}
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);
}
Aggregations