use of com.google.gerrit.entities.StoredCommentLinkInfo in project gerrit by GerritCodeReview.
the class ProjectState method getCommentLinks.
public List<CommentLinkInfo> getCommentLinks() {
Map<String, CommentLinkInfo> cls = new LinkedHashMap<>();
for (CommentLinkInfo cl : commentLinks) {
cls.put(cl.name.toLowerCase(), cl);
}
for (ProjectState s : treeInOrder()) {
for (StoredCommentLinkInfo cl : s.getConfig().getCommentLinkSections().values()) {
String name = cl.getName().toLowerCase();
if (cl.getOverrideOnly()) {
CommentLinkInfo parent = cls.get(name);
if (parent == null) {
// Ignore invalid overrides.
continue;
}
cls.put(name, StoredCommentLinkInfo.fromInfo(parent, cl.getEnabled()).toInfo());
} else {
cls.put(name, cl.toInfo());
}
}
}
return ImmutableList.copyOf(cls.values());
}
use of com.google.gerrit.entities.StoredCommentLinkInfo in project gerrit by GerritCodeReview.
the class CommentLinkProvider method parseConfig.
private List<CommentLinkInfo> parseConfig(Config cfg) {
Set<String> subsections = cfg.getSubsections(ProjectConfig.COMMENTLINK);
ImmutableList.Builder<CommentLinkInfo> cls = ImmutableList.builderWithExpectedSize(subsections.size());
for (String name : subsections) {
try {
StoredCommentLinkInfo cl = ProjectConfig.buildCommentLink(cfg, name, true);
if (cl.getOverrideOnly()) {
logger.atWarning().log("commentlink %s empty except for \"enabled\"", name);
continue;
}
cls.add(cl.toInfo());
} catch (IllegalArgumentException e) {
logger.atWarning().log("invalid commentlink: %s", e.getMessage());
}
}
return cls.build();
}
use of com.google.gerrit.entities.StoredCommentLinkInfo in project gerrit by GerritCodeReview.
the class ProjectConfigTest method addCommentLink.
@Test
public void addCommentLink() throws Exception {
RevCommit rev = tr.commit().create();
update(rev);
ProjectConfig cfg = read(rev);
StoredCommentLinkInfo cm = StoredCommentLinkInfo.builder("Test").setMatch("abc.*").setHtml("<a>link</a>").setEnabled(true).setOverrideOnly(false).build();
cfg.addCommentLinkSection(cm);
rev = commit(cfg);
assertThat(text(rev, "project.config")).isEqualTo("[commentlink \"Test\"]\n\tmatch = abc.*\n\thtml = <a>link</a>\n");
}
use of com.google.gerrit.entities.StoredCommentLinkInfo in project gerrit by GerritCodeReview.
the class StoredCommentLinkInfoSerializerTest method nullEnabled_roundTrip.
@Test
public void nullEnabled_roundTrip() {
StoredCommentLinkInfo sourceAutoValue = StoredCommentLinkInfo.builder("name").setLink("<p>html").setMatch("*").build();
StoredCommentLinkInfo storedAutoValue = StoredCommentLinkInfo.builder("name").setLink("<p>html").setMatch("*").setEnabled(true).build();
assertThat(deserialize(serialize(sourceAutoValue))).isEqualTo(storedAutoValue);
}
use of com.google.gerrit.entities.StoredCommentLinkInfo in project gerrit by GerritCodeReview.
the class StoredCommentLinkInfoSerializerTest method linkOnly_roundTrip.
@Test
public void linkOnly_roundTrip() {
StoredCommentLinkInfo autoValue = StoredCommentLinkInfo.builder("name").setEnabled(true).setLink("<p>html").setMatch("*").build();
assertThat(deserialize(serialize(autoValue))).isEqualTo(autoValue);
}
Aggregations