RevisionApi: Add method to get revision ETag
Change-Id: I266c16b05745bfb31d19a14814e1a1d6906400f2
This commit is contained in:
parent
ca13de796d
commit
c67dcbca4f
@ -899,6 +899,13 @@ public abstract class AbstractDaemonTest {
|
||||
.actions();
|
||||
}
|
||||
|
||||
protected String getETag(String id) throws Exception {
|
||||
return gApi.changes()
|
||||
.id(id)
|
||||
.current()
|
||||
.etag();
|
||||
}
|
||||
|
||||
private static Iterable<String> changeIds(Iterable<ChangeInfo> changes) {
|
||||
return Iterables.transform(changes, i -> i.changeId);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.registration.RegistrationHandle;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.change.ChangeJson;
|
||||
import com.google.gerrit.server.change.GetRevisionActions;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
import com.google.inject.Inject;
|
||||
@ -57,9 +56,6 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
return submitWholeTopicEnabledConfig();
|
||||
}
|
||||
|
||||
@Inject
|
||||
private GetRevisionActions getRevisionActions;
|
||||
|
||||
@Inject
|
||||
private ChangeJson.Factory changeJsonFactory;
|
||||
|
||||
@ -129,16 +125,16 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
String parent = createChange().getChangeId();
|
||||
String change = createChangeWithTopic().getChangeId();
|
||||
approve(change);
|
||||
String etag1 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag1 = getETag(change);
|
||||
|
||||
approve(parent);
|
||||
String etag2 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag2 = getETag(change);
|
||||
|
||||
String changeWithSameTopic = createChangeWithTopic().getChangeId();
|
||||
String etag3 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag3 = getETag(change);
|
||||
|
||||
approve(changeWithSameTopic);
|
||||
String etag4 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag4 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertThat(ImmutableList.of(etag1, etag2, etag3, etag4)).containsNoDuplicates();
|
||||
@ -155,14 +151,14 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
approve(change);
|
||||
|
||||
setApiUser(user);
|
||||
String etag1 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag1 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
String draft = createDraftWithTopic().getChangeId();
|
||||
approve(draft);
|
||||
|
||||
setApiUser(user);
|
||||
String etag2 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag2 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertThat(etag2).isNotEqualTo(etag1);
|
||||
@ -178,25 +174,25 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
approve(change);
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag1 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag1 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
approve(parent);
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag2 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag2 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
String changeWithSameTopic = createChangeWithTopic().getChangeId();
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag3 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag3 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
approve(changeWithSameTopic);
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag4 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag4 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertThat(ImmutableList.of(etag1, etag2, etag3, etag4)).containsNoDuplicates();
|
||||
@ -215,13 +211,13 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
approve(change);
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag1 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag1 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
approve(parent);
|
||||
|
||||
setApiUserAnonymous();
|
||||
String etag2 = getRevisionActions.getETag(parseCurrentRevisionResource(change));
|
||||
String etag2 = getETag(change);
|
||||
assertThat(etag2).isEqualTo(etag1);
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ public interface RevisionApi {
|
||||
CommentApi comment(String id) throws RestApiException;
|
||||
RobotCommentApi robotComment(String id) throws RestApiException;
|
||||
|
||||
String etag() throws RestApiException;
|
||||
|
||||
/**
|
||||
* Returns patch of revision.
|
||||
*/
|
||||
@ -296,5 +298,10 @@ public interface RevisionApi {
|
||||
public String description() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String etag() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -539,4 +539,9 @@ class RevisionApiImpl implements RevisionApi {
|
||||
public String description() throws RestApiException {
|
||||
return getDescription.apply(revision);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String etag() throws RestApiException {
|
||||
return revisionActions.getETag(revision);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user