use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class GroupConfigTest method refStateOfLoadedGroupIsPopulatedWithCommitSha1.
@Test
public void refStateOfLoadedGroupIsPopulatedWithCommitSha1() throws Exception {
createArbitraryGroup(groupUuid);
Optional<InternalGroup> group = loadGroup(groupUuid);
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
assertThatGroup(group).value().refState().isEqualTo(revCommit.copy());
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AuditLogReaderTest method addMultiMembers.
@Test
public void addMultiMembers() throws Exception {
InternalGroup group = createGroupAsUser(1, "test-group");
AccountGroup.Id groupId = group.getId();
AccountGroup.UUID uuid = group.getGroupUUID();
AccountGroupMemberAudit expAudit1 = createExpMemberAudit(groupId, userId, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1);
Account.Id id1 = Account.id(100002);
Account.Id id2 = Account.id(100003);
addMembers(uuid, ImmutableSet.of(id1, id2));
AccountGroupMemberAudit expAudit2 = createExpMemberAudit(groupId, id1, userId, getTipTimestamp(uuid));
AccountGroupMemberAudit expAudit3 = createExpMemberAudit(groupId, id2, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1, expAudit2, expAudit3).inOrder();
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AuditLogReaderTest method addMultiSubgroups.
@Test
public void addMultiSubgroups() throws Exception {
InternalGroup group = createGroupAsUser(1, "test-group");
AccountGroup.UUID uuid = group.getGroupUUID();
InternalGroup subgroup1 = createGroupAsUser(2, "test-group-2");
InternalGroup subgroup2 = createGroupAsUser(3, "test-group-3");
AccountGroup.UUID subgroupUuid1 = subgroup1.getGroupUUID();
AccountGroup.UUID subgroupUuid2 = subgroup2.getGroupUUID();
addSubgroups(uuid, ImmutableSet.of(subgroupUuid1, subgroupUuid2));
AccountGroupByIdAudit expAudit1 = createExpGroupAudit(group.getId(), subgroupUuid1, userId, getTipTimestamp(uuid));
AccountGroupByIdAudit expAudit2 = createExpGroupAudit(group.getId(), subgroupUuid2, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getSubgroupsAudit(allUsersRepo, uuid)).containsExactly(expAudit1, expAudit2).inOrder();
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AuditLogReaderTest method addAndRemoveMember.
@Test
public void addAndRemoveMember() throws Exception {
InternalGroup group = createGroupAsUser(1, "test-group");
AccountGroup.UUID uuid = group.getGroupUUID();
AccountGroupMemberAudit expAudit1 = createExpMemberAudit(group.getId(), userId, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1);
// User adds account 100002 to the group.
Account.Id id = Account.id(100002);
addMembers(uuid, ImmutableSet.of(id));
AccountGroupMemberAudit expAudit2 = createExpMemberAudit(group.getId(), id, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1, expAudit2).inOrder();
// User removes account 100002 from the group.
removeMembers(uuid, ImmutableSet.of(id));
expAudit2 = expAudit2.toBuilder().removed(userId, getTipTimestamp(uuid)).build();
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1, expAudit2).inOrder();
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AuditLogReaderTest method addAndRemoveSubgroups.
@Test
public void addAndRemoveSubgroups() throws Exception {
InternalGroup group = createGroupAsUser(1, "test-group");
AccountGroup.UUID uuid = group.getGroupUUID();
InternalGroup subgroup = createGroupAsUser(2, "test-group-2");
AccountGroup.UUID subgroupUuid = subgroup.getGroupUUID();
addSubgroups(uuid, ImmutableSet.of(subgroupUuid));
AccountGroupByIdAudit expAudit = createExpGroupAudit(group.getId(), subgroupUuid, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getSubgroupsAudit(allUsersRepo, uuid)).containsExactly(expAudit);
removeSubgroups(uuid, ImmutableSet.of(subgroupUuid));
expAudit = expAudit.toBuilder().removed(userId, getTipTimestamp(uuid)).build();
assertThat(auditLogReader.getSubgroupsAudit(allUsersRepo, uuid)).containsExactly(expAudit);
}
Aggregations