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