Search in sources :

Example 1 with ShowWsResponse

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

the class ShowActionTest method display_version.

@Test
public void display_version() {
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto module = db.components().insertComponent(newModuleDto(project));
    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
    ComponentDto file = db.components().insertComponent(newFileDto(directory));
    db.components().insertSnapshot(project, s -> s.setProjectVersion("1.1"));
    userSession.addProjectPermission(USER, project);
    ShowWsResponse response = newRequest(file.getDbKey());
    assertThat(response.getComponent().getVersion()).isEqualTo("1.1");
    assertThat(response.getAncestorsList()).extracting(Component::getVersion).containsOnly("1.1");
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 2 with ShowWsResponse

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

the class ShowActionTest method show_with_new_code_period_date.

@Test
public void show_with_new_code_period_date() {
    ComponentDto project = db.components().insertPrivateProject();
    db.components().insertSnapshots(newAnalysis(project).setPeriodDate(1_000_000_000L).setLast(false), newAnalysis(project).setPeriodDate(2_000_000_000L).setLast(false), newAnalysis(project).setPeriodDate(3_000_000_000L).setLast(true));
    userSession.addProjectPermission(USER, project);
    ShowWsResponse response = newRequest(project.getDbKey());
    assertThat(response.getComponent().getLeakPeriodDate()).isNotEmpty().isEqualTo(formatDateTime(new Date(3_000_000_000L)));
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ShowWsResponse

use of org.sonarqube.ws.Components.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() {
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto module = db.components().insertComponent(newModuleDto(project));
    ComponentDto directory = db.components().insertComponent(newDirectory(module, "dir"));
    ComponentDto file = db.components().insertComponent(newFileDto(directory));
    userSession.addProjectPermission(USER, project);
    ShowWsResponse response = newRequest(file.getDbKey());
    assertThat(response.getComponent().getKey()).isEqualTo(file.getDbKey());
    assertThat(response.getAncestorsList()).extracting(Component::getKey).containsOnly(directory.getDbKey(), module.getDbKey(), project.getDbKey());
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with ShowWsResponse

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

the class ShowActionTest method should_return_visibility_for_public_project.

@Test
public void should_return_visibility_for_public_project() {
    userSession.logIn().setRoot();
    ComponentDto publicProject = db.components().insertPublicProject();
    ShowWsResponse result = newRequest(publicProject.getDbKey());
    assertThat(result.getComponent().hasVisibility()).isTrue();
    assertThat(result.getComponent().getVisibility()).isEqualTo("public");
}
Also used : ShowWsResponse(org.sonarqube.ws.Components.ShowWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 5 with ShowWsResponse

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

the class ShowActionTest method should_return_visibility_for_private_project.

@Test
public void should_return_visibility_for_private_project() {
    userSession.logIn().setRoot();
    ComponentDto privateProject = db.components().insertPrivateProject();
    ShowWsResponse result = newRequest(privateProject.getDbKey());
    assertThat(result.getComponent().hasVisibility()).isTrue();
    assertThat(result.getComponent().getVisibility()).isEqualTo("private");
}
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