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