Search in sources :

Example 6 with TreeWsResponse

use of org.sonarqube.ws.WsComponents.TreeWsResponse in project sonarqube by SonarSource.

the class TreeActionTest method filter_descendants_by_qualifier.

@Test
public void filter_descendants_by_qualifier() throws IOException {
    ComponentDto project = newProjectDto(db.organizations().insert(), "project-uuid");
    componentDb.insertProjectAndSnapshot(project);
    componentDb.insertComponent(newFileDto(project, 1));
    componentDb.insertComponent(newFileDto(project, 2));
    componentDb.insertComponent(newModuleDto("module-uuid-1", project));
    db.commit();
    logInWithBrowsePermission(project);
    TreeWsResponse response = call(ws.newRequest().setParam(PARAM_STRATEGY, "all").setParam(PARAM_QUALIFIERS, Qualifiers.FILE).setParam(PARAM_COMPONENT_ID, "project-uuid"));
    assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) TreeWsResponse(org.sonarqube.ws.WsComponents.TreeWsResponse) Test(org.junit.Test)

Example 7 with TreeWsResponse

use of org.sonarqube.ws.WsComponents.TreeWsResponse in project sonarqube by SonarSource.

the class TreeAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    TreeWsResponse treeWsResponse = doHandle(toTreeWsRequest(request));
    writeProtobuf(treeWsResponse, request, response);
}
Also used : TreeWsResponse(org.sonarqube.ws.WsComponents.TreeWsResponse)

Example 8 with TreeWsResponse

use of org.sonarqube.ws.WsComponents.TreeWsResponse in project sonarqube by SonarSource.

the class TreeActionTest method return_developers.

@Test
public void return_developers() {
    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
    componentDb.insertProjectAndSnapshot(project);
    ComponentDto developer = newDeveloper(db.organizations().insert(), "developer-name");
    componentDb.insertDeveloperAndSnapshot(developer);
    componentDb.insertComponent(newDevProjectCopy("project-copy-uuid", project, developer));
    db.commit();
    logInWithBrowsePermission(developer);
    TreeWsResponse response = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, developer.uuid()));
    assertThat(response.getBaseComponent().getId()).isEqualTo(developer.uuid());
    assertThat(response.getComponentsCount()).isEqualTo(1);
    assertThat(response.getComponents(0).getId()).isEqualTo("project-copy-uuid");
    assertThat(response.getComponents(0).getRefId()).isEqualTo("project-uuid");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) TreeWsResponse(org.sonarqube.ws.WsComponents.TreeWsResponse) Test(org.junit.Test)

Example 9 with TreeWsResponse

use of org.sonarqube.ws.WsComponents.TreeWsResponse in project sonarqube by SonarSource.

the class TreeActionTest method response_is_empty_on_provisioned_projects.

@Test
public void response_is_empty_on_provisioned_projects() {
    ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
    logInWithBrowsePermission(project);
    TreeWsResponse response = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, "project-uuid"));
    assertThat(response.getBaseComponent().getId()).isEqualTo("project-uuid");
    assertThat(response.getComponentsList()).isEmpty();
    assertThat(response.getPaging().getTotal()).isEqualTo(0);
    assertThat(response.getPaging().getPageSize()).isEqualTo(100);
    assertThat(response.getPaging().getPageIndex()).isEqualTo(1);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) TreeWsResponse(org.sonarqube.ws.WsComponents.TreeWsResponse) Test(org.junit.Test)

Example 10 with TreeWsResponse

use of org.sonarqube.ws.WsComponents.TreeWsResponse in project sonarqube by SonarSource.

the class TreeActionTest method return_leaves.

@Test
public void return_leaves() throws IOException {
    ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
    componentDb.insertProjectAndSnapshot(project);
    ComponentDto module = newModuleDto("module-uuid-1", project);
    componentDb.insertComponent(module);
    componentDb.insertComponent(newFileDto(project, 1));
    componentDb.insertComponent(newFileDto(module, 2));
    ComponentDto directory = newDirectory(project, "directory-path-1");
    componentDb.insertComponent(directory);
    componentDb.insertComponent(newFileDto(module, directory, 3));
    db.commit();
    logInWithBrowsePermission(project);
    TreeWsResponse response = call(ws.newRequest().setParam(PARAM_STRATEGY, "leaves").setParam(PARAM_COMPONENT_ID, "project-uuid").setParam(PARAM_QUALIFIERS, Qualifiers.FILE));
    assertThat(response.getComponentsCount()).isEqualTo(3);
    assertThat(response.getPaging().getTotal()).isEqualTo(3);
    assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) TreeWsResponse(org.sonarqube.ws.WsComponents.TreeWsResponse) Test(org.junit.Test)

Aggregations

TreeWsResponse (org.sonarqube.ws.WsComponents.TreeWsResponse)11 ComponentDto (org.sonar.db.component.ComponentDto)10 Test (org.junit.Test)9 SnapshotDto (org.sonar.db.component.SnapshotDto)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1