use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class GhostsActionTest method ghost_projects_with_partial_query_on_key.
@Test
public void ghost_projects_with_partial_query_on_key() throws Exception {
OrganizationDto organization = db.organizations().insert();
insertGhostProject(organization, dto -> dto.setKey("ghost-key-1"));
userSessionRule.logIn().addPermission(ADMINISTER, organization);
TestResponse result = underTest.newRequest().setParam("organization", organization.getKey()).setParam(Param.TEXT_QUERY, "GHOST-key").execute();
assertThat(result.getInput()).contains("ghost-key-1");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class GhostsActionTest method ghost_projects_with_correct_pagination.
@Test
public void ghost_projects_with_correct_pagination() throws Exception {
OrganizationDto organization = db.organizations().insert();
for (int i = 1; i <= 10; i++) {
int count = i;
insertGhostProject(organization, dto -> dto.setKey("ghost-key-" + count));
}
userSessionRule.logIn().addPermission(ADMINISTER, organization);
TestResponse result = underTest.newRequest().setParam("organization", organization.getKey()).setParam(Param.PAGE, "3").setParam(Param.PAGE_SIZE, "4").execute();
String json = result.getInput();
assertJson(json).isSimilarTo("{" + " \"p\": 3," + " \"ps\": 4," + " \"total\": 10" + "}");
assertThat(StringUtils.countMatches(json, "ghost-key-")).isEqualTo(2);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class ProvisionedActionTest method all_provisioned_projects_without_analyzed_projects.
@Test
public void all_provisioned_projects_without_analyzed_projects() throws Exception {
OrganizationDto org = db.organizations().insert();
ComponentDto analyzedProject = ComponentTesting.newProjectDto(org, "analyzed-uuid-1");
db.components().insertComponents(newProvisionedProject(org, "1"), newProvisionedProject(org, "2"), analyzedProject);
db.components().insertSnapshot(SnapshotTesting.newAnalysis(analyzedProject));
userSessionRule.logIn().addPermission(PROVISION_PROJECTS, org);
TestResponse result = underTest.newRequest().setParam(PARAM_ORGANIZATION, org.getKey()).execute();
String json = result.getInput();
assertJson(json).isSimilarTo("{" + " \"projects\":[" + " {" + " \"uuid\":\"provisioned-uuid-1\"," + " \"key\":\"provisioned-key-1\"," + " \"name\":\"provisioned-name-1\"" + " }," + " {" + " \"uuid\":\"provisioned-uuid-2\"," + " \"key\":\"provisioned-key-2\"," + " \"name\":\"provisioned-name-2\"" + " }" + " ]" + "}");
assertThat(json).doesNotContain("analyzed-uuid-1");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class SetActionTest method set_tags_exclude_empty_and_blank_values.
@Test
public void set_tags_exclude_empty_and_blank_values() {
TestResponse response = call(project.key(), "finance , offshore, platform, ,");
assertTags(project.key(), "finance", "offshore", "platform");
verify(indexer).indexProject(project.uuid(), PROJECT_TAGS_UPDATE);
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class DeleteActionTest method no_response.
@Test
public void no_response() {
ComponentDto project = insertProject();
ComponentLinkDto link = insertCustomLink(project.uuid());
logInAsProjectAdministrator(project);
TestResponse response = deleteLink(link.getId());
assertThat(response.getStatus()).isEqualTo(204);
assertThat(response.getInput()).isEmpty();
}
Aggregations