CodeOwnerApprovalCheckTest: Fix test for non-pure revert

The test intends to amend the created revert commit, but since it
forgot to fetch it, it amended the commit that is being reverted and
uploaded it as a new patch set to the revert change. This means that
this commit has a wrong parent commit. For the test it's not really
making any difference at the moment, but we rather fix this.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I0ca694ee587ed93cecda9f1c44e42e460d7d2a61
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java
index 1023d2c..129b10e 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheckTest.java
@@ -24,6 +24,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.gerrit.acceptance.GitUtil;
 import com.google.gerrit.acceptance.TestAccount;
 import com.google.gerrit.acceptance.config.GerritConfig;
 import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
@@ -31,8 +32,11 @@
 import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.extensions.api.changes.ReviewInput;
 import com.google.gerrit.extensions.api.projects.DeleteBranchesInput;
+import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.common.LabelDefinitionInput;
 import com.google.gerrit.extensions.restapi.ResourceConflictException;
 import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
@@ -1998,11 +2002,16 @@
     gApi.changes().id(changeId).current().submit();
 
     // Revert the change
-    String changeIdOfRevert = gApi.changes().id(changeId).revert().get().changeId;
+    ChangeInfo revertChange = gApi.changes().id(changeId).revert().get();
 
     // Amend change to make it a non-pure revert change.
+    GitUtil.fetch(
+        testRepo,
+        RefNames.patchSetRef(PatchSet.id(Change.id(revertChange._number), 1)) + ":revert");
+    testRepo.reset("revert");
+
     amendChange(
-        changeIdOfRevert,
+        revertChange.changeId,
         "refs/for/master",
         admin,
         testRepo,
@@ -2012,7 +2021,7 @@
 
     // Check that the file is not approved.
     ImmutableSet<FileCodeOwnerStatus> fileCodeOwnerStatuses =
-        codeOwnerApprovalCheck.getFileStatusesAsSet(getChangeNotes(changeIdOfRevert));
+        codeOwnerApprovalCheck.getFileStatusesAsSet(getChangeNotes(revertChange.changeId));
     FileCodeOwnerStatusSubject fileCodeOwnerStatusSubject =
         assertThatCollection(fileCodeOwnerStatuses).onlyElement();
     fileCodeOwnerStatusSubject.hasNewPathStatus().value().hasPathThat().isEqualTo(path);