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