use of com.google.gerrit.extensions.api.projects.CommentLinkInfo in project gerrit by GerritCodeReview.
the class RefControlTest method add.
private InMemoryRepository add(ProjectConfig pc) {
PrologEnvironment.Factory envFactory = null;
ProjectControl.AssistedFactory projectControlFactory = null;
RulesCache rulesCache = null;
SitePaths sitePaths = null;
List<CommentLinkInfo> commentLinks = null;
InMemoryRepository repo;
try {
repo = repoManager.createRepository(pc.getName());
if (pc.getProject() == null) {
pc.load(repo);
}
} catch (IOException | ConfigInvalidException e) {
throw new RuntimeException(e);
}
all.put(pc.getName(), new ProjectState(sitePaths, projectCache, allProjectsName, allUsersName, projectControlFactory, envFactory, repoManager, rulesCache, commentLinks, capabilityCollectionFactory, pc));
return repo;
}
use of com.google.gerrit.extensions.api.projects.CommentLinkInfo in project gerrit by GerritCodeReview.
the class ProjectIT method updateExistingCommentLink.
@Test
public void updateExistingCommentLink() throws Exception {
ConfigInput input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
ConfigInfo info = setConfig(project, input);
Map<String, CommentLinkInfo> expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
assertCommentLinks(info, expected);
String otherLink = "https://other.example.com";
input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
setConfig(project, input);
expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
assertCommentLinks(getConfig(project), expected);
}
use of com.google.gerrit.extensions.api.projects.CommentLinkInfo in project gerrit by GerritCodeReview.
the class ProjectIT method localCommentLinkOverridesParentCommentLink.
@Test
public void localCommentLinkOverridesParentCommentLink() throws Exception {
ConfigInput input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
ConfigInfo info = setConfig(project, input);
Map<String, CommentLinkInfo> expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
assertCommentLinks(info, expected);
Project.NameKey child = projectOperations.newProject().parent(project).create();
String otherLink = "https://other.example.com";
input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
setConfig(child, input);
expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
assertCommentLinks(getConfig(child), expected);
}
use of com.google.gerrit.extensions.api.projects.CommentLinkInfo in project gerrit by GerritCodeReview.
the class ProjectIT method localCommentLinkOverridesGlobalConfig.
@Test
@GerritConfig(name = "commentlink.bugzilla.match", value = BUGZILLA_MATCH)
@GerritConfig(name = "commentlink.bugzilla.link", value = BUGZILLA_LINK)
public void localCommentLinkOverridesGlobalConfig() throws Exception {
String otherLink = "https://other.example.com";
ConfigInput input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
Map<String, CommentLinkInfo> expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
ConfigInfo info = setConfig(project, input);
assertCommentLinks(info, expected);
assertCommentLinks(getConfig(), expected);
}
use of com.google.gerrit.extensions.api.projects.CommentLinkInfo 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());
}
Aggregations