Convert AccountGroup.UUID to AutoValue
Adapt GroupReference to avoid an AccountGroup.UUID with a null value. See I6982fb24 for context. Change-Id: I26c460304eed8ffa77ba65b712ed4ffb73974286
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.common.data;
|
package com.google.gerrit.common.data;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
|
|
||||||
@@ -46,17 +48,27 @@ public class GroupReference implements Comparable<GroupReference> {
|
|||||||
/**
|
/**
|
||||||
* Create a group reference.
|
* Create a group reference.
|
||||||
*
|
*
|
||||||
* @param uuid UUID of the group, may be {@code null} if the group name couldn't be resolved
|
* @param uuid UUID of the group, must not be {@code null}
|
||||||
* @param name the group name, must not be {@code null}
|
* @param name the group name, must not be {@code null}
|
||||||
*/
|
*/
|
||||||
public GroupReference(@Nullable AccountGroup.UUID uuid, String name) {
|
public GroupReference(AccountGroup.UUID uuid, String name) {
|
||||||
setUUID(uuid);
|
setUUID(requireNonNull(uuid));
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a group reference where the group's name couldn't be resolved.
|
||||||
|
*
|
||||||
|
* @param name the group name, must not be {@code null}
|
||||||
|
*/
|
||||||
|
public GroupReference(String name) {
|
||||||
|
setUUID(null);
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AccountGroup.UUID getUUID() {
|
public AccountGroup.UUID getUUID() {
|
||||||
return uuid != null ? new AccountGroup.UUID(uuid) : null;
|
return uuid != null ? AccountGroup.uuid(uuid) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUUID(@Nullable AccountGroup.UUID newUUID) {
|
public void setUUID(@Nullable AccountGroup.UUID newUUID) {
|
||||||
|
|||||||
@@ -117,8 +117,7 @@ public class ElasticGroupIndex extends AbstractElasticIndex<AccountGroup.UUID, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
AccountGroup.UUID uuid =
|
AccountGroup.UUID uuid =
|
||||||
new AccountGroup.UUID(
|
AccountGroup.uuid(source.getAsJsonObject().get(GroupField.UUID.getName()).getAsString());
|
||||||
source.getAsJsonObject().get(GroupField.UUID.getName()).getAsString());
|
|
||||||
// Use the GroupCache rather than depending on any stored fields in the
|
// Use the GroupCache rather than depending on any stored fields in the
|
||||||
// document (of which there shouldn't be any).
|
// document (of which there shouldn't be any).
|
||||||
return groupCache.get().get(uuid).orElse(null);
|
return groupCache.get().get(uuid).orElse(null);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class LuceneGroupIndex extends AbstractLuceneIndex<AccountGroup.UUID, Int
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InternalGroup fromDocument(Document doc) {
|
protected InternalGroup fromDocument(Document doc) {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(doc.getField(UUID.getName()).stringValue());
|
AccountGroup.UUID uuid = AccountGroup.uuid(doc.getField(UUID.getName()).stringValue());
|
||||||
// Use the GroupCache rather than depending on any stored fields in the
|
// Use the GroupCache rather than depending on any stored fields in the
|
||||||
// document (of which there shouldn't be any).
|
// document (of which there shouldn't be any).
|
||||||
return groupCache.get().get(uuid).orElse(null);
|
return groupCache.get().get(uuid).orElse(null);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ 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.StandardKeyEncoder;
|
||||||
import com.google.gwtorm.client.StringKey;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -59,33 +58,22 @@ public final class AccountGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UUID uuid(String n) {
|
||||||
|
return new AutoValue_AccountGroup_UUID(n);
|
||||||
|
}
|
||||||
|
|
||||||
/** Globally unique identifier. */
|
/** Globally unique identifier. */
|
||||||
public static class UUID extends StringKey<com.google.gwtorm.client.Key<?>> {
|
@AutoValue
|
||||||
private static final long serialVersionUID = 1L;
|
public abstract static class UUID implements Comparable<UUID> {
|
||||||
|
abstract String uuid();
|
||||||
|
|
||||||
protected String uuid;
|
|
||||||
|
|
||||||
protected UUID() {}
|
|
||||||
|
|
||||||
public UUID(String n) {
|
|
||||||
uuid = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get() {
|
public String get() {
|
||||||
return uuid;
|
return uuid();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void set(String newValue) {
|
|
||||||
uuid = newValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse an {@link AccountGroup.UUID} out of a string representation. */
|
/** Parse an {@link AccountGroup.UUID} out of a string representation. */
|
||||||
public static UUID parse(String str) {
|
public static UUID parse(String str) {
|
||||||
final UUID r = new UUID();
|
return AccountGroup.uuid(new StandardKeyEncoder().decode(str));
|
||||||
r.fromString(str);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse an {@link AccountGroup.UUID} out of a ref-name. */
|
/** Parse an {@link AccountGroup.UUID} out of a ref-name. */
|
||||||
@@ -107,7 +95,17 @@ public final class AccountGroup {
|
|||||||
*/
|
*/
|
||||||
public static UUID fromRefPart(String refPart) {
|
public static UUID fromRefPart(String refPart) {
|
||||||
String uuid = RefNames.parseShardedUuidFromRefPart(refPart);
|
String uuid = RefNames.parseShardedUuidFromRefPart(refPart);
|
||||||
return uuid != null ? new AccountGroup.UUID(uuid) : null;
|
return uuid != null ? AccountGroup.uuid(uuid) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(UUID o) {
|
||||||
|
return uuid().compareTo(o.uuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new StandardKeyEncoder().encode(get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class GroupCacheImpl implements GroupCache {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<InternalGroup> load(String uuid) throws Exception {
|
public Optional<InternalGroup> load(String uuid) throws Exception {
|
||||||
try (TraceTimer timer = TraceContext.newTimer("Loading group %s by UUID", uuid)) {
|
try (TraceTimer timer = TraceContext.newTimer("Loading group %s by UUID", uuid)) {
|
||||||
return groups.getGroup(new AccountGroup.UUID(uuid));
|
return groups.getGroup(AccountGroup.uuid(uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class GroupUUID {
|
|||||||
md.update(Constants.encode("group " + groupName + "\n"));
|
md.update(Constants.encode("group " + groupName + "\n"));
|
||||||
md.update(Constants.encode("creator " + creator.toExternalString() + "\n"));
|
md.update(Constants.encode("creator " + creator.toExternalString() + "\n"));
|
||||||
md.update(Constants.encode(String.valueOf(Math.random())));
|
md.update(Constants.encode(String.valueOf(Math.random())));
|
||||||
return new AccountGroup.UUID(ObjectId.fromRaw(md.digest()).name());
|
return AccountGroup.uuid(ObjectId.fromRaw(md.digest()).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private GroupUUID() {}
|
private GroupUUID() {}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class UniversalGroupBackend implements GroupBackend {
|
|||||||
cfg.getSubsections("groups").stream()
|
cfg.getSubsections("groups").stream()
|
||||||
.filter(
|
.filter(
|
||||||
sub -> {
|
sub -> {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(sub);
|
AccountGroup.UUID uuid = AccountGroup.uuid(sub);
|
||||||
GroupBackend groupBackend = universalGroupBackend.backend(uuid);
|
GroupBackend groupBackend = universalGroupBackend.backend(uuid);
|
||||||
return groupBackend == null || groupBackend.get(uuid) == null;
|
return groupBackend == null || groupBackend.get(uuid) == null;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class AccountGroupUUIDHandler extends OptionHandler<AccountGroup.UUID> {
|
|||||||
@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);
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(n);
|
AccountGroup.UUID uuid = AccountGroup.uuid(n);
|
||||||
if (groupBackend.handles(uuid)) {
|
if (groupBackend.handles(uuid)) {
|
||||||
GroupDescription.Basic d = groupBackend.get(uuid);
|
GroupDescription.Basic d = groupBackend.get(uuid);
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ class Helper {
|
|||||||
|
|
||||||
final Set<AccountGroup.UUID> actual = new HashSet<>();
|
final Set<AccountGroup.UUID> actual = new HashSet<>();
|
||||||
for (String dn : groupDNs) {
|
for (String dn : groupDNs) {
|
||||||
actual.add(new AccountGroup.UUID(LDAP_UUID + dn));
|
actual.add(AccountGroup.uuid(LDAP_UUID + dn));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actual.isEmpty()) {
|
if (actual.isEmpty()) {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class LdapGroupBackend implements GroupBackend {
|
|||||||
private static GroupReference groupReference(ParameterizedString p, LdapQuery.Result res)
|
private static GroupReference groupReference(ParameterizedString p, LdapQuery.Result res)
|
||||||
throws NamingException {
|
throws NamingException {
|
||||||
return new GroupReference(
|
return new GroupReference(
|
||||||
new AccountGroup.UUID(LDAP_UUID + res.getDN()), LDAP_NAME + LdapRealm.apply(p, res));
|
AccountGroup.uuid(LDAP_UUID + res.getDN()), LDAP_NAME + LdapRealm.apply(p, res));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String cnFor(String dn) {
|
private static String cnFor(String dn) {
|
||||||
@@ -164,7 +164,7 @@ public class LdapGroupBackend implements GroupBackend {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<GroupReference> suggest(String name, ProjectState project) {
|
public Collection<GroupReference> suggest(String name, ProjectState project) {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(name);
|
AccountGroup.UUID uuid = AccountGroup.uuid(name);
|
||||||
if (isLdapUUID(uuid)) {
|
if (isLdapUUID(uuid)) {
|
||||||
GroupDescription.Basic g = get(uuid);
|
GroupDescription.Basic g = get(uuid);
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class GroupResolver {
|
|||||||
* @return the group, null if no group is found for the given group ID
|
* @return the group, null if no group is found for the given group ID
|
||||||
*/
|
*/
|
||||||
public GroupDescription.Basic parseId(String id) {
|
public GroupDescription.Basic parseId(String id) {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(id);
|
AccountGroup.UUID uuid = AccountGroup.uuid(id);
|
||||||
if (groupBackend.handles(uuid)) {
|
if (groupBackend.handles(uuid)) {
|
||||||
GroupDescription.Basic d = groupBackend.get(uuid);
|
GroupDescription.Basic d = groupBackend.get(uuid);
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
|
|||||||
@@ -56,19 +56,19 @@ public class SystemGroupBackend extends AbstractGroupBackend {
|
|||||||
|
|
||||||
/** Common UUID assigned to the "Anonymous Users" group. */
|
/** Common UUID assigned to the "Anonymous Users" group. */
|
||||||
public static final AccountGroup.UUID ANONYMOUS_USERS =
|
public static final AccountGroup.UUID ANONYMOUS_USERS =
|
||||||
new AccountGroup.UUID(SYSTEM_GROUP_SCHEME + "Anonymous-Users");
|
AccountGroup.uuid(SYSTEM_GROUP_SCHEME + "Anonymous-Users");
|
||||||
|
|
||||||
/** Common UUID assigned to the "Registered Users" group. */
|
/** Common UUID assigned to the "Registered Users" group. */
|
||||||
public static final AccountGroup.UUID REGISTERED_USERS =
|
public static final AccountGroup.UUID REGISTERED_USERS =
|
||||||
new AccountGroup.UUID(SYSTEM_GROUP_SCHEME + "Registered-Users");
|
AccountGroup.uuid(SYSTEM_GROUP_SCHEME + "Registered-Users");
|
||||||
|
|
||||||
/** Common UUID assigned to the "Project Owners" placeholder group. */
|
/** Common UUID assigned to the "Project Owners" placeholder group. */
|
||||||
public static final AccountGroup.UUID PROJECT_OWNERS =
|
public static final AccountGroup.UUID PROJECT_OWNERS =
|
||||||
new AccountGroup.UUID(SYSTEM_GROUP_SCHEME + "Project-Owners");
|
AccountGroup.uuid(SYSTEM_GROUP_SCHEME + "Project-Owners");
|
||||||
|
|
||||||
/** Common UUID assigned to the "Change Owner" placeholder group. */
|
/** Common UUID assigned to the "Change Owner" placeholder group. */
|
||||||
public static final AccountGroup.UUID CHANGE_OWNER =
|
public static final AccountGroup.UUID CHANGE_OWNER =
|
||||||
new AccountGroup.UUID(SYSTEM_GROUP_SCHEME + "Change-Owner");
|
AccountGroup.uuid(SYSTEM_GROUP_SCHEME + "Change-Owner");
|
||||||
|
|
||||||
private static final AccountGroup.UUID[] all = {
|
private static final AccountGroup.UUID[] all = {
|
||||||
ANONYMOUS_USERS, REGISTERED_USERS, PROJECT_OWNERS, CHANGE_OWNER,
|
ANONYMOUS_USERS, REGISTERED_USERS, PROJECT_OWNERS, CHANGE_OWNER,
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class AuditLogReader {
|
|||||||
logInvalid(uuid, c, line);
|
logInvalid(uuid, c, line);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return Optional.of(new AccountGroup.UUID(ident.getEmailAddress()));
|
return Optional.of(AccountGroup.uuid(ident.getEmailAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logInvalid(AccountGroup.UUID uuid, RevCommit c, FooterLine line) {
|
private static void logInvalid(AccountGroup.UUID uuid, RevCommit c, FooterLine line) {
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ public class GroupConfig extends VersionedMetaData {
|
|||||||
|
|
||||||
private ImmutableSet<AccountGroup.UUID> readSubgroups()
|
private ImmutableSet<AccountGroup.UUID> readSubgroups()
|
||||||
throws IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
return readFromFile(SUBGROUPS_FILE, AccountGroup.UUID::new);
|
return readFromFile(SUBGROUPS_FILE, AccountGroup::uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E> ImmutableSet<E> readFromFile(String filePath, Function<String, E> fromStringFunction)
|
private <E> ImmutableSet<E> readFromFile(String filePath, Function<String, E> fromStringFunction)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ enum GroupConfigEntry {
|
|||||||
throw new ConfigInvalidException(
|
throw new ConfigInvalidException(
|
||||||
String.format("Owner UUID of the group %s must be defined", groupUuid.get()));
|
String.format("Owner UUID of the group %s must be defined", groupUuid.get()));
|
||||||
}
|
}
|
||||||
group.setOwnerGroupUUID(new AccountGroup.UUID(ownerGroupUuid));
|
group.setOwnerGroupUUID(AccountGroup.uuid(ownerGroupUuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
|||||||
throw new ConfigInvalidException(String.format("UUID for group '%s' must be defined", name));
|
throw new ConfigInvalidException(String.format("UUID for group '%s' must be defined", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GroupReference(new AccountGroup.UUID(uuid), name);
|
return new GroupReference(AccountGroup.uuid(uuid), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCommitMessage() {
|
private String getCommitMessage() {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class TestGroupBackend implements GroupBackend {
|
|||||||
*/
|
*/
|
||||||
public GroupDescription.Basic create(String name) {
|
public GroupDescription.Basic create(String name) {
|
||||||
requireNonNull(name);
|
requireNonNull(name);
|
||||||
return create(new AccountGroup.UUID(name.startsWith(PREFIX) ? name : PREFIX + name));
|
return create(AccountGroup.uuid(name.startsWith(PREFIX) ? name : PREFIX + name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class ContributorAgreementsChecker {
|
|||||||
if ((rule.getAction() == Action.ALLOW)
|
if ((rule.getAction() == Action.ALLOW)
|
||||||
&& (rule.getGroup() != null)
|
&& (rule.getGroup() != null)
|
||||||
&& (rule.getGroup().getUUID() != null)) {
|
&& (rule.getGroup().getUUID() != null)) {
|
||||||
groupIds.add(new AccountGroup.UUID(rule.getGroup().getUUID().get()));
|
groupIds.add(AccountGroup.uuid(rule.getGroup().getUUID().get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class GroupList extends TabFile {
|
|||||||
logger.atWarning().log("null field in group list for %s:\n%s", project, text);
|
logger.atWarning().log("null field in group list for %s:\n%s", project, text);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(row.left);
|
AccountGroup.UUID uuid = AccountGroup.uuid(row.left);
|
||||||
String name = row.right;
|
String name = row.right;
|
||||||
GroupReference ref = new GroupReference(uuid, name);
|
GroupReference ref = new GroupReference(uuid, name);
|
||||||
|
|
||||||
|
|||||||
@@ -709,7 +709,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||||||
if (groupName != null) {
|
if (groupName != null) {
|
||||||
GroupReference ref = groupsByName.get(groupName);
|
GroupReference ref = groupsByName.get(groupName);
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
ref = new GroupReference(null, groupName);
|
ref = new GroupReference(groupName);
|
||||||
groupsByName.put(ref.getName(), ref);
|
groupsByName.put(ref.getName(), ref);
|
||||||
}
|
}
|
||||||
if (ref.getUUID() != null) {
|
if (ref.getUUID() != null) {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import com.google.gerrit.server.project.ProjectConfig;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
public static final AccountGroup.UUID ADMIN = new AccountGroup.UUID("test.admin");
|
public static final AccountGroup.UUID ADMIN = AccountGroup.uuid("test.admin");
|
||||||
public static final AccountGroup.UUID DEVS = new AccountGroup.UUID("test.devs");
|
public static final AccountGroup.UUID DEVS = AccountGroup.uuid("test.devs");
|
||||||
|
|
||||||
public static final LabelType codeReview() {
|
public static final LabelType codeReview() {
|
||||||
return category(
|
return category(
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class GroupQueryBuilder extends QueryBuilder<InternalGroup, GroupQueryBui
|
|||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
public Predicate<InternalGroup> uuid(String uuid) {
|
public Predicate<InternalGroup> uuid(String uuid) {
|
||||||
return GroupPredicates.uuid(new AccountGroup.UUID(uuid));
|
return GroupPredicates.uuid(AccountGroup.uuid(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
@@ -169,7 +169,7 @@ public class GroupQueryBuilder extends QueryBuilder<InternalGroup, GroupQueryBui
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AccountGroup.UUID parseGroup(String groupNameOrUuid) throws QueryParseException {
|
private AccountGroup.UUID parseGroup(String groupNameOrUuid) throws QueryParseException {
|
||||||
Optional<InternalGroup> group = args.groupCache.get(new AccountGroup.UUID(groupNameOrUuid));
|
Optional<InternalGroup> group = args.groupCache.get(AccountGroup.uuid(groupNameOrUuid));
|
||||||
if (group.isPresent()) {
|
if (group.isPresent()) {
|
||||||
return group.get().getGroupUUID();
|
return group.get().getGroupUUID();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class ListGroupsCommand extends SshCommand {
|
|||||||
if (verboseOutput) {
|
if (verboseOutput) {
|
||||||
Optional<InternalGroup> group =
|
Optional<InternalGroup> group =
|
||||||
info.ownerId != null
|
info.ownerId != null
|
||||||
? groupCache.get(new AccountGroup.UUID(Url.decode(info.ownerId)))
|
? groupCache.get(AccountGroup.uuid(Url.decode(info.ownerId)))
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
|
|
||||||
formatter.addColumn(Url.decode(info.id));
|
formatter.addColumn(Url.decode(info.id));
|
||||||
|
|||||||
@@ -412,9 +412,9 @@ public class ProjectResetterTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void groupEviction() throws Exception {
|
public void groupEviction() throws Exception {
|
||||||
AccountGroup.UUID uuid1 = new AccountGroup.UUID("abcd1");
|
AccountGroup.UUID uuid1 = AccountGroup.uuid("abcd1");
|
||||||
AccountGroup.UUID uuid2 = new AccountGroup.UUID("abcd2");
|
AccountGroup.UUID uuid2 = AccountGroup.uuid("abcd2");
|
||||||
AccountGroup.UUID uuid3 = new AccountGroup.UUID("abcd3");
|
AccountGroup.UUID uuid3 = AccountGroup.uuid("abcd3");
|
||||||
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
|
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
|
||||||
Repository allUsersRepo = repoManager.createRepository(allUsers);
|
Repository allUsersRepo = repoManager.createRepository(allUsers);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class TestGroupBackendTest extends AbstractDaemonTest {
|
|||||||
@Inject private UniversalGroupBackend universalGroupBackend;
|
@Inject private UniversalGroupBackend universalGroupBackend;
|
||||||
|
|
||||||
private final TestGroupBackend testGroupBackend = new TestGroupBackend();
|
private final TestGroupBackend testGroupBackend = new TestGroupBackend();
|
||||||
private final AccountGroup.UUID testUUID = new AccountGroup.UUID("testbackend:test");
|
private final AccountGroup.UUID testUUID = AccountGroup.uuid("testbackend:test");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handlesTestGroup() throws Exception {
|
public void handlesTestGroup() throws Exception {
|
||||||
@@ -49,7 +49,7 @@ public class TestGroupBackendTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doesNotHandleLDAP() throws Exception {
|
public void doesNotHandleLDAP() throws Exception {
|
||||||
assertThat(testGroupBackend.handles(new AccountGroup.UUID("ldap:1234"))).isFalse();
|
assertThat(testGroupBackend.handles(AccountGroup.uuid("ldap:1234"))).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID g = groupOperations.newGroup().name(name).create();
|
AccountGroup.UUID g = groupOperations.newGroup().name(name).create();
|
||||||
GroupApi groupApi = gApi.groups().id(g.get());
|
GroupApi groupApi = gApi.groups().id(g.get());
|
||||||
groupApi.description("CLA test group");
|
groupApi.description("CLA test group");
|
||||||
InternalGroup caGroup = group(new AccountGroup.UUID(groupApi.detail().id));
|
InternalGroup caGroup = group(AccountGroup.uuid(groupApi.detail().id));
|
||||||
GroupReference groupRef = new GroupReference(caGroup.getGroupUUID(), caGroup.getName());
|
GroupReference groupRef = new GroupReference(caGroup.getGroupUUID(), caGroup.getName());
|
||||||
PermissionRule rule = new PermissionRule(groupRef);
|
PermissionRule rule = new PermissionRule(groupRef);
|
||||||
rule.setAction(PermissionRule.Action.ALLOW);
|
rule.setAction(PermissionRule.Action.ALLOW);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class GroupIndexerIT {
|
|||||||
@Test
|
@Test
|
||||||
public void indexingUpdatesTheIndex() throws Exception {
|
public void indexingUpdatesTheIndex() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = createGroup("users");
|
AccountGroup.UUID groupUuid = createGroup("users");
|
||||||
AccountGroup.UUID subgroupUuid = new AccountGroup.UUID("contributors");
|
AccountGroup.UUID subgroupUuid = AccountGroup.uuid("contributors");
|
||||||
updateGroupWithoutCacheOrIndex(
|
updateGroupWithoutCacheOrIndex(
|
||||||
groupUuid,
|
groupUuid,
|
||||||
newGroupUpdate()
|
newGroupUpdate()
|
||||||
@@ -74,7 +74,7 @@ public class GroupIndexerIT {
|
|||||||
public void indexCannotBeCorruptedByStaleCache() throws Exception {
|
public void indexCannotBeCorruptedByStaleCache() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = createGroup("verifiers");
|
AccountGroup.UUID groupUuid = createGroup("verifiers");
|
||||||
loadGroupToCache(groupUuid);
|
loadGroupToCache(groupUuid);
|
||||||
AccountGroup.UUID subgroupUuid = new AccountGroup.UUID("contributors");
|
AccountGroup.UUID subgroupUuid = AccountGroup.uuid("contributors");
|
||||||
updateGroupWithoutCacheOrIndex(
|
updateGroupWithoutCacheOrIndex(
|
||||||
groupUuid,
|
groupUuid,
|
||||||
newGroupUpdate()
|
newGroupUpdate()
|
||||||
@@ -102,7 +102,7 @@ public class GroupIndexerIT {
|
|||||||
@Test
|
@Test
|
||||||
public void reindexingStaleGroupUpdatesTheIndex() throws Exception {
|
public void reindexingStaleGroupUpdatesTheIndex() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = createGroup("users");
|
AccountGroup.UUID groupUuid = createGroup("users");
|
||||||
AccountGroup.UUID subgroupUuid = new AccountGroup.UUID("contributors");
|
AccountGroup.UUID subgroupUuid = AccountGroup.uuid("contributors");
|
||||||
updateGroupWithoutCacheOrIndex(
|
updateGroupWithoutCacheOrIndex(
|
||||||
groupUuid,
|
groupUuid,
|
||||||
newGroupUpdate()
|
newGroupUpdate()
|
||||||
@@ -139,7 +139,7 @@ public class GroupIndexerIT {
|
|||||||
|
|
||||||
private AccountGroup.UUID createGroup(String name) throws RestApiException {
|
private AccountGroup.UUID createGroup(String name) throws RestApiException {
|
||||||
GroupInfo group = gApi.groups().create(name).get();
|
GroupInfo group = gApi.groups().create(name).get();
|
||||||
return new AccountGroup.UUID(group.id);
|
return AccountGroup.uuid(group.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadGroupToCache(AccountGroup.UUID groupUuid) {
|
private void reloadGroupToCache(AccountGroup.UUID groupUuid) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
public void missingGroupRef() throws Exception {
|
public void missingGroupRef() throws Exception {
|
||||||
|
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
RefUpdate ru = repo.updateRef(RefNames.refsGroups(new AccountGroup.UUID(g1.id)));
|
RefUpdate ru = repo.updateRef(RefNames.refsGroups(AccountGroup.uuid(g1.id)));
|
||||||
ru.setForceUpdate(true);
|
ru.setForceUpdate(true);
|
||||||
RefUpdate.Result result = ru.delete();
|
RefUpdate.Result result = ru.delete();
|
||||||
assertThat(result).isEqualTo(Result.FORCED);
|
assertThat(result).isEqualTo(Result.FORCED);
|
||||||
@@ -109,7 +109,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
RefRename ru =
|
RefRename ru =
|
||||||
repo.renameRef(
|
repo.renameRef(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)), RefNames.REFS_GROUPS + BOGUS_UUID);
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)), RefNames.REFS_GROUPS + BOGUS_UUID);
|
||||||
RefUpdate.Result result = ru.rename();
|
RefUpdate.Result result = ru.rename();
|
||||||
assertThat(result).isEqualTo(Result.RENAMED);
|
assertThat(result).isEqualTo(Result.RENAMED);
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,8 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
RefRename ru =
|
RefRename ru =
|
||||||
repo.renameRef(
|
repo.renameRef(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)),
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)),
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(BOGUS_UUID)));
|
RefNames.refsGroups(AccountGroup.uuid(BOGUS_UUID)));
|
||||||
RefUpdate.Result result = ru.rename();
|
RefUpdate.Result result = ru.rename();
|
||||||
assertThat(result).isEqualTo(Result.RENAMED);
|
assertThat(result).isEqualTo(Result.RENAMED);
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void groupRefDoesNotParse() throws Exception {
|
public void groupRefDoesNotParse() throws Exception {
|
||||||
updateGroupFile(
|
updateGroupFile(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)),
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)),
|
||||||
GroupConfig.GROUP_CONFIG_FILE,
|
GroupConfig.GROUP_CONFIG_FILE,
|
||||||
"[this is not valid\n");
|
"[this is not valid\n");
|
||||||
assertError("does not parse");
|
assertError("does not parse");
|
||||||
@@ -158,9 +158,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
cfg.setString("group", null, "ownerGroupUuid", gAdmin.id);
|
cfg.setString("group", null, "ownerGroupUuid", gAdmin.id);
|
||||||
|
|
||||||
updateGroupFile(
|
updateGroupFile(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)),
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)), GroupConfig.GROUP_CONFIG_FILE, cfg.toText());
|
||||||
GroupConfig.GROUP_CONFIG_FILE,
|
|
||||||
cfg.toText());
|
|
||||||
assertError("inconsistent name");
|
assertError("inconsistent name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,9 +170,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
cfg.setString("group", null, "ownerGroupUuid", gAdmin.id);
|
cfg.setString("group", null, "ownerGroupUuid", gAdmin.id);
|
||||||
|
|
||||||
updateGroupFile(
|
updateGroupFile(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)),
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)), GroupConfig.GROUP_CONFIG_FILE, cfg.toText());
|
||||||
GroupConfig.GROUP_CONFIG_FILE,
|
|
||||||
cfg.toText());
|
|
||||||
assertError("shared group id");
|
assertError("shared group id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +182,7 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
cfg.setString("group", null, "ownerGroupUuid", BOGUS_UUID);
|
cfg.setString("group", null, "ownerGroupUuid", BOGUS_UUID);
|
||||||
|
|
||||||
updateGroupFile(
|
updateGroupFile(
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)),
|
RefNames.refsGroups(AccountGroup.uuid(g1.id)), GroupConfig.GROUP_CONFIG_FILE, cfg.toText());
|
||||||
GroupConfig.GROUP_CONFIG_FILE,
|
|
||||||
cfg.toText());
|
|
||||||
assertError("nonexistent owner group");
|
assertError("nonexistent owner group");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,20 +202,19 @@ public class GroupsConsistencyIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonexistentMember() throws Exception {
|
public void nonexistentMember() throws Exception {
|
||||||
updateGroupFile(RefNames.refsGroups(new AccountGroup.UUID(g1.id)), "members", "314159265\n");
|
updateGroupFile(RefNames.refsGroups(AccountGroup.uuid(g1.id)), "members", "314159265\n");
|
||||||
assertError("nonexistent member 314159265");
|
assertError("nonexistent member 314159265");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonexistentSubgroup() throws Exception {
|
public void nonexistentSubgroup() throws Exception {
|
||||||
updateGroupFile(
|
updateGroupFile(RefNames.refsGroups(AccountGroup.uuid(g1.id)), "subgroups", BOGUS_UUID + "\n");
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(g1.id)), "subgroups", BOGUS_UUID + "\n");
|
|
||||||
assertError("has nonexistent subgroup");
|
assertError("has nonexistent subgroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cyclicSubgroup() throws Exception {
|
public void cyclicSubgroup() throws Exception {
|
||||||
updateGroupFile(RefNames.refsGroups(new AccountGroup.UUID(g1.id)), "subgroups", g1.id + "\n");
|
updateGroupFile(RefNames.refsGroups(AccountGroup.uuid(g1.id)), "subgroups", g1.id + "\n");
|
||||||
assertWarning("cycle");
|
assertWarning("cycle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
GroupInfo group = gApi.groups().create(groupInput).get();
|
GroupInfo group = gApi.groups().create(groupInput).get();
|
||||||
|
|
||||||
Collection<AccountGroup.UUID> groups = groupIncludeCache.getGroupsWithMember(accountId);
|
Collection<AccountGroup.UUID> groups = groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
assertThat(groups).containsExactly(new AccountGroup.UUID(group.id));
|
assertThat(groups).containsExactly(AccountGroup.uuid(group.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -805,13 +805,13 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
// By UUID
|
// By UUID
|
||||||
List<GroupInfo> owned = gApi.groups().list().withOwnedBy(parent.get()).get();
|
List<GroupInfo> owned = gApi.groups().list().withOwnedBy(parent.get()).get();
|
||||||
assertThat(owned.stream().map(g -> new AccountGroup.UUID(g.id)).collect(toList()))
|
assertThat(owned.stream().map(g -> AccountGroup.uuid(g.id)).collect(toList()))
|
||||||
.containsExactlyElementsIn(children);
|
.containsExactlyElementsIn(children);
|
||||||
|
|
||||||
// By name
|
// By name
|
||||||
String parentName = groupOperations.group(parent).get().name();
|
String parentName = groupOperations.group(parent).get().name();
|
||||||
owned = gApi.groups().list().withOwnedBy(parentName).get();
|
owned = gApi.groups().list().withOwnedBy(parentName).get();
|
||||||
assertThat(owned.stream().map(g -> new AccountGroup.UUID(g.id)).collect(toList()))
|
assertThat(owned.stream().map(g -> AccountGroup.uuid(g.id)).collect(toList()))
|
||||||
.containsExactlyElementsIn(children);
|
.containsExactlyElementsIn(children);
|
||||||
|
|
||||||
// By group that does not own any others
|
// By group that does not own any others
|
||||||
@@ -983,7 +983,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deleteGroupRef(String groupId) throws Exception {
|
private void deleteGroupRef(String groupId) throws Exception {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(groupId);
|
AccountGroup.UUID uuid = AccountGroup.uuid(groupId);
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
RefUpdate ru = repo.updateRef(RefNames.refsGroups(uuid));
|
RefUpdate ru = repo.updateRef(RefNames.refsGroups(uuid));
|
||||||
ru.setForceUpdate(true);
|
ru.setForceUpdate(true);
|
||||||
@@ -1036,8 +1036,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void pushToDeletedGroupBranchIsRejectedForAllUsersRepo() throws Exception {
|
public void pushToDeletedGroupBranchIsRejectedForAllUsersRepo() throws Exception {
|
||||||
String groupRef =
|
String groupRef =
|
||||||
RefNames.refsDeletedGroups(
|
RefNames.refsDeletedGroups(AccountGroup.uuid(gApi.groups().create(name("foo")).get().id));
|
||||||
new AccountGroup.UUID(gApi.groups().create(name("foo")).get().id));
|
|
||||||
createBranch(allUsers, groupRef);
|
createBranch(allUsers, groupRef);
|
||||||
assertPushToGroupBranch(allUsers, groupRef, "group update not allowed");
|
assertPushToGroupBranch(allUsers, groupRef, "group update not allowed");
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1052,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
public void pushToGroupsBranchForNonAllUsersRepo() throws Exception {
|
public void pushToGroupsBranchForNonAllUsersRepo() throws Exception {
|
||||||
assertCreateGroupBranch(project);
|
assertCreateGroupBranch(project);
|
||||||
String groupRef =
|
String groupRef =
|
||||||
RefNames.refsGroups(new AccountGroup.UUID(gApi.groups().create(name("foo")).get().id));
|
RefNames.refsGroups(AccountGroup.uuid(gApi.groups().create(name("foo")).get().id));
|
||||||
createBranch(project, groupRef);
|
createBranch(project, groupRef);
|
||||||
assertPushToGroupBranch(project, groupRef, null);
|
assertPushToGroupBranch(project, groupRef, null);
|
||||||
}
|
}
|
||||||
@@ -1062,8 +1061,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
public void pushToDeletedGroupsBranchForNonAllUsersRepo() throws Exception {
|
public void pushToDeletedGroupsBranchForNonAllUsersRepo() throws Exception {
|
||||||
assertCreateGroupBranch(project);
|
assertCreateGroupBranch(project);
|
||||||
String groupRef =
|
String groupRef =
|
||||||
RefNames.refsDeletedGroups(
|
RefNames.refsDeletedGroups(AccountGroup.uuid(gApi.groups().create(name("foo")).get().id));
|
||||||
new AccountGroup.UUID(gApi.groups().create(name("foo")).get().id));
|
|
||||||
createBranch(project, groupRef);
|
createBranch(project, groupRef);
|
||||||
assertPushToGroupBranch(project, groupRef, null);
|
assertPushToGroupBranch(project, groupRef, null);
|
||||||
}
|
}
|
||||||
@@ -1159,14 +1157,14 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void cannotCreateGroupBranch() throws Exception {
|
public void cannotCreateGroupBranch() throws Exception {
|
||||||
testCannotCreateGroupBranch(
|
testCannotCreateGroupBranch(
|
||||||
RefNames.REFS_GROUPS + "*", RefNames.refsGroups(new AccountGroup.UUID(name("foo"))));
|
RefNames.REFS_GROUPS + "*", RefNames.refsGroups(AccountGroup.uuid(name("foo"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cannotCreateDeletedGroupBranch() throws Exception {
|
public void cannotCreateDeletedGroupBranch() throws Exception {
|
||||||
testCannotCreateGroupBranch(
|
testCannotCreateGroupBranch(
|
||||||
RefNames.REFS_DELETED_GROUPS + "*",
|
RefNames.REFS_DELETED_GROUPS + "*",
|
||||||
RefNames.refsDeletedGroups(new AccountGroup.UUID(name("foo"))));
|
RefNames.refsDeletedGroups(AccountGroup.uuid(name("foo"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1216,7 +1214,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cannotDeleteDeletedGroupBranch() throws Exception {
|
public void cannotDeleteDeletedGroupBranch() throws Exception {
|
||||||
String groupRef = RefNames.refsDeletedGroups(new AccountGroup.UUID(name("foo")));
|
String groupRef = RefNames.refsDeletedGroups(AccountGroup.uuid(name("foo")));
|
||||||
createBranch(allUsers, groupRef);
|
createBranch(allUsers, groupRef);
|
||||||
testCannotDeleteGroupBranch(RefNames.REFS_DELETED_GROUPS + "*", groupRef);
|
testCannotDeleteGroupBranch(RefNames.REFS_DELETED_GROUPS + "*", groupRef);
|
||||||
}
|
}
|
||||||
@@ -1254,7 +1252,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
public void stalenessChecker() throws Exception {
|
public void stalenessChecker() throws Exception {
|
||||||
// Newly created group is not stale
|
// Newly created group is not stale
|
||||||
GroupInfo groupInfo = gApi.groups().create(name("foo")).get();
|
GroupInfo groupInfo = gApi.groups().create(name("foo")).get();
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(groupInfo.id);
|
AccountGroup.UUID groupUuid = AccountGroup.uuid(groupInfo.id);
|
||||||
assertThat(stalenessChecker.isStale(groupUuid)).isFalse();
|
assertThat(stalenessChecker.isStale(groupUuid)).isFalse();
|
||||||
|
|
||||||
// Manual update makes index document stale
|
// Manual update makes index document stale
|
||||||
@@ -1335,7 +1333,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
// Create a group without updating the cache or index,
|
// Create a group without updating the cache or index,
|
||||||
// then run the reindexer -> only the new group is reindexed.
|
// then run the reindexer -> only the new group is reindexed.
|
||||||
String groupName = "foo";
|
String groupName = "foo";
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(groupName + "-UUID");
|
AccountGroup.UUID groupUuid = AccountGroup.uuid(groupName + "-UUID");
|
||||||
groupsUpdate.createGroupInNoteDb(
|
groupsUpdate.createGroupInNoteDb(
|
||||||
InternalGroupCreation.builder()
|
InternalGroupCreation.builder()
|
||||||
.setGroupUUID(groupUuid)
|
.setGroupUUID(groupUuid)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class GroupsUpdateIT {
|
|||||||
.setMemberModification(
|
.setMemberModification(
|
||||||
new CreateAnotherGroupOnceAsSideEffectOfMemberModification("verifiers"))
|
new CreateAnotherGroupOnceAsSideEffectOfMemberModification("verifiers"))
|
||||||
.build();
|
.build();
|
||||||
updateGroup(new AccountGroup.UUID("users-UUID"), groupUpdate);
|
updateGroup(AccountGroup.uuid("users-UUID"), groupUpdate);
|
||||||
|
|
||||||
Stream<String> allGroupNames = getAllGroupNames();
|
Stream<String> allGroupNames = getAllGroupNames();
|
||||||
assertThat(allGroupNames).containsAllOf("contributors", "verifiers");
|
assertThat(allGroupNames).containsAllOf("contributors", "verifiers");
|
||||||
@@ -81,7 +81,7 @@ public class GroupsUpdateIT {
|
|||||||
InternalGroupUpdate.builder().setDescription("A description for the group").build();
|
InternalGroupUpdate.builder().setDescription("A description for the group").build();
|
||||||
|
|
||||||
expectedException.expect(NoSuchGroupException.class);
|
expectedException.expect(NoSuchGroupException.class);
|
||||||
updateGroup(new AccountGroup.UUID("nonexistent-group-UUID"), groupUpdate);
|
updateGroup(AccountGroup.uuid("nonexistent-group-UUID"), groupUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGroup(String groupName, String groupUuid) throws Exception {
|
private void createGroup(String groupName, String groupUuid) throws Exception {
|
||||||
@@ -107,7 +107,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(AccountGroup.uuid(groupUuid))
|
||||||
.setNameKey(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();
|
||||||
|
|||||||
@@ -792,7 +792,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
|||||||
groupInput.ownerId = ownerGroup != null ? ownerGroup.get() : null;
|
groupInput.ownerId = ownerGroup != null ? ownerGroup.get() : null;
|
||||||
groupInput.members =
|
groupInput.members =
|
||||||
Arrays.stream(members).map(m -> String.valueOf(m.id().get())).collect(toList());
|
Arrays.stream(members).map(m -> String.valueOf(m.id().get())).collect(toList());
|
||||||
return new AccountGroup.UUID(gApi.groups().create(groupInput).get().id);
|
return AccountGroup.uuid(gApi.groups().create(groupInput).get().id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, Ref> getAllRefs(Repository repo) throws IOException {
|
private static Map<String, Ref> getAllRefs(Repository repo) throws IOException {
|
||||||
|
|||||||
@@ -570,8 +570,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private void blockRead(GroupInfo group) throws Exception {
|
private void blockRead(GroupInfo group) throws Exception {
|
||||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||||
Util.block(
|
Util.block(u.getConfig(), Permission.READ, AccountGroup.uuid(group.id), "refs/heads/master");
|
||||||
u.getConfig(), Permission.READ, new AccountGroup.UUID(group.id), "refs/heads/master");
|
|
||||||
u.save();
|
u.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
|||||||
allow(allUsers, RefNames.REFS_GROUPS + "*", Permission.CREATE, REGISTERED_USERS);
|
allow(allUsers, RefNames.REFS_GROUPS + "*", Permission.CREATE, REGISTERED_USERS);
|
||||||
allow(allUsers, RefNames.REFS_GROUPS + "*", Permission.PUSH, REGISTERED_USERS);
|
allow(allUsers, RefNames.REFS_GROUPS + "*", Permission.PUSH, REGISTERED_USERS);
|
||||||
assertCreateFails(
|
assertCreateFails(
|
||||||
new Branch.NameKey(allUsers, RefNames.refsGroups(new AccountGroup.UUID("foo"))),
|
new Branch.NameKey(allUsers, RefNames.refsGroups(AccountGroup.uuid("foo"))),
|
||||||
RefNames.refsGroups(adminGroupUuid()),
|
RefNames.refsGroups(adminGroupUuid()),
|
||||||
ResourceConflictException.class,
|
ResourceConflictException.class,
|
||||||
"Not allowed to create group branch.");
|
"Not allowed to create group branch.");
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
|||||||
"refs/*",
|
"refs/*",
|
||||||
Permission.VIEW_PRIVATE_CHANGES,
|
Permission.VIEW_PRIVATE_CHANGES,
|
||||||
false,
|
false,
|
||||||
new AccountGroup.UUID(groupThatCanViewPrivateChanges.id));
|
AccountGroup.uuid(groupThatCanViewPrivateChanges.id));
|
||||||
|
|
||||||
// watch project as user that can't view private changes
|
// watch project as user that can't view private changes
|
||||||
requestScopeOperations.setApiUser(user.id());
|
requestScopeOperations.setApiUser(user.id());
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ public class ReflogIT extends AbstractDaemonTest {
|
|||||||
groupApi.addMembers("user");
|
groupApi.addMembers("user");
|
||||||
|
|
||||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||||
Util.allow(
|
Util.allow(u.getConfig(), Permission.OWNER, AccountGroup.uuid(groupApi.get().id), "refs/*");
|
||||||
u.getConfig(), Permission.OWNER, new AccountGroup.UUID(groupApi.get().id), "refs/*");
|
|
||||||
u.save();
|
u.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notExistingGroupCanBeCheckedForExistence() throws Exception {
|
public void notExistingGroupCanBeCheckedForExistence() throws Exception {
|
||||||
AccountGroup.UUID notExistingGroupUuid = new AccountGroup.UUID("not-existing-group");
|
AccountGroup.UUID notExistingGroupUuid = AccountGroup.uuid("not-existing-group");
|
||||||
|
|
||||||
boolean exists = groupOperations.group(notExistingGroupUuid).exists();
|
boolean exists = groupOperations.group(notExistingGroupUuid).exists();
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retrievingNotExistingGroupFails() throws Exception {
|
public void retrievingNotExistingGroupFails() throws Exception {
|
||||||
AccountGroup.UUID notExistingGroupUuid = new AccountGroup.UUID("not-existing-group");
|
AccountGroup.UUID notExistingGroupUuid = AccountGroup.uuid("not-existing-group");
|
||||||
|
|
||||||
exception.expect(IllegalStateException.class);
|
exception.expect(IllegalStateException.class);
|
||||||
groupOperations.group(notExistingGroupUuid).get();
|
groupOperations.group(notExistingGroupUuid).get();
|
||||||
@@ -296,7 +296,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ownerGroupUuidOfExistingGroupCanBeRetrieved() throws Exception {
|
public void ownerGroupUuidOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("owner group");
|
AccountGroup.UUID originalOwnerGroupUuid = AccountGroup.uuid("owner group");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void createdOnOfExistingGroupCanBeRetrieved() throws Exception {
|
public void createdOnOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
GroupInfo group = gApi.groups().create(createArbitraryGroupInput()).detail();
|
GroupInfo group = gApi.groups().create(createArbitraryGroupInput()).detail();
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(group.id);
|
AccountGroup.UUID groupUuid = AccountGroup.uuid(group.id);
|
||||||
|
|
||||||
Timestamp createdOn = groupOperations.group(groupUuid).get().createdOn();
|
Timestamp createdOn = groupOperations.group(groupUuid).get().createdOn();
|
||||||
|
|
||||||
@@ -351,9 +351,9 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subgroupsOfExistingGroupCanBeRetrieved() throws Exception {
|
public void subgroupsOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = AccountGroup.uuid("subgroup 3");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2, subgroupUuid3).create();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2, subgroupUuid3).create();
|
||||||
|
|
||||||
@@ -427,11 +427,11 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
||||||
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("original owner");
|
AccountGroup.UUID originalOwnerGroupUuid = AccountGroup.uuid("original owner");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
||||||
|
|
||||||
AccountGroup.UUID updatedOwnerGroupUuid = new AccountGroup.UUID("updated owner");
|
AccountGroup.UUID updatedOwnerGroupUuid = AccountGroup.uuid("updated owner");
|
||||||
groupOperations.group(groupUuid).forUpdate().ownerGroupUuid(updatedOwnerGroupUuid).update();
|
groupOperations.group(groupUuid).forUpdate().ownerGroupUuid(updatedOwnerGroupUuid).update();
|
||||||
|
|
||||||
AccountGroup.UUID currentOwnerGroupUuid =
|
AccountGroup.UUID currentOwnerGroupUuid =
|
||||||
@@ -520,8 +520,8 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void subgroupsCanBeAdded() throws Exception {
|
public void subgroupsCanBeAdded() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
groupOperations
|
groupOperations
|
||||||
.group(groupUuid)
|
.group(groupUuid)
|
||||||
.forUpdate()
|
.forUpdate()
|
||||||
@@ -535,8 +535,8 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subgroupsCanBeRemoved() throws Exception {
|
public void subgroupsCanBeRemoved() throws Exception {
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
@@ -548,12 +548,12 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subgroupAdditionAndRemovalCanBeMixed() throws Exception {
|
public void subgroupAdditionAndRemovalCanBeMixed() throws Exception {
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = AccountGroup.uuid("subgroup 3");
|
||||||
groupOperations
|
groupOperations
|
||||||
.group(groupUuid)
|
.group(groupUuid)
|
||||||
.forUpdate()
|
.forUpdate()
|
||||||
@@ -567,8 +567,8 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subgroupsCanBeCleared() throws Exception {
|
public void subgroupsCanBeCleared() throws Exception {
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
@@ -580,12 +580,12 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void furtherSubgroupsCanBeAddedAfterClearingAll() throws Exception {
|
public void furtherSubgroupsCanBeAddedAfterClearingAll() throws Exception {
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = AccountGroup.uuid("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = AccountGroup.uuid("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = AccountGroup.uuid("subgroup 3");
|
||||||
groupOperations
|
groupOperations
|
||||||
.group(groupUuid)
|
.group(groupUuid)
|
||||||
.forUpdate()
|
.forUpdate()
|
||||||
@@ -609,7 +609,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private AccountGroup.UUID createGroupInServer(GroupInput input) throws RestApiException {
|
private AccountGroup.UUID createGroupInServer(GroupInput input) throws RestApiException {
|
||||||
GroupInfo group = gApi.groups().create(input).detail();
|
GroupInfo group = gApi.groups().create(input).detail();
|
||||||
return new AccountGroup.UUID(group.id);
|
return AccountGroup.uuid(group.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Correspondence<AccountInfo, Account.Id> getAccountToIdCorrespondence() {
|
private static Correspondence<AccountInfo, Account.Id> getAccountToIdCorrespondence() {
|
||||||
@@ -631,7 +631,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
Optional.ofNullable(actualGroup)
|
Optional.ofNullable(actualGroup)
|
||||||
.map(group -> group.id)
|
.map(group -> group.id)
|
||||||
.map(AccountGroup.UUID::new)
|
.map(AccountGroup::uuid)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
return Objects.equals(groupUuid, expectedUuid);
|
return Objects.equals(groupUuid, expectedUuid);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void forGroupDescription() {
|
public void forGroupDescription() {
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("uuid-foo");
|
AccountGroup.UUID uuid = AccountGroup.uuid("uuid-foo");
|
||||||
GroupReference groupReference =
|
GroupReference groupReference =
|
||||||
GroupReference.forGroup(
|
GroupReference.forGroup(
|
||||||
new GroupDescription.Basic() {
|
new GroupDescription.Basic() {
|
||||||
@@ -56,7 +56,7 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void create() {
|
public void create() {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("uuid");
|
AccountGroup.UUID uuid = AccountGroup.uuid("uuid");
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
GroupReference groupReference = new GroupReference(uuid, name);
|
GroupReference groupReference = new GroupReference(uuid, name);
|
||||||
assertThat(groupReference.getUUID()).isEqualTo(uuid);
|
assertThat(groupReference.getUUID()).isEqualTo(uuid);
|
||||||
@@ -68,7 +68,7 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
// GroupReferences where the UUID is null are used to represent groups from project.config that
|
// GroupReferences where the UUID is null are used to represent groups from project.config that
|
||||||
// cannot be resolved.
|
// cannot be resolved.
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
GroupReference groupReference = new GroupReference(null, name);
|
GroupReference groupReference = new GroupReference(name);
|
||||||
assertThat(groupReference.getUUID()).isNull();
|
assertThat(groupReference.getUUID()).isNull();
|
||||||
assertThat(groupReference.getName()).isEqualTo(name);
|
assertThat(groupReference.getName()).isEqualTo(name);
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void cannotCreateWithoutName() {
|
public void cannotCreateWithoutName() {
|
||||||
exception.expect(NullPointerException.class);
|
exception.expect(NullPointerException.class);
|
||||||
new GroupReference(new AccountGroup.UUID("uuid"), null);
|
new GroupReference(AccountGroup.uuid("uuid"), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -99,12 +99,12 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAndSetUuid() {
|
public void getAndSetUuid() {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("uuid-foo");
|
AccountGroup.UUID uuid = AccountGroup.uuid("uuid-foo");
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
GroupReference groupReference = new GroupReference(uuid, name);
|
GroupReference groupReference = new GroupReference(uuid, name);
|
||||||
assertThat(groupReference.getUUID()).isEqualTo(uuid);
|
assertThat(groupReference.getUUID()).isEqualTo(uuid);
|
||||||
|
|
||||||
AccountGroup.UUID uuid2 = new AccountGroup.UUID("uuid-bar");
|
AccountGroup.UUID uuid2 = AccountGroup.uuid("uuid-bar");
|
||||||
groupReference.setUUID(uuid2);
|
groupReference.setUUID(uuid2);
|
||||||
assertThat(groupReference.getUUID()).isEqualTo(uuid2);
|
assertThat(groupReference.getUUID()).isEqualTo(uuid2);
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAndSetName() {
|
public void getAndSetName() {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("uuid-foo");
|
AccountGroup.UUID uuid = AccountGroup.uuid("uuid-foo");
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
GroupReference groupReference = new GroupReference(uuid, name);
|
GroupReference groupReference = new GroupReference(uuid, name);
|
||||||
assertThat(groupReference.getName()).isEqualTo(name);
|
assertThat(groupReference.getName()).isEqualTo(name);
|
||||||
@@ -132,14 +132,14 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void toConfigValue() {
|
public void toConfigValue() {
|
||||||
String name = "foo";
|
String name = "foo";
|
||||||
GroupReference groupReference = new GroupReference(new AccountGroup.UUID("uuid-foo"), name);
|
GroupReference groupReference = new GroupReference(AccountGroup.uuid("uuid-foo"), name);
|
||||||
assertThat(groupReference.toConfigValue()).isEqualTo("group " + name);
|
assertThat(groupReference.toConfigValue()).isEqualTo("group " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
AccountGroup.UUID uuid1 = new AccountGroup.UUID("uuid-foo");
|
AccountGroup.UUID uuid1 = AccountGroup.uuid("uuid-foo");
|
||||||
AccountGroup.UUID uuid2 = new AccountGroup.UUID("uuid-bar");
|
AccountGroup.UUID uuid2 = AccountGroup.uuid("uuid-bar");
|
||||||
String name1 = "foo";
|
String name1 = "foo";
|
||||||
String name2 = "bar";
|
String name2 = "bar";
|
||||||
|
|
||||||
@@ -154,12 +154,11 @@ public class GroupReferenceTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHashcode() {
|
public void testHashcode() {
|
||||||
AccountGroup.UUID uuid1 = new AccountGroup.UUID("uuid1");
|
AccountGroup.UUID uuid1 = AccountGroup.uuid("uuid1");
|
||||||
assertThat(new GroupReference(uuid1, "foo").hashCode())
|
assertThat(new GroupReference(uuid1, "foo").hashCode())
|
||||||
.isEqualTo(new GroupReference(uuid1, "bar").hashCode());
|
.isEqualTo(new GroupReference(uuid1, "bar").hashCode());
|
||||||
|
|
||||||
// Check that the following calls don't fail with an exception.
|
// Check that the following calls don't fail with an exception.
|
||||||
new GroupReference(null, "bar").hashCode();
|
new GroupReference("bar").hashCode();
|
||||||
new GroupReference(new AccountGroup.UUID(null), "bar").hashCode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.groupReference = new GroupReference(new AccountGroup.UUID("uuid"), "group");
|
this.groupReference = new GroupReference(AccountGroup.uuid("uuid"), "group");
|
||||||
this.permissionRule = new PermissionRule(groupReference);
|
this.permissionRule = new PermissionRule(groupReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setGroup() {
|
public void setGroup() {
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
assertThat(groupReference2).isNotEqualTo(groupReference);
|
assertThat(groupReference2).isNotEqualTo(groupReference);
|
||||||
|
|
||||||
assertThat(permissionRule.getGroup()).isEqualTo(groupReference);
|
assertThat(permissionRule.getGroup()).isEqualTo(groupReference);
|
||||||
@@ -142,10 +142,10 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromAnyBlock() {
|
public void mergeFromAnyBlock() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
|
|
||||||
permissionRule1.mergeFrom(permissionRule2);
|
permissionRule1.mergeFrom(permissionRule2);
|
||||||
@@ -170,10 +170,10 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromAnyDeny() {
|
public void mergeFromAnyDeny() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
|
|
||||||
permissionRule1.mergeFrom(permissionRule2);
|
permissionRule1.mergeFrom(permissionRule2);
|
||||||
@@ -193,10 +193,10 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromAnyBatch() {
|
public void mergeFromAnyBatch() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
|
|
||||||
permissionRule1.mergeFrom(permissionRule2);
|
permissionRule1.mergeFrom(permissionRule2);
|
||||||
@@ -216,10 +216,10 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromAnyForce() {
|
public void mergeFromAnyForce() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
|
|
||||||
permissionRule1.mergeFrom(permissionRule2);
|
permissionRule1.mergeFrom(permissionRule2);
|
||||||
@@ -239,11 +239,11 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromMergeRange() {
|
public void mergeFromMergeRange() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
permissionRule1.setRange(-1, 2);
|
permissionRule1.setRange(-1, 2);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
permissionRule2.setRange(-2, 1);
|
permissionRule2.setRange(-2, 1);
|
||||||
|
|
||||||
@@ -256,10 +256,10 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeFromGroupNotChanged() {
|
public void mergeFromGroupNotChanged() {
|
||||||
GroupReference groupReference1 = new GroupReference(new AccountGroup.UUID("uuid1"), "group1");
|
GroupReference groupReference1 = new GroupReference(AccountGroup.uuid("uuid1"), "group1");
|
||||||
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
PermissionRule permissionRule1 = new PermissionRule(groupReference1);
|
||||||
|
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
PermissionRule permissionRule2 = new PermissionRule(groupReference2);
|
||||||
|
|
||||||
permissionRule1.mergeFrom(permissionRule2);
|
permissionRule1.mergeFrom(permissionRule2);
|
||||||
@@ -348,7 +348,7 @@ public class PermissionRuleTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
GroupReference groupReference2 = new GroupReference(new AccountGroup.UUID("uuid2"), "group2");
|
GroupReference groupReference2 = new GroupReference(AccountGroup.uuid("uuid2"), "group2");
|
||||||
PermissionRule permissionRuleOther = new PermissionRule(groupReference2);
|
PermissionRule permissionRuleOther = new PermissionRule(groupReference2);
|
||||||
assertThat(permissionRule.equals(permissionRuleOther)).isFalse();
|
assertThat(permissionRule.equals(permissionRuleOther)).isFalse();
|
||||||
|
|
||||||
|
|||||||
@@ -155,14 +155,14 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void setAndGetRules() {
|
public void setAndGetRules() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
||||||
assertThat(permission.getRules()).containsExactly(permissionRule1, permissionRule2).inOrder();
|
assertThat(permission.getRules()).containsExactly(permissionRule1, permissionRule2).inOrder();
|
||||||
|
|
||||||
PermissionRule permissionRule3 =
|
PermissionRule permissionRule3 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-3"), "group3"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-3"), "group3"));
|
||||||
permission.setRules(ImmutableList.of(permissionRule3));
|
permission.setRules(ImmutableList.of(permissionRule3));
|
||||||
assertThat(permission.getRules()).containsExactly(permissionRule3);
|
assertThat(permission.getRules()).containsExactly(permissionRule3);
|
||||||
}
|
}
|
||||||
@@ -170,10 +170,10 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void cannotAddPermissionByModifyingListThatWasProvidedToAccessSection() {
|
public void cannotAddPermissionByModifyingListThatWasProvidedToAccessSection() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
GroupReference groupReference3 = new GroupReference(new AccountGroup.UUID("uuid-3"), "group3");
|
GroupReference groupReference3 = new GroupReference(AccountGroup.uuid("uuid-3"), "group3");
|
||||||
|
|
||||||
List<PermissionRule> rules = new ArrayList<>();
|
List<PermissionRule> rules = new ArrayList<>();
|
||||||
rules.add(permissionRule1);
|
rules.add(permissionRule1);
|
||||||
@@ -188,14 +188,14 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNonExistingRule() {
|
public void getNonExistingRule() {
|
||||||
GroupReference groupReference = new GroupReference(new AccountGroup.UUID("uuid-1"), "group1");
|
GroupReference groupReference = new GroupReference(AccountGroup.uuid("uuid-1"), "group1");
|
||||||
assertThat(permission.getRule(groupReference)).isNull();
|
assertThat(permission.getRule(groupReference)).isNull();
|
||||||
assertThat(permission.getRule(groupReference, false)).isNull();
|
assertThat(permission.getRule(groupReference, false)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRule() {
|
public void getRule() {
|
||||||
GroupReference groupReference = new GroupReference(new AccountGroup.UUID("uuid-1"), "group1");
|
GroupReference groupReference = new GroupReference(AccountGroup.uuid("uuid-1"), "group1");
|
||||||
PermissionRule permissionRule = new PermissionRule(groupReference);
|
PermissionRule permissionRule = new PermissionRule(groupReference);
|
||||||
permission.setRules(ImmutableList.of(permissionRule));
|
permission.setRules(ImmutableList.of(permissionRule));
|
||||||
assertThat(permission.getRule(groupReference)).isEqualTo(permissionRule);
|
assertThat(permission.getRule(groupReference)).isEqualTo(permissionRule);
|
||||||
@@ -203,7 +203,7 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createMissingRuleOnGet() {
|
public void createMissingRuleOnGet() {
|
||||||
GroupReference groupReference = new GroupReference(new AccountGroup.UUID("uuid-1"), "group1");
|
GroupReference groupReference = new GroupReference(AccountGroup.uuid("uuid-1"), "group1");
|
||||||
assertThat(permission.getRule(groupReference)).isNull();
|
assertThat(permission.getRule(groupReference)).isNull();
|
||||||
|
|
||||||
assertThat(permission.getRule(groupReference, true))
|
assertThat(permission.getRule(groupReference, true))
|
||||||
@@ -213,11 +213,11 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void addRule() {
|
public void addRule() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
||||||
GroupReference groupReference3 = new GroupReference(new AccountGroup.UUID("uuid-3"), "group3");
|
GroupReference groupReference3 = new GroupReference(AccountGroup.uuid("uuid-3"), "group3");
|
||||||
assertThat(permission.getRule(groupReference3)).isNull();
|
assertThat(permission.getRule(groupReference3)).isNull();
|
||||||
|
|
||||||
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
||||||
@@ -231,10 +231,10 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void removeRule() {
|
public void removeRule() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
GroupReference groupReference3 = new GroupReference(new AccountGroup.UUID("uuid-3"), "group3");
|
GroupReference groupReference3 = new GroupReference(AccountGroup.uuid("uuid-3"), "group3");
|
||||||
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
||||||
|
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2, permissionRule3));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2, permissionRule3));
|
||||||
@@ -248,10 +248,10 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void removeRuleByGroupReference() {
|
public void removeRuleByGroupReference() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
GroupReference groupReference3 = new GroupReference(new AccountGroup.UUID("uuid-3"), "group3");
|
GroupReference groupReference3 = new GroupReference(AccountGroup.uuid("uuid-3"), "group3");
|
||||||
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
PermissionRule permissionRule3 = new PermissionRule(groupReference3);
|
||||||
|
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2, permissionRule3));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2, permissionRule3));
|
||||||
@@ -265,9 +265,9 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void clearRules() {
|
public void clearRules() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
|
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
||||||
assertThat(permission.getRules()).isNotEmpty();
|
assertThat(permission.getRules()).isNotEmpty();
|
||||||
@@ -279,11 +279,11 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void mergePermissions() {
|
public void mergePermissions() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
PermissionRule permissionRule3 =
|
PermissionRule permissionRule3 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-3"), "group3"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-3"), "group3"));
|
||||||
|
|
||||||
Permission permission1 = new Permission("foo");
|
Permission permission1 = new Permission("foo");
|
||||||
permission1.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
permission1.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
||||||
@@ -300,9 +300,9 @@ public class PermissionTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
PermissionRule permissionRule1 =
|
PermissionRule permissionRule1 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-1"), "group1"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-1"), "group1"));
|
||||||
PermissionRule permissionRule2 =
|
PermissionRule permissionRule2 =
|
||||||
new PermissionRule(new GroupReference(new AccountGroup.UUID("uuid-2"), "group2"));
|
new PermissionRule(new GroupReference(AccountGroup.uuid("uuid-2"), "group2"));
|
||||||
|
|
||||||
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
permission.setRules(ImmutableList.of(permissionRule1, permissionRule2));
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.reviewdb.client;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.gerrit.reviewdb.client.AccountGroup.UUID.fromRef;
|
import static com.google.gerrit.reviewdb.client.AccountGroup.UUID.fromRef;
|
||||||
import static com.google.gerrit.reviewdb.client.AccountGroup.UUID.fromRefPart;
|
import static com.google.gerrit.reviewdb.client.AccountGroup.UUID.fromRefPart;
|
||||||
|
import static com.google.gerrit.reviewdb.client.AccountGroup.uuid;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -79,9 +80,9 @@ public class AccountGroupTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseUuid() {
|
public void parseUuid() {
|
||||||
assertThat(AccountGroup.UUID.parse("foo")).isEqualTo(new AccountGroup.UUID("foo"));
|
assertThat(AccountGroup.UUID.parse("foo")).isEqualTo(uuid("foo"));
|
||||||
assertThat(AccountGroup.UUID.parse("foo+bar")).isEqualTo(new AccountGroup.UUID("foo bar"));
|
assertThat(AccountGroup.UUID.parse("foo+bar")).isEqualTo(uuid("foo bar"));
|
||||||
assertThat(AccountGroup.UUID.parse("foo%3Abar")).isEqualTo(new AccountGroup.UUID("foo:bar"));
|
assertThat(AccountGroup.UUID.parse("foo%3Abar")).isEqualTo(uuid("foo:bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -95,8 +96,4 @@ public class AccountGroupTest {
|
|||||||
assertThat(AccountGroup.nameKey("foo bar").toString()).isEqualTo("foo+bar");
|
assertThat(AccountGroup.nameKey("foo bar").toString()).isEqualTo("foo+bar");
|
||||||
assertThat(AccountGroup.nameKey("foo:bar").toString()).isEqualTo("foo%3Abar");
|
assertThat(AccountGroup.nameKey("foo:bar").toString()).isEqualTo("foo%3Abar");
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccountGroup.UUID uuid(String uuid) {
|
|
||||||
return new AccountGroup.UUID(uuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,28 +58,28 @@ public class RefNamesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refForGroupIsSharded() throws Exception {
|
public void refForGroupIsSharded() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID("ABCDEFG");
|
AccountGroup.UUID groupUuid = AccountGroup.uuid("ABCDEFG");
|
||||||
String groupRef = RefNames.refsGroups(groupUuid);
|
String groupRef = RefNames.refsGroups(groupUuid);
|
||||||
assertThat(groupRef).isEqualTo("refs/groups/AB/ABCDEFG");
|
assertThat(groupRef).isEqualTo("refs/groups/AB/ABCDEFG");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refForGroupWithUuidLessThanTwoCharsIsRejected() throws Exception {
|
public void refForGroupWithUuidLessThanTwoCharsIsRejected() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID("A");
|
AccountGroup.UUID groupUuid = AccountGroup.uuid("A");
|
||||||
expectedException.expect(IllegalArgumentException.class);
|
expectedException.expect(IllegalArgumentException.class);
|
||||||
RefNames.refsGroups(groupUuid);
|
RefNames.refsGroups(groupUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refForDeletedGroupIsSharded() throws Exception {
|
public void refForDeletedGroupIsSharded() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID("ABCDEFG");
|
AccountGroup.UUID groupUuid = AccountGroup.uuid("ABCDEFG");
|
||||||
String groupRef = RefNames.refsDeletedGroups(groupUuid);
|
String groupRef = RefNames.refsDeletedGroups(groupUuid);
|
||||||
assertThat(groupRef).isEqualTo("refs/deleted-groups/AB/ABCDEFG");
|
assertThat(groupRef).isEqualTo("refs/deleted-groups/AB/ABCDEFG");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refForDeletedGroupWithUuidLessThanTwoCharsIsRejected() throws Exception {
|
public void refForDeletedGroupWithUuidLessThanTwoCharsIsRejected() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID("A");
|
AccountGroup.UUID groupUuid = AccountGroup.uuid("A");
|
||||||
expectedException.expect(IllegalArgumentException.class);
|
expectedException.expect(IllegalArgumentException.class);
|
||||||
RefNames.refsDeletedGroups(groupUuid);
|
RefNames.refsDeletedGroups(groupUuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UniversalGroupBackendTest extends GerritBaseTests {
|
public class UniversalGroupBackendTest extends GerritBaseTests {
|
||||||
private static final AccountGroup.UUID OTHER_UUID = new AccountGroup.UUID("other");
|
private static final AccountGroup.UUID OTHER_UUID = AccountGroup.uuid("other");
|
||||||
|
|
||||||
private UniversalGroupBackend backend;
|
private UniversalGroupBackend backend;
|
||||||
private IdentifiedUser user;
|
private IdentifiedUser user;
|
||||||
@@ -102,8 +102,8 @@ public class UniversalGroupBackendTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void otherMemberships() {
|
public void otherMemberships() {
|
||||||
final AccountGroup.UUID handled = new AccountGroup.UUID("handled");
|
final AccountGroup.UUID handled = AccountGroup.uuid("handled");
|
||||||
final AccountGroup.UUID notHandled = new AccountGroup.UUID("not handled");
|
final AccountGroup.UUID notHandled = AccountGroup.uuid("not handled");
|
||||||
final IdentifiedUser member = createNiceMock(IdentifiedUser.class);
|
final IdentifiedUser member = createNiceMock(IdentifiedUser.class);
|
||||||
final IdentifiedUser notMember = createNiceMock(IdentifiedUser.class);
|
final IdentifiedUser notMember = createNiceMock(IdentifiedUser.class);
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
private Project.NameKey projectName;
|
private Project.NameKey projectName;
|
||||||
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 = AccountGroup.uuid("users-XYZ");
|
||||||
private final AccountGroup.NameKey groupName = 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 =
|
||||||
@@ -194,7 +194,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedOwnerGroupUuidIsRespectedForNewGroup() throws Exception {
|
public void specifiedOwnerGroupUuidIsRespectedForNewGroup() throws Exception {
|
||||||
AccountGroup.UUID ownerGroupUuid = new AccountGroup.UUID("anotherOwnerUuid");
|
AccountGroup.UUID ownerGroupUuid = AccountGroup.uuid("anotherOwnerUuid");
|
||||||
|
|
||||||
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
@@ -205,26 +205,11 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
assertThatGroup(group).value().ownerGroupUuid().isEqualTo(ownerGroupUuid);
|
assertThatGroup(group).value().ownerGroupUuid().isEqualTo(ownerGroupUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ownerGroupUuidOfNewGroupMustNotBeNull() throws Exception {
|
|
||||||
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
|
||||||
InternalGroupUpdate groupUpdate =
|
|
||||||
InternalGroupUpdate.builder().setOwnerGroupUUID(new AccountGroup.UUID(null)).build();
|
|
||||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
|
||||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
|
||||||
|
|
||||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
|
||||||
exception.expectCause(instanceOf(ConfigInvalidException.class));
|
|
||||||
exception.expectMessage("Owner UUID of the group " + groupUuid);
|
|
||||||
groupConfig.commit(metaDataUpdate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ownerGroupUuidOfNewGroupMustNotBeEmpty() throws Exception {
|
public void ownerGroupUuidOfNewGroupMustNotBeEmpty() throws Exception {
|
||||||
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder().setOwnerGroupUUID(new AccountGroup.UUID("")).build();
|
InternalGroupUpdate.builder().setOwnerGroupUUID(AccountGroup.uuid("")).build();
|
||||||
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
GroupConfig groupConfig = GroupConfig.createForNewGroup(projectName, repository, groupCreation);
|
||||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||||
|
|
||||||
@@ -306,8 +291,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedSubgroupsAreRespectedForNewGroup() throws Exception {
|
public void specifiedSubgroupsAreRespectedForNewGroup() throws Exception {
|
||||||
AccountGroup.UUID subgroup1 = new AccountGroup.UUID("subgroup1");
|
AccountGroup.UUID subgroup1 = AccountGroup.uuid("subgroup1");
|
||||||
AccountGroup.UUID subgroup2 = new AccountGroup.UUID("subgroup2");
|
AccountGroup.UUID subgroup2 = AccountGroup.uuid("subgroup2");
|
||||||
|
|
||||||
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
@@ -481,12 +466,12 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
.value()
|
.value()
|
||||||
.subgroups()
|
.subgroups()
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
new AccountGroup.UUID("1"),
|
AccountGroup.uuid("1"),
|
||||||
new AccountGroup.UUID("2"),
|
AccountGroup.uuid("2"),
|
||||||
new AccountGroup.UUID("3"),
|
AccountGroup.uuid("3"),
|
||||||
new AccountGroup.UUID("4"),
|
AccountGroup.uuid("4"),
|
||||||
new AccountGroup.UUID("5"),
|
AccountGroup.uuid("5"),
|
||||||
new AccountGroup.UUID("6"));
|
AccountGroup.uuid("6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -495,7 +480,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
populateSubgroupsFile(groupUuid, "1\t2 3");
|
populateSubgroupsFile(groupUuid, "1\t2 3");
|
||||||
|
|
||||||
Optional<InternalGroup> group = loadGroup(groupUuid);
|
Optional<InternalGroup> group = loadGroup(groupUuid);
|
||||||
assertThatGroup(group).value().subgroups().containsExactly(new AccountGroup.UUID("1\t2 3"));
|
assertThatGroup(group).value().subgroups().containsExactly(AccountGroup.uuid("1\t2 3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -507,7 +492,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
assertThatGroup(group)
|
assertThatGroup(group)
|
||||||
.value()
|
.value()
|
||||||
.subgroups()
|
.subgroups()
|
||||||
.containsExactly(new AccountGroup.UUID("1\t2"), new AccountGroup.UUID("3"));
|
.containsExactly(AccountGroup.uuid("1\t2"), AccountGroup.uuid("3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -579,7 +564,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
AccountGroup.UUID newOwnerGroupUuid = new AccountGroup.UUID("New owner");
|
AccountGroup.UUID newOwnerGroupUuid = AccountGroup.uuid("New owner");
|
||||||
|
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder().setOwnerGroupUUID(newOwnerGroupUuid).build();
|
InternalGroupUpdate.builder().setOwnerGroupUUID(newOwnerGroupUuid).build();
|
||||||
@@ -589,29 +574,13 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
assertThatGroup(group).value().ownerGroupUuid().isEqualTo(newOwnerGroupUuid);
|
assertThatGroup(group).value().ownerGroupUuid().isEqualTo(newOwnerGroupUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ownerGroupUuidCannotBeUpdatedToNull() throws Exception {
|
|
||||||
createArbitraryGroup(groupUuid);
|
|
||||||
|
|
||||||
GroupConfig groupConfig = GroupConfig.loadForGroup(projectName, repository, groupUuid);
|
|
||||||
InternalGroupUpdate groupUpdate =
|
|
||||||
InternalGroupUpdate.builder().setOwnerGroupUUID(new AccountGroup.UUID(null)).build();
|
|
||||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
|
||||||
|
|
||||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
|
||||||
exception.expectCause(instanceOf(ConfigInvalidException.class));
|
|
||||||
exception.expectMessage("Owner UUID of the group " + groupUuid);
|
|
||||||
groupConfig.commit(metaDataUpdate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ownerGroupUuidCannotBeUpdatedToEmptyString() throws Exception {
|
public void ownerGroupUuidCannotBeUpdatedToEmptyString() 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().setOwnerGroupUUID(new AccountGroup.UUID("")).build();
|
InternalGroupUpdate.builder().setOwnerGroupUUID(AccountGroup.uuid("")).build();
|
||||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||||
|
|
||||||
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
try (MetaDataUpdate metaDataUpdate = createMetaDataUpdate()) {
|
||||||
@@ -703,8 +672,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void subgroupsCanBeAdded() throws Exception {
|
public void subgroupsCanBeAdded() throws Exception {
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
AccountGroup.UUID subgroup1 = new AccountGroup.UUID("subgroups1");
|
AccountGroup.UUID subgroup1 = AccountGroup.uuid("subgroups1");
|
||||||
AccountGroup.UUID subgroup2 = new AccountGroup.UUID("subgroups2");
|
AccountGroup.UUID subgroup2 = AccountGroup.uuid("subgroups2");
|
||||||
|
|
||||||
InternalGroupUpdate groupUpdate1 =
|
InternalGroupUpdate groupUpdate1 =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
@@ -725,8 +694,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void subgroupsCanBeDeleted() throws Exception {
|
public void subgroupsCanBeDeleted() throws Exception {
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
AccountGroup.UUID subgroup1 = new AccountGroup.UUID("subgroups1");
|
AccountGroup.UUID subgroup1 = AccountGroup.uuid("subgroups1");
|
||||||
AccountGroup.UUID subgroup2 = new AccountGroup.UUID("subgroups2");
|
AccountGroup.UUID subgroup2 = AccountGroup.uuid("subgroups2");
|
||||||
|
|
||||||
InternalGroupUpdate groupUpdate1 =
|
InternalGroupUpdate groupUpdate1 =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
@@ -769,13 +738,12 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
.setDescription("A test group")
|
.setDescription("A test group")
|
||||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
.setOwnerGroupUUID(AccountGroup.uuid("another owner"))
|
||||||
.setVisibleToAll(true)
|
.setVisibleToAll(true)
|
||||||
.setName(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(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
|
||||||
subgroups -> ImmutableSet.of(new AccountGroup.UUID("subgroup")))
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Optional<InternalGroup> createdGroup = createGroup(groupCreation, groupUpdate);
|
Optional<InternalGroup> createdGroup = createGroup(groupCreation, groupUpdate);
|
||||||
@@ -791,13 +759,12 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
.setDescription("A test group")
|
.setDescription("A test group")
|
||||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
.setOwnerGroupUUID(AccountGroup.uuid("another owner"))
|
||||||
.setVisibleToAll(true)
|
.setVisibleToAll(true)
|
||||||
.setName(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(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
|
||||||
subgroups -> ImmutableSet.of(new AccountGroup.UUID("subgroup")))
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Optional<InternalGroup> updatedGroup = updateGroup(groupUuid, groupUpdate);
|
Optional<InternalGroup> updatedGroup = updateGroup(groupUuid, groupUpdate);
|
||||||
@@ -814,13 +781,12 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
InternalGroupUpdate initialGroupUpdate =
|
InternalGroupUpdate initialGroupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
.setDescription("A test group")
|
.setDescription("A test group")
|
||||||
.setOwnerGroupUUID(new AccountGroup.UUID("another owner"))
|
.setOwnerGroupUUID(AccountGroup.uuid("another owner"))
|
||||||
.setVisibleToAll(true)
|
.setVisibleToAll(true)
|
||||||
.setName(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(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
|
||||||
subgroups -> ImmutableSet.of(new AccountGroup.UUID("subgroup")))
|
|
||||||
.build();
|
.build();
|
||||||
createGroup(groupCreation, initialGroupUpdate);
|
createGroup(groupCreation, initialGroupUpdate);
|
||||||
|
|
||||||
@@ -961,9 +927,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
|
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder().setOwnerGroupUUID(AccountGroup.uuid("Another owner")).build();
|
||||||
.setOwnerGroupUUID(new AccountGroup.UUID("Another owner"))
|
|
||||||
.build();
|
|
||||||
updateGroup(groupUuid, groupUpdate);
|
updateGroup(groupUuid, groupUpdate);
|
||||||
|
|
||||||
RevCommit commitBeforeUpdate = getLatestCommitForGroup(groupUuid);
|
RevCommit commitBeforeUpdate = getLatestCommitForGroup(groupUuid);
|
||||||
@@ -998,8 +962,7 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
.setSubgroupModification(
|
.setSubgroupModification(
|
||||||
subgroups ->
|
subgroups -> Sets.union(subgroups, ImmutableSet.of(AccountGroup.uuid("subgroup"))))
|
||||||
Sets.union(subgroups, ImmutableSet.of(new AccountGroup.UUID("subgroup"))))
|
|
||||||
.build();
|
.build();
|
||||||
updateGroup(groupUuid, groupUpdate);
|
updateGroup(groupUuid, groupUpdate);
|
||||||
|
|
||||||
@@ -1320,8 +1283,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void commitMessageOfNewGroupWithSubgroupsContainsFooters() throws Exception {
|
public void commitMessageOfNewGroupWithSubgroupsContainsFooters() throws Exception {
|
||||||
GroupDescription.Basic group1 = createGroup(new AccountGroup.UUID("129403"), "Bots");
|
GroupDescription.Basic group1 = createGroup(AccountGroup.uuid("129403"), "Bots");
|
||||||
GroupDescription.Basic group2 = createGroup(new AccountGroup.UUID("8903493"), "Verifiers");
|
GroupDescription.Basic group2 = createGroup(AccountGroup.uuid("8903493"), "Verifiers");
|
||||||
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
||||||
|
|
||||||
AuditLogFormatter auditLogFormatter =
|
AuditLogFormatter auditLogFormatter =
|
||||||
@@ -1394,8 +1357,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void commitMessageOfSubgroupAdditionContainsFooters() throws Exception {
|
public void commitMessageOfSubgroupAdditionContainsFooters() throws Exception {
|
||||||
GroupDescription.Basic group1 = createGroup(new AccountGroup.UUID("129403"), "Bots");
|
GroupDescription.Basic group1 = createGroup(AccountGroup.uuid("129403"), "Bots");
|
||||||
GroupDescription.Basic group2 = createGroup(new AccountGroup.UUID("8903493"), "Verifiers");
|
GroupDescription.Basic group2 = createGroup(AccountGroup.uuid("8903493"), "Verifiers");
|
||||||
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
||||||
|
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
@@ -1417,8 +1380,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void commitMessageOfSubgroupRemovalContainsFooters() throws Exception {
|
public void commitMessageOfSubgroupRemovalContainsFooters() throws Exception {
|
||||||
GroupDescription.Basic group1 = createGroup(new AccountGroup.UUID("129403"), "Bots");
|
GroupDescription.Basic group1 = createGroup(AccountGroup.uuid("129403"), "Bots");
|
||||||
GroupDescription.Basic group2 = createGroup(new AccountGroup.UUID("8903493"), "Verifiers");
|
GroupDescription.Basic group2 = createGroup(AccountGroup.uuid("8903493"), "Verifiers");
|
||||||
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
||||||
|
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
@@ -1466,8 +1429,8 @@ public class GroupConfigTest extends GerritBaseTests {
|
|||||||
Account account13 = createAccount(new Account.Id(13), "John");
|
Account account13 = createAccount(new Account.Id(13), "John");
|
||||||
Account account7 = createAccount(new Account.Id(7), "Jane");
|
Account account7 = createAccount(new Account.Id(7), "Jane");
|
||||||
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
|
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
|
||||||
GroupDescription.Basic group1 = createGroup(new AccountGroup.UUID("129403"), "Bots");
|
GroupDescription.Basic group1 = createGroup(AccountGroup.uuid("129403"), "Bots");
|
||||||
GroupDescription.Basic group2 = createGroup(new AccountGroup.UUID("8903493"), "Verifiers");
|
GroupDescription.Basic group2 = createGroup(AccountGroup.uuid("8903493"), "Verifiers");
|
||||||
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
ImmutableSet<GroupDescription.Basic> groups = ImmutableSet.of(group1, group2);
|
||||||
|
|
||||||
createArbitraryGroup(groupUuid);
|
createArbitraryGroup(groupUuid);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
private static final String SERVER_EMAIL = "noreply@gerritcodereview.com";
|
private static final String SERVER_EMAIL = "noreply@gerritcodereview.com";
|
||||||
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 = AccountGroup.uuid("users-XYZ");
|
||||||
private final AccountGroup.NameKey groupName = AccountGroup.nameKey("users");
|
private final AccountGroup.NameKey groupName = AccountGroup.nameKey("users");
|
||||||
|
|
||||||
private AtomicInteger idCounter;
|
private AtomicInteger idCounter;
|
||||||
@@ -128,7 +128,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
public void newGroupMustNotReuseNameOfAnotherGroup() throws Exception {
|
public void newGroupMustNotReuseNameOfAnotherGroup() throws Exception {
|
||||||
createGroup(groupUuid, groupName);
|
createGroup(groupUuid, groupName);
|
||||||
|
|
||||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("AnotherGroup");
|
AccountGroup.UUID anotherGroupUuid = AccountGroup.uuid("AnotherGroup");
|
||||||
exception.expect(DuplicateKeyException.class);
|
exception.expect(DuplicateKeyException.class);
|
||||||
exception.expectMessage(groupName.get());
|
exception.expectMessage(groupName.get());
|
||||||
GroupNameNotes.forNewGroup(allUsersName, repo, anotherGroupUuid, groupName);
|
GroupNameNotes.forNewGroup(allUsersName, repo, anotherGroupUuid, groupName);
|
||||||
@@ -201,7 +201,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
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 = AccountGroup.uuid("admins-ABC");
|
||||||
AccountGroup.NameKey anotherGroupName = AccountGroup.nameKey("admins");
|
AccountGroup.NameKey anotherGroupName = AccountGroup.nameKey("admins");
|
||||||
createGroup(anotherGroupUuid, anotherGroupName);
|
createGroup(anotherGroupUuid, anotherGroupName);
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
public void groupCannotBeRenamedWhenUuidIsWrong() throws Exception {
|
public void groupCannotBeRenamedWhenUuidIsWrong() throws Exception {
|
||||||
createGroup(groupUuid, groupName);
|
createGroup(groupUuid, groupName);
|
||||||
|
|
||||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("admins-ABC");
|
AccountGroup.UUID anotherGroupUuid = AccountGroup.uuid("admins-ABC");
|
||||||
AccountGroup.NameKey anotherName = 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());
|
||||||
@@ -248,7 +248,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
createGroup(groupUuid, groupName);
|
createGroup(groupUuid, groupName);
|
||||||
ImmutableList<CommitInfo> commitsAfterCreation = log();
|
ImmutableList<CommitInfo> commitsAfterCreation = log();
|
||||||
|
|
||||||
AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("admins-ABC");
|
AccountGroup.UUID anotherGroupUuid = AccountGroup.uuid("admins-ABC");
|
||||||
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
AccountGroup.NameKey anotherName = AccountGroup.nameKey("admins");
|
||||||
createGroup(anotherGroupUuid, anotherName);
|
createGroup(anotherGroupUuid, anotherName);
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonExistentGroupCannotBeLoaded() throws Exception {
|
public void nonExistentGroupCannotBeLoaded() throws Exception {
|
||||||
createGroup(new AccountGroup.UUID("contributors-MN"), AccountGroup.nameKey("contributors"));
|
createGroup(AccountGroup.uuid("contributors-MN"), AccountGroup.nameKey("contributors"));
|
||||||
createGroup(groupUuid, groupName);
|
createGroup(groupUuid, groupName);
|
||||||
|
|
||||||
Optional<GroupReference> group = loadGroup(AccountGroup.nameKey("admins"));
|
Optional<GroupReference> group = loadGroup(AccountGroup.nameKey("admins"));
|
||||||
@@ -350,9 +350,9 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificGroupCanBeLoaded() throws Exception {
|
public void specificGroupCanBeLoaded() throws Exception {
|
||||||
createGroup(new AccountGroup.UUID("contributors-MN"), AccountGroup.nameKey("contributors"));
|
createGroup(AccountGroup.uuid("contributors-MN"), AccountGroup.nameKey("contributors"));
|
||||||
createGroup(groupUuid, groupName);
|
createGroup(groupUuid, groupName);
|
||||||
createGroup(new AccountGroup.UUID("admins-ABC"), AccountGroup.nameKey("admins"));
|
createGroup(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);
|
||||||
@@ -367,10 +367,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 = AccountGroup.uuid("contributors-MN");
|
||||||
AccountGroup.NameKey groupName1 = 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 = AccountGroup.uuid("admins-ABC");
|
||||||
AccountGroup.NameKey groupName2 = AccountGroup.nameKey("admins");
|
AccountGroup.NameKey groupName2 = AccountGroup.nameKey("admins");
|
||||||
createGroup(groupUuid2, groupName2);
|
createGroup(groupUuid2, groupName2);
|
||||||
|
|
||||||
@@ -480,14 +480,14 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
@Test
|
@Test
|
||||||
public void updateGroupNamesRejectsNonOneToOneGroupReferences() throws Exception {
|
public void updateGroupNamesRejectsNonOneToOneGroupReferences() throws Exception {
|
||||||
assertIllegalArgument(
|
assertIllegalArgument(
|
||||||
new GroupReference(new AccountGroup.UUID("uuid1"), "name1"),
|
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||||
new GroupReference(new AccountGroup.UUID("uuid1"), "name2"));
|
new GroupReference(AccountGroup.uuid("uuid1"), "name2"));
|
||||||
assertIllegalArgument(
|
assertIllegalArgument(
|
||||||
new GroupReference(new AccountGroup.UUID("uuid1"), "name1"),
|
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||||
new GroupReference(new AccountGroup.UUID("uuid2"), "name1"));
|
new GroupReference(AccountGroup.uuid("uuid2"), "name1"));
|
||||||
assertIllegalArgument(
|
assertIllegalArgument(
|
||||||
new GroupReference(new AccountGroup.UUID("uuid1"), "name1"),
|
new GroupReference(AccountGroup.uuid("uuid1"), "name1"),
|
||||||
new GroupReference(new AccountGroup.UUID("uuid1"), "name1"));
|
new GroupReference(AccountGroup.uuid("uuid1"), "name1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -537,7 +537,7 @@ public class GroupNameNotesTest extends GerritBaseTests {
|
|||||||
|
|
||||||
private GroupReference newGroup(String name) {
|
private GroupReference newGroup(String name) {
|
||||||
int id = idCounter.incrementAndGet();
|
int id = idCounter.incrementAndGet();
|
||||||
return new GroupReference(new AccountGroup.UUID(name + "-" + id), name);
|
return new GroupReference(AccountGroup.uuid(name + "-" + id), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PersonIdent newPersonIdent() {
|
private static PersonIdent newPersonIdent() {
|
||||||
|
|||||||
@@ -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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), 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, AccountGroup.nameKey("g-1"), new AccountGroup.UUID("uuid-1"));
|
allUsersRepo, AccountGroup.nameKey("g-1"), AccountGroup.uuid("uuid-1"));
|
||||||
assertThat(problems)
|
assertThat(problems)
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
warning(
|
warning(
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class RefControlTest extends GerritBaseTests {
|
|||||||
private final AllProjectsName allProjectsName =
|
private final AllProjectsName allProjectsName =
|
||||||
new AllProjectsName(AllProjectsNameProvider.DEFAULT);
|
new AllProjectsName(AllProjectsNameProvider.DEFAULT);
|
||||||
private final AllUsersName allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
|
private final AllUsersName allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
|
||||||
private final AccountGroup.UUID fixers = new AccountGroup.UUID("test.fixers");
|
private final AccountGroup.UUID fixers = AccountGroup.uuid("test.fixers");
|
||||||
private final Map<Project.NameKey, ProjectState> all = new HashMap<>();
|
private final Map<Project.NameKey, ProjectState> all = new HashMap<>();
|
||||||
private Project.NameKey localKey = new Project.NameKey("local");
|
private Project.NameKey localKey = new Project.NameKey("local");
|
||||||
private ProjectConfig local;
|
private ProjectConfig local;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class GroupListTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void byUUID() throws Exception {
|
public void byUUID() throws Exception {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("d96b998f8a66ff433af50befb975d0e2bb6e0999");
|
AccountGroup.UUID uuid = AccountGroup.uuid("d96b998f8a66ff433af50befb975d0e2bb6e0999");
|
||||||
|
|
||||||
GroupReference groupReference = groupList.byUUID(uuid);
|
GroupReference groupReference = groupList.byUUID(uuid);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class GroupListTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void put() {
|
public void put() {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("abc");
|
AccountGroup.UUID uuid = AccountGroup.uuid("abc");
|
||||||
GroupReference groupReference = new GroupReference(uuid, "Hutzliputz");
|
GroupReference groupReference = new GroupReference(uuid, "Hutzliputz");
|
||||||
|
|
||||||
groupList.put(uuid, groupReference);
|
groupList.put(uuid, groupReference);
|
||||||
@@ -81,7 +81,7 @@ public class GroupListTest extends GerritBaseTests {
|
|||||||
Collection<GroupReference> result = groupList.references();
|
Collection<GroupReference> result = groupList.references();
|
||||||
|
|
||||||
assertEquals(2, result.size());
|
assertEquals(2, result.size());
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("ebe31c01aec2c9ac3b3c03e87a47450829ff4310");
|
AccountGroup.UUID uuid = AccountGroup.uuid("ebe31c01aec2c9ac3b3c03e87a47450829ff4310");
|
||||||
GroupReference expected = new GroupReference(uuid, "Administrators");
|
GroupReference expected = new GroupReference(uuid, "Administrators");
|
||||||
|
|
||||||
assertTrue(result.contains(expected));
|
assertTrue(result.contains(expected));
|
||||||
@@ -92,7 +92,7 @@ public class GroupListTest extends GerritBaseTests {
|
|||||||
Set<AccountGroup.UUID> result = groupList.uuids();
|
Set<AccountGroup.UUID> result = groupList.uuids();
|
||||||
|
|
||||||
assertEquals(2, result.size());
|
assertEquals(2, result.size());
|
||||||
AccountGroup.UUID expected = new AccountGroup.UUID("ebe31c01aec2c9ac3b3c03e87a47450829ff4310");
|
AccountGroup.UUID expected = AccountGroup.uuid("ebe31c01aec2c9ac3b3c03e87a47450829ff4310");
|
||||||
assertTrue(result.contains(expected));
|
assertTrue(result.contains(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,11 +108,11 @@ public class GroupListTest extends GerritBaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retainAll() throws Exception {
|
public void retainAll() throws Exception {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID("d96b998f8a66ff433af50befb975d0e2bb6e0999");
|
AccountGroup.UUID uuid = AccountGroup.uuid("d96b998f8a66ff433af50befb975d0e2bb6e0999");
|
||||||
groupList.retainUUIDs(Collections.singleton(uuid));
|
groupList.retainUUIDs(Collections.singleton(uuid));
|
||||||
|
|
||||||
assertNotNull(groupList.byUUID(uuid));
|
assertNotNull(groupList.byUUID(uuid));
|
||||||
assertNull(groupList.byUUID(new AccountGroup.UUID("ebe31c01aec2c9ac3b3c03e87a47450829ff4310")));
|
assertNull(groupList.byUUID(AccountGroup.uuid("ebe31c01aec2c9ac3b3c03e87a47450829ff4310")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ public class ProjectConfigTest extends GerritBaseTests {
|
|||||||
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
private final GroupReference developers =
|
private final GroupReference developers =
|
||||||
new GroupReference(new AccountGroup.UUID("X"), "Developers");
|
new GroupReference(AccountGroup.uuid("X"), "Developers");
|
||||||
private final GroupReference staff = new GroupReference(new AccountGroup.UUID("Y"), "Staff");
|
private final GroupReference staff = new GroupReference(AccountGroup.uuid("Y"), "Staff");
|
||||||
|
|
||||||
private SitePaths sitePaths;
|
private SitePaths sitePaths;
|
||||||
private ProjectConfig.Factory factory;
|
private ProjectConfig.Factory factory;
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
|||||||
|
|
||||||
// update group in the database so that group index is stale
|
// update group in the database so that group index is stale
|
||||||
String newDescription = "barY";
|
String newDescription = "barY";
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(group1.id);
|
AccountGroup.UUID groupUuid = AccountGroup.uuid(group1.id);
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder().setDescription(newDescription).build();
|
InternalGroupUpdate.builder().setDescription(newDescription).build();
|
||||||
groupsUpdateProvider.get().updateGroupInNoteDb(groupUuid, groupUpdate);
|
groupsUpdateProvider.get().updateGroupInNoteDb(groupUuid, groupUpdate);
|
||||||
@@ -356,7 +356,7 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void rawDocument() throws Exception {
|
public void rawDocument() throws Exception {
|
||||||
GroupInfo group1 = createGroup(name("group1"));
|
GroupInfo group1 = createGroup(name("group1"));
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(group1.id);
|
AccountGroup.UUID uuid = AccountGroup.uuid(group1.id);
|
||||||
|
|
||||||
Optional<FieldBundle> rawFields =
|
Optional<FieldBundle> rawFields =
|
||||||
indexes
|
indexes
|
||||||
@@ -376,7 +376,7 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
|||||||
@Test
|
@Test
|
||||||
public void byDeletedGroup() throws Exception {
|
public void byDeletedGroup() throws Exception {
|
||||||
GroupInfo group = createGroup(name("group"));
|
GroupInfo group = createGroup(name("group"));
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(group.id);
|
AccountGroup.UUID uuid = AccountGroup.uuid(group.id);
|
||||||
String query = "uuid:" + uuid;
|
String query = "uuid:" + uuid;
|
||||||
assertQuery(query, group);
|
assertQuery(query, group);
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ public abstract class TestGroup {
|
|||||||
TestGroup testGroup = autoBuild();
|
TestGroup testGroup = autoBuild();
|
||||||
AccountGroup.NameKey name = testGroup.getNameKey().orElse(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(AccountGroup.uuid(name + "-UUID"));
|
||||||
testGroup.getGroupUuid().orElse(new AccountGroup.UUID(name + "-UUID"));
|
|
||||||
Timestamp createdOn = testGroup.getCreatedOn().orElseGet(TimeUtil::nowTs);
|
Timestamp createdOn = testGroup.getCreatedOn().orElseGet(TimeUtil::nowTs);
|
||||||
AccountGroup accountGroup = new AccountGroup(name, id, uuid, createdOn);
|
AccountGroup accountGroup = new AccountGroup(name, id, uuid, createdOn);
|
||||||
testGroup.getOwnerGroupUuid().ifPresent(accountGroup::setOwnerGroupUUID);
|
testGroup.getOwnerGroupUuid().ifPresent(accountGroup::setOwnerGroupUUID);
|
||||||
|
|||||||
Submodule plugins/singleusergroup updated: 25bcffa8e0...04783e4763
Reference in New Issue
Block a user