Convert AccountGroup.NameKey to AutoValue
See I6982fb24 for context. Change-Id: I7a312c4aee94c8e2ebd7c2542c760ce54f190f04
This commit is contained in:
@@ -1322,13 +1322,13 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected InternalGroup group(String groupName) {
|
||||
InternalGroup group = groupCache.get(new AccountGroup.NameKey(groupName)).orElse(null);
|
||||
InternalGroup group = groupCache.get(AccountGroup.nameKey(groupName)).orElse(null);
|
||||
assertThat(group).named(groupName).isNotNull();
|
||||
return group;
|
||||
}
|
||||
|
||||
protected GroupReference groupRef(String groupName) {
|
||||
InternalGroup group = groupCache.get(new AccountGroup.NameKey(groupName)).orElse(null);
|
||||
InternalGroup group = groupCache.get(AccountGroup.nameKey(groupName)).orElse(null);
|
||||
assertThat(group).isNotNull();
|
||||
return new GroupReference(group.getGroupUUID(), group.getName());
|
||||
}
|
||||
@@ -1350,7 +1350,7 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected void assertGroupDoesNotExist(String groupName) {
|
||||
InternalGroup group = groupCache.get(new AccountGroup.NameKey(groupName)).orElse(null);
|
||||
InternalGroup group = groupCache.get(AccountGroup.nameKey(groupName)).orElse(null);
|
||||
assertThat(group).named(groupName).isNull();
|
||||
}
|
||||
|
||||
|
@@ -98,7 +98,7 @@ public class AccountCreator {
|
||||
|
||||
if (groupNames != null) {
|
||||
for (String n : groupNames) {
|
||||
AccountGroup.NameKey k = new AccountGroup.NameKey(n);
|
||||
AccountGroup.NameKey k = AccountGroup.nameKey(n);
|
||||
Optional<InternalGroup> group = groupCache.get(k);
|
||||
if (!group.isPresent()) {
|
||||
throw new NoSuchGroupException(n);
|
||||
|
@@ -81,7 +81,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
||||
AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId());
|
||||
String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get());
|
||||
AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent);
|
||||
AccountGroup.NameKey nameKey = new AccountGroup.NameKey(groupName);
|
||||
AccountGroup.NameKey nameKey = AccountGroup.nameKey(groupName);
|
||||
return InternalGroupCreation.builder()
|
||||
.setId(groupId)
|
||||
.setGroupUUID(groupUuid)
|
||||
@@ -153,7 +153,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
||||
|
||||
private InternalGroupUpdate toInternalGroupUpdate(TestGroupUpdate groupUpdate) {
|
||||
InternalGroupUpdate.Builder builder = InternalGroupUpdate.builder();
|
||||
groupUpdate.name().map(AccountGroup.NameKey::new).ifPresent(builder::setName);
|
||||
groupUpdate.name().map(AccountGroup::nameKey).ifPresent(builder::setName);
|
||||
groupUpdate.description().ifPresent(builder::setDescription);
|
||||
groupUpdate.ownerGroupUuid().ifPresent(builder::setOwnerGroupUUID);
|
||||
groupUpdate.visibleToAll().ifPresent(builder::setVisibleToAll);
|
||||
|
@@ -14,8 +14,10 @@
|
||||
|
||||
package com.google.gerrit.reviewdb.client;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gwtorm.client.IntKey;
|
||||
import com.google.gwtorm.client.StandardKeyEncoder;
|
||||
import com.google.gwtorm.client.StringKey;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
@@ -33,26 +35,27 @@ public final class AccountGroup {
|
||||
return Timestamp.from(AUDIT_CREATION_INSTANT_MS);
|
||||
}
|
||||
|
||||
public static NameKey nameKey(String n) {
|
||||
return new AutoValue_AccountGroup_NameKey(n);
|
||||
}
|
||||
|
||||
/** Group name key */
|
||||
public static class NameKey extends StringKey<com.google.gwtorm.client.Key<?>> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@AutoValue
|
||||
public abstract static class NameKey implements Comparable<NameKey> {
|
||||
abstract String name();
|
||||
|
||||
protected String name;
|
||||
|
||||
protected NameKey() {}
|
||||
|
||||
public NameKey(String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return name;
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
name = newValue;
|
||||
public int compareTo(NameKey o) {
|
||||
return name().compareTo(o.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StandardKeyEncoder().encode(get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ public class CreateGroupArgs {
|
||||
}
|
||||
|
||||
public void setGroupName(String n) {
|
||||
groupName = n != null ? new AccountGroup.NameKey(n) : null;
|
||||
groupName = n != null ? AccountGroup.nameKey(n) : null;
|
||||
}
|
||||
|
||||
public void setGroupName(AccountGroup.NameKey n) {
|
||||
|
@@ -166,7 +166,7 @@ public class GroupCacheImpl implements GroupCache {
|
||||
@Override
|
||||
public Optional<InternalGroup> load(String name) throws Exception {
|
||||
try (TraceTimer timer = TraceContext.newTimer("Loading group '%s' by name", name)) {
|
||||
return groupQueryProvider.get().byName(new AccountGroup.NameKey(name));
|
||||
return groupQueryProvider.get().byName(AccountGroup.nameKey(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public class AccountGroupIdHandler extends OptionHandler<AccountGroup.Id> {
|
||||
@Override
|
||||
public final int parseArguments(Parameters params) throws CmdLineException {
|
||||
final String n = params.getParameter(0);
|
||||
Optional<InternalGroup> group = groupCache.get(new AccountGroup.NameKey(n));
|
||||
Optional<InternalGroup> group = groupCache.get(AccountGroup.nameKey(n));
|
||||
if (!group.isPresent()) {
|
||||
throw new CmdLineException(owner, localizable("Group \"%s\" does not exist"), n);
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ enum GroupConfigEntry {
|
||||
// the NoteDb migration converted such groups faithfully, so we need to be able to read them
|
||||
// back here.
|
||||
name = Strings.nullToEmpty(name);
|
||||
group.setNameKey(new AccountGroup.NameKey(name));
|
||||
group.setNameKey(AccountGroup.nameKey(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -266,7 +266,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
||||
RevCommit oldCommit = ref != null ? rw.parseCommit(ref.getObjectId()) : null;
|
||||
|
||||
for (Map.Entry<AccountGroup.UUID, String> e : biMap.entrySet()) {
|
||||
AccountGroup.NameKey nameKey = new AccountGroup.NameKey(e.getValue());
|
||||
AccountGroup.NameKey nameKey = AccountGroup.nameKey(e.getValue());
|
||||
ObjectId noteKey = getNoteKey(nameKey);
|
||||
noteMap.set(noteKey, getAsNoteData(e.getKey(), nameKey), inserter);
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@ public class GroupsNoteDbConsistencyChecker {
|
||||
continue;
|
||||
}
|
||||
|
||||
ObjectId nameKey = GroupNameNotes.getNoteKey(new AccountGroup.NameKey(gRef.getName()));
|
||||
ObjectId nameKey = GroupNameNotes.getNoteKey(AccountGroup.nameKey(gRef.getName()));
|
||||
if (!Objects.equals(nameKey, note)) {
|
||||
result.problems.add(
|
||||
error("notename entry %s does not match name %s", note, gRef.getName()));
|
||||
|
@@ -74,7 +74,7 @@ public class PutName implements RestModifyView<GroupResource, NameInput> {
|
||||
ConfigInvalidException {
|
||||
AccountGroup.UUID groupUuid = group.getGroupUUID();
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey(newName)).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey(newName)).build();
|
||||
try {
|
||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
|
@@ -218,7 +218,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
private InternalGroupCreation getGroupCreation(Sequences seqs, GroupReference groupReference) {
|
||||
int next = seqs.nextGroupId();
|
||||
return InternalGroupCreation.builder()
|
||||
.setNameKey(new AccountGroup.NameKey(groupReference.getName()))
|
||||
.setNameKey(AccountGroup.nameKey(groupReference.getName()))
|
||||
.setId(new AccountGroup.Id(next))
|
||||
.setGroupUUID(groupReference.getUUID())
|
||||
.build();
|
||||
|
@@ -69,7 +69,7 @@ public class ListMembersCommand extends SshCommand {
|
||||
}
|
||||
|
||||
void display(PrintWriter writer) throws PermissionBackendException {
|
||||
Optional<InternalGroup> group = groupCache.get(new AccountGroup.NameKey(name));
|
||||
Optional<InternalGroup> group = groupCache.get(AccountGroup.nameKey(name));
|
||||
String errorText = "Group not found or not visible\n";
|
||||
|
||||
if (!group.isPresent()) {
|
||||
|
@@ -145,7 +145,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
||||
public void nameRefDoesNotParse() throws Exception {
|
||||
updateGroupFile(
|
||||
RefNames.REFS_GROUPNAMES,
|
||||
GroupNameNotes.getNoteKey(new AccountGroup.NameKey(g1.name)).getName(),
|
||||
GroupNameNotes.getNoteKey(AccountGroup.nameKey(g1.name)).getName(),
|
||||
"[this is not valid\n");
|
||||
assertError("does not parse");
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
||||
|
||||
updateGroupFile(
|
||||
RefNames.REFS_GROUPNAMES,
|
||||
GroupNameNotes.getNoteKey(new AccountGroup.NameKey(bogusName)).getName(),
|
||||
GroupNameNotes.getNoteKey(AccountGroup.nameKey(bogusName)).getName(),
|
||||
config.toText());
|
||||
assertError("entry missing as group ref");
|
||||
}
|
||||
|
@@ -214,7 +214,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void cachedGroupByNameIsUpdatedOnCreation() throws Exception {
|
||||
String newGroupName = name("newGroup");
|
||||
AccountGroup.NameKey nameKey = new AccountGroup.NameKey(newGroupName);
|
||||
AccountGroup.NameKey nameKey = AccountGroup.nameKey(newGroupName);
|
||||
assertThat(groupCache.get(nameKey)).isEmpty();
|
||||
gApi.groups().create(newGroupName);
|
||||
assertThat(groupCache.get(nameKey)).isPresent();
|
||||
@@ -1339,7 +1339,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
groupsUpdate.createGroupInNoteDb(
|
||||
InternalGroupCreation.builder()
|
||||
.setGroupUUID(groupUuid)
|
||||
.setNameKey(new AccountGroup.NameKey(groupName))
|
||||
.setNameKey(AccountGroup.nameKey(groupName))
|
||||
.setId(new AccountGroup.Id(seq.nextGroupId()))
|
||||
.build(),
|
||||
InternalGroupUpdate.builder().build());
|
||||
|
@@ -65,7 +65,7 @@ public class GroupsUpdateIT {
|
||||
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("contributors"))
|
||||
.setName(AccountGroup.nameKey("contributors"))
|
||||
.setMemberModification(
|
||||
new CreateAnotherGroupOnceAsSideEffectOfMemberModification("verifiers"))
|
||||
.build();
|
||||
@@ -108,7 +108,7 @@ public class GroupsUpdateIT {
|
||||
private static InternalGroupCreation getGroupCreation(String groupName, String groupUuid) {
|
||||
return InternalGroupCreation.builder()
|
||||
.setGroupUUID(new AccountGroup.UUID(groupUuid))
|
||||
.setNameKey(new AccountGroup.NameKey(groupName))
|
||||
.setNameKey(AccountGroup.nameKey(groupName))
|
||||
.setId(new AccountGroup.Id(Math.abs(groupName.hashCode())))
|
||||
.build();
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class IndexChangeIT extends AbstractDaemonTest {
|
||||
Util.allow(
|
||||
u.getConfig(),
|
||||
Permission.READ,
|
||||
groupCache.get(new AccountGroup.NameKey(group)).get().getGroupUUID(),
|
||||
groupCache.get(AccountGroup.nameKey(group)).get().getGroupUUID(),
|
||||
"refs/*");
|
||||
Util.block(u.getConfig(), Permission.READ, REGISTERED_USERS, "refs/*");
|
||||
u.save();
|
||||
|
@@ -265,7 +265,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
in.owners.add(
|
||||
Integer.toString(
|
||||
groupCache
|
||||
.get(new AccountGroup.NameKey("Administrators"))
|
||||
.get(AccountGroup.nameKey("Administrators"))
|
||||
.orElse(null)
|
||||
.getId()
|
||||
.get())); // by ID
|
||||
|
@@ -269,7 +269,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
||||
|
||||
AccountGroup.NameKey groupName = groupOperations.group(groupUuid).get().nameKey();
|
||||
|
||||
assertThat(groupName).isEqualTo(new AccountGroup.NameKey("ABC-789-this-name-must-be-unique"));
|
||||
assertThat(groupName).isEqualTo(AccountGroup.nameKey("ABC-789-this-name-must-be-unique"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -91,9 +91,9 @@ public class AccountGroupTest {
|
||||
|
||||
@Test
|
||||
public void nameKeyToString() {
|
||||
assertThat(new AccountGroup.NameKey("foo").toString()).isEqualTo("foo");
|
||||
assertThat(new AccountGroup.NameKey("foo bar").toString()).isEqualTo("foo+bar");
|
||||
assertThat(new AccountGroup.NameKey("foo:bar").toString()).isEqualTo("foo%3Abar");
|
||||
assertThat(AccountGroup.nameKey("foo").toString()).isEqualTo("foo");
|
||||
assertThat(AccountGroup.nameKey("foo bar").toString()).isEqualTo("foo+bar");
|
||||
assertThat(AccountGroup.nameKey("foo:bar").toString()).isEqualTo("foo%3Abar");
|
||||
}
|
||||
|
||||
private AccountGroup.UUID uuid(String uuid) {
|
||||
|
@@ -239,7 +239,7 @@ public final class AuditLogReaderTest extends AbstractGroupTest {
|
||||
InternalGroupCreation groupCreation =
|
||||
InternalGroupCreation.builder()
|
||||
.setGroupUUID(GroupUUID.make(groupName, serverIdent))
|
||||
.setNameKey(new AccountGroup.NameKey(groupName))
|
||||
.setNameKey(AccountGroup.nameKey(groupName))
|
||||
.setId(new AccountGroup.Id(next))
|
||||
.build();
|
||||
InternalGroupUpdate groupUpdate =
|
||||
|
@@ -60,7 +60,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
private Repository repository;
|
||||
private TestRepository<?> testRepository;
|
||||
private final AccountGroup.UUID groupUuid = new AccountGroup.UUID("users-XYZ");
|
||||
private final AccountGroup.NameKey groupName = new AccountGroup.NameKey("users");
|
||||
private final AccountGroup.NameKey groupName = AccountGroup.nameKey("users");
|
||||
private final AccountGroup.Id groupId = new AccountGroup.Id(123);
|
||||
private final AuditLogFormatter auditLogFormatter =
|
||||
AuditLogFormatter.createBackedBy(ImmutableSet.of(), ImmutableSet.of(), "server-id");
|
||||
@@ -95,7 +95,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void nameOfGroupUpdateOverridesGroupCreation() throws Exception {
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("Another name");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("Another name");
|
||||
|
||||
InternalGroupCreation groupCreation =
|
||||
getPrefilledGroupCreationBuilder().setNameKey(groupName).build();
|
||||
@@ -109,20 +109,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void nameOfNewGroupMustNotBeEmpty() throws Exception {
|
||||
InternalGroupCreation groupCreation =
|
||||
getPrefilledGroupCreationBuilder().setNameKey(new AccountGroup.NameKey("")).build();
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
|
||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
||||
exception.expectCause(instanceOf(ConfigInvalidException.class));
|
||||
exception.expectMessage("Name of the group " + groupUuid);
|
||||
groupConfig.commit(metaDataUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameOfNewGroupMustNotBeNull() throws Exception {
|
||||
InternalGroupCreation groupCreation =
|
||||
getPrefilledGroupCreationBuilder().setNameKey(new AccountGroup.NameKey(null)).build();
|
||||
getPrefilledGroupCreationBuilder().setNameKey(AccountGroup.nameKey("")).build();
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
|
||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
||||
@@ -526,7 +513,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void nameCanBeUpdated() throws Exception {
|
||||
createArbitraryGroup(groupUuid);
|
||||
AccountGroup.NameKey newName = new AccountGroup.NameKey("New name");
|
||||
AccountGroup.NameKey newName = AccountGroup.nameKey("New name");
|
||||
|
||||
InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder().setName(newName).build();
|
||||
updateGroup(groupUuid, groupUpdate);
|
||||
@@ -535,29 +522,13 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
assertThatGroup(group).value().nameKey().isEqualTo(newName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameCannotBeUpdatedToNull() throws Exception {
|
||||
createArbitraryGroup(groupUuid);
|
||||
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey(null)).build();
|
||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||
|
||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
||||
exception.expectCause(instanceOf(ConfigInvalidException.class));
|
||||
exception.expectMessage("Name of the group " + groupUuid);
|
||||
groupConfig.commit(metaDataUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameCannotBeUpdatedToEmptyString() throws Exception {
|
||||
createArbitraryGroup(groupUuid);
|
||||
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("")).build();
|
||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||
|
||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
||||
@@ -570,7 +541,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void nameCanBeUpdatedToEmptyStringIfExplicitlySpecified() throws Exception {
|
||||
createArbitraryGroup(groupUuid);
|
||||
AccountGroup.NameKey emptyName = new AccountGroup.NameKey("");
|
||||
AccountGroup.NameKey emptyName = AccountGroup.nameKey("");
|
||||
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
||||
groupConfig.setAllowSaveEmptyName();
|
||||
@@ -675,7 +646,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
InternalGroupUpdate laterGroupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(updatedOn)
|
||||
.build();
|
||||
Optional<InternalGroup> group = updateGroup(groupCreation.getGroupUUID(), laterGroupUpdate);
|
||||
@@ -800,7 +771,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
.setDescription("A test group")
|
||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
||||
.setVisibleToAll(true)
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(new Timestamp(92900892))
|
||||
.setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
|
||||
.setSubgroupModification(
|
||||
@@ -822,7 +793,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
.setDescription("A test group")
|
||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
||||
.setVisibleToAll(true)
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(new Timestamp(92900892))
|
||||
.setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
|
||||
.setSubgroupModification(
|
||||
@@ -845,7 +816,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
.setDescription("A test group")
|
||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
||||
.setVisibleToAll(true)
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(new Timestamp(92900892))
|
||||
.setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
|
||||
.setSubgroupModification(
|
||||
@@ -855,7 +826,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
// Only update one of the properties.
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Another name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Another name")).build();
|
||||
|
||||
Optional<InternalGroup> updatedGroup = updateGroup(groupCreation.getGroupUUID(), groupUpdate);
|
||||
Optional<InternalGroup> reloadedGroup = loadGroup(groupCreation.getGroupUUID());
|
||||
@@ -870,7 +841,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
commit(groupConfig);
|
||||
|
||||
AccountGroup.NameKey name = new AccountGroup.NameKey("Robots");
|
||||
AccountGroup.NameKey name = AccountGroup.nameKey("Robots");
|
||||
InternalGroupUpdate groupUpdate1 = InternalGroupUpdate.builder().setName(name).build();
|
||||
groupConfig.setGroupUpdate(groupUpdate1, auditLogFormatter);
|
||||
commit(groupConfig);
|
||||
@@ -907,7 +878,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
RevCommit commitAfterCreation = getLatestCommitForGroup(groupUuid);
|
||||
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Another name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Another name")).build();
|
||||
updateGroup(groupUuid, groupUpdate);
|
||||
|
||||
RevCommit commitAfterUpdate = getLatestCommitForGroup(groupUuid);
|
||||
@@ -1045,7 +1016,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
getPrefilledGroupCreationBuilder().setGroupUUID(groupUuid).build();
|
||||
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Another name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Another name")).build();
|
||||
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||
@@ -1128,7 +1099,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
.build();
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(createdOn)
|
||||
.build();
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
@@ -1161,7 +1132,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
.build();
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(createdOn)
|
||||
.build();
|
||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||
@@ -1187,7 +1158,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
createArbitraryGroup(groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Another name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Another name")).build();
|
||||
updateGroup(groupUuid, groupUpdate);
|
||||
|
||||
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
|
||||
@@ -1202,7 +1173,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
createArbitraryGroup(groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(new Timestamp(updatedOnAsSecondsSinceEpoch * 1000))
|
||||
.build();
|
||||
updateGroup(groupUuid, groupUpdate);
|
||||
@@ -1220,7 +1191,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
createArbitraryGroup(groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(updatedOn)
|
||||
.build();
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
||||
@@ -1248,7 +1219,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
createArbitraryGroup(groupUuid);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Another name"))
|
||||
.setName(AccountGroup.nameKey("Another name"))
|
||||
.setUpdatedOn(updatedOn)
|
||||
.build();
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
||||
@@ -1281,14 +1252,14 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
public void groupCanBeLoadedAtASpecificRevision() throws Exception {
|
||||
createArbitraryGroup(groupUuid);
|
||||
|
||||
AccountGroup.NameKey firstName = new AccountGroup.NameKey("Bots");
|
||||
AccountGroup.NameKey firstName = AccountGroup.nameKey("Bots");
|
||||
InternalGroupUpdate groupUpdate1 = InternalGroupUpdate.builder().setName(firstName).build();
|
||||
updateGroup(groupUuid, groupUpdate1);
|
||||
|
||||
RevCommit commitAfterUpdate1 = getLatestCommitForGroup(groupUuid);
|
||||
|
||||
InternalGroupUpdate groupUpdate2 =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Robots")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Robots")).build();
|
||||
updateGroup(groupUuid, groupUpdate2);
|
||||
|
||||
GroupConfig groupConfig =
|
||||
@@ -1315,7 +1286,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
InternalGroupCreation groupCreation =
|
||||
getPrefilledGroupCreationBuilder().setGroupUUID(groupUuid).build();
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Another name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Another name")).build();
|
||||
createGroup(groupCreation, groupUpdate);
|
||||
|
||||
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
|
||||
@@ -1478,11 +1449,11 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
createArbitraryGroup(groupUuid);
|
||||
|
||||
InternalGroupUpdate groupUpdate1 =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("Old name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("Old name")).build();
|
||||
updateGroup(groupUuid, groupUpdate1);
|
||||
|
||||
InternalGroupUpdate groupUpdate2 =
|
||||
InternalGroupUpdate.builder().setName(new AccountGroup.NameKey("New name")).build();
|
||||
InternalGroupUpdate.builder().setName(AccountGroup.nameKey("New name")).build();
|
||||
updateGroup(groupUuid, groupUpdate2);
|
||||
|
||||
RevCommit revCommit = getLatestCommitForGroup(groupUuid);
|
||||
@@ -1506,7 +1477,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
InternalGroupUpdate groupUpdate1 =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("Old name"))
|
||||
.setName(AccountGroup.nameKey("Old name"))
|
||||
.setMemberModification(members -> ImmutableSet.of(account7.getId()))
|
||||
.setSubgroupModification(subgroups -> ImmutableSet.of(group2.getGroupUUID()))
|
||||
.build();
|
||||
@@ -1514,7 +1485,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
||||
|
||||
InternalGroupUpdate groupUpdate2 =
|
||||
InternalGroupUpdate.builder()
|
||||
.setName(new AccountGroup.NameKey("New name"))
|
||||
.setName(AccountGroup.nameKey("New name"))
|
||||
.setMemberModification(members -> ImmutableSet.of(account13.getId()))
|
||||
.setSubgroupModification(subgroups -> ImmutableSet.of(group1.getGroupUUID()))
|
||||
.build();
|
||||
|
@@ -75,7 +75,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
private static final TimeZone TZ = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
|
||||
private final AccountGroup.UUID groupUuid = new AccountGroup.UUID("users-XYZ");
|
||||
private final AccountGroup.NameKey groupName = new AccountGroup.NameKey("users");
|
||||
private final AccountGroup.NameKey groupName = AccountGroup.nameKey("users");
|
||||
|
||||
private AtomicInteger idCounter;
|
||||
private AllUsersName allUsersName;
|
||||
@@ -117,7 +117,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void nameOfNewGroupMayBeEmpty() throws Exception {
|
||||
AccountGroup.NameKey emptyName = new AccountGroup.NameKey("");
|
||||
AccountGroup.NameKey emptyName = AccountGroup.nameKey("");
|
||||
createGroup(groupUuid, emptyName);
|
||||
|
||||
Optional<GroupReference> groupReference = loadGroup(emptyName);
|
||||
@@ -138,7 +138,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void newGroupMayReuseUuidOfAnotherGroup() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
createGroup(groupUuid, anotherName);
|
||||
|
||||
Optional<GroupReference> group1 = loadGroup(groupName);
|
||||
@@ -151,7 +151,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void groupCanBeRenamed() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
renameGroup(groupUuid, groupName, anotherName);
|
||||
|
||||
Optional<GroupReference> groupReference = loadGroup(anotherName);
|
||||
@@ -163,7 +163,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void previousNameOfGroupCannotBeUsedAfterRename() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
renameGroup(groupUuid, groupName, anotherName);
|
||||
|
||||
Optional<GroupReference> group = loadGroup(groupName);
|
||||
@@ -182,7 +182,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void oldNameOfGroupMustBeSpecifiedForRename() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
exception.expect(NullPointerException.class);
|
||||
GroupNameNotes.forRename(allUsersName, repo, groupUuid, null, anotherName);
|
||||
}
|
||||
@@ -191,8 +191,8 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void groupCannotBeRenamedWhenOldNameIsWrong() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherOldName = new AccountGroup.NameKey("contributors");
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherOldName = AccountGroup.nameKey("contributors");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
exception.expect(ConfigInvalidException.class);
|
||||
exception.expectMessage(anotherOldName.get());
|
||||
GroupNameNotes.forRename(allUsersName, repo, groupUuid, anotherOldName, anotherName);
|
||||
@@ -202,7 +202,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void groupCannotBeRenamedToNameOfAnotherGroup() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("admins-ABC");
|
||||
AccountGroup.NameKey anotherGroupName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherGroupName = AccountGroup.nameKey("admins");
|
||||
createGroup(anotherGroupUuid, anotherGroupName);
|
||||
|
||||
exception.expect(DuplicateKeyException.class);
|
||||
@@ -214,7 +214,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void groupCannotBeRenamedWithoutSpecifiedUuid() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
exception.expect(NullPointerException.class);
|
||||
GroupNameNotes.forRename(allUsersName, repo, null, groupName, anotherName);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("admins-ABC");
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
exception.expect(ConfigInvalidException.class);
|
||||
exception.expectMessage(groupUuid.get());
|
||||
GroupNameNotes.forRename(allUsersName, repo, anotherGroupUuid, groupName, anotherName);
|
||||
@@ -249,7 +249,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
ImmutableList<CommitInfo> commitsAfterCreation = log();
|
||||
|
||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("admins-ABC");
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
createGroup(anotherGroupUuid, anotherName);
|
||||
|
||||
ImmutableList<CommitInfo> commitsAfterFurtherGroup = log();
|
||||
@@ -262,7 +262,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
createGroup(groupUuid, groupName);
|
||||
ImmutableList<CommitInfo> commitsAfterCreation = log();
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
renameGroup(groupUuid, groupName, anotherName);
|
||||
|
||||
ImmutableList<CommitInfo> commitsAfterRename = log();
|
||||
@@ -298,7 +298,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void newCommitIsNotCreatedWhenCommittingGroupRenamingTwice() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
GroupNameNotes groupNameNotes =
|
||||
GroupNameNotes.forRename(allUsersName, repo, groupUuid, groupName, anotherName);
|
||||
|
||||
@@ -323,7 +323,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
public void commitMessageMentionsGroupRenaming() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
AccountGroup.NameKey anotherName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||
renameGroup(groupUuid, groupName, anotherName);
|
||||
|
||||
ImmutableList<CommitInfo> commits = log();
|
||||
@@ -341,18 +341,18 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void nonExistentGroupCannotBeLoaded() throws Exception {
|
||||
createGroup(new AccountGroup.UUID("contributors-MN"), new AccountGroup.NameKey("contributors"));
|
||||
createGroup(new AccountGroup.UUID("contributors-MN"), AccountGroup.nameKey("contributors"));
|
||||
createGroup(groupUuid, groupName);
|
||||
|
||||
Optional<GroupReference> group = loadGroup(new AccountGroup.NameKey("admins"));
|
||||
Optional<GroupReference> group = loadGroup(AccountGroup.nameKey("admins"));
|
||||
assertThatGroup(group).isAbsent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificGroupCanBeLoaded() throws Exception {
|
||||
createGroup(new AccountGroup.UUID("contributors-MN"), new AccountGroup.NameKey("contributors"));
|
||||
createGroup(new AccountGroup.UUID("contributors-MN"), AccountGroup.nameKey("contributors"));
|
||||
createGroup(groupUuid, groupName);
|
||||
createGroup(new AccountGroup.UUID("admins-ABC"), new AccountGroup.NameKey("admins"));
|
||||
createGroup(new AccountGroup.UUID("admins-ABC"), AccountGroup.nameKey("admins"));
|
||||
|
||||
Optional<GroupReference> group = loadGroup(groupName);
|
||||
assertThatGroup(group).value().groupUuid().isEqualTo(groupUuid);
|
||||
@@ -368,10 +368,10 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void allGroupsCanBeLoaded() throws Exception {
|
||||
AccountGroup.UUID groupUuid1 = new AccountGroup.UUID("contributors-MN");
|
||||
AccountGroup.NameKey groupName1 = new AccountGroup.NameKey("contributors");
|
||||
AccountGroup.NameKey groupName1 = AccountGroup.nameKey("contributors");
|
||||
createGroup(groupUuid1, groupName1);
|
||||
AccountGroup.UUID groupUuid2 = new AccountGroup.UUID("admins-ABC");
|
||||
AccountGroup.NameKey groupName2 = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey groupName2 = AccountGroup.nameKey("admins");
|
||||
createGroup(groupUuid2, groupName2);
|
||||
|
||||
ImmutableList<GroupReference> allGroups = GroupNameNotes.loadAllGroups(repo);
|
||||
@@ -384,7 +384,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void loadedGroupsContainGroupsWithDuplicateGroupUuids() throws Exception {
|
||||
createGroup(groupUuid, groupName);
|
||||
AccountGroup.NameKey anotherGroupName = new AccountGroup.NameKey("admins");
|
||||
AccountGroup.NameKey anotherGroupName = AccountGroup.nameKey("admins");
|
||||
createGroup(groupUuid, anotherGroupName);
|
||||
|
||||
ImmutableList<GroupReference> allGroups = GroupNameNotes.loadAllGroups(repo);
|
||||
@@ -427,7 +427,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
TestRepository<?> tr = new TestRepository<>(repo);
|
||||
ObjectId k1 = getNoteKey(g1);
|
||||
ObjectId k2 = getNoteKey(g2);
|
||||
ObjectId k3 = GroupNameNotes.getNoteKey(new AccountGroup.NameKey("c"));
|
||||
ObjectId k3 = GroupNameNotes.getNoteKey(AccountGroup.nameKey("c"));
|
||||
PersonIdent ident = newPersonIdent();
|
||||
ObjectId origCommitId =
|
||||
tr.branch(REFS_GROUPNAMES)
|
||||
@@ -545,7 +545,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
||||
}
|
||||
|
||||
private static ObjectId getNoteKey(GroupReference g) {
|
||||
return GroupNameNotes.getNoteKey(new AccountGroup.NameKey(g.getName()));
|
||||
return GroupNameNotes.getNoteKey(AccountGroup.nameKey(g.getName()));
|
||||
}
|
||||
|
||||
private void updateAllGroups(PersonIdent ident, GroupReference... groupRefs) throws Exception {
|
||||
|
@@ -30,7 +30,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
public void groupNamesRefIsMissing() throws Exception {
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(warning("Group with name 'g-1' doesn't exist in the list of all names"));
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-2", "[group]\n\tuuid = uuid-2\n\tname = g-2\n");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(warning("Group with name 'g-1' doesn't exist in the list of all names"));
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-1", "[group]\n\tuuid = uuid-1\n\tname = g-1\n");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems).isEmpty();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-1", "[group]\n\tuuid = uuid-2\n\tname = g-1\n");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(
|
||||
warning(
|
||||
@@ -72,7 +72,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-1", "[group]\n\tuuid = uuid-1\n\tname = g-2\n");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(warning("group note of name 'g-1' claims to represent name of 'g-2'"));
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-1", "[group]\n\tuuid = uuid-2\n\tname = g-2\n");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(
|
||||
warning(
|
||||
@@ -97,7 +97,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
updateGroupNamesRef("g-1", "[invalid");
|
||||
List<ConsistencyProblemInfo> problems =
|
||||
GroupsNoteDbConsistencyChecker.checkWithGroupNameNotes(
|
||||
allUsersRepo, new AccountGroup.NameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
allUsersRepo, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
||||
assertThat(problems)
|
||||
.containsExactly(
|
||||
warning(
|
||||
@@ -105,7 +105,7 @@ public class GroupsNoteDbConsistencyCheckerTest extends AbstractGroupTest {
|
||||
}
|
||||
|
||||
private void updateGroupNamesRef(String groupName, String content) throws Exception {
|
||||
String nameKey = GroupNameNotes.getNoteKey(new AccountGroup.NameKey(groupName)).getName();
|
||||
String nameKey = GroupNameNotes.getNoteKey(AccountGroup.nameKey(groupName)).getName();
|
||||
GroupTestUtil.updateGroupFile(
|
||||
allUsersRepo, serverIdent, RefNames.REFS_GROUPNAMES, nameKey, content);
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ public abstract class TestGroup {
|
||||
public abstract Builder setNameKey(AccountGroup.NameKey nameKey);
|
||||
|
||||
public Builder setName(String name) {
|
||||
return setNameKey(new AccountGroup.NameKey(name));
|
||||
return setNameKey(AccountGroup.nameKey(name));
|
||||
}
|
||||
|
||||
public abstract Builder setGroupUuid(AccountGroup.UUID uuid);
|
||||
@@ -66,7 +66,7 @@ public abstract class TestGroup {
|
||||
|
||||
public AccountGroup build() {
|
||||
TestGroup testGroup = autoBuild();
|
||||
AccountGroup.NameKey name = testGroup.getNameKey().orElse(new AccountGroup.NameKey("users"));
|
||||
AccountGroup.NameKey name = testGroup.getNameKey().orElse(AccountGroup.nameKey("users"));
|
||||
AccountGroup.Id id = testGroup.getId().orElse(new AccountGroup.Id(Math.abs(name.hashCode())));
|
||||
AccountGroup.UUID uuid =
|
||||
testGroup.getGroupUuid().orElse(new AccountGroup.UUID(name + "-UUID"));
|
||||
|
Reference in New Issue
Block a user