ProjectIT: Factor out a method to set the max object size limit
Change-Id: Iea22ff442f4fe6b577fe5fbce42496abc422eae8
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
index 272e2c5..cc88a6d 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -150,16 +150,13 @@
@Test
public void maxObjectSizeCanBeSetAndCleared() throws Exception {
// Set a value
- ConfigInput input = new ConfigInput();
- input.maxObjectSizeLimit = "100k";
- ConfigInfo info = setConfig(input);
+ ConfigInfo info = setMaxObjectSize("100k");
assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
// Clear the value
- input.maxObjectSizeLimit = "0";
- info = setConfig(input);
+ info = setMaxObjectSize("0");
assertThat(info.maxObjectSizeLimit.value).isNull();
assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
@@ -169,9 +166,7 @@
public void maxObjectSizeIsNotInheritedFromParentProject() throws Exception {
Project.NameKey child = createProject(name("child"), project);
- ConfigInput input = new ConfigInput();
- input.maxObjectSizeLimit = "100k";
- ConfigInfo info = setConfig(input);
+ ConfigInfo info = setMaxObjectSize("100k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
@@ -193,9 +188,7 @@
@Test
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
public void maxObjectSizeOverridesGlobalConfigWhenLower() throws Exception {
- ConfigInput input = new ConfigInput();
- input.maxObjectSizeLimit = "100k";
- ConfigInfo info = setConfig(input);
+ ConfigInfo info = setMaxObjectSize("100k");
assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
@@ -204,9 +197,7 @@
@Test
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
public void maxObjectSizeDoesNotOverrideGlobalConfigWhenHigher() throws Exception {
- ConfigInput input = new ConfigInput();
- input.maxObjectSizeLimit = "300k";
- ConfigInfo info = setConfig(input);
+ ConfigInfo info = setMaxObjectSize("300k");
assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("300k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
@@ -214,11 +205,9 @@
@Test
public void invalidMaxObjectSizeIsRejected() throws Exception {
- ConfigInput input = new ConfigInput();
- input.maxObjectSizeLimit = "100 foo";
exception.expect(ResourceConflictException.class);
exception.expectMessage("100 foo");
- setConfig(input);
+ setMaxObjectSize("100 foo");
}
private ConfigInfo setConfig(Project.NameKey name, ConfigInput input) throws Exception {
@@ -229,6 +218,12 @@
return setConfig(project, input);
}
+ private ConfigInfo setMaxObjectSize(String value) throws Exception {
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = value;
+ return setConfig(input);
+ }
+
private ConfigInfo getConfig(Project.NameKey name) throws Exception {
return gApi.projects().name(name.get()).config();
}