use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class ExportLinksStepTest method export_links.
@Test
public void export_links() {
ProjectLinkDto link1 = db.componentLinks().insertCustomLink(PROJECT);
ProjectLinkDto link2 = db.componentLinks().insertProvidedLink(PROJECT);
db.componentLinks().insertCustomLink(db.components().insertPrivateProject());
underTest.execute(new TestComputationStepContext());
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 links exported");
assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.LINKS)).extracting(Link::getUuid, Link::getName, Link::getType, Link::getHref).containsExactlyInAnyOrder(tuple(link1.getUuid(), link1.getName(), link1.getType(), link1.getHref()), tuple(link2.getUuid(), "", link2.getType(), link2.getHref()));
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class ExportLinksStepTest method test_all_fields.
@Test
public void test_all_fields() {
ProjectLinkDto link = db.componentLinks().insertCustomLink(PROJECT, l -> l.setName("name").setHref("href").setType("type"));
underTest.execute(new TestComputationStepContext());
Link reloaded = dumpWriter.getWrittenMessagesOf(DumpElement.LINKS).get(0);
assertThat(reloaded.getUuid()).isEqualTo(link.getUuid());
assertThat(reloaded.getName()).isEqualTo(link.getName());
assertThat(reloaded.getHref()).isEqualTo(link.getHref());
assertThat(reloaded.getType()).isEqualTo(link.getType());
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class DeleteAction method doHandle.
private void doHandle(String id) {
try (DbSession dbSession = dbClient.openSession(false)) {
ProjectLinkDto link = dbClient.projectLinkDao().selectByUuid(dbSession, id);
link = NotFoundException.checkFound(link, "Link with id '%s' not found", id);
checkProjectAdminPermission(link);
checkNotProvided(link);
dbClient.projectLinkDao().delete(dbSession, link.getUuid());
dbSession.commit();
}
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method remove_custom_link.
@Test
public void remove_custom_link() {
ComponentDto project = db.components().insertPrivateProject();
ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
logInAsProjectAdministrator(project);
deleteLink(link);
assertLinkIsDeleted(link.getUuid());
}
use of org.sonar.db.component.ProjectLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method keep_links_of_another_project.
@Test
public void keep_links_of_another_project() {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
ProjectLinkDto customLink1 = db.componentLinks().insertCustomLink(project1);
ProjectLinkDto customLink2 = db.componentLinks().insertCustomLink(project2);
userSession.logIn().addProjectPermission(ADMIN, project1, project2);
deleteLink(customLink1);
assertLinkIsDeleted(customLink1.getUuid());
assertLinkIsNotDeleted(customLink2.getUuid());
}
Aggregations