ApplyPatch: Suppress deprecation warning for Hashing.sha1()

Git requires us to provide a SHA1, we cannot choose another hash
function.

Release-Notes: skip
Change-Id: I41a41b15176f681d7f69c96fbfc35d260e2cf62f
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/server/restapi/change/ApplyPatchUtil.java b/java/com/google/gerrit/server/restapi/change/ApplyPatchUtil.java
index c0c5f56..185a6ac 100644
--- a/java/com/google/gerrit/server/restapi/change/ApplyPatchUtil.java
+++ b/java/com/google/gerrit/server/restapi/change/ApplyPatchUtil.java
@@ -17,6 +17,8 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.hash.HashCode;
 import com.google.common.hash.Hashing;
 import com.google.gerrit.extensions.api.changes.ApplyPatchInput;
 import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -152,7 +154,7 @@
                 + "\n[[[Original patch trimmed due to size. Decoded string size: "
                 + patchDescription.length()
                 + ". Decoded string SHA1: "
-                + Hashing.sha1().hashString(patchDescription, UTF_8)
+                + sha1(patchDescription)
                 + ".]]]");
       }
     }
@@ -166,7 +168,7 @@
                 + "\n[[[Result patch trimmed due to size. Decoded string size: "
                 + resultPatch.length()
                 + ". Decoded string SHA1: "
-                + Hashing.sha1().hashString(resultPatch, UTF_8)
+                + sha1(resultPatch)
                 + ".]]]");
       }
     }
@@ -219,5 +221,11 @@
     return patch;
   }
 
+  @SuppressWarnings("deprecation")
+  @VisibleForTesting
+  public static HashCode sha1(String s) {
+    return Hashing.sha1().hashString(s, UTF_8);
+  }
+
   private ApplyPatchUtil() {}
 }
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ApplyPatchIT.java b/javatests/com/google/gerrit/acceptance/api/change/ApplyPatchIT.java
index f242cdb..0367080 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ApplyPatchIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ApplyPatchIT.java
@@ -28,7 +28,6 @@
 import static org.eclipse.jgit.lib.Constants.HEAD;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.hash.Hashing;
 import com.google.gerrit.acceptance.AbstractDaemonTest;
 import com.google.gerrit.acceptance.PushOneCommit;
 import com.google.gerrit.acceptance.RestResponse;
@@ -57,6 +56,7 @@
 import com.google.gerrit.extensions.restapi.ResourceConflictException;
 import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
 import com.google.gerrit.extensions.restapi.RestApiException;
+import com.google.gerrit.server.restapi.change.ApplyPatchUtil;
 import com.google.inject.Inject;
 import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
 import org.eclipse.jgit.junit.TestRepository;
@@ -363,7 +363,7 @@
                 + "\n[[[Original patch trimmed due to size. Decoded string size: "
                 + removePatchHeader(patch).length()
                 + ". Decoded string SHA1: "
-                + Hashing.sha1().hashString(removePatchHeader(patch), UTF_8)
+                + ApplyPatchUtil.sha1(removePatchHeader(patch))
                 + ".]]]"
                 + "\n\nChange-Id: "
                 + result.changeId