Convert Account.Id to AutoValue
Despite the larger delta, this change is only slightly more complex than
refactoring the lesser-used ID types.
See I6982fb24 for context.
Change-Id: I7461a57cf52f2c4b0fa999a62746f94c6d201459
diff --git a/java/com/google/gerrit/acceptance/AccountCreator.java b/java/com/google/gerrit/acceptance/AccountCreator.java
index 8e3e656..898c5c7 100644
--- a/java/com/google/gerrit/acceptance/AccountCreator.java
+++ b/java/com/google/gerrit/acceptance/AccountCreator.java
@@ -76,7 +76,7 @@
if (account != null) {
return account;
}
- Account.Id id = new Account.Id(sequences.nextAccountId());
+ Account.Id id = Account.id(sequences.nextAccountId());
List<ExternalId> extIds = new ArrayList<>(2);
String httpPass = null;
diff --git a/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java b/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java
index 7641e47..0228bac 100644
--- a/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java
+++ b/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java
@@ -68,7 +68,7 @@
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
throws IOException, ConfigInvalidException {
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
return accountsUpdate.insert("Create Test Account", accountId, accountUpdater);
}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
index c25aa90..60cdb64 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
@@ -118,7 +118,7 @@
source = json.getAsJsonObject().get("fields");
}
- Account.Id id = new Account.Id(source.getAsJsonObject().get(ID.getName()).getAsInt());
+ Account.Id id = Account.id(source.getAsJsonObject().get(ID.getName()).getAsInt());
// Use the AccountCache rather than depending on any stored fields in the document (of which
// there shouldn't be any). The most expensive part to compute anyway is the effective group
// IDs, and we don't have a good way to reindex when those change.
diff --git a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
index 5782399..dfd345a 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
@@ -278,7 +278,7 @@
if (reviewedBy.size() == 1 && aId == ChangeField.NOT_REVIEWED) {
break;
}
- accounts.add(new Account.Id(aId));
+ accounts.add(Account.id(aId));
}
cd.setReviewedBy(accounts);
}
diff --git a/java/com/google/gerrit/httpd/WebSessionManager.java b/java/com/google/gerrit/httpd/WebSessionManager.java
index d09b4dd..d7c41bf 100644
--- a/java/com/google/gerrit/httpd/WebSessionManager.java
+++ b/java/com/google/gerrit/httpd/WebSessionManager.java
@@ -286,7 +286,7 @@
case 0:
break PARSE;
case 1:
- accountId = new Account.Id(readVarInt32(in));
+ accountId = Account.id(readVarInt32(in));
continue;
case 2:
refreshCookieAt = readFixInt64(in);
diff --git a/java/com/google/gerrit/lucene/LuceneAccountIndex.java b/java/com/google/gerrit/lucene/LuceneAccountIndex.java
index 0b787b6..41d16aa2 100644
--- a/java/com/google/gerrit/lucene/LuceneAccountIndex.java
+++ b/java/com/google/gerrit/lucene/LuceneAccountIndex.java
@@ -154,7 +154,7 @@
@Override
protected AccountState fromDocument(Document doc) {
- Account.Id id = new Account.Id(doc.getField(ID.getName()).numericValue().intValue());
+ Account.Id id = Account.id(doc.getField(ID.getName()).numericValue().intValue());
// Use the AccountCache rather than depending on any stored fields in the document (of which
// there shouldn't be any). The most expensive part to compute anyway is the effective group
// IDs, and we don't have a good way to reindex when those change.
diff --git a/java/com/google/gerrit/lucene/LuceneChangeIndex.java b/java/com/google/gerrit/lucene/LuceneChangeIndex.java
index 8bf0b6b..07246ab 100644
--- a/java/com/google/gerrit/lucene/LuceneChangeIndex.java
+++ b/java/com/google/gerrit/lucene/LuceneChangeIndex.java
@@ -556,7 +556,7 @@
if (reviewedBy.size() == 1 && id == ChangeField.NOT_REVIEWED) {
break;
}
- accounts.add(new Account.Id(id));
+ accounts.add(Account.id(id));
}
cd.setReviewedBy(accounts);
}
diff --git a/java/com/google/gerrit/pgm/init/InitAdminUser.java b/java/com/google/gerrit/pgm/init/InitAdminUser.java
index 27e6ce9..674f9c1 100644
--- a/java/com/google/gerrit/pgm/init/InitAdminUser.java
+++ b/java/com/google/gerrit/pgm/init/InitAdminUser.java
@@ -101,7 +101,7 @@
if (!accounts.hasAnyAccount()) {
ui.header("Gerrit Administrator");
if (ui.yesno(true, "Create administrator user")) {
- Account.Id id = new Account.Id(sequencesOnInit.nextAccountId());
+ Account.Id id = Account.id(sequencesOnInit.nextAccountId());
String username = ui.readString("admin", "username");
String name = ui.readString("Administrator", "name");
String httpPassword = ui.readString("secret", "HTTP password");
diff --git a/java/com/google/gerrit/reviewdb/client/Account.java b/java/com/google/gerrit/reviewdb/client/Account.java
index 47c9b40..2642654 100644
--- a/java/com/google/gerrit/reviewdb/client/Account.java
+++ b/java/com/google/gerrit/reviewdb/client/Account.java
@@ -18,9 +18,9 @@
import static com.google.gerrit.reviewdb.client.RefNames.REFS_STARRED_CHANGES;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_USERS;
+import com.google.auto.value.AutoValue;
import com.google.common.primitives.Ints;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
-import com.google.gwtorm.client.IntKey;
import java.sql.Timestamp;
import java.util.Optional;
@@ -46,31 +46,16 @@
* </ul>
*/
public final class Account {
+ public static Id id(int id) {
+ return new AutoValue_Account_Id(id);
+ }
+
/** Key local to Gerrit to identify a user. */
- public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> {
- private static final long serialVersionUID = 1L;
-
- protected int id;
-
- protected Id() {}
-
- public Id(int id) {
- this.id = id;
- }
-
- @Override
- public int get() {
- return id;
- }
-
- @Override
- protected void set(int newValue) {
- id = newValue;
- }
-
+ @AutoValue
+ public abstract static class Id implements Comparable<Id> {
/** Parse an Account.Id out of a string representation. */
public static Optional<Id> tryParse(String str) {
- return Optional.ofNullable(Ints.tryParse(str)).map(Id::new);
+ return Optional.ofNullable(Ints.tryParse(str)).map(Account::id);
}
public static Id fromRef(String name) {
@@ -95,12 +80,12 @@
*/
public static Id fromRefPart(String name) {
Integer id = RefNames.parseShardedRefPart(name);
- return id != null ? new Account.Id(id) : null;
+ return id != null ? Account.id(id) : null;
}
public static Id parseAfterShardedRefPart(String name) {
Integer id = RefNames.parseAfterShardedRefPart(name);
- return id != null ? new Account.Id(id) : null;
+ return id != null ? Account.id(id) : null;
}
/**
@@ -115,7 +100,23 @@
*/
public static Id fromRefSuffix(String name) {
Integer id = RefNames.parseRefSuffix(name);
- return id != null ? new Account.Id(id) : null;
+ return id != null ? Account.id(id) : null;
+ }
+
+ abstract int id();
+
+ public int get() {
+ return id();
+ }
+
+ @Override
+ public int compareTo(Id o) {
+ return Integer.compare(id(), o.id());
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toString(get());
}
}
diff --git a/java/com/google/gerrit/reviewdb/client/Comment.java b/java/com/google/gerrit/reviewdb/client/Comment.java
index e03d0fa..9e6c77b 100644
--- a/java/com/google/gerrit/reviewdb/client/Comment.java
+++ b/java/com/google/gerrit/reviewdb/client/Comment.java
@@ -104,7 +104,7 @@
}
public Account.Id getId() {
- return new Account.Id(id);
+ return Account.id(id);
}
@Override
diff --git a/java/com/google/gerrit/reviewdb/converter/AccountIdProtoConverter.java b/java/com/google/gerrit/reviewdb/converter/AccountIdProtoConverter.java
index 8dd1794..51e98c7 100644
--- a/java/com/google/gerrit/reviewdb/converter/AccountIdProtoConverter.java
+++ b/java/com/google/gerrit/reviewdb/converter/AccountIdProtoConverter.java
@@ -28,7 +28,7 @@
@Override
public Account.Id fromProto(Entities.Account_Id proto) {
- return new Account.Id(proto.getId());
+ return Account.id(proto.getId());
}
@Override
diff --git a/java/com/google/gerrit/server/StarredChangesUtil.java b/java/com/google/gerrit/server/StarredChangesUtil.java
index 676cf2e..d092ac8 100644
--- a/java/com/google/gerrit/server/StarredChangesUtil.java
+++ b/java/com/google/gerrit/server/StarredChangesUtil.java
@@ -88,7 +88,7 @@
if (id == null) {
return null;
}
- Account.Id accountId = new Account.Id(id);
+ Account.Id accountId = Account.id(id);
String label = s.substring(p + 1);
return create(accountId, label);
}
@@ -274,7 +274,7 @@
if (id == null) {
continue;
}
- Account.Id accountId = new Account.Id(id);
+ Account.Id accountId = Account.id(id);
builder.put(accountId, readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)));
}
return builder.build();
diff --git a/java/com/google/gerrit/server/account/AccountManager.java b/java/com/google/gerrit/server/account/AccountManager.java
index eb6b491..7e49c10 100644
--- a/java/com/google/gerrit/server/account/AccountManager.java
+++ b/java/com/google/gerrit/server/account/AccountManager.java
@@ -272,7 +272,7 @@
private AuthResult create(AuthRequest who)
throws AccountException, IOException, ConfigInvalidException {
- Account.Id newId = new Account.Id(sequences.nextAccountId());
+ Account.Id newId = Account.id(sequences.nextAccountId());
logger.atFine().log("Assigning new Id %s to account", newId);
ExternalId extId =
diff --git a/java/com/google/gerrit/server/account/InternalAccountDirectory.java b/java/com/google/gerrit/server/account/InternalAccountDirectory.java
index ce97ff9..49afaf2 100644
--- a/java/com/google/gerrit/server/account/InternalAccountDirectory.java
+++ b/java/com/google/gerrit/server/account/InternalAccountDirectory.java
@@ -98,11 +98,10 @@
Set<FillOptions> fillOptionsWithoutSecondaryEmails =
Sets.difference(options, EnumSet.of(FillOptions.SECONDARY_EMAILS));
- Set<Account.Id> ids =
- Streams.stream(in).map(a -> new Account.Id(a._accountId)).collect(toSet());
+ Set<Account.Id> ids = Streams.stream(in).map(a -> Account.id(a._accountId)).collect(toSet());
Map<Account.Id, AccountState> accountStates = accountCache.get(ids);
for (AccountInfo info : in) {
- Account.Id id = new Account.Id(info._accountId);
+ Account.Id id = Account.id(info._accountId);
AccountState state = accountStates.get(id);
if (state != null) {
if (!options.contains(FillOptions.SECONDARY_EMAILS)
diff --git a/java/com/google/gerrit/server/account/externalids/AllExternalIds.java b/java/com/google/gerrit/server/account/externalids/AllExternalIds.java
index 5d12ae1..611b44d 100644
--- a/java/com/google/gerrit/server/account/externalids/AllExternalIds.java
+++ b/java/com/google/gerrit/server/account/externalids/AllExternalIds.java
@@ -96,7 +96,7 @@
private static ExternalId toExternalId(ObjectIdConverter idConverter, ExternalIdProto proto) {
return ExternalId.create(
ExternalId.Key.parse(proto.getKey()),
- new Account.Id(proto.getAccountId()),
+ Account.id(proto.getAccountId()),
// ExternalId treats null and empty strings the same, so no need to distinguish here.
proto.getEmail(),
proto.getPassword(),
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalId.java b/java/com/google/gerrit/server/account/externalids/ExternalId.java
index c363b5b..dc80904 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalId.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalId.java
@@ -361,7 +361,7 @@
return create(
externalIdKey,
- new Account.Id(accountId),
+ Account.id(accountId),
Strings.emptyToNull(email),
Strings.emptyToNull(password),
blobId);
diff --git a/java/com/google/gerrit/server/auth/oauth/OAuthTokenCache.java b/java/com/google/gerrit/server/auth/oauth/OAuthTokenCache.java
index 78b58e1..4d7d70e 100644
--- a/java/com/google/gerrit/server/auth/oauth/OAuthTokenCache.java
+++ b/java/com/google/gerrit/server/auth/oauth/OAuthTokenCache.java
@@ -48,8 +48,7 @@
.version(1)
.keySerializer(
CacheSerializer.convert(
- IntegerCacheSerializer.INSTANCE,
- Converter.from(Account.Id::get, Account.Id::new)))
+ IntegerCacheSerializer.INSTANCE, Converter.from(Account.Id::get, Account::id)))
.valueSerializer(new Serializer());
}
};
diff --git a/java/com/google/gerrit/server/change/ChangeJson.java b/java/com/google/gerrit/server/change/ChangeJson.java
index 9e43cee..a164853 100644
--- a/java/com/google/gerrit/server/change/ChangeJson.java
+++ b/java/com/google/gerrit/server/change/ChangeJson.java
@@ -699,7 +699,7 @@
continue;
}
for (ApprovalInfo ai : label.all) {
- Account.Id id = new Account.Id(ai._accountId);
+ Account.Id id = Account.id(ai._accountId);
if (canRemoveAnyReviewer
|| removeReviewerControl.testRemoveReviewer(
@@ -719,7 +719,7 @@
if (ccs != null) {
for (AccountInfo ai : ccs) {
if (ai._accountId != null) {
- Account.Id id = new Account.Id(ai._accountId);
+ Account.Id id = Account.id(ai._accountId);
if (canRemoveAnyReviewer
|| removeReviewerControl.testRemoveReviewer(cd, userProvider.get(), id, 0)) {
removable.add(id);
diff --git a/java/com/google/gerrit/server/events/StreamEventsApiListener.java b/java/com/google/gerrit/server/events/StreamEventsApiListener.java
index 3add4ca..5b7d9b1 100644
--- a/java/com/google/gerrit/server/events/StreamEventsApiListener.java
+++ b/java/com/google/gerrit/server/events/StreamEventsApiListener.java
@@ -162,7 +162,7 @@
return Suppliers.memoize(
() ->
account != null
- ? eventFactory.asAccountAttribute(new Account.Id(account._accountId))
+ ? eventFactory.asAccountAttribute(Account.id(account._accountId))
: null);
}
diff --git a/java/com/google/gerrit/server/group/db/GroupConfig.java b/java/com/google/gerrit/server/group/db/GroupConfig.java
index a1f8ccd..2c9a851 100644
--- a/java/com/google/gerrit/server/group/db/GroupConfig.java
+++ b/java/com/google/gerrit/server/group/db/GroupConfig.java
@@ -411,7 +411,7 @@
}
private ImmutableSet<Account.Id> readMembers() throws IOException, ConfigInvalidException {
- return readFromFile(MEMBERS_FILE, entry -> new Account.Id(Integer.parseInt(entry)));
+ return readFromFile(MEMBERS_FILE, entry -> Account.id(Integer.parseInt(entry)));
}
private ImmutableSet<AccountGroup.UUID> readSubgroups()
diff --git a/java/com/google/gerrit/server/index/change/ChangeField.java b/java/com/google/gerrit/server/index/change/ChangeField.java
index 394761b..0592b57 100644
--- a/java/com/google/gerrit/server/index/change/ChangeField.java
+++ b/java/com/google/gerrit/server/index/change/ChangeField.java
@@ -776,7 +776,7 @@
SubmitRecord.Label srl = new SubmitRecord.Label();
srl.label = label.label;
srl.status = label.status;
- srl.appliedBy = label.appliedBy != null ? new Account.Id(label.appliedBy) : null;
+ srl.appliedBy = label.appliedBy != null ? Account.id(label.appliedBy) : null;
rec.labels.add(srl);
}
}
diff --git a/java/com/google/gerrit/server/notedb/ChangeNotesState.java b/java/com/google/gerrit/server/notedb/ChangeNotesState.java
index 3a983be..ad74b64 100644
--- a/java/com/google/gerrit/server/notedb/ChangeNotesState.java
+++ b/java/com/google/gerrit/server/notedb/ChangeNotesState.java
@@ -551,9 +551,7 @@
.changeId(changeId)
.columns(toChangeColumns(changeId, proto.getColumns()))
.pastAssignees(
- proto.getPastAssigneeList().stream()
- .map(Account.Id::new)
- .collect(toImmutableSet()))
+ proto.getPastAssigneeList().stream().map(Account::id).collect(toImmutableSet()))
.hashtags(proto.getHashtagList())
.patchSets(
proto.getPatchSetList().stream()
@@ -570,9 +568,7 @@
.pendingReviewers(toReviewerSet(proto.getPendingReviewerList()))
.pendingReviewersByEmail(toReviewerByEmailSet(proto.getPendingReviewerByEmailList()))
.allPastReviewers(
- proto.getPastReviewerList().stream()
- .map(Account.Id::new)
- .collect(toImmutableList()))
+ proto.getPastReviewerList().stream().map(Account::id).collect(toImmutableList()))
.reviewerUpdates(toReviewerStatusUpdateList(proto.getReviewerUpdateList()))
.submitRecords(
proto.getSubmitRecordList().stream()
@@ -602,7 +598,7 @@
.changeKey(new Change.Key(proto.getChangeKey()))
.createdOn(new Timestamp(proto.getCreatedOn()))
.lastUpdatedOn(new Timestamp(proto.getLastUpdatedOn()))
- .owner(new Account.Id(proto.getOwner()))
+ .owner(Account.id(proto.getOwner()))
.branch(proto.getBranch());
if (proto.getHasCurrentPatchSetId()) {
b.currentPatchSetId(new PatchSet.Id(changeId, proto.getCurrentPatchSetId()));
@@ -618,7 +614,7 @@
b.submissionId(proto.getSubmissionId());
}
if (proto.getHasAssignee()) {
- b.assignee(new Account.Id(proto.getAssignee()));
+ b.assignee(Account.id(proto.getAssignee()));
}
if (proto.getHasStatus()) {
b.status(STATUS_CONVERTER.convert(proto.getStatus()));
@@ -638,7 +634,7 @@
for (ReviewerSetEntryProto e : protos) {
b.put(
REVIEWER_STATE_CONVERTER.convert(e.getState()),
- new Account.Id(e.getAccountId()),
+ Account.id(e.getAccountId()),
new Timestamp(e.getTimestamp()));
}
return ReviewerSet.fromTable(b.build());
@@ -664,8 +660,8 @@
b.add(
ReviewerStatusUpdate.create(
new Timestamp(proto.getDate()),
- new Account.Id(proto.getUpdatedBy()),
- new Account.Id(proto.getReviewer()),
+ Account.id(proto.getUpdatedBy()),
+ Account.id(proto.getReviewer()),
REVIEWER_STATE_CONVERTER.convert(proto.getState())));
}
return b.build();
diff --git a/java/com/google/gerrit/server/notedb/ChangeUpdate.java b/java/com/google/gerrit/server/notedb/ChangeUpdate.java
index b218d9b..8c34ce0 100644
--- a/java/com/google/gerrit/server/notedb/ChangeUpdate.java
+++ b/java/com/google/gerrit/server/notedb/ChangeUpdate.java
@@ -39,7 +39,7 @@
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS;
import static com.google.gerrit.server.notedb.NoteDbUtil.sanitizeFooter;
-import static java.util.Comparator.comparing;
+import static java.util.Comparator.naturalOrder;
import static java.util.Objects.requireNonNull;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
@@ -64,7 +64,6 @@
import com.google.gerrit.server.logging.RequestId;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.util.LabelVote;
-import com.google.gwtorm.client.IntKey;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import java.io.IOException;
@@ -173,7 +172,7 @@
private static Table<String, Account.Id, Optional<Short>> approvals(
Comparator<String> nameComparator) {
- return TreeBasedTable.create(nameComparator, comparing(IntKey::get));
+ return TreeBasedTable.create(nameComparator, naturalOrder());
}
@AssistedInject
diff --git a/java/com/google/gerrit/server/notedb/NoteDbUtil.java b/java/com/google/gerrit/server/notedb/NoteDbUtil.java
index 667ceab..6b8eb4b 100644
--- a/java/com/google/gerrit/server/notedb/NoteDbUtil.java
+++ b/java/com/google/gerrit/server/notedb/NoteDbUtil.java
@@ -37,7 +37,7 @@
if (host.equals(serverId)) {
Integer id = Ints.tryParse(email.substring(0, at));
if (id != null) {
- return Optional.of(new Account.Id(id));
+ return Optional.of(Account.id(id));
}
}
}
diff --git a/java/com/google/gerrit/server/query/account/AccountPredicates.java b/java/com/google/gerrit/server/query/account/AccountPredicates.java
index cb96bc5..55b3eda 100644
--- a/java/com/google/gerrit/server/query/account/AccountPredicates.java
+++ b/java/com/google/gerrit/server/query/account/AccountPredicates.java
@@ -44,7 +44,7 @@
List<Predicate<AccountState>> preds = Lists.newArrayListWithCapacity(3);
Integer id = Ints.tryParse(query);
if (id != null) {
- preds.add(id(new Account.Id(id)));
+ preds.add(id(Account.id(id)));
}
if (canSeeSecondaryEmails) {
preds.add(equalsNameIncludingSecondaryEmails(query));
diff --git a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
index 0227153..59a2720 100644
--- a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
+++ b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
@@ -188,7 +188,7 @@
public static final String ARG_ID_USER = "user";
public static final String ARG_ID_GROUP = "group";
public static final String ARG_ID_OWNER = "owner";
- public static final Account.Id OWNER_ACCOUNT_ID = new Account.Id(0);
+ public static final Account.Id OWNER_ACCOUNT_ID = Account.id(0);
private static final QueryBuilder.Definition<ChangeData, ChangeQueryBuilder> mydef =
new QueryBuilder.Definition<>(ChangeQueryBuilder.class);
@@ -569,11 +569,11 @@
}
if ("assigned".equalsIgnoreCase(value)) {
- return Predicate.not(new AssigneePredicate(new Account.Id(ChangeField.NO_ASSIGNEE)));
+ return Predicate.not(new AssigneePredicate(Account.id(ChangeField.NO_ASSIGNEE)));
}
if ("unassigned".equalsIgnoreCase(value)) {
- return new AssigneePredicate(new Account.Id(ChangeField.NO_ASSIGNEE));
+ return new AssigneePredicate(Account.id(ChangeField.NO_ASSIGNEE));
}
if ("submittable".equalsIgnoreCase(value)) {
diff --git a/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java b/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java
index ddb6f32..1b3029f 100644
--- a/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java
+++ b/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java
@@ -25,7 +25,7 @@
import java.util.Set;
public class IsReviewedPredicate extends ChangeIndexPredicate {
- protected static final Account.Id NOT_REVIEWED = new Account.Id(ChangeField.NOT_REVIEWED);
+ protected static final Account.Id NOT_REVIEWED = Account.id(ChangeField.NOT_REVIEWED);
public static Predicate<ChangeData> create() {
return Predicate.not(new IsReviewedPredicate(NOT_REVIEWED));
diff --git a/java/com/google/gerrit/server/restapi/account/CreateAccount.java b/java/com/google/gerrit/server/restapi/account/CreateAccount.java
index b19994c..92937f1 100644
--- a/java/com/google/gerrit/server/restapi/account/CreateAccount.java
+++ b/java/com/google/gerrit/server/restapi/account/CreateAccount.java
@@ -119,7 +119,7 @@
Set<AccountGroup.UUID> groups = parseGroups(input.groups);
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
List<ExternalId> extIds = new ArrayList<>();
if (input.email != null) {
diff --git a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
index 779f277..1704153 100644
--- a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
+++ b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
@@ -247,7 +247,7 @@
.readRaw();
List<Account.Id> matches =
result.toList().stream()
- .map(f -> new Account.Id(f.getValue(AccountField.ID).intValue()))
+ .map(f -> Account.id(f.getValue(AccountField.ID).intValue()))
.collect(toList());
logger.atFine().log("Matches: %s", matches);
return matches;
diff --git a/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java b/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java
index 9cde54c..c036c86 100644
--- a/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java
+++ b/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java
@@ -540,7 +540,7 @@
if (status instanceof StructureTerm && status.arity() == 1) {
Term who = status.arg(0);
if (isUser(who)) {
- label.appliedBy = new Account.Id(((IntegerTerm) who.arg(0)).intValue());
+ label.appliedBy = Account.id(((IntegerTerm) who.arg(0)).intValue());
} else {
throw new UserTermExpected(label);
}
diff --git a/javatests/com/google/gerrit/acceptance/ProjectResetterTest.java b/javatests/com/google/gerrit/acceptance/ProjectResetterTest.java
index ceb7c05..6a089e5 100644
--- a/javatests/com/google/gerrit/acceptance/ProjectResetterTest.java
+++ b/javatests/com/google/gerrit/acceptance/ProjectResetterTest.java
@@ -259,7 +259,7 @@
@Test
public void accountEvictionIfUserBranchIsReset() throws Exception {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
Ref userBranch = createRef(allUsersRepo, RefNames.refsUsers(accountId));
@@ -275,7 +275,7 @@
EasyMock.replay(accountIndexer);
// Non-user branch because it's not in All-Users.
- Ref nonUserBranch = createRef(RefNames.refsUsers(new Account.Id(2)));
+ Ref nonUserBranch = createRef(RefNames.refsUsers(Account.id(2)));
try (ProjectResetter resetProject =
builder(null, accountCache, accountIndexer, null, null, null, null)
@@ -289,7 +289,7 @@
@Test
public void accountEvictionIfUserBranchIsDeleted() throws Exception {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
@@ -307,7 +307,7 @@
builder(null, accountCache, accountIndexer, null, null, null, null)
.build(new ProjectResetter.Config().reset(project).reset(allUsers))) {
// Non-user branch because it's not in All-Users.
- createRef(RefNames.refsUsers(new Account.Id(2)));
+ createRef(RefNames.refsUsers(Account.id(2)));
createRef(allUsersRepo, RefNames.refsUsers(accountId));
}
@@ -317,13 +317,13 @@
@Test
public void accountEvictionIfExternalIdsBranchIsReset() throws Exception {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
Ref externalIds = createRef(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
createRef(allUsersRepo, RefNames.refsUsers(accountId));
- Account.Id accountId2 = new Account.Id(2);
+ Account.Id accountId2 = Account.id(2);
AccountCache accountCache = EasyMock.createNiceMock(AccountCache.class);
accountCache.evict(accountId);
@@ -340,7 +340,7 @@
EasyMock.replay(accountIndexer);
// Non-user branch because it's not in All-Users.
- Ref nonUserBranch = createRef(RefNames.refsUsers(new Account.Id(3)));
+ Ref nonUserBranch = createRef(RefNames.refsUsers(Account.id(3)));
try (ProjectResetter resetProject =
builder(null, accountCache, accountIndexer, null, null, null, null)
@@ -355,12 +355,12 @@
@Test
public void accountEvictionIfExternalIdsBranchIsDeleted() throws Exception {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
createRef(allUsersRepo, RefNames.refsUsers(accountId));
- Account.Id accountId2 = new Account.Id(2);
+ Account.Id accountId2 = Account.id(2);
AccountCache accountCache = EasyMock.createNiceMock(AccountCache.class);
accountCache.evict(accountId);
@@ -377,7 +377,7 @@
EasyMock.replay(accountIndexer);
// Non-user branch because it's not in All-Users.
- Ref nonUserBranch = createRef(RefNames.refsUsers(new Account.Id(3)));
+ Ref nonUserBranch = createRef(RefNames.refsUsers(Account.id(3)));
try (ProjectResetter resetProject =
builder(null, accountCache, accountIndexer, null, null, null, null)
@@ -392,7 +392,7 @@
@Test
public void accountEvictionFromAccountCreatorIfUserBranchIsDeleted() throws Exception {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
Project.NameKey allUsers = new Project.NameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
index 82ea692..ec4098b 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
@@ -341,7 +341,7 @@
assertThat(accountInfo.email).isEqualTo(input.email);
assertThat(accountInfo.status).isNull();
- Account.Id accountId = new Account.Id(accountInfo._accountId);
+ Account.Id accountId = Account.id(accountInfo._accountId);
accountIndexedCounter.assertReindexOf(accountId, 1);
assertThat(externalIds.byAccount(accountId))
.containsExactly(
@@ -373,7 +373,7 @@
@Test
public void commitMessageOnAccountUpdates() throws Exception {
AccountsUpdate au = accountsUpdateProvider.get();
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
au.insert("Create Test Account", accountId, u -> {});
assertLastCommitMessageOfUserBranch(accountId, "Create Test Account");
@@ -395,7 +395,7 @@
public void createAtomically() throws Exception {
TestTimeUtil.resetWithClockStep(1, SECONDS);
try {
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
String fullName = "Foo";
ExternalId extId = ExternalId.createEmail(accountId, "foo@example.com");
AccountState accountState =
@@ -424,7 +424,7 @@
@Test
public void updateNonExistingAccount() throws Exception {
- Account.Id nonExistingAccountId = new Account.Id(999999);
+ Account.Id nonExistingAccountId = Account.id(999999);
AtomicBoolean consumerCalled = new AtomicBoolean();
Optional<AccountState> accountState =
accountsUpdateProvider
@@ -1775,7 +1775,7 @@
grant(allUsers, RefNames.REFS_USERS + "*", Permission.CREATE);
grant(allUsers, RefNames.REFS_USERS + "*", Permission.PUSH);
- String userRef = RefNames.refsUsers(new Account.Id(seq.nextAccountId()));
+ String userRef = RefNames.refsUsers(Account.id(seq.nextAccountId()));
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
PushOneCommit.Result r = pushFactory.create(admin.newIdent(), allUsersRepo).to(userRef);
r.assertErrorStatus();
@@ -1792,7 +1792,7 @@
grant(allUsers, RefNames.REFS_USERS + "*", Permission.CREATE);
grant(allUsers, RefNames.REFS_USERS + "*", Permission.PUSH);
- String userRef = RefNames.refsUsers(new Account.Id(seq.nextAccountId()));
+ String userRef = RefNames.refsUsers(Account.id(seq.nextAccountId()));
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
pushFactory.create(admin.newIdent(), allUsersRepo).to(userRef).assertOkStatus();
@@ -2150,7 +2150,7 @@
// metaId is set when account is created
AccountsUpdate au = accountsUpdateProvider.get();
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
AccountState accountState = au.insert("Create Test Account", accountId, u -> {});
assertThat(accountState.getAccount().getMetaId()).isEqualTo(getMetaId(accountId));
@@ -2435,7 +2435,7 @@
public void atomicReadMofifyWriteExternalIds() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId extIdA1 = ExternalId.create("foo", "A-1", accountId);
accountsUpdateProvider
.get()
@@ -2514,7 +2514,7 @@
public void stalenessChecker() throws Exception {
// Newly created account is not stale.
AccountInfo accountInfo = gApi.accounts().create(name("foo")).get();
- Account.Id accountId = new Account.Id(accountInfo._accountId);
+ Account.Id accountId = Account.id(accountInfo._accountId);
assertThat(stalenessChecker.isStale(accountId)).isFalse();
// Manually updating the user ref makes the index document stale.
@@ -2927,7 +2927,7 @@
}
void assertReindexOf(AccountInfo accountInfo) {
- assertReindexOf(new Account.Id(accountInfo._accountId), 1);
+ assertReindexOf(Account.id(accountInfo._accountId), 1);
}
void assertReindexOf(TestAccount testAccount, int expectedCount) {
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIndexerIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIndexerIT.java
index 60a61d1..7b20dbb 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIndexerIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIndexerIT.java
@@ -136,7 +136,7 @@
private Account.Id createAccount(String name) throws RestApiException {
AccountInfo account = gApi.accounts().create(name).get();
- return new Account.Id(account._accountId);
+ return Account.id(account._accountId);
}
private void reloadAccountToCache(Account.Id accountId) {
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountManagerIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountManagerIT.java
index edb98d0..85a94e9 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountManagerIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountManagerIT.java
@@ -122,7 +122,7 @@
@Test
public void authenticateWithEmail() throws Exception {
String email = "foo@example.com";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key mailtoExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_MAILTO, email);
accountsUpdate.insert(
"Create Test Account",
@@ -137,7 +137,7 @@
@Test
public void authenticateWithUsername() throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -152,7 +152,7 @@
@Test
public void authenticateWithExternalUser() throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username);
accountsUpdate.insert(
"Create Test Account",
@@ -168,7 +168,7 @@
public void authenticateWithUsernameAndUpdateEmail() throws Exception {
String username = "foo";
String email = "foo@example.com";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -196,7 +196,7 @@
public void authenticateWithUsernameAndUpdateDisplayName() throws Exception {
String username = "foo";
String email = "foo@example.com";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -224,7 +224,7 @@
assertNoSuchExternalIds(gerritExtIdKey);
// Create orphaned SCHEME_GERRIT external ID.
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId gerritExtId = ExternalId.create(gerritExtIdKey, accountId);
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
@@ -242,7 +242,7 @@
@Test
public void cannotAuthenticateWithInactiveAccount() throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -259,7 +259,7 @@
public void cannotActivateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsDisabled()
throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -279,7 +279,7 @@
public void activateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsEnabled()
throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -300,7 +300,7 @@
public void cannotDeactivateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsDisabled()
throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -322,7 +322,7 @@
public void deactivateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsEnabled()
throws Exception {
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -350,7 +350,7 @@
// Create an account with an SCHEME_EXTERNAL external ID that occupies the email.
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username);
accountsUpdate.insert(
"Create Test Account",
@@ -371,7 +371,7 @@
// Create an account with an SCHEME_EXTERNAL external ID that occupies the email.
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username);
accountsUpdate.insert(
"Create Test Account",
@@ -394,7 +394,7 @@
// Create an account with a SCHEME_GERRIT external ID and an email.
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -404,7 +404,7 @@
.addExternalId(ExternalId.createWithEmail(gerritExtIdKey, accountId, email)));
// Create another account with an SCHEME_EXTERNAL external ID that occupies the new email.
- Account.Id accountId2 = new Account.Id(seq.nextAccountId());
+ Account.Id accountId2 = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, "bar");
accountsUpdate.insert(
"Create Test Account",
@@ -437,7 +437,7 @@
public void linkNewExternalId() throws Exception {
// Create an account with a SCHEME_GERRIT external ID and no email
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert(
"Create Test Account",
@@ -461,7 +461,7 @@
public void updateExternalIdOnLink() throws Exception {
// Create an account with a SCHEME_GERRIT external ID and no email
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username);
accountsUpdate.insert(
"Create Test Account",
@@ -484,7 +484,7 @@
public void cannotLinkExternalIdThatIsAlreadyUsed() throws Exception {
// Create an account with a SCHEME_EXTERNAL external ID
String username1 = "foo";
- Account.Id accountId1 = new Account.Id(seq.nextAccountId());
+ Account.Id accountId1 = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey1 = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username1);
accountsUpdate.insert(
"Create Test Account",
@@ -493,7 +493,7 @@
// Create another account with a SCHEME_EXTERNAL external ID
String username2 = "bar";
- Account.Id accountId2 = new Account.Id(seq.nextAccountId());
+ Account.Id accountId2 = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey2 = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username2);
accountsUpdate.insert(
"Create Test Account",
@@ -514,7 +514,7 @@
// Create an account with an SCHEME_EXTERNAL external ID that occupies the email.
String username = "foo";
- Account.Id accountId = new Account.Id(seq.nextAccountId());
+ Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key externalExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_EXTERNAL, username);
accountsUpdate.insert(
"Create Test Account",
@@ -523,7 +523,7 @@
// Create another account with a SCHEME_GERRIT external ID and no email
String username2 = "foo";
- Account.Id accountId2 = new Account.Id(seq.nextAccountId());
+ Account.Id accountId2 = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = ExternalId.Key.create(ExternalId.SCHEME_GERRIT, username2);
accountsUpdate.insert(
"Create Test Account",
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
index ebb3978..917532a 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
@@ -3886,7 +3886,7 @@
if (r == null) {
return ImmutableList.of();
}
- return Iterables.transform(r, a -> new Account.Id(a._accountId));
+ return Iterables.transform(r, a -> Account.id(a._accountId));
}
private ChangeResource parseResource(PushOneCommit.Result r) throws Exception {
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
index fc65eca..cdaf837 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -1562,6 +1562,6 @@
}
private static Iterable<Account.Id> getReviewers(Collection<AccountInfo> r) {
- return Iterables.transform(r, a -> new Account.Id(a._accountId));
+ return Iterables.transform(r, a -> Account.id(a._accountId));
}
}
diff --git a/javatests/com/google/gerrit/acceptance/rest/account/AccountAssert.java b/javatests/com/google/gerrit/acceptance/rest/account/AccountAssert.java
index 5e652c0..63e9ebf 100644
--- a/javatests/com/google/gerrit/acceptance/rest/account/AccountAssert.java
+++ b/javatests/com/google/gerrit/acceptance/rest/account/AccountAssert.java
@@ -32,7 +32,7 @@
public static void assertAccountInfos(List<TestAccount> expected, List<AccountInfo> actual) {
Iterable<Account.Id> expectedIds = TestAccount.ids(expected);
- Iterable<Account.Id> actualIds = Iterables.transform(actual, a -> new Account.Id(a._accountId));
+ Iterable<Account.Id> actualIds = Iterables.transform(actual, a -> Account.id(a._accountId));
assertThat(actualIds).containsExactlyElementsIn(expectedIds).inOrder();
for (int i = 0; i < expected.size(); i++) {
AccountAssert.assertAccountInfo(expected.get(i), actual.get(i));
diff --git a/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java b/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java
index 8ff80a0..998a2a4 100644
--- a/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java
@@ -687,7 +687,7 @@
}
private ExternalId createExternalIdForNonExistingAccount(String externalId) {
- return ExternalId.create(ExternalId.Key.parse(externalId), new Account.Id(1));
+ return ExternalId.create(ExternalId.Key.parse(externalId), Account.id(1));
}
private ExternalId createExternalIdWithInvalidEmail(String externalId) {
@@ -714,7 +714,7 @@
@Test
public void readExternalIdWithAccountIdThatCanBeExpressedInKiB() throws Exception {
ExternalId.Key extIdKey = ExternalId.Key.parse("foo:bar");
- Account.Id accountId = new Account.Id(1024 * 100);
+ Account.Id accountId = Account.id(1024 * 100);
accountsUpdateProvider
.get()
.insert(
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java b/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java
index f191e08..0fadd40 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java
@@ -1232,7 +1232,7 @@
LabelInfo cr = c.labels.get("Code-Review");
assertThat(cr.all).hasSize(1);
assertThat(cr.all.get(0).value).isEqualTo(2);
- assertThat(new Account.Id(cr.all.get(0)._accountId)).isEqualTo(user.id());
+ assertThat(Account.id(cr.all.get(0)._accountId)).isEqualTo(user.id());
}
protected void assertMerged(String changeId) throws RestApiException {
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java b/javatests/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
index b0fad7e..631c3d8 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/DeleteVoteIT.java
@@ -104,6 +104,6 @@
}
private Iterable<Account.Id> getReviewers(Collection<AccountInfo> r) {
- return Iterables.transform(r, a -> new Account.Id(a._accountId));
+ return Iterables.transform(r, a -> Account.id(a._accountId));
}
}
diff --git a/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java b/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
index c36e418..c0d09d7 100644
--- a/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/project/CreateBranchIT.java
@@ -112,7 +112,7 @@
allow(allUsers, RefNames.REFS_USERS + "*", Permission.CREATE, REGISTERED_USERS);
allow(allUsers, RefNames.REFS_USERS + "*", Permission.PUSH, REGISTERED_USERS);
assertCreateFails(
- new Branch.NameKey(allUsers, RefNames.refsUsers(new Account.Id(1))),
+ new Branch.NameKey(allUsers, RefNames.refsUsers(Account.id(1))),
RefNames.refsUsers(admin.id()),
ResourceConflictException.class,
"Not allowed to create user branch.");
diff --git a/javatests/com/google/gerrit/acceptance/server/account/AccountResolverIT.java b/javatests/com/google/gerrit/acceptance/server/account/AccountResolverIT.java
index fa1b467..d0faaf3 100644
--- a/javatests/com/google/gerrit/acceptance/server/account/AccountResolverIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/account/AccountResolverIT.java
@@ -123,7 +123,7 @@
Account.Id idWithExistingIdAsFullname =
accountOperations.newAccount().fullname(existingId.toString()).create();
- Account.Id nonexistentId = new Account.Id(sequences.nextAccountId());
+ Account.Id nonexistentId = Account.id(sequences.nextAccountId());
accountOperations.newAccount().fullname(nonexistentId.toString()).create();
assertThat(resolve(existingId)).containsExactly(existingId);
@@ -137,7 +137,7 @@
Account.Id existingId = accountOperations.newAccount().fullname("Test User").create();
accountOperations.newAccount().fullname(existingId.toString()).create();
- Account.Id nonexistentId = new Account.Id(sequences.nextAccountId());
+ Account.Id nonexistentId = Account.id(sequences.nextAccountId());
accountOperations.newAccount().fullname("Any Name (" + nonexistentId + ")").create();
accountOperations.newAccount().fullname(nonexistentId.toString()).create();
diff --git a/javatests/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImplTest.java b/javatests/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImplTest.java
index 4d888ae..1c47e9d 100644
--- a/javatests/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImplTest.java
+++ b/javatests/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImplTest.java
@@ -329,9 +329,9 @@
@Test
public void membersOfExistingGroupCanBeRetrieved() throws Exception {
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
- Account.Id memberId3 = new Account.Id(3000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
+ Account.Id memberId3 = Account.id(3000);
AccountGroup.UUID groupUuid =
groupOperations.newGroup().members(memberId1, memberId2, memberId3).create();
@@ -453,8 +453,8 @@
public void membersCanBeAdded() throws Exception {
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create();
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
groupOperations.group(groupUuid).forUpdate().addMember(memberId1).addMember(memberId2).update();
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
@@ -463,8 +463,8 @@
@Test
public void membersCanBeRemoved() throws Exception {
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
groupOperations.group(groupUuid).forUpdate().removeMember(memberId2).update();
@@ -475,11 +475,11 @@
@Test
public void memberAdditionAndRemovalCanBeMixed() throws Exception {
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
- Account.Id memberId3 = new Account.Id(3000);
+ Account.Id memberId3 = Account.id(3000);
groupOperations
.group(groupUuid)
.forUpdate()
@@ -493,8 +493,8 @@
@Test
public void membersCanBeCleared() throws Exception {
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
groupOperations.group(groupUuid).forUpdate().clearMembers().update();
@@ -505,11 +505,11 @@
@Test
public void furtherMembersCanBeAddedAfterClearingAll() throws Exception {
- Account.Id memberId1 = new Account.Id(1000);
- Account.Id memberId2 = new Account.Id(2000);
+ Account.Id memberId1 = Account.id(1000);
+ Account.Id memberId2 = Account.id(2000);
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
- Account.Id memberId3 = new Account.Id(3000);
+ Account.Id memberId3 = Account.id(3000);
groupOperations.group(groupUuid).forUpdate().clearMembers().addMember(memberId3).update();
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
@@ -618,7 +618,7 @@
Account.Id accountId =
Optional.ofNullable(actualAccount)
.map(account -> account._accountId)
- .map(Account.Id::new)
+ .map(Account::id)
.orElse(null);
return Objects.equals(accountId, expectedId);
},
diff --git a/javatests/com/google/gerrit/acceptance/testsuite/request/RequestScopeOperationsImplTest.java b/javatests/com/google/gerrit/acceptance/testsuite/request/RequestScopeOperationsImplTest.java
index 5cbed1b..96075ec 100644
--- a/javatests/com/google/gerrit/acceptance/testsuite/request/RequestScopeOperationsImplTest.java
+++ b/javatests/com/google/gerrit/acceptance/testsuite/request/RequestScopeOperationsImplTest.java
@@ -68,7 +68,7 @@
public void setApiUserToNonExistingUser() throws Exception {
fastCheckCurrentUser(admin.id());
try {
- requestScopeOperations.setApiUser(new Account.Id(sequences.nextAccountId()));
+ requestScopeOperations.setApiUser(Account.id(sequences.nextAccountId()));
assert_().fail("expected RuntimeException");
} catch (RuntimeException e) {
// Expected.
diff --git a/javatests/com/google/gerrit/common/data/LabelFunctionTest.java b/javatests/com/google/gerrit/common/data/LabelFunctionTest.java
index 8873c81..8d6ec58 100644
--- a/javatests/com/google/gerrit/common/data/LabelFunctionTest.java
+++ b/javatests/com/google/gerrit/common/data/LabelFunctionTest.java
@@ -97,7 +97,7 @@
}
private static PatchSetApproval makeApproval(int value) {
- Account.Id accountId = new Account.Id(10000 + value);
+ Account.Id accountId = Account.id(10000 + value);
PatchSetApproval.Key key = makeKey(PS_ID, accountId, LABEL_ID);
return new PatchSetApproval(key, (short) value, Date.from(Instant.now()));
}
diff --git a/javatests/com/google/gerrit/mail/AbstractParserTest.java b/javatests/com/google/gerrit/mail/AbstractParserTest.java
index bcff6a7..1d92977 100644
--- a/javatests/com/google/gerrit/mail/AbstractParserTest.java
+++ b/javatests/com/google/gerrit/mail/AbstractParserTest.java
@@ -56,7 +56,7 @@
Comment c =
new Comment(
new Comment.Key(uuid, file, 1),
- new Account.Id(0),
+ Account.id(0),
new Timestamp(0L),
(short) 0,
message,
@@ -70,7 +70,7 @@
Comment c =
new Comment(
new Comment.Key(uuid, file, 1),
- new Account.Id(0),
+ Account.id(0),
new Timestamp(0L),
(short) 0,
message,
diff --git a/javatests/com/google/gerrit/reviewdb/client/AccountTest.java b/javatests/com/google/gerrit/reviewdb/client/AccountTest.java
index 11a562f..e8ab613 100644
--- a/javatests/com/google/gerrit/reviewdb/client/AccountTest.java
+++ b/javatests/com/google/gerrit/reviewdb/client/AccountTest.java
@@ -18,6 +18,7 @@
import static com.google.gerrit.reviewdb.client.Account.Id.fromRef;
import static com.google.gerrit.reviewdb.client.Account.Id.fromRefPart;
import static com.google.gerrit.reviewdb.client.Account.Id.fromRefSuffix;
+import static com.google.gerrit.reviewdb.client.Account.id;
import org.junit.Test;
@@ -90,8 +91,4 @@
assertThat(fromRefSuffix("12/34")).isEqualTo(id(34));
assertThat(fromRefSuffix("ab/cd")).isNull();
}
-
- private Account.Id id(int n) {
- return new Account.Id(n);
- }
}
diff --git a/javatests/com/google/gerrit/reviewdb/client/PatchSetApprovalTest.java b/javatests/com/google/gerrit/reviewdb/client/PatchSetApprovalTest.java
index ed09d4a..183f1e1 100644
--- a/javatests/com/google/gerrit/reviewdb/client/PatchSetApprovalTest.java
+++ b/javatests/com/google/gerrit/reviewdb/client/PatchSetApprovalTest.java
@@ -26,13 +26,13 @@
public void keyEquality() {
PatchSetApproval.Key k1 =
PatchSetApproval.key(
- new PatchSet.Id(new Change.Id(1), 2), new Account.Id(3), LabelId.create("My-Label"));
+ new PatchSet.Id(new Change.Id(1), 2), Account.id(3), LabelId.create("My-Label"));
PatchSetApproval.Key k2 =
PatchSetApproval.key(
- new PatchSet.Id(new Change.Id(1), 2), new Account.Id(3), LabelId.create("My-Label"));
+ new PatchSet.Id(new Change.Id(1), 2), Account.id(3), LabelId.create("My-Label"));
PatchSetApproval.Key k3 =
PatchSetApproval.key(
- new PatchSet.Id(new Change.Id(1), 2), new Account.Id(3), LabelId.create("Other-Label"));
+ new PatchSet.Id(new Change.Id(1), 2), Account.id(3), LabelId.create("Other-Label"));
assertThat(k2).isEqualTo(k1);
assertThat(k3).isNotEqualTo(k1);
diff --git a/javatests/com/google/gerrit/reviewdb/client/RefNamesTest.java b/javatests/com/google/gerrit/reviewdb/client/RefNamesTest.java
index efa1834..d58376c 100644
--- a/javatests/com/google/gerrit/reviewdb/client/RefNamesTest.java
+++ b/javatests/com/google/gerrit/reviewdb/client/RefNamesTest.java
@@ -32,7 +32,7 @@
@Rule public ExpectedException expectedException = ExpectedException.none();
- private final Account.Id accountId = new Account.Id(1011123);
+ private final Account.Id accountId = Account.id(1011123);
private final Change.Id changeId = new Change.Id(67473);
private final PatchSet.Id psId = new PatchSet.Id(changeId, 42);
diff --git a/javatests/com/google/gerrit/reviewdb/converter/AccountIdProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/AccountIdProtoConverterTest.java
index 123a973..18ce0fe 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/AccountIdProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/AccountIdProtoConverterTest.java
@@ -30,7 +30,7 @@
@Test
public void allValuesConvertedToProto() {
- Account.Id accountId = new Account.Id(24);
+ Account.Id accountId = Account.id(24);
Entities.Account_Id proto = accountIdProtoConverter.toProto(accountId);
@@ -40,7 +40,7 @@
@Test
public void allValuesConvertedToProtoAndBackAgain() {
- Account.Id accountId = new Account.Id(34832);
+ Account.Id accountId = Account.id(34832);
Account.Id convertedAccountId =
accountIdProtoConverter.fromProto(accountIdProtoConverter.toProto(accountId));
@@ -61,7 +61,8 @@
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
@Test
- public void fieldsExistAsExpected() {
- assertThatSerializedClass(Account.Id.class).hasFields(ImmutableMap.of("id", int.class));
+ public void methodsExistAsExpected() {
+ assertThatSerializedClass(Account.Id.class)
+ .hasAutoValueMethods(ImmutableMap.of("id", int.class));
}
}
diff --git a/javatests/com/google/gerrit/reviewdb/converter/ChangeMessageProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/ChangeMessageProtoConverterTest.java
index 65bdfbb..eb508df 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/ChangeMessageProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/ChangeMessageProtoConverterTest.java
@@ -39,12 +39,12 @@
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(new Change.Id(543), "change-message-21"),
- new Account.Id(63),
+ Account.id(63),
new Timestamp(9876543),
new PatchSet.Id(new Change.Id(34), 13));
changeMessage.setMessage("This is a change message.");
changeMessage.setTag("An arbitrary tag.");
- changeMessage.setRealAuthor(new Account.Id(10003));
+ changeMessage.setRealAuthor(Account.id(10003));
Entities.ChangeMessage proto = changeMessageProtoConverter.toProto(changeMessage);
@@ -72,7 +72,7 @@
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(new Change.Id(543), "change-message-21"),
- new Account.Id(63),
+ Account.id(63),
new Timestamp(9876543),
new PatchSet.Id(new Change.Id(34), 13));
@@ -100,7 +100,7 @@
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(new Change.Id(543), "change-message-21"),
- new Account.Id(63),
+ Account.id(63),
null,
null);
@@ -142,12 +142,12 @@
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(new Change.Id(543), "change-message-21"),
- new Account.Id(63),
+ Account.id(63),
new Timestamp(9876543),
new PatchSet.Id(new Change.Id(34), 13));
changeMessage.setMessage("This is a change message.");
changeMessage.setTag("An arbitrary tag.");
- changeMessage.setRealAuthor(new Account.Id(10003));
+ changeMessage.setRealAuthor(Account.id(10003));
ChangeMessage convertedChangeMessage =
changeMessageProtoConverter.fromProto(changeMessageProtoConverter.toProto(changeMessage));
@@ -159,7 +159,7 @@
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(new Change.Id(543), "change-message-21"),
- new Account.Id(63),
+ Account.id(63),
new Timestamp(9876543),
new PatchSet.Id(new Change.Id(34), 13));
diff --git a/javatests/com/google/gerrit/reviewdb/converter/ChangeProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/ChangeProtoConverterTest.java
index 61bf105..477a92b 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/ChangeProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/ChangeProtoConverterTest.java
@@ -40,7 +40,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch 74"),
new Timestamp(987654L));
change.setLastUpdatedOn(new Timestamp(1234567L));
@@ -49,7 +49,7 @@
new PatchSet.Id(new Change.Id(14), 23), "subject XYZ", "original subject ABC");
change.setTopic("my topic");
change.setSubmissionId("submission ID 234");
- change.setAssignee(new Account.Id(100001));
+ change.setAssignee(Account.id(100001));
change.setPrivate(true);
change.setWorkInProgress(true);
change.setReviewStarted(true);
@@ -90,7 +90,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch-74"),
new Timestamp(987654L));
@@ -126,7 +126,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch-74"),
new Timestamp(987654L));
// O as ID actually means that no current patch set is present.
@@ -164,7 +164,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch-74"),
new Timestamp(987654L));
change.setCurrentPatchSet(new PatchSet.Id(new Change.Id(14), 23), "subject ABC", null);
@@ -201,7 +201,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch-74"),
new Timestamp(987654L));
change.setLastUpdatedOn(new Timestamp(1234567L));
@@ -210,7 +210,7 @@
new PatchSet.Id(new Change.Id(14), 23), "subject XYZ", "original subject ABC");
change.setTopic("my topic");
change.setSubmissionId("submission ID 234");
- change.setAssignee(new Account.Id(100001));
+ change.setAssignee(Account.id(100001));
change.setPrivate(true);
change.setWorkInProgress(true);
change.setReviewStarted(true);
@@ -226,7 +226,7 @@
new Change(
new Change.Key("change 1"),
new Change.Id(14),
- new Account.Id(35),
+ Account.id(35),
new Branch.NameKey(new Project.NameKey("project 67"), "branch-74"),
new Timestamp(987654L));
diff --git a/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalKeyProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalKeyProtoConverterTest.java
index 724d985..c156a67 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalKeyProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalKeyProtoConverterTest.java
@@ -38,9 +38,7 @@
public void allValuesConvertedToProto() {
PatchSetApproval.Key key =
PatchSetApproval.key(
- new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
- LabelId.create("label-8"));
+ new PatchSet.Id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8"));
Entities.PatchSetApproval_Key proto = protoConverter.toProto(key);
@@ -60,9 +58,7 @@
public void allValuesConvertedToProtoAndBackAgain() {
PatchSetApproval.Key key =
PatchSetApproval.key(
- new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
- LabelId.create("label-8"));
+ new PatchSet.Id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8"));
PatchSetApproval.Key convertedKey = protoConverter.fromProto(protoConverter.toProto(key));
diff --git a/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalProtoConverterTest.java
index 6d514913..f262f7e 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/PatchSetApprovalProtoConverterTest.java
@@ -42,12 +42,12 @@
new PatchSetApproval(
PatchSetApproval.key(
new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
+ Account.id(100013),
LabelId.create("label-8")),
(short) 456,
new Date(987654L));
patchSetApproval.setTag("tag-21");
- patchSetApproval.setRealAccountId(new Account.Id(612));
+ patchSetApproval.setRealAccountId(Account.id(612));
patchSetApproval.setPostSubmit(true);
Entities.PatchSetApproval proto = protoConverter.toProto(patchSetApproval);
@@ -77,7 +77,7 @@
new PatchSetApproval(
PatchSetApproval.key(
new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
+ Account.id(100013),
LabelId.create("label-8")),
(short) 456,
new Date(987654L));
@@ -108,12 +108,12 @@
new PatchSetApproval(
PatchSetApproval.key(
new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
+ Account.id(100013),
LabelId.create("label-8")),
(short) 456,
new Date(987654L));
patchSetApproval.setTag("tag-21");
- patchSetApproval.setRealAccountId(new Account.Id(612));
+ patchSetApproval.setRealAccountId(Account.id(612));
patchSetApproval.setPostSubmit(true);
PatchSetApproval convertedPatchSetApproval =
@@ -127,7 +127,7 @@
new PatchSetApproval(
PatchSetApproval.key(
new PatchSet.Id(new Change.Id(42), 14),
- new Account.Id(100013),
+ Account.id(100013),
LabelId.create("label-8")),
(short) 456,
new Date(987654L));
@@ -155,7 +155,7 @@
PatchSetApproval patchSetApproval = protoConverter.fromProto(proto);
assertThat(patchSetApproval.getPatchSetId()).isEqualTo(new PatchSet.Id(new Change.Id(42), 14));
- assertThat(patchSetApproval.getAccountId()).isEqualTo(new Account.Id(100013));
+ assertThat(patchSetApproval.getAccountId()).isEqualTo(Account.id(100013));
assertThat(patchSetApproval.getLabelId()).isEqualTo(LabelId.create("label-8"));
// Default values for unset protobuf fields which can't be unset in the entity object.
assertThat(patchSetApproval.getValue()).isEqualTo(0);
diff --git a/javatests/com/google/gerrit/reviewdb/converter/PatchSetProtoConverterTest.java b/javatests/com/google/gerrit/reviewdb/converter/PatchSetProtoConverterTest.java
index b8d2b1e..187e4b1 100644
--- a/javatests/com/google/gerrit/reviewdb/converter/PatchSetProtoConverterTest.java
+++ b/javatests/com/google/gerrit/reviewdb/converter/PatchSetProtoConverterTest.java
@@ -38,7 +38,7 @@
public void allValuesConvertedToProto() {
PatchSet patchSet = new PatchSet(new PatchSet.Id(new Change.Id(103), 73));
patchSet.setRevision(new RevId("aabbccddeeff"));
- patchSet.setUploader(new Account.Id(452));
+ patchSet.setUploader(Account.id(452));
patchSet.setCreatedOn(new Timestamp(930349320L));
patchSet.setGroups(ImmutableList.of("group1, group2"));
patchSet.setPushCertificate("my push certificate");
@@ -82,7 +82,7 @@
public void allValuesConvertedToProtoAndBackAgain() {
PatchSet patchSet = new PatchSet(new PatchSet.Id(new Change.Id(103), 73));
patchSet.setRevision(new RevId("aabbccddeeff"));
- patchSet.setUploader(new Account.Id(452));
+ patchSet.setUploader(Account.id(452));
patchSet.setCreatedOn(new Timestamp(930349320L));
patchSet.setGroups(ImmutableList.of("group1, group2"));
patchSet.setPushCertificate("my push certificate");
diff --git a/javatests/com/google/gerrit/server/IdentifiedUserTest.java b/javatests/com/google/gerrit/server/IdentifiedUserTest.java
index 485de49..e4278c2 100644
--- a/javatests/com/google/gerrit/server/IdentifiedUserTest.java
+++ b/javatests/com/google/gerrit/server/IdentifiedUserTest.java
@@ -99,7 +99,7 @@
Injector injector = Guice.createInjector(mod);
injector.injectMembers(this);
- Account account = new Account(new Account.Id(1), TimeUtil.nowTs());
+ Account account = new Account(Account.id(1), TimeUtil.nowTs());
Account.Id ownerId = account.getId();
identifiedUser = identifiedUserFactory.create(ownerId);
diff --git a/javatests/com/google/gerrit/server/account/AccountResolverTest.java b/javatests/com/google/gerrit/server/account/AccountResolverTest.java
index 5f662e9..b2484c2 100644
--- a/javatests/com/google/gerrit/server/account/AccountResolverTest.java
+++ b/javatests/com/google/gerrit/server/account/AccountResolverTest.java
@@ -333,17 +333,17 @@
private AccountState newAccount(int id) {
return AccountState.forAccount(
- new AllUsersName("All-Users"), new Account(new Account.Id(id), TimeUtil.nowTs()));
+ new AllUsersName("All-Users"), new Account(Account.id(id), TimeUtil.nowTs()));
}
private AccountState newInactiveAccount(int id) {
- Account a = new Account(new Account.Id(id), TimeUtil.nowTs());
+ Account a = new Account(Account.id(id), TimeUtil.nowTs());
a.setActive(false);
return AccountState.forAccount(new AllUsersName("All-Users"), a);
}
private static ImmutableSet<Account.Id> ids(int... ids) {
- return Arrays.stream(ids).mapToObj(Account.Id::new).collect(toImmutableSet());
+ return Arrays.stream(ids).mapToObj(Account::id).collect(toImmutableSet());
}
private static Supplier<Predicate<AccountState>> allVisible() {
@@ -352,7 +352,7 @@
private static Supplier<Predicate<AccountState>> only(int... ids) {
ImmutableSet<Account.Id> idSet =
- Arrays.stream(ids).mapToObj(Account.Id::new).collect(toImmutableSet());
+ Arrays.stream(ids).mapToObj(Account::id).collect(toImmutableSet());
return () -> a -> idSet.contains(a.getAccount().getId());
}
diff --git a/javatests/com/google/gerrit/server/account/AuthorizedKeysTest.java b/javatests/com/google/gerrit/server/account/AuthorizedKeysTest.java
index 51a34f5..fb98ab5 100644
--- a/javatests/com/google/gerrit/server/account/AuthorizedKeysTest.java
+++ b/javatests/com/google/gerrit/server/account/AuthorizedKeysTest.java
@@ -55,7 +55,7 @@
+ "zRuEL5e/QOu9yGq9xkWApCmg6edpWAHG+Bx4AldU78MiZvzoB7gMMdxc9RmZ1gYj/DjxV"
+ "w== john.doe@example.com";
- private final Account.Id accountId = new Account.Id(1);
+ private final Account.Id accountId = Account.id(1);
@Test
public void test() throws Exception {
@@ -151,7 +151,7 @@
private static void assertParse(
StringBuilder authorizedKeys, List<Optional<AccountSshKey>> expectedKeys) {
- Account.Id accountId = new Account.Id(1);
+ Account.Id accountId = Account.id(1);
List<Optional<AccountSshKey>> parsedKeys =
AuthorizedKeys.parse(accountId, authorizedKeys.toString());
assertThat(parsedKeys).containsExactlyElementsIn(expectedKeys);
@@ -171,7 +171,7 @@
* @return the expected line for this key in the authorized_keys file
*/
private static String addKey(List<Optional<AccountSshKey>> keys, String pub) {
- AccountSshKey key = AccountSshKey.create(new Account.Id(1), keys.size() + 1, pub);
+ AccountSshKey key = AccountSshKey.create(Account.id(1), keys.size() + 1, pub);
keys.add(Optional.of(key));
return key.sshPublicKey() + "\n";
}
@@ -182,7 +182,7 @@
* @return the expected line for this key in the authorized_keys file
*/
private static String addInvalidKey(List<Optional<AccountSshKey>> keys, String pub) {
- AccountSshKey key = AccountSshKey.createInvalid(new Account.Id(1), keys.size() + 1, pub);
+ AccountSshKey key = AccountSshKey.createInvalid(Account.id(1), keys.size() + 1, pub);
keys.add(Optional.of(key));
return AuthorizedKeys.INVALID_KEY_COMMENT_PREFIX + key.sshPublicKey() + "\n";
}
diff --git a/javatests/com/google/gerrit/server/account/WatchConfigTest.java b/javatests/com/google/gerrit/server/account/WatchConfigTest.java
index 2ac7be7..12aa807 100644
--- a/javatests/com/google/gerrit/server/account/WatchConfigTest.java
+++ b/javatests/com/google/gerrit/server/account/WatchConfigTest.java
@@ -54,7 +54,7 @@
+ " notify = [NEW_PATCHSETS]\n"
+ " notify = * [NEW_PATCHSETS, ALL_COMMENTS]\n");
Map<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches =
- ProjectWatches.parse(new Account.Id(1000000), cfg, this);
+ ProjectWatches.parse(Account.id(1000000), cfg, this);
assertThat(validationErrors).isEmpty();
@@ -87,7 +87,7 @@
+ "[project \"otherProject\"]\n"
+ " notify = [NEW_PATCHSETS]\n");
- ProjectWatches.parse(new Account.Id(1000000), cfg, this);
+ ProjectWatches.parse(Account.id(1000000), cfg, this);
assertThat(validationErrors).hasSize(1);
assertThat(validationErrors.get(0).getMessage())
.isEqualTo(
@@ -177,7 +177,7 @@
}
private NotifyValue parseNotifyValue(String notifyValue) {
- return NotifyValue.parse(new Account.Id(1000000), "project", notifyValue, this);
+ return NotifyValue.parse(Account.id(1000000), "project", notifyValue, this);
}
@Override
diff --git a/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java b/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
index d757f71..efb8cd9 100644
--- a/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
+++ b/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
@@ -39,8 +39,8 @@
@Test
public void serializeMultipleExternalIds() throws Exception {
- Account.Id accountId1 = new Account.Id(1001);
- Account.Id accountId2 = new Account.Id(1002);
+ Account.Id accountId1 = Account.id(1001);
+ Account.Id accountId2 = Account.id(1002);
assertRoundTrip(
allExternalIds(
ExternalId.create("scheme1", "id1", accountId1),
@@ -62,7 +62,7 @@
@Test
public void serializeExternalIdWithEmail() throws Exception {
assertRoundTrip(
- allExternalIds(ExternalId.createEmail(new Account.Id(1001), "foo@example.com")),
+ allExternalIds(ExternalId.createEmail(Account.id(1001), "foo@example.com")),
AllExternalIdsProto.newBuilder()
.addExternalId(
ExternalIdProto.newBuilder()
@@ -76,7 +76,7 @@
public void serializeExternalIdWithPassword() throws Exception {
assertRoundTrip(
allExternalIds(
- ExternalId.create("scheme", "id", new Account.Id(1001), null, "hashed password")),
+ ExternalId.create("scheme", "id", Account.id(1001), null, "hashed password")),
AllExternalIdsProto.newBuilder()
.addExternalId(
ExternalIdProto.newBuilder()
@@ -91,7 +91,7 @@
assertRoundTrip(
allExternalIds(
ExternalId.create(
- ExternalId.create("scheme", "id", new Account.Id(1001)),
+ ExternalId.create("scheme", "id", Account.id(1001)),
ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"))),
AllExternalIdsProto.newBuilder()
.addExternalId(
diff --git a/javatests/com/google/gerrit/server/change/WalkSorterTest.java b/javatests/com/google/gerrit/server/change/WalkSorterTest.java
index 189dfbc..bf2ef01 100644
--- a/javatests/com/google/gerrit/server/change/WalkSorterTest.java
+++ b/javatests/com/google/gerrit/server/change/WalkSorterTest.java
@@ -45,7 +45,7 @@
@Before
public void setUp() {
- userId = new Account.Id(1);
+ userId = Account.id(1);
repoManager = new InMemoryRepositoryManager();
}
diff --git a/javatests/com/google/gerrit/server/edit/ChangeEditTest.java b/javatests/com/google/gerrit/server/edit/ChangeEditTest.java
index 4c0b5a1..25a3598 100644
--- a/javatests/com/google/gerrit/server/edit/ChangeEditTest.java
+++ b/javatests/com/google/gerrit/server/edit/ChangeEditTest.java
@@ -26,7 +26,7 @@
public class ChangeEditTest extends GerritBaseTests {
@Test
public void changeEditRef() throws Exception {
- Account.Id accountId = new Account.Id(1000042);
+ Account.Id accountId = Account.id(1000042);
Change.Id changeId = new Change.Id(56414);
PatchSet.Id psId = new PatchSet.Id(changeId, 50);
String refName = RefNames.refsEdit(accountId, changeId, psId);
diff --git a/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java b/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java
index 4a1f47c..58e0374 100644
--- a/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java
+++ b/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java
@@ -112,7 +112,7 @@
@Override
public Account.Id getAccountId() {
- return new Account.Id(1);
+ return Account.id(1);
}
};
}
diff --git a/javatests/com/google/gerrit/server/group/db/AbstractGroupTest.java b/javatests/com/google/gerrit/server/group/db/AbstractGroupTest.java
index 9fc6da1..2bb22ed 100644
--- a/javatests/com/google/gerrit/server/group/db/AbstractGroupTest.java
+++ b/javatests/com/google/gerrit/server/group/db/AbstractGroupTest.java
@@ -65,9 +65,9 @@
allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
repoManager = new InMemoryRepositoryManager();
allUsersRepo = repoManager.createRepository(allUsersName);
- serverAccountId = new Account.Id(SERVER_ACCOUNT_NUMBER);
+ serverAccountId = Account.id(SERVER_ACCOUNT_NUMBER);
serverIdent = new PersonIdent(SERVER_NAME, SERVER_EMAIL, TimeUtil.nowTs(), TZ);
- userId = new Account.Id(USER_ACCOUNT_NUMBER);
+ userId = Account.id(USER_ACCOUNT_NUMBER);
userIdent = newPersonIdent(userId, serverIdent);
}
diff --git a/javatests/com/google/gerrit/server/group/db/AuditLogReaderTest.java b/javatests/com/google/gerrit/server/group/db/AuditLogReaderTest.java
index ce6258d..34a25bd 100644
--- a/javatests/com/google/gerrit/server/group/db/AuditLogReaderTest.java
+++ b/javatests/com/google/gerrit/server/group/db/AuditLogReaderTest.java
@@ -66,7 +66,7 @@
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1);
// User adds account 100002 to the group.
- Account.Id id = new Account.Id(100002);
+ Account.Id id = Account.id(100002);
addMembers(uuid, ImmutableSet.of(id));
AccountGroupMemberAudit expAudit2 =
@@ -94,8 +94,8 @@
createExpMemberAudit(groupId, userId, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expAudit1);
- Account.Id id1 = new Account.Id(100002);
- Account.Id id2 = new Account.Id(100003);
+ Account.Id id1 = Account.id(100002);
+ Account.Id id2 = Account.id(100003);
addMembers(uuid, ImmutableSet.of(id1, id2));
AccountGroupMemberAudit expAudit2 =
@@ -158,9 +158,9 @@
createExpMemberAudit(groupId, userId, userId, getTipTimestamp(uuid));
assertThat(auditLogReader.getMembersAudit(allUsersRepo, uuid)).containsExactly(expMemberAudit);
- Account.Id id1 = new Account.Id(100002);
- Account.Id id2 = new Account.Id(100003);
- Account.Id id3 = new Account.Id(100004);
+ Account.Id id1 = Account.id(100002);
+ Account.Id id2 = Account.id(100003);
+ Account.Id id3 = Account.id(100004);
InternalGroup subgroup1 = createGroupAsUser(2, "test-group-2");
InternalGroup subgroup2 = createGroupAsUser(3, "test-group-3");
InternalGroup subgroup3 = createGroupAsUser(4, "test-group-4");
diff --git a/javatests/com/google/gerrit/server/group/db/GroupConfigTest.java b/javatests/com/google/gerrit/server/group/db/GroupConfigTest.java
index d4f64a9..4ce0d29 100644
--- a/javatests/com/google/gerrit/server/group/db/GroupConfigTest.java
+++ b/javatests/com/google/gerrit/server/group/db/GroupConfigTest.java
@@ -275,8 +275,8 @@
@Test
public void specifiedMembersAreRespectedForNewGroup() throws Exception {
- Account.Id member1 = new Account.Id(1);
- Account.Id member2 = new Account.Id(2);
+ Account.Id member1 = Account.id(1);
+ Account.Id member2 = Account.id(2);
InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
InternalGroupUpdate groupUpdate =
@@ -402,12 +402,12 @@
.value()
.members()
.containsExactly(
- new Account.Id(1),
- new Account.Id(2),
- new Account.Id(3),
- new Account.Id(4),
- new Account.Id(5),
- new Account.Id(6));
+ Account.id(1),
+ Account.id(2),
+ Account.id(3),
+ Account.id(4),
+ Account.id(5),
+ Account.id(6));
}
@Test
@@ -628,8 +628,8 @@
@Test
public void membersCanBeAdded() throws Exception {
createArbitraryGroup(groupUuid);
- Account.Id member1 = new Account.Id(1);
- Account.Id member2 = new Account.Id(2);
+ Account.Id member1 = Account.id(1);
+ Account.Id member2 = Account.id(2);
InternalGroupUpdate groupUpdate1 =
InternalGroupUpdate.builder()
@@ -650,8 +650,8 @@
@Test
public void membersCanBeDeleted() throws Exception {
createArbitraryGroup(groupUuid);
- Account.Id member1 = new Account.Id(1);
- Account.Id member2 = new Account.Id(2);
+ Account.Id member1 = Account.id(1);
+ Account.Id member2 = Account.id(2);
InternalGroupUpdate groupUpdate1 =
InternalGroupUpdate.builder()
@@ -742,7 +742,7 @@
.setVisibleToAll(true)
.setName(AccountGroup.nameKey("Another name"))
.setUpdatedOn(new Timestamp(92900892))
- .setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
+ .setMemberModification(members -> ImmutableSet.of(Account.id(1), Account.id(2)))
.setSubgroupModification(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
.build();
@@ -763,7 +763,7 @@
.setVisibleToAll(true)
.setName(AccountGroup.nameKey("Another name"))
.setUpdatedOn(new Timestamp(92900892))
- .setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
+ .setMemberModification(members -> ImmutableSet.of(Account.id(1), Account.id(2)))
.setSubgroupModification(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
.build();
@@ -785,7 +785,7 @@
.setVisibleToAll(true)
.setName(AccountGroup.nameKey("Another name"))
.setUpdatedOn(new Timestamp(92900892))
- .setMemberModification(members -> ImmutableSet.of(new Account.Id(1), new Account.Id(2)))
+ .setMemberModification(members -> ImmutableSet.of(Account.id(1), Account.id(2)))
.setSubgroupModification(subgroups -> ImmutableSet.of(AccountGroup.uuid("subgroup")))
.build();
createGroup(groupCreation, initialGroupUpdate);
@@ -943,8 +943,7 @@
InternalGroupUpdate groupUpdate =
InternalGroupUpdate.builder()
- .setMemberModification(
- members -> Sets.union(members, ImmutableSet.of(new Account.Id(10))))
+ .setMemberModification(members -> Sets.union(members, ImmutableSet.of(Account.id(10))))
.build();
updateGroup(groupUuid, groupUpdate);
@@ -1258,8 +1257,8 @@
@Test
public void commitMessageOfNewGroupWithMembersContainsFooters() throws Exception {
- Account account13 = createAccount(new Account.Id(13), "John");
- Account account7 = createAccount(new Account.Id(7), "Jane");
+ Account account13 = createAccount(Account.id(13), "John");
+ Account account7 = createAccount(Account.id(7), "Jane");
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
AuditLogFormatter auditLogFormatter =
@@ -1308,8 +1307,8 @@
@Test
public void commitMessageOfMemberAdditionContainsFooters() throws Exception {
- Account account13 = createAccount(new Account.Id(13), "John");
- Account account7 = createAccount(new Account.Id(7), "Jane");
+ Account account13 = createAccount(Account.id(13), "John");
+ Account account7 = createAccount(Account.id(7), "Jane");
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
createArbitraryGroup(groupUuid);
@@ -1330,8 +1329,8 @@
@Test
public void commitMessageOfMemberRemovalContainsFooters() throws Exception {
- Account account13 = createAccount(new Account.Id(13), "John");
- Account account7 = createAccount(new Account.Id(7), "Jane");
+ Account account13 = createAccount(Account.id(13), "John");
+ Account account7 = createAccount(Account.id(7), "Jane");
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
createArbitraryGroup(groupUuid);
@@ -1426,8 +1425,8 @@
@Test
public void commitMessageFootersCanBeMixed() throws Exception {
- Account account13 = createAccount(new Account.Id(13), "John");
- Account account7 = createAccount(new Account.Id(7), "Jane");
+ Account account13 = createAccount(Account.id(13), "John");
+ Account account7 = createAccount(Account.id(7), "Jane");
ImmutableSet<Account> accounts = ImmutableSet.of(account13, account7);
GroupDescription.Basic group1 = createGroup(AccountGroup.uuid("129403"), "Bots");
GroupDescription.Basic group2 = createGroup(AccountGroup.uuid("8903493"), "Verifiers");
diff --git a/javatests/com/google/gerrit/server/index/account/AccountFieldTest.java b/javatests/com/google/gerrit/server/index/account/AccountFieldTest.java
index c69fa20..868deeb 100644
--- a/javatests/com/google/gerrit/server/index/account/AccountFieldTest.java
+++ b/javatests/com/google/gerrit/server/index/account/AccountFieldTest.java
@@ -37,7 +37,7 @@
@Test
public void refStateFieldValues() throws Exception {
AllUsersName allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
- Account account = new Account(new Account.Id(1), TimeUtil.nowTs());
+ Account account = new Account(Account.id(1), TimeUtil.nowTs());
String metaId = "0e39795bb25dc914118224995c53c5c36923a461";
account.setMetaId(metaId);
List<String> values =
@@ -50,7 +50,7 @@
@Test
public void externalIdStateFieldValues() throws Exception {
- Account.Id id = new Account.Id(1);
+ Account.Id id = Account.id(1);
Account account = new Account(id, TimeUtil.nowTs());
ExternalId extId1 =
ExternalId.create(
diff --git a/javatests/com/google/gerrit/server/index/change/ChangeFieldTest.java b/javatests/com/google/gerrit/server/index/change/ChangeFieldTest.java
index 758c304..d3762af 100644
--- a/javatests/com/google/gerrit/server/index/change/ChangeFieldTest.java
+++ b/javatests/com/google/gerrit/server/index/change/ChangeFieldTest.java
@@ -53,9 +53,9 @@
public void reviewerFieldValues() {
Table<ReviewerStateInternal, Account.Id, Timestamp> t = HashBasedTable.create();
Timestamp t1 = TimeUtil.nowTs();
- t.put(ReviewerStateInternal.REVIEWER, new Account.Id(1), t1);
+ t.put(ReviewerStateInternal.REVIEWER, Account.id(1), t1);
Timestamp t2 = TimeUtil.nowTs();
- t.put(ReviewerStateInternal.CC, new Account.Id(2), t2);
+ t.put(ReviewerStateInternal.CC, Account.id(2), t2);
ReviewerSet reviewers = ReviewerSet.fromTable(t);
List<String> values = ChangeField.getReviewerFieldValues(reviewers);
@@ -75,7 +75,7 @@
SubmitRecord.Status.OK,
label(SubmitRecord.Label.Status.MAY, "Label-1", null),
label(SubmitRecord.Label.Status.OK, "Label-2", 1))),
- new Account.Id(1)))
+ Account.id(1)))
.containsExactly("OK", "MAY,label-1", "OK,label-2", "OK,label-2,0", "OK,label-2,1");
}
@@ -142,7 +142,7 @@
l.status = status;
l.label = label;
if (appliedBy != null) {
- l.appliedBy = new Account.Id(appliedBy);
+ l.appliedBy = Account.id(appliedBy);
}
return l;
}
diff --git a/javatests/com/google/gerrit/server/mail/send/FromAddressGeneratorProviderTest.java b/javatests/com/google/gerrit/server/mail/send/FromAddressGeneratorProviderTest.java
index 537ebff..73c59f2 100644
--- a/javatests/com/google/gerrit/server/mail/send/FromAddressGeneratorProviderTest.java
+++ b/javatests/com/google/gerrit/server/mail/send/FromAddressGeneratorProviderTest.java
@@ -380,7 +380,7 @@
}
private AccountState makeUser(String name, String email) {
- final Account.Id userId = new Account.Id(42);
+ final Account.Id userId = Account.id(42);
final Account account = new Account(userId, TimeUtil.nowTs());
account.setFullName(name);
account.setPreferredEmail(email);
diff --git a/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java
index a1f318f..1a408c3 100644
--- a/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java
+++ b/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java
@@ -116,11 +116,11 @@
tr = new TestRepository<>(repo);
rw = tr.getRevWalk();
accountCache = new FakeAccountCache();
- Account co = new Account(new Account.Id(1), TimeUtil.nowTs());
+ Account co = new Account(Account.id(1), TimeUtil.nowTs());
co.setFullName("Change Owner");
co.setPreferredEmail("change@owner.com");
accountCache.put(co);
- Account ou = new Account(new Account.Id(2), TimeUtil.nowTs());
+ Account ou = new Account(Account.id(2), TimeUtil.nowTs());
ou.setFullName("Other Account");
ou.setPreferredEmail("other@account.com");
accountCache.put(ou);
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
index 342bc43..bfe3910 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
@@ -78,7 +78,7 @@
.changeKey(new Change.Key(CHANGE_KEY))
.createdOn(new Timestamp(123456L))
.lastUpdatedOn(new Timestamp(234567L))
- .owner(new Account.Id(1000))
+ .owner(Account.id(1000))
.branch("refs/heads/master")
.subject("Test change")
.isPrivate(false)
@@ -134,7 +134,7 @@
@Test
public void serializeOwner() throws Exception {
assertRoundTrip(
- newBuilder().columns(cols.toBuilder().owner(new Account.Id(7777)).build()).build(),
+ newBuilder().columns(cols.toBuilder().owner(Account.id(7777)).build()).build(),
ChangeNotesStateProto.newBuilder()
.setMetaId(SHA_BYTES)
.setChangeId(ID.get())
@@ -243,7 +243,7 @@
@Test
public void serializeAssignee() throws Exception {
assertRoundTrip(
- newBuilder().columns(cols.toBuilder().assignee(new Account.Id(2000)).build()).build(),
+ newBuilder().columns(cols.toBuilder().assignee(Account.id(2000)).build()).build(),
ChangeNotesStateProto.newBuilder()
.setMetaId(SHA_BYTES)
.setChangeId(ID.get())
@@ -309,9 +309,7 @@
@Test
public void serializePastAssignees() throws Exception {
assertRoundTrip(
- newBuilder()
- .pastAssignees(ImmutableSet.of(new Account.Id(2002), new Account.Id(2001)))
- .build(),
+ newBuilder().pastAssignees(ImmutableSet.of(Account.id(2002), Account.id(2001))).build(),
ChangeNotesStateProto.newBuilder()
.setMetaId(SHA_BYTES)
.setChangeId(ID.get())
@@ -337,14 +335,14 @@
@Test
public void serializePatchSets() throws Exception {
PatchSet ps1 = new PatchSet(new PatchSet.Id(ID, 1));
- ps1.setUploader(new Account.Id(2000));
+ ps1.setUploader(Account.id(2000));
ps1.setRevision(new RevId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
ps1.setCreatedOn(cols.createdOn());
ByteString ps1Bytes = toByteString(ps1, PatchSetProtoConverter.INSTANCE);
assertThat(ps1Bytes.size()).isEqualTo(66);
PatchSet ps2 = new PatchSet(new PatchSet.Id(ID, 2));
- ps2.setUploader(new Account.Id(3000));
+ ps2.setUploader(Account.id(3000));
ps2.setRevision(new RevId("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"));
ps2.setCreatedOn(cols.lastUpdatedOn());
ByteString ps2Bytes = toByteString(ps2, PatchSetProtoConverter.INSTANCE);
@@ -369,7 +367,7 @@
PatchSetApproval a1 =
new PatchSetApproval(
PatchSetApproval.key(
- new PatchSet.Id(ID, 1), new Account.Id(2001), LabelId.create("Code-Review")),
+ new PatchSet.Id(ID, 1), Account.id(2001), LabelId.create("Code-Review")),
(short) 1,
new Timestamp(1212L));
ByteString a1Bytes = toByteString(a1, PatchSetApprovalProtoConverter.INSTANCE);
@@ -378,7 +376,7 @@
PatchSetApproval a2 =
new PatchSetApproval(
PatchSetApproval.key(
- new PatchSet.Id(ID, 1), new Account.Id(2002), LabelId.create("Verified")),
+ new PatchSet.Id(ID, 1), Account.id(2002), LabelId.create("Verified")),
(short) -1,
new Timestamp(3434L));
ByteString a2Bytes = toByteString(a2, PatchSetApprovalProtoConverter.INSTANCE);
@@ -406,11 +404,8 @@
.reviewers(
ReviewerSet.fromTable(
ImmutableTable.<ReviewerStateInternal, Account.Id, Timestamp>builder()
- .put(ReviewerStateInternal.CC, new Account.Id(2001), new Timestamp(1212L))
- .put(
- ReviewerStateInternal.REVIEWER,
- new Account.Id(2002),
- new Timestamp(3434L))
+ .put(ReviewerStateInternal.CC, Account.id(2001), new Timestamp(1212L))
+ .put(ReviewerStateInternal.REVIEWER, Account.id(2002), new Timestamp(3434L))
.build()))
.build(),
ChangeNotesStateProto.newBuilder()
@@ -503,11 +498,8 @@
.pendingReviewers(
ReviewerSet.fromTable(
ImmutableTable.<ReviewerStateInternal, Account.Id, Timestamp>builder()
- .put(ReviewerStateInternal.CC, new Account.Id(2001), new Timestamp(1212L))
- .put(
- ReviewerStateInternal.REVIEWER,
- new Account.Id(2002),
- new Timestamp(3434L))
+ .put(ReviewerStateInternal.CC, Account.id(2001), new Timestamp(1212L))
+ .put(ReviewerStateInternal.REVIEWER, Account.id(2002), new Timestamp(3434L))
.build()))
.build(),
ChangeNotesStateProto.newBuilder()
@@ -564,9 +556,7 @@
@Test
public void serializeAllPastReviewers() throws Exception {
assertRoundTrip(
- newBuilder()
- .allPastReviewers(ImmutableList.of(new Account.Id(2002), new Account.Id(2001)))
- .build(),
+ newBuilder().allPastReviewers(ImmutableList.of(Account.id(2002), Account.id(2001))).build(),
ChangeNotesStateProto.newBuilder()
.setMetaId(SHA_BYTES)
.setChangeId(ID.get())
@@ -584,13 +574,13 @@
ImmutableList.of(
ReviewerStatusUpdate.create(
new Timestamp(1212L),
- new Account.Id(1000),
- new Account.Id(2002),
+ Account.id(1000),
+ Account.id(2002),
ReviewerStateInternal.CC),
ReviewerStatusUpdate.create(
new Timestamp(3434L),
- new Account.Id(1000),
- new Account.Id(2001),
+ Account.id(1000),
+ Account.id(2001),
ReviewerStateInternal.REVIEWER)))
.build(),
ChangeNotesStateProto.newBuilder()
@@ -636,7 +626,7 @@
ChangeMessage m1 =
new ChangeMessage(
new ChangeMessage.Key(ID, "uuid1"),
- new Account.Id(1000),
+ Account.id(1000),
new Timestamp(1212L),
new PatchSet.Id(ID, 1));
ByteString m1Bytes = toByteString(m1, ChangeMessageProtoConverter.INSTANCE);
@@ -645,7 +635,7 @@
ChangeMessage m2 =
new ChangeMessage(
new ChangeMessage.Key(ID, "uuid2"),
- new Account.Id(2000),
+ Account.id(2000),
new Timestamp(3434L),
new PatchSet.Id(ID, 2));
ByteString m2Bytes = toByteString(m2, ChangeMessageProtoConverter.INSTANCE);
@@ -668,7 +658,7 @@
Comment c1 =
new Comment(
new Comment.Key("uuid1", "file1", 1),
- new Account.Id(1001),
+ Account.id(1001),
new Timestamp(1212L),
(short) 1,
"message 1",
@@ -680,7 +670,7 @@
Comment c2 =
new Comment(
new Comment.Key("uuid2", "file2", 2),
- new Account.Id(1002),
+ Account.id(1002),
new Timestamp(3434L),
(short) 2,
"message 2",
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
index a57a984..f73c71c 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
@@ -516,8 +516,8 @@
.isEqualTo(
ReviewerSet.fromTable(
ImmutableTable.<ReviewerStateInternal, Account.Id, Timestamp>builder()
- .put(REVIEWER, new Account.Id(1), ts)
- .put(REVIEWER, new Account.Id(2), ts)
+ .put(REVIEWER, Account.id(1), ts)
+ .put(REVIEWER, Account.id(2), ts)
.build()));
}
@@ -535,8 +535,8 @@
.isEqualTo(
ReviewerSet.fromTable(
ImmutableTable.<ReviewerStateInternal, Account.Id, Timestamp>builder()
- .put(REVIEWER, new Account.Id(1), ts)
- .put(CC, new Account.Id(2), ts)
+ .put(REVIEWER, Account.id(1), ts)
+ .put(CC, Account.id(2), ts)
.build()));
}
@@ -550,7 +550,7 @@
ChangeNotes notes = newNotes(c);
Timestamp ts = new Timestamp(update.getWhen().getTime());
assertThat(notes.getReviewers())
- .isEqualTo(ReviewerSet.fromTable(ImmutableTable.of(REVIEWER, new Account.Id(2), ts)));
+ .isEqualTo(ReviewerSet.fromTable(ImmutableTable.of(REVIEWER, Account.id(2), ts)));
update = newUpdate(c, otherUser);
update.putReviewer(otherUser.getAccount().getId(), CC);
@@ -559,7 +559,7 @@
notes = newNotes(c);
ts = new Timestamp(update.getWhen().getTime());
assertThat(notes.getReviewers())
- .isEqualTo(ReviewerSet.fromTable(ImmutableTable.of(CC, new Account.Id(2), ts)));
+ .isEqualTo(ReviewerSet.fromTable(ImmutableTable.of(CC, Account.id(2), ts)));
}
@Test
@@ -1673,7 +1673,7 @@
@Test
public void patchLineCommentNotesFormatWeirdUser() throws Exception {
- Account account = new Account(new Account.Id(3), TimeUtil.nowTs());
+ Account account = new Account(Account.id(3), TimeUtil.nowTs());
account.setFullName("Weird\n\u0002<User>\n");
account.setPreferredEmail(" we\r\nird@ex>ample<.com");
accountCache.put(account);
diff --git a/javatests/com/google/gerrit/server/notedb/CommentTimestampAdapterTest.java b/javatests/com/google/gerrit/server/notedb/CommentTimestampAdapterTest.java
index 4dd2005..d146969 100644
--- a/javatests/com/google/gerrit/server/notedb/CommentTimestampAdapterTest.java
+++ b/javatests/com/google/gerrit/server/notedb/CommentTimestampAdapterTest.java
@@ -153,7 +153,7 @@
Comment c =
new Comment(
new Comment.Key("uuid", "filename", 1),
- new Account.Id(100),
+ Account.id(100),
NON_DST_TS,
(short) 0,
"message",
diff --git a/javatests/com/google/gerrit/server/notedb/CommitMessageOutputTest.java b/javatests/com/google/gerrit/server/notedb/CommitMessageOutputTest.java
index 5552572..9e1d0c1 100644
--- a/javatests/com/google/gerrit/server/notedb/CommitMessageOutputTest.java
+++ b/javatests/com/google/gerrit/server/notedb/CommitMessageOutputTest.java
@@ -199,7 +199,7 @@
@Test
public void anonymousUser() throws Exception {
- Account anon = new Account(new Account.Id(3), TimeUtil.nowTs());
+ Account anon = new Account(Account.id(3), TimeUtil.nowTs());
accountCache.put(anon);
Change c = newChange();
ChangeUpdate update = newUpdate(c, userFactory.create(anon.getId()));
diff --git a/javatests/com/google/gerrit/server/query/account/AbstractQueryAccountsTest.java b/javatests/com/google/gerrit/server/query/account/AbstractQueryAccountsTest.java
index a2b2866..dad26e1 100644
--- a/javatests/com/google/gerrit/server/query/account/AbstractQueryAccountsTest.java
+++ b/javatests/com/google/gerrit/server/query/account/AbstractQueryAccountsTest.java
@@ -253,7 +253,7 @@
addEmails(user1, secondaryEmail);
AccountInfo user2 = newAccount("user");
- requestContext.setContext(newRequestContext(new Account.Id(user2._accountId)));
+ requestContext.setContext(newRequestContext(Account.id(user2._accountId)));
if (getSchemaVersion() < 5) {
assertMissingField(AccountField.PREFERRED_EMAIL);
@@ -340,7 +340,7 @@
AccountInfo user2 = newAccountWithFullName("jroe", "Jane Roe");
AccountInfo user3 = newAccount("user");
- requestContext.setContext(newRequestContext(new Account.Id(user3._accountId)));
+ requestContext.setContext(newRequestContext(Account.id(user3._accountId)));
assertQuery("notexisting");
assertQuery("Not Existing");
@@ -575,7 +575,7 @@
String[] secondaryEmails = new String[] {"dfg@example.com", "hij@example.com"};
addEmails(otherUser, secondaryEmails);
- requestContext.setContext(newRequestContext(new Account.Id(user._accountId)));
+ requestContext.setContext(newRequestContext(Account.id(user._accountId)));
List<AccountInfo> result = newQuery(otherUser.username).withSuggest(true).get();
assertThat(result.get(0).secondaryEmails).isNull();
@@ -600,7 +600,7 @@
AccountInfo user1 = newAccountWithFullName("tester", "Test Usre");
// update account without reindex so that account index is stale
- Account.Id accountId = new Account.Id(user1._accountId);
+ Account.Id accountId = Account.id(user1._accountId);
String newName = "Test User";
try (Repository repo = repoManager.openRepository(allUsers)) {
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsers, repo);
@@ -629,7 +629,7 @@
indexes
.getSearchIndex()
.getRaw(
- new Account.Id(userInfo._accountId),
+ Account.id(userInfo._accountId),
QueryOptions.create(
IndexConfig.createDefault(),
0,
@@ -777,7 +777,7 @@
}
private void addEmails(AccountInfo account, String... emails) throws Exception {
- Account.Id id = new Account.Id(account._accountId);
+ Account.Id id = Account.id(account._accountId);
for (String email : emails) {
accountManager.link(id, AuthRequest.forEmail(email));
}
diff --git a/javatests/com/google/gerrit/server/query/change/ChangeDataTest.java b/javatests/com/google/gerrit/server/query/change/ChangeDataTest.java
index aba0018..d77cbcd 100644
--- a/javatests/com/google/gerrit/server/query/change/ChangeDataTest.java
+++ b/javatests/com/google/gerrit/server/query/change/ChangeDataTest.java
@@ -30,7 +30,7 @@
public void setPatchSetsClearsCurrentPatchSet() throws Exception {
Project.NameKey project = new Project.NameKey("project");
ChangeData cd = ChangeData.createForTest(project, new Change.Id(1), 1);
- cd.setChange(TestChanges.newChange(project, new Account.Id(1000)));
+ cd.setChange(TestChanges.newChange(project, Account.id(1000)));
PatchSet curr1 = cd.currentPatchSet();
int currId = curr1.getId().get();
PatchSet ps1 = new PatchSet(new PatchSet.Id(cd.getId(), currId + 1));
diff --git a/javatests/com/google/gerrit/server/rules/IgnoreSelfApprovalRuleTest.java b/javatests/com/google/gerrit/server/rules/IgnoreSelfApprovalRuleTest.java
index a2a718a..a0d0f3c 100644
--- a/javatests/com/google/gerrit/server/rules/IgnoreSelfApprovalRuleTest.java
+++ b/javatests/com/google/gerrit/server/rules/IgnoreSelfApprovalRuleTest.java
@@ -92,6 +92,6 @@
}
private static Account.Id makeAccount(int account) {
- return new Account.Id(account);
+ return Account.id(account);
}
}
diff --git a/plugins/hooks b/plugins/hooks
index 4928874..976a6d1 160000
--- a/plugins/hooks
+++ b/plugins/hooks
@@ -1 +1 @@
-Subproject commit 492887449bf66b0f828aa26506629a8f5838f4d3
+Subproject commit 976a6d10eec7b971254217df0399407f8543b37f
diff --git a/plugins/singleusergroup b/plugins/singleusergroup
index 04783e4..ce8b761 160000
--- a/plugins/singleusergroup
+++ b/plugins/singleusergroup
@@ -1 +1 @@
-Subproject commit 04783e4763622e3378e2f35d72cde6e14e3239ad
+Subproject commit ce8b76168588c0ee5fbb04bee31ba89088957c86