Adapt to the removal of cache diff

The "diff" cache has been removed in stable-3.5 (I52738c85), in favour
of two new caches, the git_file_diff cache (introduced in  Ia278881c0f)
and the gerrit_file_diff cache (introduced in I23f616d1).

Adapt the migration servlet accordingly and adjust the tests
expectations.

Bug: Issue 15287
Change-Id: I7610f2e580fac9fe25024aeee4e02f66da33c430
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
index 1235e53..79e4b38 100644
--- a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
@@ -185,7 +185,8 @@
             .put("web_sessions", DefaultConfig.create(45, 221, 1000, 1))
             .put("change_notes", DefaultConfig.create(36, 10240, 1000, 3))
             .put("accounts", DefaultConfig.create(30, 256, 1000, 1))
-            .put("diff", DefaultConfig.create(98, 10240, 1000, 2))
+            .put("gerrit_file_diff", DefaultConfig.create(98, 10240, 1000, 2))
+            .put("git_file_diff", DefaultConfig.create(98, 10240, 1000, 2))
             .put("diff_intraline", DefaultConfig.create(512, 2048, 1000, 2))
             .put("diff_summary", DefaultConfig.create(128, 2048, 1000, 1))
             .put("external_ids_map", DefaultConfig.create(128, 204800, 2, 1))
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/H2MigrationServlet.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/H2MigrationServlet.java
index f35f0ee..965c717 100644
--- a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/H2MigrationServlet.java
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/H2MigrationServlet.java
@@ -42,8 +42,10 @@
 import com.google.gerrit.server.patch.DiffSummaryKey;
 import com.google.gerrit.server.patch.IntraLineDiff;
 import com.google.gerrit.server.patch.IntraLineDiffKey;
-import com.google.gerrit.server.patch.PatchList;
-import com.google.gerrit.server.patch.PatchListKey;
+import com.google.gerrit.server.patch.filediff.FileDiffCacheKey;
+import com.google.gerrit.server.patch.filediff.FileDiffOutput;
+import com.google.gerrit.server.patch.gitfilediff.GitFileDiff;
+import com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheKey;
 import com.google.gerrit.server.query.change.ConflictKey;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -104,7 +106,9 @@
       @Named("git_tags") PersistentCacheDef<String, TagSetHolder> gitTagsCacheDef,
       @Named("change_notes")
           PersistentCacheDef<ChangeNotesCache.Key, ChangeNotesState> changeNotesCacheDef,
-      @Named("diff") PersistentCacheDef<PatchListKey, PatchList> diffCacheDef,
+      @Named("gerrit_file_diff")
+          PersistentCacheDef<FileDiffCacheKey, FileDiffOutput> gerritFileDiffDef,
+      @Named("git_file_diff") PersistentCacheDef<GitFileDiffCacheKey, GitFileDiff> gitFileDiffDef,
       @Named("diff_intraline")
           PersistentCacheDef<IntraLineDiffKey, IntraLineDiff> diffIntraLineCacheDef,
       @Named("diff_summary") PersistentCacheDef<DiffSummaryKey, DiffSummary> diffSummaryCacheDef,
@@ -126,7 +130,8 @@
                 pureRevertCacheDef,
                 gitTagsCacheDef,
                 changeNotesCacheDef,
-                diffCacheDef,
+                gerritFileDiffDef,
+                gitFileDiffDef,
                 diffIntraLineCacheDef,
                 diffSummaryCacheDef,
                 persistedProjectsCacheDef,
diff --git a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AnalyzeH2CachesIT.java b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AnalyzeH2CachesIT.java
index 482b9da..c02d581 100644
--- a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AnalyzeH2CachesIT.java
+++ b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AnalyzeH2CachesIT.java
@@ -49,7 +49,8 @@
     String result = adminSshSession.exec(cmd);
 
     adminSshSession.assertSuccess();
-    assertThat(result).contains("[cache \"diff\"]\n" + "\tmaxEntries = 1\n");
+    assertThat(result).contains("[cache \"git_file_diff\"]\n" + "\tmaxEntries = 1\n");
+    assertThat(result).contains("[cache \"gerrit_file_diff\"]\n" + "\tmaxEntries = 2\n");
     assertThat(result).contains("[cache \"accounts\"]\n" + "\tmaxEntries = 4\n");
     assertThat(result).contains("[cache \"diff_summary\"]\n" + "\tmaxEntries = 1\n");
     assertThat(result).contains("[cache \"persisted_projects\"]\n" + "\tmaxEntries = 3\n");
@@ -68,7 +69,8 @@
             "WARN: Cache diff_intraline is empty, skipping.",
             "WARN: Cache change_kind is empty, skipping.",
             "WARN: Cache diff_summary is empty, skipping.",
-            "WARN: Cache diff is empty, skipping.",
+            "WARN: Cache gerrit_file_diff is empty, skipping.",
+            "WARN: Cache git_file_diff is empty, skipping.",
             "WARN: Cache pure_revert is empty, skipping.",
             "WARN: Cache git_tags is empty, skipping.");
     String result = adminSshSession.exec(cmd);
@@ -87,7 +89,8 @@
             "WARN: Cache diff_intraline is empty, skipping.",
             "WARN: Cache change_kind is empty, skipping.",
             "WARN: Cache diff_summary is empty, skipping.",
-            "WARN: Cache diff is empty, skipping.",
+            "WARN: Cache gerrit_file_diff is empty, skipping.",
+            "WARN: Cache git_file_diff is empty, skipping.",
             "WARN: Cache pure_revert is empty, skipping.",
             "WARN: Cache git_tags is empty, skipping.");
     String result = adminSshSession.exec(cmd);
diff --git a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AutoAdjustCachesIT.java b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AutoAdjustCachesIT.java
index 57b0e46..087e804 100644
--- a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AutoAdjustCachesIT.java
+++ b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/AutoAdjustCachesIT.java
@@ -59,7 +59,8 @@
   private static final String SSH_CMD = "cache-chroniclemap auto-adjust-caches";
   private static final String REST_CMD = "/plugins/cache-chroniclemap/auto-adjust-caches";
   private static final String GROUPS_BYUUID_PERSISTED = "groups_byuuid_persisted";
-  private static final String DIFF = "diff";
+  private static final String GERRIT_FILE_DIFF = "gerrit_file_diff";
+  private static final String GIT_FILE_DIFF = "git_file_diff";
   private static final String DIFF_SUMMARY = "diff_summary";
   private static final String ACCOUNTS = "accounts";
   private static final String PERSISTED_PROJECTS = "persisted_projects";
@@ -71,7 +72,13 @@
   private static final Function<String, Boolean> MATCH_ALL = (n) -> true;
 
   private static final ImmutableList<String> EXPECTED_CACHES =
-      ImmutableList.of(GROUPS_BYUUID_PERSISTED, DIFF, DIFF_SUMMARY, ACCOUNTS, PERSISTED_PROJECTS);
+      ImmutableList.of(
+          GROUPS_BYUUID_PERSISTED,
+          GERRIT_FILE_DIFF,
+          GIT_FILE_DIFF,
+          DIFF_SUMMARY,
+          ACCOUNTS,
+          PERSISTED_PROJECTS);
 
   @Inject private SitePaths sitePaths;