use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_with_last_analysis_date.
@Test
public void show_with_last_analysis_date() {
ComponentDto project = db.components().insertPrivateProject();
db.components().insertSnapshots(newAnalysis(project).setCreatedAt(1_000_000_000L).setLast(false), newAnalysis(project).setCreatedAt(2_000_000_000L).setLast(false), newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
userSession.addProjectPermission(USER, project);
ShowWsResponse response = newRequest(project.getDbKey());
assertThat(response.getComponent().getAnalysisDate()).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_and_analysis_date.
@Test
public void show_with_ancestors_and_analysis_date() {
ComponentDto project = db.components().insertPrivateProject();
db.components().insertSnapshot(newAnalysis(project).setCreatedAt(3_000_000_000L).setLast(true));
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());
String expectedDate = formatDateTime(new Date(3_000_000_000L));
assertThat(response.getAncestorsList()).extracting(Component::getAnalysisDate).containsOnly(expectedDate, expectedDate, expectedDate);
}
use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method pull_request.
@Test
public void pull_request() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
String pullRequest = "pr-1234";
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(pullRequest).setBranchType(PULL_REQUEST));
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_PULL_REQUEST, pullRequest).executeProtobuf(ShowWsResponse.class);
assertThat(response.getComponent()).extracting(Component::getKey, Component::getPullRequest, Component::getVersion).containsExactlyInAnyOrder(file.getKey(), pullRequest, "1.1");
assertThat(response.getAncestorsList()).extracting(Component::getKey, Component::getPullRequest, Component::getVersion).containsExactlyInAnyOrder(tuple(directory.getKey(), pullRequest, "1.1"), tuple(module.getKey(), pullRequest, "1.1"), tuple(branch.getKey(), pullRequest, "1.1"));
}
use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method assertNeedIssueSyncEqual.
private void assertNeedIssueSyncEqual(@Nullable String pullRequest, @Nullable String branch, ComponentDto component, boolean needIssueSync) {
TestRequest testRequest = ws.newRequest().setParam(PARAM_COMPONENT, component.getKey());
Optional.ofNullable(pullRequest).ifPresent(pr -> testRequest.setParam(PARAM_PULL_REQUEST, pr));
Optional.ofNullable(branch).ifPresent(br -> testRequest.setParam(PARAM_BRANCH, br));
ShowWsResponse response = testRequest.executeProtobuf(ShowWsResponse.class);
assertThat(response.getComponent()).extracting(Component::getNeedIssueSync).isEqualTo(needIssueSync);
}
use of org.sonarqube.ws.Components.ShowWsResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_without_ancestors_when_project.
@Test
public void show_without_ancestors_when_project() {
ComponentDto project = db.components().insertPrivateProject();
db.components().insertComponent(newModuleDto(project));
userSession.addProjectPermission(USER, project);
ShowWsResponse response = newRequest(project.getDbKey());
assertThat(response.getComponent().getKey()).isEqualTo(project.getDbKey());
assertThat(response.getAncestorsList()).isEmpty();
}
Aggregations