Search in sources :

Example 56 with TestResponse

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");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 57 with TestResponse

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);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 58 with TestResponse

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");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 59 with TestResponse

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);
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 60 with TestResponse

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();
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) TestResponse(org.sonar.server.ws.TestResponse) ComponentDto(org.sonar.db.component.ComponentDto) 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