Remove duplicate methods to create non-parsable code owner config
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I4209280021586aee2a9c97e233ed1f91ef9d036a
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
index f944314..61a34f5 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
@@ -230,6 +230,21 @@
}
/**
+ * Creates a non-parseable code owner config file at the given path.
+ *
+ * @param path path of the code owner config file
+ */
+ protected void createNonParseableCodeOwnerConfig(String path) throws Exception {
+ disableCodeOwnersForProject(project);
+ String changeId =
+ createChange("Add invalid code owners file", JgitPath.of(path).get(), "INVALID")
+ .getChangeId();
+ approve(changeId);
+ gApi.changes().id(changeId).current().submit();
+ enableCodeOwnersForProject(project);
+ }
+
+ /**
* Creates a new change for the given test account.
*
* @param testAccount the account that should own the new change
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 e6870c2..9a31ca1 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesIT.java
@@ -35,7 +35,6 @@
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
-import com.google.gerrit.plugins.codeowners.JgitPath;
import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersIT;
import com.google.gerrit.plugins.codeowners.backend.CodeOwnerBackend;
import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
@@ -608,16 +607,6 @@
throw new IllegalStateException("unknown code owner backend: " + backend.getClass().getName());
}
- private void createNonParseableCodeOwnerConfig(String path) throws Exception {
- disableCodeOwnersForProject(project);
- String changeId =
- createChange("Add invalid code owners file", JgitPath.of(path).get(), "INVALID")
- .getChangeId();
- approve(changeId);
- gApi.changes().id(changeId).current().submit();
- enableCodeOwnersForProject(project);
- }
-
private String getParsingErrorMessage(
ImmutableMap<Class<? extends CodeOwnerBackend>, String> messagesByBackend) {
CodeOwnerBackend codeOwnerBackend = backendConfig.getDefaultBackend();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerConfigFilesIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerConfigFilesIT.java
index 31d1b87..c17e4e2 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerConfigFilesIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/GetCodeOwnerConfigFilesIT.java
@@ -206,7 +206,7 @@
@Test
public void getCodeOwnerConfigFilesIfInvalidCodeOwnerConfigFilesExist() throws Exception {
- createInvalidCodeOwnerConfig(getCodeOwnerConfigFileName());
+ createNonParseableCodeOwnerConfig(getCodeOwnerConfigFileName());
CodeOwnerConfig.Key codeOwnerConfigKey =
codeOwnerConfigOperations
@@ -230,7 +230,7 @@
@Test
public void includeInvalidCodeOwnerConfigFiles() throws Exception {
String nameOfInvalidCodeOwnerConfigFile = getCodeOwnerConfigFileName();
- createInvalidCodeOwnerConfig(nameOfInvalidCodeOwnerConfigFile);
+ createNonParseableCodeOwnerConfig(nameOfInvalidCodeOwnerConfigFile);
CodeOwnerConfig.Key codeOwnerConfigKey =
codeOwnerConfigOperations
@@ -444,14 +444,4 @@
}
throw new IllegalStateException("unknown code owner backend: " + backend.getClass().getName());
}
-
- private void createInvalidCodeOwnerConfig(String path) throws Exception {
- disableCodeOwnersForProject(project);
- String changeId =
- createChange("Add invalid code owners file", JgitPath.of(path).get(), "INVALID")
- .getChangeId();
- approve(changeId);
- gApi.changes().id(changeId).current().submit();
- enableCodeOwnersForProject(project);
- }
}
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java
index c26f000..df2e602 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigScannerTest.java
@@ -25,7 +25,6 @@
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.entities.BranchNameKey;
import com.google.gerrit.entities.RefNames;
-import com.google.gerrit.plugins.codeowners.JgitPath;
import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
import com.google.gerrit.plugins.codeowners.acceptance.testsuite.CodeOwnerConfigOperations;
import java.nio.file.Paths;
@@ -153,7 +152,7 @@
@Test
public void visitorNotInvokedForInvalidCodeOwnerConfigFiles() throws Exception {
- createInvalidCodeOwnerConfig("/OWNERS");
+ createNonParseableCodeOwnerConfig("/OWNERS");
visit();
verifyZeroInteractions(visitor);
@@ -167,7 +166,7 @@
@Test
public void visitorInvokedForValidCodeOwnerConfigFilesEvenIfInvalidCodeOwnerConfigFileExist()
throws Exception {
- createInvalidCodeOwnerConfig("/OWNERS");
+ createNonParseableCodeOwnerConfig("/OWNERS");
// Create a valid code owner config file.
CodeOwnerConfig.Key codeOwnerConfigKey =
@@ -554,7 +553,7 @@
@Test
public void containsACodeOwnerConfigFile_invalidCodeOwnerConfigFileExists() throws Exception {
- createInvalidCodeOwnerConfig("/OWNERS");
+ createNonParseableCodeOwnerConfig("/OWNERS");
codeOwnerConfigOperations
.newCodeOwnerConfig()
@@ -574,7 +573,7 @@
@Test
public void containsOnlyInvalidCodeOwnerConfigFiles() throws Exception {
- createInvalidCodeOwnerConfig("/OWNERS");
+ createNonParseableCodeOwnerConfig("/OWNERS");
assertThat(
codeOwnerConfigScannerFactory
@@ -625,14 +624,4 @@
.includeDefaultCodeOwnerConfig(includeDefaultCodeOwnerConfig)
.visit(BranchNameKey.create(project, "master"), visitor, invalidCodeOwnerConfigCallback);
}
-
- private void createInvalidCodeOwnerConfig(String path) throws Exception {
- disableCodeOwnersForProject(project);
- String changeId =
- createChange("Add invalid code owners file", JgitPath.of(path).get(), "INVALID")
- .getChangeId();
- approve(changeId);
- gApi.changes().id(changeId).current().submit();
- enableCodeOwnersForProject(project);
- }
}