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