Merge "GetRevisionActions: Remove ETag"
This commit is contained in:
@@ -88,15 +88,12 @@ import com.google.gerrit.extensions.events.ChangeIndexedListener;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.BinaryResult;
|
||||
import com.google.gerrit.extensions.restapi.ETagView;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.extensions.webui.PatchSetWebLink;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.restapi.change.GetRevisionActions;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -122,7 +119,6 @@ import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RevisionIT extends AbstractDaemonTest {
|
||||
@Inject private GetRevisionActions getRevisionActions;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private ExtensionRegistry extensionRegistry;
|
||||
@@ -1827,23 +1823,6 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
assertThat(current(r).actions().keySet()).containsExactly("cherrypick");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void actionsETag() throws Exception {
|
||||
PushOneCommit.Result r1 = createChange();
|
||||
PushOneCommit.Result r2 = createChange();
|
||||
|
||||
String oldETag = checkETag(getRevisionActions, r2, null);
|
||||
current(r2).review(ReviewInput.approve());
|
||||
oldETag = checkETag(getRevisionActions, r2, oldETag);
|
||||
|
||||
// Dependent change is included in ETag.
|
||||
current(r1).review(ReviewInput.approve());
|
||||
oldETag = checkETag(getRevisionActions, r2, oldETag);
|
||||
|
||||
current(r2).submit();
|
||||
checkETag(getRevisionActions, r2, oldETag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteVoteOnNonCurrentPatchSet() throws Exception {
|
||||
PushOneCommit.Result r = createChange(); // patch set 1
|
||||
@@ -2015,13 +1994,6 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
return gApi.changes().id(r.getChangeId()).current();
|
||||
}
|
||||
|
||||
private String checkETag(ETagView<RevisionResource> view, PushOneCommit.Result r, String oldETag)
|
||||
throws Exception {
|
||||
String eTag = view.getETag(parseRevisionResource(r));
|
||||
assertThat(eTag).isNotEqualTo(oldETag);
|
||||
return eTag;
|
||||
}
|
||||
|
||||
private PushOneCommit.Result createCherryPickableMerge(
|
||||
String parent1FileName, String parent2FileName) throws Exception {
|
||||
RevCommit initialCommit = getHead(repo(), "HEAD");
|
||||
|
||||
@@ -20,26 +20,20 @@ import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_ACTI
|
||||
import static com.google.gerrit.extensions.client.ListChangesOption.CURRENT_REVISION;
|
||||
import static com.google.gerrit.truth.MapSubject.assertThatMap;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.ExtensionRegistry;
|
||||
import com.google.gerrit.acceptance.ExtensionRegistry.Registration;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.entities.Change;
|
||||
import com.google.gerrit.entities.PatchSet;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
import com.google.gerrit.server.change.RevisionJson;
|
||||
import com.google.gerrit.server.change.testing.TestChangeETagComputation;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.testing.ConfigSuite;
|
||||
import com.google.inject.Inject;
|
||||
@@ -56,7 +50,6 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
return submitWholeTopicEnabledConfig();
|
||||
}
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private RevisionJson.Factory revisionJsonFactory;
|
||||
@Inject private ExtensionRegistry extensionRegistry;
|
||||
|
||||
@@ -68,10 +61,6 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
return gApi.changes().id(id).get().actions;
|
||||
}
|
||||
|
||||
protected String getETag(String id) throws Exception {
|
||||
return gApi.changes().id(id).current().etag();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeActionOneMergedChangeHasOnlyNormalRevert() throws Exception {
|
||||
String changeId = createChangeWithTopic().getChangeId();
|
||||
@@ -137,124 +126,6 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revisionActionsETag() throws Exception {
|
||||
String parent = createChange().getChangeId();
|
||||
String change = createChangeWithTopic().getChangeId();
|
||||
approve(change);
|
||||
String etag1 = getETag(change);
|
||||
|
||||
approve(parent);
|
||||
String etag2 = getETag(change);
|
||||
|
||||
String changeWithSameTopic = createChangeWithTopic().getChangeId();
|
||||
String etag3 = getETag(change);
|
||||
|
||||
approve(changeWithSameTopic);
|
||||
String etag4 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertThat(ImmutableList.of(etag1, etag2, etag3, etag4)).containsNoDuplicates();
|
||||
} else {
|
||||
assertThat(etag2).isNotEqualTo(etag1);
|
||||
assertThat(etag3).isEqualTo(etag2);
|
||||
assertThat(etag4).isEqualTo(etag2);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revisionActionsAnonymousETag() throws Exception {
|
||||
String parent = createChange().getChangeId();
|
||||
String change = createChangeWithTopic().getChangeId();
|
||||
approve(change);
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag1 = getETag(change);
|
||||
|
||||
requestScopeOperations.setApiUser(admin.id());
|
||||
approve(parent);
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag2 = getETag(change);
|
||||
|
||||
requestScopeOperations.setApiUser(admin.id());
|
||||
String changeWithSameTopic = createChangeWithTopic().getChangeId();
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag3 = getETag(change);
|
||||
|
||||
requestScopeOperations.setApiUser(admin.id());
|
||||
approve(changeWithSameTopic);
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag4 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertThat(ImmutableList.of(etag1, etag2, etag3, etag4)).containsNoDuplicates();
|
||||
} else {
|
||||
assertThat(etag2).isNotEqualTo(etag1);
|
||||
assertThat(etag3).isEqualTo(etag2);
|
||||
assertThat(etag4).isEqualTo(etag2);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestProjectInput(submitType = SubmitType.CHERRY_PICK)
|
||||
public void revisionActionsAnonymousETagCherryPickStrategy() throws Exception {
|
||||
String parent = createChange().getChangeId();
|
||||
String change = createChange().getChangeId();
|
||||
approve(change);
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag1 = getETag(change);
|
||||
|
||||
requestScopeOperations.setApiUser(admin.id());
|
||||
approve(parent);
|
||||
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag2 = getETag(change);
|
||||
assertThat(etag2).isEqualTo(etag1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pluginCanContributeToETagComputation() throws Exception {
|
||||
String change = createChange().getChangeId();
|
||||
String oldETag = getETag(change);
|
||||
|
||||
try (Registration registration =
|
||||
extensionRegistry.newRegistration().add(TestChangeETagComputation.withETag("foo"))) {
|
||||
assertThat(getETag(change)).isNotEqualTo(oldETag);
|
||||
}
|
||||
|
||||
assertThat(getETag(change)).isEqualTo(oldETag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returningNullFromETagComputationDoesNotBreakGerrit() throws Exception {
|
||||
String change = createChange().getChangeId();
|
||||
String oldETag = getETag(change);
|
||||
|
||||
try (Registration registration =
|
||||
extensionRegistry.newRegistration().add(TestChangeETagComputation.withETag(null))) {
|
||||
assertThat(getETag(change)).isEqualTo(oldETag);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void throwingExceptionFromETagComputationDoesNotBreakGerrit() throws Exception {
|
||||
String change = createChange().getChangeId();
|
||||
String oldETag = getETag(change);
|
||||
|
||||
try (Registration registration =
|
||||
extensionRegistry
|
||||
.newRegistration()
|
||||
.add(
|
||||
TestChangeETagComputation.withException(
|
||||
new StorageException("exception during test")))) {
|
||||
assertThat(getETag(change)).isEqualTo(oldETag);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void revisionActionsTwoChangesInTopic_conflicting() throws Exception {
|
||||
String changeId = createChangeWithTopic().getChangeId();
|
||||
|
||||
Reference in New Issue
Block a user