use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method fail_when_delete_provided_link.
@Test
public void fail_when_delete_provided_link() {
ComponentDto project = insertProject();
ComponentLinkDto link = insertHomepageLink(project.uuid());
logInAsProjectAdministrator(project);
expectedException.expect(BadRequestException.class);
deleteLink(link.getId());
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method keep_links_of_another_project.
@Test
public void keep_links_of_another_project() {
ComponentDto project1 = insertProject();
ComponentDto project2 = insertProject("another", "abcd");
ComponentLinkDto customLink1 = insertCustomLink(project1.uuid());
ComponentLinkDto customLink2 = insertCustomLink(project2.uuid());
Long id1 = customLink1.getId();
Long id2 = customLink2.getId();
userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project1.uuid(), project2.uuid());
deleteLink(id1);
assertLinkIsDeleted(id1);
assertLinkIsNotDeleted(id2);
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class DeleteActionTest method insertHomepageLink.
private ComponentLinkDto insertHomepageLink(String projectUuid) {
ComponentLinkDto link = new ComponentLinkDto().setComponentUuid(projectUuid).setName("Homepage").setType("homepage").setHref("http://example.org");
insertLink(link);
return link;
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class DeleteAction method doHandle.
private void doHandle(DeleteWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
long id = request.getId();
ComponentLinkDto link = dbClient.componentLinkDao().selectById(dbSession, id);
link = WsUtils.checkFound(link, "Link with id '%s' not found", id);
checkProjectAdminPermission(link);
checkNotProvided(link);
dbClient.componentLinkDao().delete(dbSession, link.getId());
dbSession.commit();
}
}
use of org.sonar.db.component.ComponentLinkDto in project sonarqube by SonarSource.
the class SearchMyProjectsActionTest method search_json_example.
@Test
public void search_json_example() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto jdk7 = insertJdk7(organizationDto);
ComponentDto cLang = insertClang(organizationDto);
dbClient.componentLinkDao().insert(dbSession, new ComponentLinkDto().setComponentUuid(jdk7.uuid()).setHref("http://www.oracle.com").setType(ComponentLinkDto.TYPE_HOME_PAGE).setName("Home"));
dbClient.componentLinkDao().insert(dbSession, new ComponentLinkDto().setComponentUuid(jdk7.uuid()).setHref("http://download.java.net/openjdk/jdk8/").setType(ComponentLinkDto.TYPE_SOURCES).setName("Sources"));
long oneTime = DateUtils.parseDateTime("2016-06-10T13:17:53+0000").getTime();
long anotherTime = DateUtils.parseDateTime("2016-06-11T14:25:53+0000").getTime();
SnapshotDto jdk7Snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(jdk7).setCreatedAt(oneTime));
SnapshotDto cLangSnapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(cLang).setCreatedAt(anotherTime));
dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, jdk7, jdk7Snapshot).setData(Level.ERROR.name()));
dbClient.measureDao().insert(dbSession, newMeasureDto(alertStatusMetric, cLang, cLangSnapshot).setData(Level.OK.name()));
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, jdk7);
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, cLang);
db.commit();
System.setProperty("user.timezone", "UTC");
String result = ws.newRequest().execute().getInput();
assertJson(result).isSimilarTo(getClass().getResource("search_my_projects-example.json"));
}
Aggregations