use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method fail_when_delete_provided_link.
@Test
public void fail_when_delete_provided_link() {
ComponentDto project = db.components().insertPrivateProject();
ProjectLinkDto link = db.componentLinks().insertProvidedLink(project);
logInAsProjectAdministrator(project);
assertThatThrownBy(() -> deleteLink(link)).isInstanceOf(BadRequestException.class).hasMessageContaining("Provided link cannot be deleted");
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class SearchActionTest method several_projects.
@Test
public void several_projects() {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
ProjectLinkDto link1 = db.componentLinks().insertCustomLink(project1);
ProjectLinkDto link2 = db.componentLinks().insertCustomLink(project2);
userSession.logIn().setRoot();
SearchWsResponse response = callByKey(project1.getKey());
assertThat(response.getLinksList()).extracting(Link::getId, Link::getName).containsExactlyInAnyOrder(tuple(link1.getUuid(), link1.getName()));
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class SearchActionTest method response_fields.
@Test
public void response_fields() {
ComponentDto project = db.components().insertPrivateProject();
ProjectLinkDto homepageLink = db.componentLinks().insertProvidedLink(project);
ProjectLinkDto customLink = db.componentLinks().insertCustomLink(project);
logInAsProjectAdministrator(project);
SearchWsResponse response = callByKey(project.getKey());
assertThat(response.getLinksList()).extracting(Link::getId, Link::getName, Link::getType, Link::getUrl).containsExactlyInAnyOrder(tuple(homepageLink.getUuid(), "", homepageLink.getType(), homepageLink.getHref()), tuple(customLink.getUuid(), customLink.getName(), customLink.getType(), customLink.getHref()));
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class SearchActionTest method project_user_can_search_for_links.
@Test
public void project_user_can_search_for_links() {
ComponentDto project = db.components().insertPrivateProject();
ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
userSession.logIn().addProjectPermission(UserRole.USER, project);
SearchWsResponse response = callByKey(project.getKey());
assertThat(response.getLinksList()).extracting(Link::getId, Link::getName).containsExactlyInAnyOrder(tuple(link.getUuid(), link.getName()));
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class ExportLinksStep method execute.
@Override
public void execute(Context context) {
long count = 0L;
try {
try (DbSession dbSession = dbClient.openSession(false);
StreamWriter<ProjectDump.Link> linksWriter = dumpWriter.newStreamWriter(DumpElement.LINKS)) {
ProjectDump.Link.Builder builder = ProjectDump.Link.newBuilder();
List<ProjectLinkDto> links = dbSession.getMapper(ProjectExportMapper.class).selectLinksForExport(projectHolder.projectDto().getUuid());
for (ProjectLinkDto link : links) {
builder.clear().setUuid(link.getUuid()).setName(defaultString(link.getName())).setHref(defaultString(link.getHref())).setType(defaultString(link.getType())).setComponentRef(componentRepository.getRef(link.getProjectUuid()));
linksWriter.write(builder.build());
++count;
}
Loggers.get(getClass()).debug("{} links exported", count);
}
} catch (Exception e) {
throw new IllegalStateException(format("Link export failed after processing %d link(s) successfully", count), e);
}
}
Aggregations