Search in sources :

Example 1 with ShowWsResponse

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");
}
Also used : ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse) Test(org.junit.Test)

Example 2 with ShowWsResponse

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();
}
Also used : ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse) Test(org.junit.Test)

Example 3 with ShowWsResponse

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());
}
Also used : WsComponents(org.sonarqube.ws.WsComponents) ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with ShowWsResponse

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);
}
Also used : ShowWsRequest(org.sonarqube.ws.client.component.ShowWsRequest) ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse)

Example 5 with ShowWsResponse

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);
}
Also used : WsComponents(org.sonarqube.ws.WsComponents) ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ShowWsResponse (org.sonarqube.ws.WsComponents.ShowWsResponse)7 Test (org.junit.Test)6 ComponentDto (org.sonar.db.component.ComponentDto)4 Date (java.util.Date)2 WsComponents (org.sonarqube.ws.WsComponents)2 ShowWsRequest (org.sonarqube.ws.client.component.ShowWsRequest)1