Search in sources :

Example 6 with ShowWsResponse

use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method show_with_browse_permission.

@Test
public void show_with_browse_permission() {
    ComponentDto project = newPrivateProjectDto("project-uuid");
    db.components().insertProjectAndSnapshot(project);
    userSession.logIn().addProjectPermission(USER, project);
    ShowWsResponse response = newRequest(project.getDbKey());
    assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 7 with ShowWsResponse

use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method branch.

@Test
public void branch() {
    ComponentDto project = db.components().insertPrivateProject();
    userSession.addProjectPermission(UserRole.USER, project);
    String branchKey = "my_branch";
    ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchKey));
    ComponentDto module = db.components().insertComponent(newModuleDto(branch));
    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
    ComponentDto file = db.components().insertComponent(newFileDto(directory));
    db.components().insertSnapshot(branch, s -> s.setProjectVersion("1.1"));
    ShowWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_BRANCH, branchKey).executeProtobuf(ShowWsResponse.class);
    assertThat(response.getComponent()).extracting(Component::getKey, Component::getBranch, Component::getVersion).containsExactlyInAnyOrder(file.getKey(), branchKey, "1.1");
    assertThat(response.getAncestorsList()).extracting(Component::getKey, Component::getBranch, Component::getVersion).containsExactlyInAnyOrder(tuple(directory.getKey(), branchKey, "1.1"), tuple(module.getKey(), branchKey, "1.1"), tuple(branch.getKey(), branchKey, "1.1"));
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 8 with ShowWsResponse

use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method should_return_visibility_for_portfolio.

@Test
public void should_return_visibility_for_portfolio() {
    userSession.logIn().setRoot();
    ComponentDto view = db.components().insertPrivatePortfolio();
    ShowWsResponse result = newRequest(view.getDbKey());
    assertThat(result.getComponent().hasVisibility()).isTrue();
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 9 with ShowWsResponse

use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.

the class ShowAction method handle.

@Override
public void handle(org.sonar.api.server.ws.Request request, Response response) throws Exception {
    Request showRequest = toShowWsRequest(request);
    ShowWsResponse showWsResponse = doHandle(showRequest);
    writeProtobuf(showWsResponse, request, response);
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse)

Example 10 with ShowWsResponse

use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method should_not_return_visibility_for_module.

@Test
public void should_not_return_visibility_for_module() {
    userSession.logIn().setRoot();
    ComponentDto privateProject = db.components().insertPrivateProject();
    ComponentDto module = db.components().insertComponent(newModuleDto(privateProject));
    ShowWsResponse result = newRequest(module.getDbKey());
    assertThat(result.getComponent().hasVisibility()).isFalse();
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

ShowWsResponse (org.sonarqube.ws.Components.ShowWsResponse)15 Test (org.junit.Test)13 ComponentDto (org.sonar.db.component.ComponentDto)13 Date (java.util.Date)3 TestRequest (org.sonar.server.ws.TestRequest)1