Adapt to Branch.NameKey refactoring

Change-Id: I0879aaf8ad2ae340a109802ab2a62d4cfeeca71a
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/AllConfigDownstreamAction.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/AllConfigDownstreamAction.java
index ca803d8..947c8e1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/AllConfigDownstreamAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/AllConfigDownstreamAction.java
@@ -53,7 +53,7 @@
   public Response<List<String>> apply(BranchResource branchResource)
       throws RestApiException, IOException {
 
-    String branchName = branchResource.getBranchKey().getShortName();
+    String branchName = branchResource.getBranchKey().shortName();
     String projectName = branchResource.getName();
 
     try {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
index 584a53e..1b0b409 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
@@ -106,7 +106,7 @@
   @Override
   public Description getDescription(RevisionResource resource) {
     String project = resource.getProject().get();
-    String branch = resource.getChange().getDest().getShortName();
+    String branch = resource.getChange().getDest().shortName();
     Description desc = new Description();
     desc = desc.setLabel("Recreate automerges").setTitle("Recreate automerges downstream");
     try {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/ConfigDownstreamAction.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/ConfigDownstreamAction.java
index e681d8a..6af7c79 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/ConfigDownstreamAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/ConfigDownstreamAction.java
@@ -56,7 +56,7 @@
   public Response<Map<String, Boolean>> apply(RevisionResource rev, Input input)
       throws RestApiException, IOException {
 
-    String branchName = rev.getChange().getDest().getShortName();
+    String branchName = rev.getChange().getDest().shortName();
     String projectName = rev.getProject().get();
 
     try {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorIT.java b/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorIT.java
index ce86869..85f65df 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorIT.java
@@ -81,8 +81,8 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -132,8 +132,8 @@
     PushOneCommit.Result initialResult = createChange("subject", "filename", "echo Hello");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = initialResult.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "left"));
-    createBranch(new Branch.NameKey(projectName, "right"));
+    createBranch(Branch.nameKey(projectName, "left"));
+    createBranch(Branch.nameKey(projectName, "right"));
     initialResult.assertOkStatus();
     merge(initialResult);
     // Reset to create a sibling
@@ -150,7 +150,7 @@
     String rightRevision = gApi.projects().name(projectName).branch("right").get().revision;
     // For this test, right != left
     assertThat(leftRevision).isNotEqualTo(rightRevision);
-    createBranch(new Branch.NameKey(projectName, "bottom"));
+    createBranch(Branch.nameKey(projectName, "bottom"));
     pushDiamondConfig(manifestNameKey.get(), projectName);
     // After we upload our config, we upload a new patchset to create the downstreams
     PushOneCommit.Result result =
@@ -226,8 +226,8 @@
     PushOneCommit.Result initialResult = createChange("subject", "filename", "echo Hello");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = initialResult.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "left"));
-    createBranch(new Branch.NameKey(projectName, "right"));
+    createBranch(Branch.nameKey(projectName, "left"));
+    createBranch(Branch.nameKey(projectName, "right"));
     initialResult.assertOkStatus();
     merge(initialResult);
 
@@ -235,7 +235,7 @@
     String rightRevision = gApi.projects().name(projectName).branch("right").get().revision;
     // For this test, right == left
     assertThat(leftRevision).isEqualTo(rightRevision);
-    createBranch(new Branch.NameKey(projectName, "bottom"));
+    createBranch(Branch.nameKey(projectName, "bottom"));
     pushDiamondConfig(manifestNameKey.get(), projectName);
 
     // Freeze time so that the merge commit from left->bottom and right->bottom have same SHA
@@ -296,7 +296,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushSimpleConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -348,7 +348,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushSimpleConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -413,8 +413,8 @@
             testRepo, "master", "DO NOT MERGE subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId(), "DO NOT MERGE subject", "filename", "content");
@@ -475,8 +475,8 @@
             "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId(), "DO NOT MERGE ANYWHERE subject", "filename", "content");
@@ -528,8 +528,8 @@
     PushOneCommit.Result result = createChange("subject", "filename", "echo Hello");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     result.assertOkStatus();
     merge(result);
     // Reset to create a sibling
@@ -591,8 +591,8 @@
     PushOneCommit.Result result = createChange("subject", "filename", "echo Hello");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     result.assertOkStatus();
     merge(result);
     // Reset to create a sibling
@@ -660,8 +660,8 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -686,8 +686,8 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -714,8 +714,8 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     pushDefaultConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one", "ds_two");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -740,8 +740,8 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "branch{}braces"));
-    createBranch(new Branch.NameKey(projectName, "branch\"quotes"));
+    createBranch(Branch.nameKey(projectName, "branch{}braces"));
+    createBranch(Branch.nameKey(projectName, "branch\"quotes"));
     pushDefaultConfig(
         "automerger.config",
         manifestNameKey.get(),
@@ -769,7 +769,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().project().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushSimpleConfig("automerger.config", manifestNameKey.get(), projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -791,8 +791,8 @@
     // Project name is scoped by test, so we need to get it from our initial change
     Project.NameKey projectNameKey = initialResult.getChange().project();
     String projectName = projectNameKey.get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     initialResult.assertOkStatus();
     merge(initialResult);
 
@@ -858,8 +858,8 @@
     // Project name is scoped by test, so we need to get it from our initial change
     Project.NameKey projectNameKey = initialResult.getChange().project();
     String projectName = projectNameKey.get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     initialResult.assertOkStatus();
     merge(initialResult);
 
@@ -933,8 +933,8 @@
     // Project name is scoped by test, so we need to get it from our initial change
     Project.NameKey projectNameKey = initialResult.getChange().project();
     String projectName = projectNameKey.get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
-    createBranch(new Branch.NameKey(projectName, "ds_two"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_two"));
     initialResult.assertOkStatus();
     merge(initialResult);
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/automerger/MergeValidatorIT.java b/src/test/java/com/googlesource/gerrit/plugins/automerger/MergeValidatorIT.java
index 0608d63..9987582 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/automerger/MergeValidatorIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/automerger/MergeValidatorIT.java
@@ -68,7 +68,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().change().getProject().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushConfig("automerger.config", projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -82,7 +82,7 @@
     PushOneCommit.Result result = createChange("subject", "filename", "content");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().change().getProject().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushConfig("automerger.config", projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -115,7 +115,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().change().getProject().get();
-    createBranch(new Branch.NameKey(projectName, "branch\"quotes"));
+    createBranch(Branch.nameKey(projectName, "branch\"quotes"));
     pushConfig("automerger.config", projectName, "branch\"quotes");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -130,7 +130,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().change().getProject().get();
-    createBranch(new Branch.NameKey(projectName, "branch{}braces"));
+    createBranch(Branch.nameKey(projectName, "branch{}braces"));
     pushConfig("automerger.config", projectName, "branch{}braces");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());
@@ -145,7 +145,7 @@
         createChange(testRepo, "master", "subject", "filename", "content", "testtopic");
     // Project name is scoped by test, so we need to get it from our initial change
     String projectName = result.getChange().change().getProject().get();
-    createBranch(new Branch.NameKey(projectName, "ds_one"));
+    createBranch(Branch.nameKey(projectName, "ds_one"));
     pushConfig("automerger.config", projectName, "ds_one");
     // After we upload our config, we upload a new patchset to create the downstreams
     amendChange(result.getChangeId());