ProjectConfig: Make GroupReference an AutoValue and remove byName map
This commit is part of a larger series that aims at making all state cached by ProjectCache immutable and serializable. We want cached entities to be immutable because it minimizes all sorts of threading issues. This commit is an incremental step towards this goal. We used to keep an inverse map from name to GroupReference. Since the size of the map is low - usually below 10 - we remove this logic and go over all values when required instead. Change-Id: I76d7d698f35f3ec0abe7a3365f89ebf08e984f81
This commit is contained in:
@@ -393,8 +393,8 @@ public class GroupNameNotesTest {
|
||||
|
||||
ImmutableList<GroupReference> allGroups = GroupNameNotes.loadAllGroups(repo);
|
||||
|
||||
GroupReference group1 = new GroupReference(groupUuid1, groupName1.get());
|
||||
GroupReference group2 = new GroupReference(groupUuid2, groupName2.get());
|
||||
GroupReference group1 = GroupReference.create(groupUuid1, groupName1.get());
|
||||
GroupReference group2 = GroupReference.create(groupUuid2, groupName2.get());
|
||||
assertThat(allGroups).containsExactly(group1, group2);
|
||||
}
|
||||
|
||||
@@ -406,8 +406,8 @@ public class GroupNameNotesTest {
|
||||
|
||||
ImmutableList<GroupReference> allGroups = GroupNameNotes.loadAllGroups(repo);
|
||||
|
||||
GroupReference group1 = new GroupReference(groupUuid, groupName.get());
|
||||
GroupReference group2 = new GroupReference(groupUuid, anotherGroupName.get());
|
||||
GroupReference group1 = GroupReference.create(groupUuid, groupName.get());
|
||||
GroupReference group2 = GroupReference.create(groupUuid, anotherGroupName.get());
|
||||
assertThat(allGroups).containsExactly(group1, group2);
|
||||
}
|
||||
|
||||
@@ -498,14 +498,14 @@ public class GroupNameNotesTest {
|
||||
@Test
|
||||
public void updateGroupNamesRejectsNonOneToOneGroupReferences() throws Exception {
|
||||
assertIllegalArgument(
|
||||
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||
new GroupReference(AccountGroup.uuid("uuid1"), "name2"));
|
||||
GroupReference.create(AccountGroup.uuid("uuid1"), "name1"),
|
||||
GroupReference.create(AccountGroup.uuid("uuid1"), "name2"));
|
||||
assertIllegalArgument(
|
||||
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||
new GroupReference(AccountGroup.uuid("uuid2"), "name1"));
|
||||
GroupReference.create(AccountGroup.uuid("uuid1"), "name1"),
|
||||
GroupReference.create(AccountGroup.uuid("uuid2"), "name1"));
|
||||
assertIllegalArgument(
|
||||
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||
new GroupReference(AccountGroup.uuid("uuid1"), "name1"));
|
||||
GroupReference.create(AccountGroup.uuid("uuid1"), "name1"),
|
||||
GroupReference.create(AccountGroup.uuid("uuid1"), "name1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -554,7 +554,7 @@ public class GroupNameNotesTest {
|
||||
|
||||
private GroupReference newGroup(String name) {
|
||||
int id = idCounter.incrementAndGet();
|
||||
return new GroupReference(AccountGroup.uuid(name + "-" + id), name);
|
||||
return GroupReference.create(AccountGroup.uuid(name + "-" + id), name);
|
||||
}
|
||||
|
||||
private static PersonIdent newPersonIdent() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GroupListTest {
|
||||
@Test
|
||||
public void put() {
|
||||
AccountGroup.UUID uuid = AccountGroup.uuid("abc");
|
||||
GroupReference groupReference = new GroupReference(uuid, "Hutzliputz");
|
||||
GroupReference groupReference = GroupReference.create(uuid, "Hutzliputz");
|
||||
|
||||
groupList.put(uuid, groupReference);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GroupListTest {
|
||||
|
||||
assertEquals(2, result.size());
|
||||
AccountGroup.UUID uuid = AccountGroup.uuid("ebe31c01aec2c9ac3b3c03e87a47450829ff4310");
|
||||
GroupReference expected = new GroupReference(uuid, "Administrators");
|
||||
GroupReference expected = GroupReference.create(uuid, "Administrators");
|
||||
|
||||
assertTrue(result.contains(expected));
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class ProjectConfigTest {
|
||||
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
private final GroupReference developers =
|
||||
new GroupReference(AccountGroup.uuid("X"), "Developers");
|
||||
private final GroupReference staff = new GroupReference(AccountGroup.uuid("Y"), "Staff");
|
||||
GroupReference.create(AccountGroup.uuid("X"), "Developers");
|
||||
private final GroupReference staff = GroupReference.create(AccountGroup.uuid("Y"), "Staff");
|
||||
|
||||
private SitePaths sitePaths;
|
||||
private ProjectConfig.Factory factory;
|
||||
|
||||
@@ -1861,7 +1861,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
ProjectConfig config = projectConfigFactory.read(md);
|
||||
AccessSection s = config.getAccessSection(ref, true);
|
||||
Permission p = s.getPermission(permission, true);
|
||||
PermissionRule rule = new PermissionRule(new GroupReference(groupUUID, groupUUID.get()));
|
||||
PermissionRule rule = new PermissionRule(GroupReference.create(groupUUID, groupUUID.get()));
|
||||
rule.setForce(force);
|
||||
p.add(rule);
|
||||
config.commit(md);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class AllProjectsCreatorTest {
|
||||
|
||||
private GroupReference createGroupReference(String name) {
|
||||
AccountGroup.UUID groupUuid = GroupUuid.make(name, serverUser);
|
||||
return new GroupReference(groupUuid, name);
|
||||
return GroupReference.create(groupUuid, name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user