use of org.sonarqube.ws.WsComponents.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_with_browse_permission.
@Test
public void show_with_browse_permission() {
userSession.logIn().addProjectUuidPermissions(UserRole.USER, "project-uuid");
componentDb.insertProjectAndSnapshot(newProjectDto(db.organizations().insert(), "project-uuid"));
ShowWsResponse response = newRequest("project-uuid", null);
assertThat(response.getComponent().getId()).isEqualTo("project-uuid");
}
use of org.sonarqube.ws.WsComponents.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_provided_project.
@Test
public void show_provided_project() {
userSession.logIn().setRoot();
componentDb.insertComponent(newProjectDto(db.organizations().insert(), "project-uuid").setEnabled(false));
ShowWsResponse response = newRequest("project-uuid", null);
assertThat(response.getComponent().getId()).isEqualTo("project-uuid");
assertThat(response.getComponent().hasAnalysisDate()).isFalse();
}
use of org.sonarqube.ws.WsComponents.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_with_ancestors_when_not_project.
@Test
public void show_with_ancestors_when_not_project() throws Exception {
ComponentDto project = componentDb.insertProject();
ComponentDto module = componentDb.insertComponent(newModuleDto(project));
ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir"));
ComponentDto file = componentDb.insertComponent(newFileDto(directory));
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
ShowWsResponse response = newRequest(null, file.key());
assertThat(response.getComponent().getKey()).isEqualTo(file.key());
assertThat(response.getAncestorsList()).extracting(WsComponents.Component::getKey).containsOnly(directory.key(), module.key(), project.key());
}
use of org.sonarqube.ws.WsComponents.ShowWsResponse in project sonarqube by SonarSource.
the class ShowAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
ShowWsRequest showWsRequest = toShowWsRequest(request);
ShowWsResponse showWsResponse = doHandle(showWsRequest);
writeProtobuf(showWsResponse, request, response);
}
use of org.sonarqube.ws.WsComponents.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_with_ancestors_and_analysis_date.
@Test
public void show_with_ancestors_and_analysis_date() throws Exception {
ComponentDto project = componentDb.insertProject();
componentDb.insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
ComponentDto module = componentDb.insertComponent(newModuleDto(project));
ComponentDto directory = componentDb.insertComponent(newDirectory(module, "dir"));
ComponentDto file = componentDb.insertComponent(newFileDto(directory));
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
ShowWsResponse response = newRequest(null, file.key());
String expectedDate = formatDateTime(new Date(3_000_000_000L));
assertThat(response.getAncestorsList()).extracting(WsComponents.Component::getAnalysisDate).containsOnly(expectedDate, expectedDate, expectedDate);
}
Aggregations