Search in sources :

Example 1 with CommentLinkInfo

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;
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) SitePaths(com.google.gerrit.server.config.SitePaths) IOException(java.io.IOException) PrologEnvironment(com.google.gerrit.rules.PrologEnvironment) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) RulesCache(com.google.gerrit.rules.RulesCache)

Example 2 with CommentLinkInfo

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);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) HashMap(java.util.HashMap) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with CommentLinkInfo

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);
}
Also used : Project(com.google.gerrit.entities.Project) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) HashMap(java.util.HashMap) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with CommentLinkInfo

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);
}
Also used : ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) HashMap(java.util.HashMap) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with CommentLinkInfo

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());
}
Also used : StoredCommentLinkInfo(com.google.gerrit.entities.StoredCommentLinkInfo) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) StoredCommentLinkInfo(com.google.gerrit.entities.StoredCommentLinkInfo) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

CommentLinkInfo (com.google.gerrit.extensions.api.projects.CommentLinkInfo)14 ConfigInfo (com.google.gerrit.extensions.api.projects.ConfigInfo)8 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)7 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 Project (com.google.gerrit.entities.Project)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2 StoredCommentLinkInfo (com.google.gerrit.entities.StoredCommentLinkInfo)2 ProjectState (com.google.gerrit.server.project.ProjectState)2 Cache (com.google.common.cache.Cache)1 ImmutableList (com.google.common.collect.ImmutableList)1 BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)1 InheritedBooleanInfo (com.google.gerrit.extensions.api.projects.ConfigInfo.InheritedBooleanInfo)1 SubmitTypeInfo (com.google.gerrit.extensions.api.projects.ConfigInfo.SubmitTypeInfo)1 AccountDefaultDisplayName (com.google.gerrit.extensions.common.AccountDefaultDisplayName)1 ActionInfo (com.google.gerrit.extensions.common.ActionInfo)1 GitReferenceUpdatedListener (com.google.gerrit.extensions.events.GitReferenceUpdatedListener)1 PluginEventListener (com.google.gerrit.extensions.events.PluginEventListener)1 UiAction (com.google.gerrit.extensions.webui.UiAction)1