Add GerritConfig annotation processing to GerritServerTests
This commits adds GerritConfig annotation processing to GerritServerTests which makes the annotation usable in any test that inherits from GerritServerTests. Change-Id: I6a3afb23925433cb7cb2b449f410ef210e6dc628
This commit is contained in:
@@ -13,6 +13,7 @@ java_library(
|
||||
"//lib/mockito",
|
||||
],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/acceptance/config",
|
||||
"//java/com/google/gerrit/acceptance/testsuite/project",
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/entities",
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
|
||||
package com.google.gerrit.testing;
|
||||
|
||||
import com.google.gerrit.acceptance.config.ConfigAnnotationParser;
|
||||
import com.google.gerrit.acceptance.config.GerritConfig;
|
||||
import com.google.gerrit.acceptance.config.GerritConfigs;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestRule;
|
||||
@@ -23,16 +26,24 @@ import org.junit.runners.model.Statement;
|
||||
@RunWith(ConfigSuite.class)
|
||||
public class GerritServerTests {
|
||||
@ConfigSuite.Parameter public Config config;
|
||||
|
||||
@ConfigSuite.Name private String configName;
|
||||
|
||||
@Rule
|
||||
public TestRule testRunner =
|
||||
(base, description) ->
|
||||
new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
base.evaluate();
|
||||
}
|
||||
};
|
||||
(base, description) -> {
|
||||
GerritConfig gerritConfig = description.getAnnotation(GerritConfig.class);
|
||||
if (gerritConfig != null) {
|
||||
config = ConfigAnnotationParser.parse(config, gerritConfig);
|
||||
}
|
||||
GerritConfigs gerritConfigs = description.getAnnotation(GerritConfigs.class);
|
||||
if (gerritConfigs != null) {
|
||||
config = ConfigAnnotationParser.parse(config, gerritConfigs);
|
||||
}
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
base.evaluate();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user