Search in sources :

Example 11 with GroupReference

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

the class GroupNameNotesTest method updateGroupNames.

@Test
public void updateGroupNames() throws Exception {
    GroupReference g1 = newGroup("a");
    GroupReference g2 = newGroup("b");
    PersonIdent ident = newPersonIdent();
    updateAllGroups(ident, g1, g2);
    ImmutableList<CommitInfo> log = log();
    assertThat(log).hasSize(1);
    assertThat(log.get(0)).parents().isEmpty();
    assertThat(log.get(0)).message().isEqualTo("Store 2 group names");
    assertThat(log.get(0)).author().matches(ident);
    assertThat(log.get(0)).committer().matches(ident);
    assertThat(GroupNameNotes.loadAllGroups(repo)).containsExactly(g1, g2);
    // Updating the same set of names is a no-op.
    String commit = log.get(0).commit;
    updateAllGroups(newPersonIdent(), g1, g2);
    log = log();
    assertThat(log).hasSize(1);
    assertThat(log.get(0)).commit().isEqualTo(commit);
}
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 12 with GroupReference

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

the class GroupNameNotesTest method allGroupsCanBeLoaded.

@Test
public void allGroupsCanBeLoaded() throws Exception {
    AccountGroup.UUID groupUuid1 = AccountGroup.uuid("contributors-MN");
    AccountGroup.NameKey groupName1 = AccountGroup.nameKey("contributors");
    createGroup(groupUuid1, groupName1);
    AccountGroup.UUID groupUuid2 = AccountGroup.uuid("admins-ABC");
    AccountGroup.NameKey groupName2 = AccountGroup.nameKey("admins");
    createGroup(groupUuid2, groupName2);
    ImmutableList<GroupReference> allGroups = GroupNameNotes.loadAllGroups(repo);
    GroupReference group1 = GroupReference.create(groupUuid1, groupName1.get());
    GroupReference group2 = GroupReference.create(groupUuid2, groupName2.get());
    assertThat(allGroups).containsExactly(group1, group2);
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) GroupReference(com.google.gerrit.entities.GroupReference) Test(org.junit.Test)

Example 13 with GroupReference

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

the class GroupReferenceTest method toConfigValue.

@Test
public void toConfigValue() {
    String name = "foo";
    GroupReference groupReference = GroupReference.create(AccountGroup.uuid("uuid-foo"), name);
    assertThat(groupReference.toConfigValue()).isEqualTo("group " + name);
}
Also used : GroupReference(com.google.gerrit.entities.GroupReference) Test(org.junit.Test)

Example 14 with GroupReference

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

the class GroupReferenceTest method create.

@Test
public void create() {
    AccountGroup.UUID uuid = AccountGroup.uuid("uuid");
    String name = "foo";
    GroupReference groupReference = GroupReference.create(uuid, name);
    assertThat(groupReference.getUUID()).isEqualTo(uuid);
    assertThat(groupReference.getName()).isEqualTo(name);
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) GroupReference(com.google.gerrit.entities.GroupReference) UUID(com.google.gerrit.entities.AccountGroup.UUID) Test(org.junit.Test)

Example 15 with GroupReference

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

the class GroupReferenceTest method createWithoutUuid.

@Test
public void createWithoutUuid() {
    // GroupReferences where the UUID is null are used to represent groups from project.config that
    // cannot be resolved.
    String name = "foo";
    GroupReference groupReference = GroupReference.create(name);
    assertThat(groupReference.getUUID()).isNull();
    assertThat(groupReference.getName()).isEqualTo(name);
}
Also used : GroupReference(com.google.gerrit.entities.GroupReference) 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