Convert Change.Id to AutoValue
See I6982fb24 for context. Change-Id: I95de46939a11d9a6116680f5b881cdfcf6fe705a
This commit is contained in:
		@@ -208,7 +208,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
 | 
			
		||||
      int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
 | 
			
		||||
      // IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
 | 
			
		||||
      String projectName = requireNonNull(source.get(ChangeField.PROJECT.getName()).getAsString());
 | 
			
		||||
      return changeDataFactory.create(Project.nameKey(projectName), new Change.Id(id));
 | 
			
		||||
      return changeDataFactory.create(Project.nameKey(projectName), Change.id(id));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ChangeData cd =
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ class DirectChangeByCommit extends HttpServlet {
 | 
			
		||||
      // If exactly one change matches, link to that change.
 | 
			
		||||
      // TODO Link to a specific patch set, if one matched.
 | 
			
		||||
      ChangeInfo ci = results.iterator().next();
 | 
			
		||||
      token = PageLinks.toChange(Project.nameKey(ci.project), new Change.Id(ci._number));
 | 
			
		||||
      token = PageLinks.toChange(Project.nameKey(ci.project), Change.id(ci._number));
 | 
			
		||||
    } else {
 | 
			
		||||
      // Otherwise, link to the query page.
 | 
			
		||||
      token = PageLinks.toChangeQuery(query);
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ public class NumericChangeIdRedirectServlet extends HttpServlet {
 | 
			
		||||
      rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
 | 
			
		||||
      return;
 | 
			
		||||
    } catch (PermissionBackendException | RuntimeException e) {
 | 
			
		||||
      throw new IOException("Unable to lookup change " + id.id, e);
 | 
			
		||||
      throw new IOException("Unable to lookup change " + id.get(), e);
 | 
			
		||||
    }
 | 
			
		||||
    String path =
 | 
			
		||||
        PageLinks.toChange(changeResource.getProject(), changeResource.getChange().getId());
 | 
			
		||||
 
 | 
			
		||||
@@ -450,7 +450,7 @@ public class LuceneChangeIndex implements ChangeIndex {
 | 
			
		||||
      cd = changeDataFactory.create(parseProtoFrom(proto, ChangeProtoConverter.INSTANCE));
 | 
			
		||||
    } else {
 | 
			
		||||
      IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
 | 
			
		||||
      Change.Id id = new Change.Id(f.numericValue().intValue());
 | 
			
		||||
      Change.Id id = Change.id(f.numericValue().intValue());
 | 
			
		||||
      // IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
 | 
			
		||||
      IndexableField project = doc.get(PROJECT.getName()).iterator().next();
 | 
			
		||||
      cd = changeDataFactory.create(Project.nameKey(project.stringValue()), id);
 | 
			
		||||
 
 | 
			
		||||
@@ -14,12 +14,13 @@
 | 
			
		||||
 | 
			
		||||
package com.google.gerrit.reviewdb.client;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.base.Preconditions.checkArgument;
 | 
			
		||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES;
 | 
			
		||||
 | 
			
		||||
import com.google.auto.value.AutoValue;
 | 
			
		||||
import com.google.common.primitives.Ints;
 | 
			
		||||
import com.google.gerrit.common.Nullable;
 | 
			
		||||
import com.google.gerrit.extensions.client.ChangeStatus;
 | 
			
		||||
import com.google.gwtorm.client.IntKey;
 | 
			
		||||
import com.google.gwtorm.client.StandardKeyEncoder;
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
@@ -94,45 +95,17 @@ import java.util.Arrays;
 | 
			
		||||
 * notice of a replacement patch set is sent, or when notice of the change submission occurs.
 | 
			
		||||
 */
 | 
			
		||||
public final class Change {
 | 
			
		||||
  public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    public 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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String toRefPrefix() {
 | 
			
		||||
      return refPrefixBuilder().toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    StringBuilder refPrefixBuilder() {
 | 
			
		||||
      StringBuilder r = new StringBuilder(32).append(REFS_CHANGES);
 | 
			
		||||
      int m = id % 100;
 | 
			
		||||
      if (m < 10) {
 | 
			
		||||
        r.append('0');
 | 
			
		||||
      }
 | 
			
		||||
      return r.append(m).append('/').append(id).append('/');
 | 
			
		||||
    }
 | 
			
		||||
  public static Id id(int id) {
 | 
			
		||||
    return new AutoValue_Change_Id(id);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @AutoValue
 | 
			
		||||
  public abstract static class Id {
 | 
			
		||||
    /** Parse a Change.Id out of a string representation. */
 | 
			
		||||
    public static Id parse(String str) {
 | 
			
		||||
      final Id r = new Id();
 | 
			
		||||
      r.fromString(str);
 | 
			
		||||
      return r;
 | 
			
		||||
      Integer id = Ints.tryParse(str);
 | 
			
		||||
      checkArgument(id != null, "invalid change ID: %s", str);
 | 
			
		||||
      return Change.id(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Id fromRef(String ref) {
 | 
			
		||||
@@ -147,7 +120,7 @@ public final class Change {
 | 
			
		||||
      if (ref.substring(ce).equals(RefNames.META_SUFFIX)
 | 
			
		||||
          || ref.substring(ce).equals(RefNames.ROBOT_COMMENTS_SUFFIX)
 | 
			
		||||
          || PatchSet.Id.fromRef(ref, ce) >= 0) {
 | 
			
		||||
        return new Change.Id(Integer.parseInt(ref.substring(cs, ce)));
 | 
			
		||||
        return Change.id(Integer.parseInt(ref.substring(cs, ce)));
 | 
			
		||||
      }
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
@@ -170,7 +143,7 @@ public final class Change {
 | 
			
		||||
      }
 | 
			
		||||
      int ce = nextNonDigit(ref, cs);
 | 
			
		||||
      if (ce < ref.length() && ref.charAt(ce) == '/' && isNumeric(ref, ce + 1)) {
 | 
			
		||||
        return new Change.Id(Integer.parseInt(ref.substring(cs, ce)));
 | 
			
		||||
        return Change.id(Integer.parseInt(ref.substring(cs, ce)));
 | 
			
		||||
      }
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
@@ -192,14 +165,14 @@ public final class Change {
 | 
			
		||||
      int endChangeId = nextNonDigit(ref, startChangeId);
 | 
			
		||||
      String id = ref.substring(startChangeId, endChangeId);
 | 
			
		||||
      if (id != null && !id.isEmpty()) {
 | 
			
		||||
        return new Change.Id(Integer.parseInt(id));
 | 
			
		||||
        return Change.id(Integer.parseInt(id));
 | 
			
		||||
      }
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Id fromRefPart(String ref) {
 | 
			
		||||
      Integer id = RefNames.parseShardedRefPart(ref);
 | 
			
		||||
      return id != null ? new Change.Id(id) : null;
 | 
			
		||||
      return id != null ? Change.id(id) : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static int startIndex(String ref) {
 | 
			
		||||
@@ -250,6 +223,30 @@ public final class Change {
 | 
			
		||||
      }
 | 
			
		||||
      return i;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    abstract int id();
 | 
			
		||||
 | 
			
		||||
    public int get() {
 | 
			
		||||
      return id();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String toRefPrefix() {
 | 
			
		||||
      return refPrefixBuilder().toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    StringBuilder refPrefixBuilder() {
 | 
			
		||||
      StringBuilder r = new StringBuilder(32).append(REFS_CHANGES);
 | 
			
		||||
      int m = get() % 100;
 | 
			
		||||
      if (m < 10) {
 | 
			
		||||
        r.append('0');
 | 
			
		||||
      }
 | 
			
		||||
      return r.append(m).append('/').append(get()).append('/');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
      return Integer.toString(get());
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static Key key(String key) {
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ public final class Patch {
 | 
			
		||||
      checkKeyFormat(changeId != null, str);
 | 
			
		||||
      Integer patchSetNum = Ints.tryParse(parts.get(1));
 | 
			
		||||
      checkKeyFormat(patchSetNum != null, str);
 | 
			
		||||
      return key(PatchSet.id(new Change.Id(changeId), patchSetNum), parts.get(2));
 | 
			
		||||
      return key(PatchSet.id(Change.id(changeId), patchSetNum), parts.get(2));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void checkKeyFormat(boolean test, String input) {
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ public final class PatchSet {
 | 
			
		||||
      checkIdFormat(changeId != null, str);
 | 
			
		||||
      Integer id = Ints.tryParse(parts.get(1));
 | 
			
		||||
      checkIdFormat(id != null, str);
 | 
			
		||||
      return PatchSet.id(new Change.Id(changeId), id);
 | 
			
		||||
      return PatchSet.id(Change.id(changeId), id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void checkIdFormat(boolean test, String input) {
 | 
			
		||||
@@ -111,7 +111,7 @@ public final class PatchSet {
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
      int changeId = Integer.parseInt(ref.substring(cs, ce));
 | 
			
		||||
      return PatchSet.id(new Change.Id(changeId), patchSetId);
 | 
			
		||||
      return PatchSet.id(Change.id(changeId), patchSetId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static int fromRef(String ref, int changeIdEnd) {
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ public enum ChangeIdProtoConverter implements ProtoConverter<Entities.Change_Id,
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public Change.Id fromProto(Entities.Change_Id proto) {
 | 
			
		||||
    return new Change.Id(proto.getId());
 | 
			
		||||
    return Change.id(proto.getId());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ class ChangesImpl implements Changes {
 | 
			
		||||
  public ChangeApi create(ChangeInput in) throws RestApiException {
 | 
			
		||||
    try {
 | 
			
		||||
      ChangeInfo out = createChange.apply(TopLevelResource.INSTANCE, in).value();
 | 
			
		||||
      return api.create(changes.parse(new Change.Id(out._number)));
 | 
			
		||||
      return api.create(changes.parse(Change.id(out._number)));
 | 
			
		||||
    } catch (Exception e) {
 | 
			
		||||
      throw asRestApiException("Cannot create change", e);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -160,7 +160,7 @@ public class ChangeFinder {
 | 
			
		||||
      Integer n = Ints.tryParse(id);
 | 
			
		||||
      if (n != null) {
 | 
			
		||||
        checkIdType(ChangeIdType.NUMERIC_ID, enforceDeprecation, n.toString());
 | 
			
		||||
        return find(new Change.Id(n));
 | 
			
		||||
        return find(Change.id(n));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -193,7 +193,7 @@ public class ChangeFinder {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private List<ChangeNotes> fromProjectNumber(String project, int changeNumber) {
 | 
			
		||||
    Change.Id cId = new Change.Id(changeNumber);
 | 
			
		||||
    Change.Id cId = Change.id(changeNumber);
 | 
			
		||||
    try {
 | 
			
		||||
      return ImmutableList.of(
 | 
			
		||||
          changeNotesFactory.createChecked(Project.NameKey.parse(project), cId));
 | 
			
		||||
 
 | 
			
		||||
@@ -297,7 +297,7 @@ public class ChangeJson {
 | 
			
		||||
      Map<Change.Id, ChangeInfo> cache = Maps.newHashMapWithExpectedSize(in.size());
 | 
			
		||||
      for (QueryResult<ChangeData> r : in) {
 | 
			
		||||
        List<ChangeInfo> infos = toChangeInfos(r.entities(), cache);
 | 
			
		||||
        infos.forEach(c -> cache.put(new Change.Id(c._number), c));
 | 
			
		||||
        infos.forEach(c -> cache.put(Change.id(c._number), c));
 | 
			
		||||
        if (!infos.isEmpty() && r.more()) {
 | 
			
		||||
          infos.get(infos.size() - 1)._moreChanges = true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ public class RebaseUtil {
 | 
			
		||||
    // Try parsing base as a change number (assume current patch set).
 | 
			
		||||
    Integer baseChangeId = Ints.tryParse(base);
 | 
			
		||||
    if (baseChangeId != null) {
 | 
			
		||||
      ChangeNotes baseNotes = notesFor(rsrc, new Change.Id(baseChangeId));
 | 
			
		||||
      ChangeNotes baseNotes = notesFor(rsrc, Change.id(baseChangeId));
 | 
			
		||||
      if (baseNotes != null) {
 | 
			
		||||
        return Base.create(baseNotes, psUtil.current(baseNotes));
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -201,7 +201,7 @@ public class EventBroker implements EventDispatcher {
 | 
			
		||||
          return isVisibleTo(change, user);
 | 
			
		||||
        } catch (NoSuchChangeException e) {
 | 
			
		||||
          logger.atFine().log(
 | 
			
		||||
              "Change %s cannot be found, falling back on ref visibility check", cid.id);
 | 
			
		||||
              "Change %s cannot be found, falling back on ref visibility check", cid.get());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return isVisibleTo(refEvent.getBranchNameKey(), user);
 | 
			
		||||
 
 | 
			
		||||
@@ -137,7 +137,7 @@ public class StreamEventsApiListener
 | 
			
		||||
 | 
			
		||||
  private ChangeNotes getNotes(ChangeInfo info) {
 | 
			
		||||
    try {
 | 
			
		||||
      return changeNotesFactory.createChecked(new Change.Id(info._number));
 | 
			
		||||
      return changeNotesFactory.createChecked(Change.id(info._number));
 | 
			
		||||
    } catch (NoSuchChangeException e) {
 | 
			
		||||
      throw new StorageException(e);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2424,7 +2424,7 @@ class ReceiveCommits {
 | 
			
		||||
    private void setChangeId(int id) {
 | 
			
		||||
      possiblyOverrideWorkInProgress();
 | 
			
		||||
 | 
			
		||||
      changeId = new Change.Id(id);
 | 
			
		||||
      changeId = Change.id(id);
 | 
			
		||||
      ins =
 | 
			
		||||
          changeInserterFactory
 | 
			
		||||
              .create(changeId, commit, refName)
 | 
			
		||||
 
 | 
			
		||||
@@ -211,7 +211,7 @@ public class MailProcessor {
 | 
			
		||||
      throws UpdateException, RestApiException {
 | 
			
		||||
    try (ManualRequestContext ctx = oneOffRequestContext.openAs(sender)) {
 | 
			
		||||
      List<ChangeData> changeDataList =
 | 
			
		||||
          queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
 | 
			
		||||
          queryProvider.get().byLegacyChangeId(Change.id(metadata.changeNumber));
 | 
			
		||||
      if (changeDataList.size() != 1) {
 | 
			
		||||
        logger.atSevere().log(
 | 
			
		||||
            "Message %s references unique change %s,"
 | 
			
		||||
 
 | 
			
		||||
@@ -99,7 +99,7 @@ public class ChangeNotesCache {
 | 
			
		||||
        ChangeNotesKeyProto proto = Protos.parseUnchecked(ChangeNotesKeyProto.parser(), in);
 | 
			
		||||
        return Key.create(
 | 
			
		||||
            Project.nameKey(proto.getProject()),
 | 
			
		||||
            new Change.Id(proto.getChangeId()),
 | 
			
		||||
            Change.id(proto.getChangeId()),
 | 
			
		||||
            ObjectIdConverter.create().fromByteString(proto.getId()));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -976,7 +976,7 @@ class ChangeNotesParser {
 | 
			
		||||
    if (revertOf == null) {
 | 
			
		||||
      throw invalidFooter(FOOTER_REVERT_OF, footer);
 | 
			
		||||
    }
 | 
			
		||||
    return new Change.Id(revertOf);
 | 
			
		||||
    return Change.id(revertOf);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void pruneReviewers() {
 | 
			
		||||
 
 | 
			
		||||
@@ -543,7 +543,7 @@ public abstract class ChangeNotesState {
 | 
			
		||||
    @Override
 | 
			
		||||
    public ChangeNotesState deserialize(byte[] in) {
 | 
			
		||||
      ChangeNotesStateProto proto = Protos.parseUnchecked(ChangeNotesStateProto.parser(), in);
 | 
			
		||||
      Change.Id changeId = new Change.Id(proto.getChangeId());
 | 
			
		||||
      Change.Id changeId = Change.id(proto.getChangeId());
 | 
			
		||||
 | 
			
		||||
      ChangeNotesState.Builder b =
 | 
			
		||||
          builder()
 | 
			
		||||
@@ -623,7 +623,7 @@ public abstract class ChangeNotesState {
 | 
			
		||||
          .workInProgress(proto.getWorkInProgress())
 | 
			
		||||
          .reviewStarted(proto.getReviewStarted());
 | 
			
		||||
      if (proto.getHasRevertOf()) {
 | 
			
		||||
        b.revertOf(new Change.Id(proto.getRevertOf()));
 | 
			
		||||
        b.revertOf(Change.id(proto.getRevertOf()));
 | 
			
		||||
      }
 | 
			
		||||
      return b.build();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -461,7 +461,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData, ChangeQueryBuil
 | 
			
		||||
    if (PAT_LEGACY_ID.matcher(query).matches()) {
 | 
			
		||||
      Integer id = Ints.tryParse(query);
 | 
			
		||||
      if (id != null) {
 | 
			
		||||
        return new LegacyChangeIdPredicate(new Change.Id(id));
 | 
			
		||||
        return new LegacyChangeIdPredicate(Change.id(id));
 | 
			
		||||
      }
 | 
			
		||||
    } else if (PAT_CHANGE_ID.matcher(query).matches()) {
 | 
			
		||||
      return new ChangeIdPredicate(parseChangeId(query));
 | 
			
		||||
 
 | 
			
		||||
@@ -342,7 +342,7 @@ public class CherryPickChange {
 | 
			
		||||
      ObjectId sourceCommit,
 | 
			
		||||
      CherryPickInput input)
 | 
			
		||||
      throws IOException {
 | 
			
		||||
    Change.Id changeId = new Change.Id(seq.nextChangeId());
 | 
			
		||||
    Change.Id changeId = Change.id(seq.nextChangeId());
 | 
			
		||||
    ChangeInserter ins = changeInserterFactory.create(changeId, cherryPickCommit, refName);
 | 
			
		||||
    Branch.NameKey sourceBranch = sourceChange == null ? null : sourceChange.getDest();
 | 
			
		||||
    ins.setMessage(
 | 
			
		||||
 
 | 
			
		||||
@@ -297,7 +297,7 @@ public class CreateChange
 | 
			
		||||
        c = newCommit(oi, rw, author, mergeTip, commitMessage);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      Change.Id changeId = new Change.Id(seq.nextChangeId());
 | 
			
		||||
      Change.Id changeId = Change.id(seq.nextChangeId());
 | 
			
		||||
      ChangeInserter ins = changeInserterFactory.create(changeId, c, input.branch);
 | 
			
		||||
      ins.setMessage(String.format("Uploaded patch set %s.", ins.getPatchSetId().get()));
 | 
			
		||||
      ins.setTopic(input.topic);
 | 
			
		||||
 
 | 
			
		||||
@@ -210,7 +210,7 @@ public class Revert extends RetryingRestModifyView<ChangeResource, RevertInput,
 | 
			
		||||
              message);
 | 
			
		||||
      revertCommitBuilder.setMessage(ChangeIdUtil.insertId(message, computedChangeId, true));
 | 
			
		||||
 | 
			
		||||
      Change.Id changeId = new Change.Id(seq.nextChangeId());
 | 
			
		||||
      Change.Id changeId = Change.id(seq.nextChangeId());
 | 
			
		||||
      ObjectId id = oi.insert(revertCommitBuilder);
 | 
			
		||||
      RevCommit revertCommit = revWalk.parseCommit(id);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,8 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
 | 
			
		||||
      EnumSet.of(ListChangesOption.CURRENT_REVISION, ListChangesOption.SUBMITTABLE);
 | 
			
		||||
 | 
			
		||||
  private static final Comparator<ChangeData> COMPARATOR =
 | 
			
		||||
      Comparator.comparing(ChangeData::project).thenComparing(cd -> cd.getId().id, reverseOrder());
 | 
			
		||||
      Comparator.comparing(ChangeData::project)
 | 
			
		||||
          .thenComparing(cd -> cd.getId().get(), reverseOrder());
 | 
			
		||||
 | 
			
		||||
  private final ChangeJson.Factory json;
 | 
			
		||||
  private final Provider<InternalChangeQuery> queryProvider;
 | 
			
		||||
 
 | 
			
		||||
@@ -134,7 +134,7 @@ public class CreateAccessChange implements RestModifyView<ProjectResource, Proje
 | 
			
		||||
 | 
			
		||||
      md.setMessage("Review access change");
 | 
			
		||||
      md.setInsertChangeId(true);
 | 
			
		||||
      Change.Id changeId = new Change.Id(seq.nextChangeId());
 | 
			
		||||
      Change.Id changeId = Change.id(seq.nextChangeId());
 | 
			
		||||
 | 
			
		||||
      RevCommit commit =
 | 
			
		||||
          config.commitToNewRef(md, PatchSet.id(changeId, Change.INITIAL_PATCH_SET_ID).toRefName());
 | 
			
		||||
 
 | 
			
		||||
@@ -121,7 +121,7 @@ public class ChangeArgumentParser {
 | 
			
		||||
 | 
			
		||||
  private List<Change.Id> parseId(String id) throws UnloggedFailure {
 | 
			
		||||
    try {
 | 
			
		||||
      return Arrays.asList(new Change.Id(Integer.parseInt(id)));
 | 
			
		||||
      return Arrays.asList(Change.id(Integer.parseInt(id)));
 | 
			
		||||
    } catch (NumberFormatException e) {
 | 
			
		||||
      throw new UnloggedFailure(2, "Invalid change ID " + id, e);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class TestChanges {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static Change newChange(Project.NameKey project, Account.Id userId, int id) {
 | 
			
		||||
    Change.Id changeId = new Change.Id(id);
 | 
			
		||||
    Change.Id changeId = Change.id(id);
 | 
			
		||||
    Change c =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("Iabcd1234abcd1234abcd1234abcd1234abcd1234"),
 | 
			
		||||
 
 | 
			
		||||
@@ -660,7 +660,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    assertThat(change.stars).contains(DEFAULT_LABEL);
 | 
			
		||||
    refUpdateCounter.assertRefUpdateFor(
 | 
			
		||||
        RefUpdateCounter.projectRef(
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(new Change.Id(change._number), admin.id())));
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(Change.id(change._number), admin.id())));
 | 
			
		||||
 | 
			
		||||
    gApi.accounts().self().unstarChange(triplet);
 | 
			
		||||
    change = info(triplet);
 | 
			
		||||
@@ -668,7 +668,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    assertThat(change.stars).isNull();
 | 
			
		||||
    refUpdateCounter.assertRefUpdateFor(
 | 
			
		||||
        RefUpdateCounter.projectRef(
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(new Change.Id(change._number), admin.id())));
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(Change.id(change._number), admin.id())));
 | 
			
		||||
 | 
			
		||||
    accountIndexedCounter.assertNoReindex();
 | 
			
		||||
  }
 | 
			
		||||
@@ -699,7 +699,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    assertThat(starredChange.stars).containsExactly("blue", "red", DEFAULT_LABEL).inOrder();
 | 
			
		||||
    refUpdateCounter.assertRefUpdateFor(
 | 
			
		||||
        RefUpdateCounter.projectRef(
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(new Change.Id(change._number), admin.id())));
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(Change.id(change._number), admin.id())));
 | 
			
		||||
 | 
			
		||||
    gApi.accounts()
 | 
			
		||||
        .self()
 | 
			
		||||
@@ -718,7 +718,7 @@ public class AccountIT extends AbstractDaemonTest {
 | 
			
		||||
    assertThat(starredChange.stars).containsExactly("red", "yellow").inOrder();
 | 
			
		||||
    refUpdateCounter.assertRefUpdateFor(
 | 
			
		||||
        RefUpdateCounter.projectRef(
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(new Change.Id(change._number), admin.id())));
 | 
			
		||||
            allUsers, RefNames.refsStarredChanges(Change.id(change._number), admin.id())));
 | 
			
		||||
 | 
			
		||||
    accountIndexedCounter.assertNoReindex();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1087,7 +1087,7 @@ public class ChangeIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
      assertThat(query(changeId)).isEmpty();
 | 
			
		||||
 | 
			
		||||
      String ref = new Change.Id(id).toRefPrefix() + "1";
 | 
			
		||||
      String ref = Change.id(id).toRefPrefix() + "1";
 | 
			
		||||
      eventRecorder.assertRefUpdatedEvents(projectName.get(), ref, null, commit, commit, null);
 | 
			
		||||
      eventRecorder.assertChangeDeletedEvents(changeId, deleteAs.email());
 | 
			
		||||
    } finally {
 | 
			
		||||
@@ -2882,7 +2882,7 @@ public class ChangeIT extends AbstractDaemonTest {
 | 
			
		||||
    try (Repository repo = repoManager.openRepository(project);
 | 
			
		||||
        RevWalk rw = new RevWalk(repo)) {
 | 
			
		||||
      RevCommit commitPatchSetCreation =
 | 
			
		||||
          rw.parseCommit(repo.exactRef(changeMetaRef(new Change.Id(c._number))).getObjectId());
 | 
			
		||||
          rw.parseCommit(repo.exactRef(changeMetaRef(Change.id(c._number))).getObjectId());
 | 
			
		||||
 | 
			
		||||
      assertThat(commitPatchSetCreation.getShortMessage()).isEqualTo("Create patch set 2");
 | 
			
		||||
      PersonIdent expectedAuthor =
 | 
			
		||||
@@ -2952,7 +2952,7 @@ public class ChangeIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
    // Amend change as user
 | 
			
		||||
    PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/for/master", user, userTestRepo);
 | 
			
		||||
    r2.assertErrorStatus("cannot add patch set to " + r1.getChange().getId().id + ".");
 | 
			
		||||
    r2.assertErrorStatus("cannot add patch set to " + r1.getChange().getId().get() + ".");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
 
 | 
			
		||||
@@ -173,7 +173,7 @@ public class PrivateChangeIT extends AbstractDaemonTest {
 | 
			
		||||
    PushOneCommit.Result result = createChange();
 | 
			
		||||
    String changeId = result.getChangeId();
 | 
			
		||||
    merge(result);
 | 
			
		||||
    markMergedChangePrivate(new Change.Id(gApi.changes().id(changeId).get()._number));
 | 
			
		||||
    markMergedChangePrivate(Change.id(gApi.changes().id(changeId).get()._number));
 | 
			
		||||
 | 
			
		||||
    gApi.changes().id(changeId).setPrivate(false, null);
 | 
			
		||||
    assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
 | 
			
		||||
@@ -218,7 +218,7 @@ public class PrivateChangeIT extends AbstractDaemonTest {
 | 
			
		||||
    String changeId = result.getChangeId();
 | 
			
		||||
    gApi.changes().id(changeId).addReviewer(admin.id().toString());
 | 
			
		||||
    merge(result);
 | 
			
		||||
    markMergedChangePrivate(new Change.Id(gApi.changes().id(changeId).get()._number));
 | 
			
		||||
    markMergedChangePrivate(Change.id(gApi.changes().id(changeId).get()._number));
 | 
			
		||||
 | 
			
		||||
    requestScopeOperations.setApiUser(user.id());
 | 
			
		||||
    gApi.changes().id(changeId).setPrivate(false, null);
 | 
			
		||||
 
 | 
			
		||||
@@ -1330,7 +1330,7 @@ public class RevisionIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
    exception.expect(BadRequestException.class);
 | 
			
		||||
    exception.expectMessage(
 | 
			
		||||
        String.format("not found in revision %d,1", r.getChange().change().getId().id));
 | 
			
		||||
        String.format("not found in revision %d,1", r.getChange().change().getId().get()));
 | 
			
		||||
    gApi.changes().id(r.getChangeId()).revision(1).review(reviewInput);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -273,7 +273,7 @@ public class PushPermissionsIT extends AbstractDaemonTest {
 | 
			
		||||
    ci.project = project.get();
 | 
			
		||||
    ci.branch = "master";
 | 
			
		||||
    ci.subject = "A change";
 | 
			
		||||
    Change.Id id = new Change.Id(gApi.changes().create(ci).get()._number);
 | 
			
		||||
    Change.Id id = Change.id(gApi.changes().create(ci).get()._number);
 | 
			
		||||
 | 
			
		||||
    requestScopeOperations.setApiUser(admin.id());
 | 
			
		||||
    ObjectId ps1Id = forceFetch(PatchSet.id(id, 1).toRefName());
 | 
			
		||||
 
 | 
			
		||||
@@ -384,7 +384,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
 | 
			
		||||
  public void uploadPackAllRefsAreVisibleOrphanedTag() throws Exception {
 | 
			
		||||
    allow("refs/*", Permission.READ, REGISTERED_USERS);
 | 
			
		||||
    // Delete the pending change on 'branch' and 'branch' itself so that the tag gets orphaned
 | 
			
		||||
    gApi.changes().id(cd4.getId().id).delete();
 | 
			
		||||
    gApi.changes().id(cd4.getId().get()).delete();
 | 
			
		||||
    gApi.projects().name(project.get()).branch("refs/heads/branch").delete();
 | 
			
		||||
 | 
			
		||||
    requestScopeOperations.setApiUser(user.id());
 | 
			
		||||
 
 | 
			
		||||
@@ -1212,7 +1212,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
 | 
			
		||||
    assertThat(c.currentRevision).isEqualTo(expectedId.name());
 | 
			
		||||
    assertThat(c.revisions.get(expectedId.name())._number).isEqualTo(expectedNum);
 | 
			
		||||
    try (Repository repo = repoManager.openRepository(Project.nameKey(c.project))) {
 | 
			
		||||
      String refName = PatchSet.id(new Change.Id(c._number), expectedNum).toRefName();
 | 
			
		||||
      String refName = PatchSet.id(Change.id(c._number), expectedNum).toRefName();
 | 
			
		||||
      Ref ref = repo.exactRef(refName);
 | 
			
		||||
      assertThat(ref).named(refName).isNotNull();
 | 
			
		||||
      assertThat(ref.getObjectId()).isEqualTo(expectedId);
 | 
			
		||||
 
 | 
			
		||||
@@ -351,7 +351,7 @@ public class ActionsIT extends AbstractDaemonTest {
 | 
			
		||||
    String id = createChange().getChangeId();
 | 
			
		||||
    amendChange(id);
 | 
			
		||||
    ChangeInfo origChange = gApi.changes().id(id).get(CHANGE_ACTIONS);
 | 
			
		||||
    Change.Id changeId = new Change.Id(origChange._number);
 | 
			
		||||
    Change.Id changeId = Change.id(origChange._number);
 | 
			
		||||
 | 
			
		||||
    class Visitor implements ActionVisitor {
 | 
			
		||||
      @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -98,14 +98,14 @@ public class ChangeIdIT extends AbstractDaemonTest {
 | 
			
		||||
    // This test tests a redirect that is primarily intended for the UI (though the backend doesn't
 | 
			
		||||
    // really care who the caller is). The redirect rewrites a shorthand change number URL (/123) to
 | 
			
		||||
    // it's canonical long form (/c/project/+/123).
 | 
			
		||||
    int changeId = createChange().getChange().getId().id;
 | 
			
		||||
    int changeId = createChange().getChange().getId().get();
 | 
			
		||||
    RestResponse res = anonymousRestSession.get("/" + changeId);
 | 
			
		||||
    res.assertTemporaryRedirect("/c/" + project.get() + "/+/" + changeId + "/");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void changeNumberRedirectsWithTrailingSlash() throws Exception {
 | 
			
		||||
    int changeId = createChange().getChange().getId().id;
 | 
			
		||||
    int changeId = createChange().getChange().getId().get();
 | 
			
		||||
    RestResponse res = anonymousRestSession.get("/" + changeId + "/");
 | 
			
		||||
    res.assertTemporaryRedirect("/c/" + project.get() + "/+/" + changeId + "/");
 | 
			
		||||
  }
 | 
			
		||||
@@ -125,8 +125,8 @@ public class ChangeIdIT extends AbstractDaemonTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void hiddenChangeNotFound() throws Exception {
 | 
			
		||||
    Change.Id changeId = createChange().getChange().getId();
 | 
			
		||||
    gApi.changes().id(changeId.id).setPrivate(true, null);
 | 
			
		||||
    RestResponse res = anonymousRestSession.get("/" + changeId.id);
 | 
			
		||||
    gApi.changes().id(changeId.get()).setPrivate(true, null);
 | 
			
		||||
    RestResponse res = anonymousRestSession.get("/" + changeId.get());
 | 
			
		||||
    res.assertNotFound();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -279,7 +279,7 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
 | 
			
		||||
    List<ChangeMessageInfo> messagesBeforeDeletion = gApi.changes().id(changeNum).messages();
 | 
			
		||||
 | 
			
		||||
    List<CommentInfo> commentsBefore = getChangeSortedComments(changeNum);
 | 
			
		||||
    List<RevCommit> commitsBefore = getChangeMetaCommitsInReverseOrder(new Change.Id(changeNum));
 | 
			
		||||
    List<RevCommit> commitsBefore = getChangeMetaCommitsInReverseOrder(Change.id(changeNum));
 | 
			
		||||
 | 
			
		||||
    String id = messagesBeforeDeletion.get(deletedMessageIndex).id;
 | 
			
		||||
    DeleteChangeMessageInput input = new DeleteChangeMessageInput(reason);
 | 
			
		||||
@@ -340,8 +340,7 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
 | 
			
		||||
      TestAccount deletedBy,
 | 
			
		||||
      String deleteReason)
 | 
			
		||||
      throws Exception {
 | 
			
		||||
    List<RevCommit> commitsAfterDeletion =
 | 
			
		||||
        getChangeMetaCommitsInReverseOrder(new Change.Id(changeNum));
 | 
			
		||||
    List<RevCommit> commitsAfterDeletion = getChangeMetaCommitsInReverseOrder(Change.id(changeNum));
 | 
			
		||||
    assertThat(commitsAfterDeletion).hasSize(commitsBeforeDeletion.size());
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < commitsBeforeDeletion.size(); i++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -274,7 +274,7 @@ public class CreateChangeIT extends AbstractDaemonTest {
 | 
			
		||||
    try (Repository repo = repoManager.openRepository(project);
 | 
			
		||||
        RevWalk rw = new RevWalk(repo)) {
 | 
			
		||||
      RevCommit commit =
 | 
			
		||||
          rw.parseCommit(repo.exactRef(changeMetaRef(new Change.Id(c._number))).getObjectId());
 | 
			
		||||
          rw.parseCommit(repo.exactRef(changeMetaRef(Change.id(c._number))).getObjectId());
 | 
			
		||||
 | 
			
		||||
      assertThat(commit.getShortMessage()).isEqualTo("Create change");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -699,7 +699,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
 | 
			
		||||
      assertThat(e.getMessage())
 | 
			
		||||
          .isEqualTo(
 | 
			
		||||
              "A change to be submitted with "
 | 
			
		||||
                  + change2Result.getChange().getId().id
 | 
			
		||||
                  + change2Result.getChange().getId().get()
 | 
			
		||||
                  + " is not visible");
 | 
			
		||||
    }
 | 
			
		||||
    assertRefUpdatedEvents();
 | 
			
		||||
@@ -759,7 +759,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
 | 
			
		||||
      assertThat(e.getMessage())
 | 
			
		||||
          .isEqualTo(
 | 
			
		||||
              "A change to be submitted with "
 | 
			
		||||
                  + change1.getChange().getId().id
 | 
			
		||||
                  + change1.getChange().getId().get()
 | 
			
		||||
                  + " is not visible");
 | 
			
		||||
    }
 | 
			
		||||
    assertRefUpdatedEvents();
 | 
			
		||||
 
 | 
			
		||||
@@ -744,7 +744,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private ChangeNotes insertChange(TestAccount owner, String dest) throws Exception {
 | 
			
		||||
    Change.Id id = new Change.Id(sequences.nextChangeId());
 | 
			
		||||
    Change.Id id = Change.id(sequences.nextChangeId());
 | 
			
		||||
    ChangeInserter ins;
 | 
			
		||||
    try (BatchUpdate bu = newUpdate(owner.id())) {
 | 
			
		||||
      RevCommit commit = patchSetCommit(PatchSet.id(id, 1));
 | 
			
		||||
 
 | 
			
		||||
@@ -188,7 +188,7 @@ public class NoteDbOnlyIT extends AbstractDaemonTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void missingChange() throws Exception {
 | 
			
		||||
    Change.Id changeId = new Change.Id(1234567);
 | 
			
		||||
    Change.Id changeId = Change.id(1234567);
 | 
			
		||||
    assertNoSuchChangeException(() -> notesFactory.create(project, changeId));
 | 
			
		||||
    assertNoSuchChangeException(() -> notesFactory.createChecked(project, changeId));
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -149,7 +149,7 @@ public class PrologRuleEvaluatorIT extends AbstractDaemonTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private ChangeData makeChangeData() {
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(project, new Change.Id(1), 1);
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(project, Change.id(1), 1);
 | 
			
		||||
    cd.setChange(TestChanges.newChange(project, admin.id()));
 | 
			
		||||
    return cd;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ import org.junit.Test;
 | 
			
		||||
public class LabelFunctionTest extends GerritBaseTests {
 | 
			
		||||
  private static final String LABEL_NAME = "Verified";
 | 
			
		||||
  private static final LabelId LABEL_ID = LabelId.create(LABEL_NAME);
 | 
			
		||||
  private static final Change.Id CHANGE_ID = new Change.Id(100);
 | 
			
		||||
  private static final Change.Id CHANGE_ID = Change.id(100);
 | 
			
		||||
  private static final PatchSet.Id PS_ID = PatchSet.id(CHANGE_ID, 1);
 | 
			
		||||
  private static final LabelType VERIFIED_LABEL = makeLabel();
 | 
			
		||||
  private static final PatchSetApproval APPROVAL_2 = makeApproval(2);
 | 
			
		||||
 
 | 
			
		||||
@@ -123,8 +123,8 @@ public class ChangeTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void toRefPrefix() {
 | 
			
		||||
    assertThat(new Change.Id(1).toRefPrefix()).isEqualTo("refs/changes/01/1/");
 | 
			
		||||
    assertThat(new Change.Id(1234).toRefPrefix()).isEqualTo("refs/changes/34/1234/");
 | 
			
		||||
    assertThat(Change.id(1).toRefPrefix()).isEqualTo("refs/changes/01/1/");
 | 
			
		||||
    assertThat(Change.id(1234).toRefPrefix()).isEqualTo("refs/changes/34/1234/");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
@@ -150,7 +150,7 @@ public class ChangeTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void idToString() {
 | 
			
		||||
    assertThat(new Change.Id(3).toString()).isEqualTo("3");
 | 
			
		||||
    assertThat(Change.id(3).toString()).isEqualTo("3");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
@@ -161,7 +161,7 @@ public class ChangeTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertRef(int changeId, String refName) {
 | 
			
		||||
    assertThat(Change.Id.fromRef(refName)).isEqualTo(new Change.Id(changeId));
 | 
			
		||||
    assertThat(Change.Id.fromRef(refName)).isEqualTo(Change.id(changeId));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertNotRef(String refName) {
 | 
			
		||||
@@ -169,7 +169,7 @@ public class ChangeTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertAllUsersRef(int changeId, String refName) {
 | 
			
		||||
    assertThat(Change.Id.fromAllUsersRef(refName)).isEqualTo(new Change.Id(changeId));
 | 
			
		||||
    assertThat(Change.Id.fromAllUsersRef(refName)).isEqualTo(Change.id(changeId));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertNotAllUsersRef(String refName) {
 | 
			
		||||
@@ -177,7 +177,7 @@ public class ChangeTest {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertRefPart(int changeId, String refName) {
 | 
			
		||||
    assertEquals(new Change.Id(changeId), Change.Id.fromRefPart(refName));
 | 
			
		||||
    assertEquals(Change.id(changeId), Change.Id.fromRefPart(refName));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertNotRefPart(String refName) {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,13 +26,13 @@ public class PatchSetApprovalTest extends GerritBaseTests {
 | 
			
		||||
  public void keyEquality() {
 | 
			
		||||
    PatchSetApproval.Key k1 =
 | 
			
		||||
        PatchSetApproval.key(
 | 
			
		||||
            PatchSet.id(new Change.Id(1), 2), Account.id(3), LabelId.create("My-Label"));
 | 
			
		||||
            PatchSet.id(Change.id(1), 2), Account.id(3), LabelId.create("My-Label"));
 | 
			
		||||
    PatchSetApproval.Key k2 =
 | 
			
		||||
        PatchSetApproval.key(
 | 
			
		||||
            PatchSet.id(new Change.Id(1), 2), Account.id(3), LabelId.create("My-Label"));
 | 
			
		||||
            PatchSet.id(Change.id(1), 2), Account.id(3), LabelId.create("My-Label"));
 | 
			
		||||
    PatchSetApproval.Key k3 =
 | 
			
		||||
        PatchSetApproval.key(
 | 
			
		||||
            PatchSet.id(new Change.Id(1), 2), Account.id(3), LabelId.create("Other-Label"));
 | 
			
		||||
            PatchSet.id(Change.id(1), 2), Account.id(3), LabelId.create("Other-Label"));
 | 
			
		||||
 | 
			
		||||
    assertThat(k2).isEqualTo(k1);
 | 
			
		||||
    assertThat(k3).isNotEqualTo(k1);
 | 
			
		||||
 
 | 
			
		||||
@@ -83,14 +83,14 @@ public class PatchSetTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void toRefName() {
 | 
			
		||||
    assertThat(PatchSet.id(new Change.Id(1), 23).toRefName()).isEqualTo("refs/changes/01/1/23");
 | 
			
		||||
    assertThat(PatchSet.id(new Change.Id(1234), 5).toRefName()).isEqualTo("refs/changes/34/1234/5");
 | 
			
		||||
    assertThat(PatchSet.id(Change.id(1), 23).toRefName()).isEqualTo("refs/changes/01/1/23");
 | 
			
		||||
    assertThat(PatchSet.id(Change.id(1234), 5).toRefName()).isEqualTo("refs/changes/34/1234/5");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void parseId() {
 | 
			
		||||
    assertThat(PatchSet.Id.parse("1,2")).isEqualTo(PatchSet.id(new Change.Id(1), 2));
 | 
			
		||||
    assertThat(PatchSet.Id.parse("01,02")).isEqualTo(PatchSet.id(new Change.Id(1), 2));
 | 
			
		||||
    assertThat(PatchSet.Id.parse("1,2")).isEqualTo(PatchSet.id(Change.id(1), 2));
 | 
			
		||||
    assertThat(PatchSet.Id.parse("01,02")).isEqualTo(PatchSet.id(Change.id(1), 2));
 | 
			
		||||
    assertInvalidId(null);
 | 
			
		||||
    assertInvalidId("");
 | 
			
		||||
    assertInvalidId("1");
 | 
			
		||||
@@ -103,12 +103,12 @@ public class PatchSetTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void idToString() {
 | 
			
		||||
    assertThat(PatchSet.id(new Change.Id(2), 3).toString()).isEqualTo("2,3");
 | 
			
		||||
    assertThat(PatchSet.id(Change.id(2), 3).toString()).isEqualTo("2,3");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertRef(int changeId, int psId, String refName) {
 | 
			
		||||
    assertThat(PatchSet.isChangeRef(refName)).isTrue();
 | 
			
		||||
    assertThat(PatchSet.Id.fromRef(refName)).isEqualTo(PatchSet.id(new Change.Id(changeId), psId));
 | 
			
		||||
    assertThat(PatchSet.Id.fromRef(refName)).isEqualTo(PatchSet.id(Change.id(changeId), psId));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static void assertNotRef(String refName) {
 | 
			
		||||
 
 | 
			
		||||
@@ -34,9 +34,9 @@ public class PatchTest extends GerritBaseTests {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void parseKey() {
 | 
			
		||||
    assertThat(Patch.Key.parse("1,2,foo.txt"))
 | 
			
		||||
        .isEqualTo(Patch.key(PatchSet.id(new Change.Id(1), 2), "foo.txt"));
 | 
			
		||||
        .isEqualTo(Patch.key(PatchSet.id(Change.id(1), 2), "foo.txt"));
 | 
			
		||||
    assertThat(Patch.Key.parse("01,02,foo.txt"))
 | 
			
		||||
        .isEqualTo(Patch.key(PatchSet.id(new Change.Id(1), 2), "foo.txt"));
 | 
			
		||||
        .isEqualTo(Patch.key(PatchSet.id(Change.id(1), 2), "foo.txt"));
 | 
			
		||||
    assertInvalidKey(null);
 | 
			
		||||
    assertInvalidKey("");
 | 
			
		||||
    assertInvalidKey("1,2");
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ public class RefNamesTest {
 | 
			
		||||
  @Rule public ExpectedException expectedException = ExpectedException.none();
 | 
			
		||||
 | 
			
		||||
  private final Account.Id accountId = Account.id(1011123);
 | 
			
		||||
  private final Change.Id changeId = new Change.Id(67473);
 | 
			
		||||
  private final Change.Id changeId = Change.id(67473);
 | 
			
		||||
  private final PatchSet.Id psId = PatchSet.id(changeId, 42);
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ public class ChangeIdProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    Change.Id changeId = new Change.Id(94);
 | 
			
		||||
    Change.Id changeId = Change.id(94);
 | 
			
		||||
 | 
			
		||||
    Entities.Change_Id proto = changeIdProtoConverter.toProto(changeId);
 | 
			
		||||
 | 
			
		||||
@@ -40,7 +40,7 @@ public class ChangeIdProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    Change.Id changeId = new Change.Id(2903482);
 | 
			
		||||
    Change.Id changeId = Change.id(2903482);
 | 
			
		||||
 | 
			
		||||
    Change.Id convertedChangeId =
 | 
			
		||||
        changeIdProtoConverter.fromProto(changeIdProtoConverter.toProto(changeId));
 | 
			
		||||
@@ -61,7 +61,8 @@ public class ChangeIdProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  /** See {@link SerializedClassSubject} for background and what to do if this test fails. */
 | 
			
		||||
  @Test
 | 
			
		||||
  public void fieldsExistAsExpected() {
 | 
			
		||||
    assertThatSerializedClass(Change.Id.class).hasFields(ImmutableMap.of("id", int.class));
 | 
			
		||||
  public void methodsExistAsExpected() {
 | 
			
		||||
    assertThatSerializedClass(Change.Id.class)
 | 
			
		||||
        .hasAutoValueMethods(ImmutableMap.of("id", int.class));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ public class ChangeMessageKeyProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    ChangeMessage.Key messageKey = ChangeMessage.key(new Change.Id(704), "aabbcc");
 | 
			
		||||
    ChangeMessage.Key messageKey = ChangeMessage.key(Change.id(704), "aabbcc");
 | 
			
		||||
 | 
			
		||||
    Entities.ChangeMessage_Key proto = messageKeyProtoConverter.toProto(messageKey);
 | 
			
		||||
 | 
			
		||||
@@ -47,7 +47,7 @@ public class ChangeMessageKeyProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    ChangeMessage.Key messageKey = ChangeMessage.key(new Change.Id(704), "aabbcc");
 | 
			
		||||
    ChangeMessage.Key messageKey = ChangeMessage.key(Change.id(704), "aabbcc");
 | 
			
		||||
 | 
			
		||||
    ChangeMessage.Key convertedMessageKey =
 | 
			
		||||
        messageKeyProtoConverter.fromProto(messageKeyProtoConverter.toProto(messageKey));
 | 
			
		||||
 
 | 
			
		||||
@@ -38,10 +38,10 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"),
 | 
			
		||||
            ChangeMessage.key(Change.id(543), "change-message-21"),
 | 
			
		||||
            Account.id(63),
 | 
			
		||||
            new Timestamp(9876543),
 | 
			
		||||
            PatchSet.id(new Change.Id(34), 13));
 | 
			
		||||
            PatchSet.id(Change.id(34), 13));
 | 
			
		||||
    changeMessage.setMessage("This is a change message.");
 | 
			
		||||
    changeMessage.setTag("An arbitrary tag.");
 | 
			
		||||
    changeMessage.setRealAuthor(Account.id(10003));
 | 
			
		||||
@@ -71,10 +71,10 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  public void mainValuesConvertedToProto() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"),
 | 
			
		||||
            ChangeMessage.key(Change.id(543), "change-message-21"),
 | 
			
		||||
            Account.id(63),
 | 
			
		||||
            new Timestamp(9876543),
 | 
			
		||||
            PatchSet.id(new Change.Id(34), 13));
 | 
			
		||||
            PatchSet.id(Change.id(34), 13));
 | 
			
		||||
 | 
			
		||||
    Entities.ChangeMessage proto = changeMessageProtoConverter.toProto(changeMessage);
 | 
			
		||||
 | 
			
		||||
@@ -99,7 +99,7 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  public void realAuthorIsNotAutomaticallySetToAuthorWhenConvertedToProto() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"), Account.id(63), null, null);
 | 
			
		||||
            ChangeMessage.key(Change.id(543), "change-message-21"), Account.id(63), null, null);
 | 
			
		||||
 | 
			
		||||
    Entities.ChangeMessage proto = changeMessageProtoConverter.toProto(changeMessage);
 | 
			
		||||
 | 
			
		||||
@@ -119,8 +119,7 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
    // writtenOn may not be null according to the column definition but it's optional for the
 | 
			
		||||
    // protobuf definition. -> assume as optional and hence test null
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"), null, null, null);
 | 
			
		||||
        new ChangeMessage(ChangeMessage.key(Change.id(543), "change-message-21"), null, null, null);
 | 
			
		||||
 | 
			
		||||
    Entities.ChangeMessage proto = changeMessageProtoConverter.toProto(changeMessage);
 | 
			
		||||
 | 
			
		||||
@@ -138,10 +137,10 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"),
 | 
			
		||||
            ChangeMessage.key(Change.id(543), "change-message-21"),
 | 
			
		||||
            Account.id(63),
 | 
			
		||||
            new Timestamp(9876543),
 | 
			
		||||
            PatchSet.id(new Change.Id(34), 13));
 | 
			
		||||
            PatchSet.id(Change.id(34), 13));
 | 
			
		||||
    changeMessage.setMessage("This is a change message.");
 | 
			
		||||
    changeMessage.setTag("An arbitrary tag.");
 | 
			
		||||
    changeMessage.setRealAuthor(Account.id(10003));
 | 
			
		||||
@@ -155,10 +154,10 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  public void mainValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"),
 | 
			
		||||
            ChangeMessage.key(Change.id(543), "change-message-21"),
 | 
			
		||||
            Account.id(63),
 | 
			
		||||
            new Timestamp(9876543),
 | 
			
		||||
            PatchSet.id(new Change.Id(34), 13));
 | 
			
		||||
            PatchSet.id(Change.id(34), 13));
 | 
			
		||||
 | 
			
		||||
    ChangeMessage convertedChangeMessage =
 | 
			
		||||
        changeMessageProtoConverter.fromProto(changeMessageProtoConverter.toProto(changeMessage));
 | 
			
		||||
@@ -168,8 +167,7 @@ public class ChangeMessageProtoConverterTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void mandatoryValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    ChangeMessage changeMessage =
 | 
			
		||||
        new ChangeMessage(
 | 
			
		||||
            ChangeMessage.key(new Change.Id(543), "change-message-21"), null, null, null);
 | 
			
		||||
        new ChangeMessage(ChangeMessage.key(Change.id(543), "change-message-21"), null, null, null);
 | 
			
		||||
 | 
			
		||||
    ChangeMessage convertedChangeMessage =
 | 
			
		||||
        changeMessageProtoConverter.fromProto(changeMessageProtoConverter.toProto(changeMessage));
 | 
			
		||||
 
 | 
			
		||||
@@ -39,21 +39,21 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch 74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
    change.setLastUpdatedOn(new Timestamp(1234567L));
 | 
			
		||||
    change.setStatus(Change.Status.MERGED);
 | 
			
		||||
    change.setCurrentPatchSet(
 | 
			
		||||
        PatchSet.id(new Change.Id(14), 23), "subject XYZ", "original subject ABC");
 | 
			
		||||
        PatchSet.id(Change.id(14), 23), "subject XYZ", "original subject ABC");
 | 
			
		||||
    change.setTopic("my topic");
 | 
			
		||||
    change.setSubmissionId("submission ID 234");
 | 
			
		||||
    change.setAssignee(Account.id(100001));
 | 
			
		||||
    change.setPrivate(true);
 | 
			
		||||
    change.setWorkInProgress(true);
 | 
			
		||||
    change.setReviewStarted(true);
 | 
			
		||||
    change.setRevertOf(new Change.Id(180));
 | 
			
		||||
    change.setRevertOf(Change.id(180));
 | 
			
		||||
 | 
			
		||||
    Entities.Change proto = changeProtoConverter.toProto(change);
 | 
			
		||||
 | 
			
		||||
@@ -89,7 +89,7 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch-74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
@@ -125,12 +125,12 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch-74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
    // O as ID actually means that no current patch set is present.
 | 
			
		||||
    change.setCurrentPatchSet(PatchSet.id(new Change.Id(14), 0), null, null);
 | 
			
		||||
    change.setCurrentPatchSet(PatchSet.id(Change.id(14), 0), null, null);
 | 
			
		||||
 | 
			
		||||
    Entities.Change proto = changeProtoConverter.toProto(change);
 | 
			
		||||
 | 
			
		||||
@@ -163,11 +163,11 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch-74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
    change.setCurrentPatchSet(PatchSet.id(new Change.Id(14), 23), "subject ABC", null);
 | 
			
		||||
    change.setCurrentPatchSet(PatchSet.id(Change.id(14), 23), "subject ABC", null);
 | 
			
		||||
 | 
			
		||||
    Entities.Change proto = changeProtoConverter.toProto(change);
 | 
			
		||||
 | 
			
		||||
@@ -200,21 +200,21 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch-74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
    change.setLastUpdatedOn(new Timestamp(1234567L));
 | 
			
		||||
    change.setStatus(Change.Status.MERGED);
 | 
			
		||||
    change.setCurrentPatchSet(
 | 
			
		||||
        PatchSet.id(new Change.Id(14), 23), "subject XYZ", "original subject ABC");
 | 
			
		||||
        PatchSet.id(Change.id(14), 23), "subject XYZ", "original subject ABC");
 | 
			
		||||
    change.setTopic("my topic");
 | 
			
		||||
    change.setSubmissionId("submission ID 234");
 | 
			
		||||
    change.setAssignee(Account.id(100001));
 | 
			
		||||
    change.setPrivate(true);
 | 
			
		||||
    change.setWorkInProgress(true);
 | 
			
		||||
    change.setReviewStarted(true);
 | 
			
		||||
    change.setRevertOf(new Change.Id(180));
 | 
			
		||||
    change.setRevertOf(Change.id(180));
 | 
			
		||||
 | 
			
		||||
    Change convertedChange = changeProtoConverter.fromProto(changeProtoConverter.toProto(change));
 | 
			
		||||
    assertEqualChange(convertedChange, change);
 | 
			
		||||
@@ -225,7 +225,7 @@ public class ChangeProtoConverterTest {
 | 
			
		||||
    Change change =
 | 
			
		||||
        new Change(
 | 
			
		||||
            Change.key("change 1"),
 | 
			
		||||
            new Change.Id(14),
 | 
			
		||||
            Change.id(14),
 | 
			
		||||
            Account.id(35),
 | 
			
		||||
            Branch.nameKey(Project.nameKey("project 67"), "branch-74"),
 | 
			
		||||
            new Timestamp(987654L));
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ public class PatchSetApprovalKeyProtoConverterTest {
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    PatchSetApproval.Key key =
 | 
			
		||||
        PatchSetApproval.key(
 | 
			
		||||
            PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8"));
 | 
			
		||||
            PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8"));
 | 
			
		||||
 | 
			
		||||
    Entities.PatchSetApproval_Key proto = protoConverter.toProto(key);
 | 
			
		||||
 | 
			
		||||
@@ -58,7 +58,7 @@ public class PatchSetApprovalKeyProtoConverterTest {
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    PatchSetApproval.Key key =
 | 
			
		||||
        PatchSetApproval.key(
 | 
			
		||||
            PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8"));
 | 
			
		||||
            PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8"));
 | 
			
		||||
 | 
			
		||||
    PatchSetApproval.Key convertedKey = protoConverter.fromProto(protoConverter.toProto(key));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ public class PatchSetApprovalProtoConverterTest {
 | 
			
		||||
    PatchSetApproval patchSetApproval =
 | 
			
		||||
        new PatchSetApproval(
 | 
			
		||||
            PatchSetApproval.key(
 | 
			
		||||
                PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
                PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
            (short) 456,
 | 
			
		||||
            new Date(987654L));
 | 
			
		||||
    patchSetApproval.setTag("tag-21");
 | 
			
		||||
@@ -74,7 +74,7 @@ public class PatchSetApprovalProtoConverterTest {
 | 
			
		||||
    PatchSetApproval patchSetApproval =
 | 
			
		||||
        new PatchSetApproval(
 | 
			
		||||
            PatchSetApproval.key(
 | 
			
		||||
                PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
                PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
            (short) 456,
 | 
			
		||||
            new Date(987654L));
 | 
			
		||||
 | 
			
		||||
@@ -103,7 +103,7 @@ public class PatchSetApprovalProtoConverterTest {
 | 
			
		||||
    PatchSetApproval patchSetApproval =
 | 
			
		||||
        new PatchSetApproval(
 | 
			
		||||
            PatchSetApproval.key(
 | 
			
		||||
                PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
                PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
            (short) 456,
 | 
			
		||||
            new Date(987654L));
 | 
			
		||||
    patchSetApproval.setTag("tag-21");
 | 
			
		||||
@@ -120,7 +120,7 @@ public class PatchSetApprovalProtoConverterTest {
 | 
			
		||||
    PatchSetApproval patchSetApproval =
 | 
			
		||||
        new PatchSetApproval(
 | 
			
		||||
            PatchSetApproval.key(
 | 
			
		||||
                PatchSet.id(new Change.Id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
                PatchSet.id(Change.id(42), 14), Account.id(100013), LabelId.create("label-8")),
 | 
			
		||||
            (short) 456,
 | 
			
		||||
            new Date(987654L));
 | 
			
		||||
 | 
			
		||||
@@ -146,7 +146,7 @@ public class PatchSetApprovalProtoConverterTest {
 | 
			
		||||
            .build();
 | 
			
		||||
    PatchSetApproval patchSetApproval = protoConverter.fromProto(proto);
 | 
			
		||||
 | 
			
		||||
    assertThat(patchSetApproval.getPatchSetId()).isEqualTo(PatchSet.id(new Change.Id(42), 14));
 | 
			
		||||
    assertThat(patchSetApproval.getPatchSetId()).isEqualTo(PatchSet.id(Change.id(42), 14));
 | 
			
		||||
    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.
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ public class PatchSetIdProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    PatchSet.Id patchSetId = PatchSet.id(new Change.Id(103), 73);
 | 
			
		||||
    PatchSet.Id patchSetId = PatchSet.id(Change.id(103), 73);
 | 
			
		||||
 | 
			
		||||
    Entities.PatchSet_Id proto = patchSetIdProtoConverter.toProto(patchSetId);
 | 
			
		||||
 | 
			
		||||
@@ -47,7 +47,7 @@ public class PatchSetIdProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    PatchSet.Id patchSetId = PatchSet.id(new Change.Id(20), 13);
 | 
			
		||||
    PatchSet.Id patchSetId = PatchSet.id(Change.id(20), 13);
 | 
			
		||||
 | 
			
		||||
    PatchSet.Id convertedPatchSetId =
 | 
			
		||||
        patchSetIdProtoConverter.fromProto(patchSetIdProtoConverter.toProto(patchSetId));
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ public class PatchSetProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProto() {
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(new Change.Id(103), 73));
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(Change.id(103), 73));
 | 
			
		||||
    patchSet.setRevision(new RevId("aabbccddeeff"));
 | 
			
		||||
    patchSet.setUploader(Account.id(452));
 | 
			
		||||
    patchSet.setCreatedOn(new Timestamp(930349320L));
 | 
			
		||||
@@ -64,7 +64,7 @@ public class PatchSetProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void mandatoryValuesConvertedToProto() {
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(new Change.Id(103), 73));
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(Change.id(103), 73));
 | 
			
		||||
 | 
			
		||||
    Entities.PatchSet proto = patchSetProtoConverter.toProto(patchSet);
 | 
			
		||||
 | 
			
		||||
@@ -80,7 +80,7 @@ public class PatchSetProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void allValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(new Change.Id(103), 73));
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(Change.id(103), 73));
 | 
			
		||||
    patchSet.setRevision(new RevId("aabbccddeeff"));
 | 
			
		||||
    patchSet.setUploader(Account.id(452));
 | 
			
		||||
    patchSet.setCreatedOn(new Timestamp(930349320L));
 | 
			
		||||
@@ -95,7 +95,7 @@ public class PatchSetProtoConverterTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void mandatoryValuesConvertedToProtoAndBackAgain() {
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(new Change.Id(103), 73));
 | 
			
		||||
    PatchSet patchSet = new PatchSet(PatchSet.id(Change.id(103), 73));
 | 
			
		||||
 | 
			
		||||
    PatchSet convertedPatchSet =
 | 
			
		||||
        patchSetProtoConverter.fromProto(patchSetProtoConverter.toProto(patchSet));
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@ public class LabelNormalizerTest extends GerritBaseTests {
 | 
			
		||||
    input.newBranch = true;
 | 
			
		||||
    input.subject = "Test change";
 | 
			
		||||
    ChangeInfo info = gApi.changes().create(input).get();
 | 
			
		||||
    notes = changeNotesFactory.createChecked(allProjects, new Change.Id(info._number));
 | 
			
		||||
    notes = changeNotesFactory.createChecked(allProjects, Change.id(info._number));
 | 
			
		||||
    change = notes.getChange();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ public class ChangeEditTest extends GerritBaseTests {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void changeEditRef() throws Exception {
 | 
			
		||||
    Account.Id accountId = Account.id(1000042);
 | 
			
		||||
    Change.Id changeId = new Change.Id(56414);
 | 
			
		||||
    Change.Id changeId = Change.id(56414);
 | 
			
		||||
    PatchSet.Id psId = PatchSet.id(changeId, 50);
 | 
			
		||||
    String refName = RefNames.refsEdit(accountId, changeId, psId);
 | 
			
		||||
    assertEquals("refs/users/42/1000042/edit-56414/50", refName);
 | 
			
		||||
 
 | 
			
		||||
@@ -285,7 +285,7 @@ public class GroupCollectorTest extends GerritBaseTests {
 | 
			
		||||
  // TODO(dborowitz): Tests for octopus merges.
 | 
			
		||||
 | 
			
		||||
  private static PatchSet.Id psId(int c, int p) {
 | 
			
		||||
    return PatchSet.id(new Change.Id(c), p);
 | 
			
		||||
    return PatchSet.id(Change.id(c), p);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private RevWalk newWalk(ObjectId start, ObjectId branchTip) throws Exception {
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ public class ChangeFieldTest extends GerritBaseTests {
 | 
			
		||||
        .containsExactly(
 | 
			
		||||
            "REVIEWER,1", "REVIEWER,1," + t1.getTime(), "CC,2", "CC,2," + t2.getTime());
 | 
			
		||||
 | 
			
		||||
    assertThat(ChangeField.parseReviewerFieldValues(new Change.Id(1), values)).isEqualTo(reviewers);
 | 
			
		||||
    assertThat(ChangeField.parseReviewerFieldValues(Change.id(1), values)).isEqualTo(reviewers);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
 | 
			
		||||
  private static final Project.NameKey P1 = Project.nameKey("project1");
 | 
			
		||||
  private static final Project.NameKey P2 = Project.nameKey("project2");
 | 
			
		||||
 | 
			
		||||
  private static final Change.Id C = new Change.Id(1234);
 | 
			
		||||
  private static final Change.Id C = Change.id(1234);
 | 
			
		||||
 | 
			
		||||
  private GitRepositoryManager repoManager;
 | 
			
		||||
  private Repository r1;
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ public final class ChangeNotesCacheTest {
 | 
			
		||||
    ChangeNotesCache.Key key =
 | 
			
		||||
        ChangeNotesCache.Key.create(
 | 
			
		||||
            Project.nameKey("project"),
 | 
			
		||||
            new Change.Id(1234),
 | 
			
		||||
            Change.id(1234),
 | 
			
		||||
            ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
 | 
			
		||||
    byte[] serialized = ChangeNotesCache.Key.Serializer.INSTANCE.serialize(key);
 | 
			
		||||
    assertThat(ChangeNotesKeyProto.parseFrom(serialized))
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
public class ChangeNotesStateTest extends GerritBaseTests {
 | 
			
		||||
  private static final Change.Id ID = new Change.Id(123);
 | 
			
		||||
  private static final Change.Id ID = Change.id(123);
 | 
			
		||||
  private static final ObjectId SHA =
 | 
			
		||||
      ObjectId.fromString("1234567812345678123456781234567812345678");
 | 
			
		||||
  private static final ByteString SHA_BYTES = ObjectIdConverter.create().toByteString(SHA);
 | 
			
		||||
@@ -298,7 +298,7 @@ public class ChangeNotesStateTest extends GerritBaseTests {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void serializeRevertOf() throws Exception {
 | 
			
		||||
    assertRoundTrip(
 | 
			
		||||
        newBuilder().columns(cols.toBuilder().revertOf(new Change.Id(999)).build()).build(),
 | 
			
		||||
        newBuilder().columns(cols.toBuilder().revertOf(Change.id(999)).build()).build(),
 | 
			
		||||
        ChangeNotesStateProto.newBuilder()
 | 
			
		||||
            .setMetaId(SHA_BYTES)
 | 
			
		||||
            .setChangeId(ID.get())
 | 
			
		||||
 
 | 
			
		||||
@@ -2435,7 +2435,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
  public void byCommitsOnBranchNotMergedSkipsMissingChanges() throws Exception {
 | 
			
		||||
    TestRepository<Repo> repo = createProject("repo");
 | 
			
		||||
    ObjectId missing =
 | 
			
		||||
        repo.branch(PatchSet.id(new Change.Id(987654), 1).toRefName())
 | 
			
		||||
        repo.branch(PatchSet.id(Change.id(987654), 1).toRefName())
 | 
			
		||||
            .commit()
 | 
			
		||||
            .message("No change for this commit")
 | 
			
		||||
            .insertChangeId()
 | 
			
		||||
@@ -2591,8 +2591,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
    gApi.changes().id(changeToRevert.id).current().submit();
 | 
			
		||||
 | 
			
		||||
    ChangeInfo changeThatReverts = gApi.changes().id(changeToRevert.id).revert().get();
 | 
			
		||||
    assertQueryByIds(
 | 
			
		||||
        "revertof:" + changeToRevert._number, new Change.Id(changeThatReverts._number));
 | 
			
		||||
    assertQueryByIds("revertof:" + changeToRevert._number, Change.id(changeThatReverts._number));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Change builder for helping in tests for dashboard sections. */
 | 
			
		||||
@@ -3208,7 +3207,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
      branch = "refs/heads/" + branch;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Change.Id id = new Change.Id(seq.nextChangeId());
 | 
			
		||||
    Change.Id id = Change.id(seq.nextChangeId());
 | 
			
		||||
    ChangeInserter ins =
 | 
			
		||||
        changeFactory
 | 
			
		||||
            .create(id, commit, branch)
 | 
			
		||||
@@ -3392,7 +3391,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected static Iterable<Change.Id> ids(Iterable<ChangeInfo> changes) {
 | 
			
		||||
    return Streams.stream(changes).map(c -> new Change.Id(c._number)).collect(toList());
 | 
			
		||||
    return Streams.stream(changes).map(c -> Change.id(c._number)).collect(toList());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected static long lastUpdatedMs(Change c) {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ public class ChangeDataTest extends GerritBaseTests {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void setPatchSetsClearsCurrentPatchSet() throws Exception {
 | 
			
		||||
    Project.NameKey project = Project.nameKey("project");
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(project, new Change.Id(1), 1);
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(project, Change.id(1), 1);
 | 
			
		||||
    cd.setChange(TestChanges.newChange(project, Account.id(1000)));
 | 
			
		||||
    PatchSet curr1 = cd.currentPatchSet();
 | 
			
		||||
    int currId = curr1.getId().get();
 | 
			
		||||
 
 | 
			
		||||
@@ -83,7 +83,7 @@ public class RegexPathPredicateTest extends GerritBaseTests {
 | 
			
		||||
 | 
			
		||||
  private static ChangeData change(String... files) {
 | 
			
		||||
    Arrays.sort(files);
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(Project.nameKey("project"), new Change.Id(1), 1);
 | 
			
		||||
    ChangeData cd = ChangeData.createForTest(Project.nameKey("project"), Change.id(1), 1);
 | 
			
		||||
    cd.setCurrentFilePaths(Arrays.asList(files));
 | 
			
		||||
    return cd;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ import java.util.List;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
public class IgnoreSelfApprovalRuleTest extends GerritBaseTests {
 | 
			
		||||
  private static final Change.Id CHANGE_ID = new Change.Id(100);
 | 
			
		||||
  private static final Change.Id CHANGE_ID = Change.id(100);
 | 
			
		||||
  private static final PatchSet.Id PS_ID = PatchSet.id(CHANGE_ID, 1);
 | 
			
		||||
  private static final LabelType VERIFIED = makeLabel("Verified");
 | 
			
		||||
  private static final Account.Id USER1 = makeAccount(100001);
 | 
			
		||||
 
 | 
			
		||||
@@ -228,7 +228,7 @@ public class BatchUpdateTest extends GerritBaseTests {
 | 
			
		||||
  private Change.Id createChangeWithUpdates(int totalUpdates) throws Exception {
 | 
			
		||||
    checkArgument(totalUpdates > 0);
 | 
			
		||||
    checkArgument(totalUpdates <= MAX_UPDATES);
 | 
			
		||||
    Change.Id id = new Change.Id(sequences.nextChangeId());
 | 
			
		||||
    Change.Id id = Change.id(sequences.nextChangeId());
 | 
			
		||||
    try (BatchUpdate bu = batchUpdateFactory.create(project, user.get(), TimeUtil.nowTs())) {
 | 
			
		||||
      bu.insertChange(
 | 
			
		||||
          changeInserterFactory.create(
 | 
			
		||||
 
 | 
			
		||||
 Submodule plugins/hooks updated: a108d1df76...9401a4ec26
									
								
							
		Reference in New Issue
	
	Block a user