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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations