Search in sources :

Example 51 with GroupReference

use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.

the class ProjectCacheIT method pluginConfig_cachedValueEqualsConfigValue.

@Test
public void pluginConfig_cachedValueEqualsConfigValue() throws Exception {
    GroupReference group = GroupReference.create(AccountGroup.uuid("uuid"), "local-group-name");
    try (AbstractDaemonTest.ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().updatePluginConfig("important-plugin", cfg -> {
            cfg.setGroupReference("group-config-name", group);
            cfg.setString("key", "my-plugin-value");
        });
        u.save();
    }
    PluginConfig pluginConfig = projectCache.get(project).get().getPluginConfig("important-plugin");
    assertThat(pluginConfig.getString("key")).isEqualTo("my-plugin-value");
    assertThat(pluginConfig.getGroupReference("group-config-name")).isPresent();
    assertThat(pluginConfig.getGroupReference("group-config-name")).hasValue(group);
}
Also used : PluginConfig(com.google.gerrit.server.config.PluginConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GroupReference(com.google.gerrit.entities.GroupReference) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 52 with GroupReference

use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.

the class ProjectCacheIT method pluginConfig_inheritedCachedValueEqualsConfigValue.

@Test
public void pluginConfig_inheritedCachedValueEqualsConfigValue() throws Exception {
    GroupReference group = GroupReference.create(AccountGroup.uuid("uuid"), "local-group-name");
    try (AbstractDaemonTest.ProjectConfigUpdate u = updateProject(allProjects)) {
        u.getConfig().updatePluginConfig("important-plugin", cfg -> {
            cfg.setGroupReference("group-config-name", group);
            cfg.setString("key", "my-plugin-value");
        });
        u.save();
    }
    PluginConfig pluginConfig = pluginConfigFactory.getFromProjectConfigWithInheritance(project, "important-plugin");
    assertThat(pluginConfig.getString("key")).isEqualTo("my-plugin-value");
    assertThat(pluginConfig.getGroupReference("group-config-name")).isPresent();
    assertThat(pluginConfig.getGroupReference("group-config-name")).hasValue(group);
}
Also used : PluginConfig(com.google.gerrit.server.config.PluginConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GroupReference(com.google.gerrit.entities.GroupReference) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 53 with GroupReference

use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.

the class GroupReferenceSerializerTest method roundTripWithMinimalValues.

@Test
public void roundTripWithMinimalValues() {
    GroupReference groupReferenceAutoValue = GroupReference.create("name");
    assertThat(deserialize(serialize(groupReferenceAutoValue))).isEqualTo(groupReferenceAutoValue);
}
Also used : GroupReference(com.google.gerrit.entities.GroupReference) Test(org.junit.Test)

Example 54 with GroupReference

use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.

the class GroupNameNotesTest method updateGroupNamesWithEmptyCollectionClearsAllNotes.

@Test
public void updateGroupNamesWithEmptyCollectionClearsAllNotes() throws Exception {
    GroupReference g1 = newGroup("a");
    GroupReference g2 = newGroup("b");
    PersonIdent ident = newPersonIdent();
    updateAllGroups(ident, g1, g2);
    assertThat(GroupNameNotes.loadAllGroups(repo)).containsExactly(g1, g2);
    updateAllGroups(ident);
    assertThat(GroupNameNotes.loadAllGroups(repo)).isEmpty();
    ImmutableList<CommitInfo> log = log();
    assertThat(log).hasSize(2);
    assertThat(log.get(1)).message().isEqualTo("Store 0 group names");
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) GroupReference(com.google.gerrit.entities.GroupReference) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) Test(org.junit.Test)

Example 55 with GroupReference

use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.

the class GroupNameNotesTest method updateGroupNamesOverwritesExistingNotes.

@Test
public void updateGroupNamesOverwritesExistingNotes() throws Exception {
    GroupReference g1 = newGroup("a");
    GroupReference g2 = newGroup("b");
    try (TestRepository<Repository> tr = new TestRepository<>(repo)) {
        ObjectId k1 = getNoteKey(g1);
        ObjectId k2 = getNoteKey(g2);
        ObjectId k3 = GroupNameNotes.getNoteKey(AccountGroup.nameKey("c"));
        PersonIdent ident = newPersonIdent();
        ObjectId origCommitId = tr.branch(REFS_GROUPNAMES).commit().message("Prepopulate group name").author(ident).committer(ident).add(k1.name(), "[group]\n\tuuid = a-1\n\tname = a\nanotherKey = foo\n").add(k2.name(), "[group]\n\tuuid = a-1\n\tname = b\n").add(k3.name(), "[group]\n\tuuid = c-3\n\tname = c\n").create().copy();
        ident = newPersonIdent();
        updateAllGroups(ident, g1, g2);
        assertThat(GroupNameNotes.loadAllGroups(repo)).containsExactly(g1, g2);
        ImmutableList<CommitInfo> log = log();
        assertThat(log).hasSize(2);
        assertThat(log.get(0)).commit().isEqualTo(origCommitId.name());
        assertThat(log.get(1)).message().isEqualTo("Store 2 group names");
        assertThat(log.get(1)).author().matches(ident);
        assertThat(log.get(1)).committer().matches(ident);
    }
    // Old note content was overwritten.
    assertThat(readNameNote(g1)).isEqualTo("[group]\n\tuuid = a-1\n\tname = a\n");
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) TestRepository(org.eclipse.jgit.junit.TestRepository) Repository(org.eclipse.jgit.lib.Repository) TestRepository(org.eclipse.jgit.junit.TestRepository) ObjectId(org.eclipse.jgit.lib.ObjectId) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GroupReference(com.google.gerrit.entities.GroupReference) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) Test(org.junit.Test)

Aggregations

GroupReference (com.google.gerrit.entities.GroupReference)59 Test (org.junit.Test)24 AccountGroup (com.google.gerrit.entities.AccountGroup)18 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)8 GroupDescription (com.google.gerrit.entities.GroupDescription)8 InternalGroup (com.google.gerrit.entities.InternalGroup)7 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)7 IOException (java.io.IOException)7 Repository (org.eclipse.jgit.lib.Repository)7 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)6 Config (org.eclipse.jgit.lib.Config)6 CachedProjectConfig (com.google.gerrit.entities.CachedProjectConfig)5 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)5 NotifyConfig (com.google.gerrit.entities.NotifyConfig)4 ArrayList (java.util.ArrayList)4 Account (com.google.gerrit.entities.Account)3 BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)3 Permission (com.google.gerrit.entities.Permission)3 PermissionRule (com.google.gerrit.entities.PermissionRule)3 ProjectAccessInfo (com.google.gerrit.extensions.api.access.ProjectAccessInfo)3