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