Use method from AbstractDaemonTest to create branches

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I650bb2011582214a277f51c0129e0e3ba9b530ac
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java
index e17063a..b163b1f 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java
@@ -25,11 +25,11 @@
 import com.google.gerrit.acceptance.config.GerritConfig;
 import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
 import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
+import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Permission;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo;
-import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.RestApiException;
@@ -89,7 +89,7 @@
   @Test
   public void nonVisibleBranchesAreSkipped() throws Exception {
     String branchName = "non-visible";
-    gApi.projects().name(project.get()).branch(branchName).create(new BranchInput());
+    createBranch(BranchNameKey.create(project, branchName));
 
     projectOperations
         .project(project)
@@ -236,8 +236,8 @@
 
   @Test
   public void validateSpecifiedBranches() throws Exception {
-    gApi.projects().name(project.get()).branch("stable-1.0").create(new BranchInput());
-    gApi.projects().name(project.get()).branch("stable-1.1").create(new BranchInput());
+    createBranch(BranchNameKey.create(project, "stable-1.0"));
+    createBranch(BranchNameKey.create(project, "stable-1.1"));
 
     assertThat(
             projectCodeOwnersApiFactory
@@ -252,8 +252,8 @@
 
   @Test
   public void validateSpecifiedBranches_shortNames() throws Exception {
-    gApi.projects().name(project.get()).branch("stable-1.0").create(new BranchInput());
-    gApi.projects().name(project.get()).branch("stable-1.1").create(new BranchInput());
+    createBranch(BranchNameKey.create(project, "stable-1.0"));
+    createBranch(BranchNameKey.create(project, "stable-1.1"));
 
     assertThat(
             projectCodeOwnersApiFactory
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
index 5595f93..dcc6464 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
@@ -27,9 +27,9 @@
 import com.google.gerrit.acceptance.config.GerritConfig;
 import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
 import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
+import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Permission;
 import com.google.gerrit.entities.Project;
-import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.extensions.api.projects.ConfigInput;
 import com.google.gerrit.extensions.client.ChangeStatus;
 import com.google.gerrit.extensions.client.ProjectState;
@@ -1213,7 +1213,7 @@
   public void validateMergeCommitCreatedViaTheCreateChangeRestApi() throws Exception {
     // Create another branch.
     String branchName = "stable";
-    gApi.projects().name(project.get()).branch(branchName).create(new BranchInput());
+    createBranch(BranchNameKey.create(project, branchName));
 
     // Create a code owner config file in the other branch.
     codeOwnerConfigOperations
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
index 7718b5d..d872186 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/testsuite/CodeOwnerConfigOperationsImplTest.java
@@ -22,8 +22,8 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.truth.Truth8;
+import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.RefNames;
-import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
 import com.google.gerrit.plugins.codeowners.acceptance.testsuite.CodeOwnerConfigOperations.PerCodeOwnerConfigOperations;
 import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
@@ -113,7 +113,7 @@
   @Test
   public void specifiedBranchIsRespectedForCodeOwnerConfigCreation() throws Exception {
     String branchName = "foo";
-    gApi.projects().name(project.get()).branch(branchName).create(new BranchInput());
+    createBranch(BranchNameKey.create(project, branchName));
 
     CodeOwnerConfig.Key codeOwnerConfigKey =
         codeOwnerConfigOperations
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java
index 27d7202..e5d06ac 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java
@@ -31,7 +31,6 @@
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.entities.Project.NameKey;
-import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.extensions.api.projects.ConfigInput;
 import com.google.gerrit.extensions.client.ProjectState;
 import com.google.gerrit.extensions.registration.DynamicMap;
@@ -1302,14 +1301,10 @@
 
     // Create other branches in project.
     String branchName = "foo";
-    BranchInput branchInput = new BranchInput();
-    branchInput.ref = branchName;
-    branchInput.revision = projectOperations.project(project).getHead("master").name();
-    gApi.projects().name(project.get()).branch(branchInput.ref).create(branchInput);
+    createBranch(BranchNameKey.create(project, branchName));
 
     // Create other branches in other project.
-    branchInput.revision = projectOperations.project(otherProject).getHead("master").name();
-    gApi.projects().name(otherProject.get()).branch(branchInput.ref).create(branchInput);
+    createBranch(BranchNameKey.create(otherProject, branchName));
 
     // create importing config with global code owner and import with relative path
     CodeOwnerConfig.Key rootCodeOwnerConfigKey =
@@ -1351,10 +1346,7 @@
   public void importFromOtherBranch() throws Exception {
     // Create other branch.
     String otherBranch = "foo";
-    BranchInput branchInput = new BranchInput();
-    branchInput.ref = otherBranch;
-    branchInput.revision = projectOperations.project(project).getHead("master").name();
-    gApi.projects().name(project.get()).branch(branchInput.ref).create(branchInput);
+    createBranch(BranchNameKey.create(project, otherBranch));
 
     // create importing config with global code owner and import with relative path
     CodeOwnerConfig.Key rootCodeOwnerConfigKey =
@@ -1399,10 +1391,7 @@
 
     // Create other branch.
     String otherBranch = "foo";
-    BranchInput branchInput = new BranchInput();
-    branchInput.ref = otherBranch;
-    branchInput.revision = projectOperations.project(otherProject).getHead("master").name();
-    gApi.projects().name(otherProject.get()).branch(branchInput.ref).create(branchInput);
+    createBranch(BranchNameKey.create(otherProject, otherBranch));
 
     // create importing config with global code owner and import with relative path
     CodeOwnerConfig.Key rootCodeOwnerConfigKey =
diff --git a/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerProjectConfigJsonTest.java b/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerProjectConfigJsonTest.java
index 6300a99..704d34d 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerProjectConfigJsonTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/restapi/CodeOwnerProjectConfigJsonTest.java
@@ -22,7 +22,6 @@
 
 import com.google.gerrit.entities.BranchNameKey;
 import com.google.gerrit.entities.LabelType;
-import com.google.gerrit.extensions.api.projects.BranchInput;
 import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
 import com.google.gerrit.plugins.codeowners.api.BackendInfo;
 import com.google.gerrit.plugins.codeowners.api.CodeOwnerProjectConfigInfo;
@@ -92,7 +91,7 @@
 
   @Test
   public void formatBackendIds() throws Exception {
-    gApi.projects().name(project.get()).branch("stable-2.10").create(new BranchInput());
+    createBranch(BranchNameKey.create(project, "stable-2.10"));
 
     when(codeOwnersPluginConfiguration.getBackend(project)).thenReturn(findOwnersBackend);
     when(codeOwnersPluginConfiguration.getBackend(BranchNameKey.create(project, "master")))
@@ -132,7 +131,7 @@
   @Test
   public void formatCodeOwnerProjectConfig() throws Exception {
     createOwnersOverrideLabel();
-    gApi.projects().name(project.get()).branch("stable-2.10").create(new BranchInput());
+    createBranch(BranchNameKey.create(project, "stable-2.10"));
 
     when(codeOwnersPluginConfiguration.isDisabled(project)).thenReturn(true);
     when(codeOwnersPluginConfiguration.getBackend(project)).thenReturn(findOwnersBackend);