Fix capabilities acceptance test broken by batch changes limit

This was missed before in Ic929dc4 and the acceptance tests are
currently broken:
  FAILURE testCapabilitiesUser: batchChangesLimit
  java.lang.NoSuchFieldException: batchChangesLimit

Add handling of the batch changes limit field in the acceptance
test.

Change-Id: I486864594cbccaaf0a6f14f14c0b5bc7107e580d
This commit is contained in:
Bruce Zu
2014-11-21 15:03:45 +08:00
committed by David Pursehouse
parent 03c2db91b3
commit 66017ae116
3 changed files with 18 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ package com.google.gerrit.acceptance.rest.account;
import static com.google.gerrit.common.data.GlobalCapability.ACCESS_DATABASE;
import static com.google.gerrit.common.data.GlobalCapability.ADMINISTRATE_SERVER;
import static com.google.gerrit.common.data.GlobalCapability.BATCH_CHANGES_LIMIT;
import static com.google.gerrit.common.data.GlobalCapability.DEFAULT_MAX_BATCH_CHANGES_LIMIT;
import static com.google.gerrit.common.data.GlobalCapability.DEFAULT_MAX_QUERY_LIMIT;
import static com.google.gerrit.common.data.GlobalCapability.PRIORITY;
import static com.google.gerrit.common.data.GlobalCapability.QUERY_LIMIT;
@@ -23,6 +25,7 @@ import static com.google.gerrit.common.data.GlobalCapability.RUN_AS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@@ -57,6 +60,9 @@ public class CapabilitiesIT extends AbstractDaemonTest {
for (String c : GlobalCapability.getAllNames()) {
if (ADMINISTRATE_SERVER.equals(c)) {
assertFalse(info.administrateServer);
} else if (BATCH_CHANGES_LIMIT.equals(c)) {
assertEquals(0, info.batchChangesLimit.min);
assertEquals(DEFAULT_MAX_BATCH_CHANGES_LIMIT, info.batchChangesLimit.max);
} else if (PRIORITY.equals(c)) {
assertFalse(info.priority);
} else if (QUERY_LIMIT.equals(c)) {
@@ -78,7 +84,11 @@ public class CapabilitiesIT extends AbstractDaemonTest {
CapabilityInfo info = (new Gson()).fromJson(r.getReader(),
new TypeToken<CapabilityInfo>() {}.getType());
for (String c : GlobalCapability.getAllNames()) {
if (PRIORITY.equals(c)) {
if (BATCH_CHANGES_LIMIT.equals(c)) {
// It does not have default value for any user as it can override the
// 'receive.batchChangesLimit'. It needs to be granted explicitly.
assertNull(info.batchChangesLimit);
} else if (PRIORITY.equals(c)) {
assertFalse(info.priority);
} else if (QUERY_LIMIT.equals(c)) {
assertNotNull("missing queryLimit", info.queryLimit);

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.acceptance.rest.account;
class CapabilityInfo {
public boolean accessDatabase;
public boolean administrateServer;
public BatchChangesLimit batchChangesLimit;
public boolean createAccount;
public boolean createGroup;
public boolean createProject;
@@ -39,4 +40,9 @@ class CapabilityInfo {
short min;
short max;
}
static class BatchChangesLimit {
short min;
short max;
}
}

View File

@@ -43,7 +43,7 @@ public class GlobalCapability {
* limit. This is just used as a suggestion for prepopulating the field in the
* access UI.
*/
private static final int DEFAULT_MAX_BATCH_CHANGES_LIMIT = 0;
public static final int DEFAULT_MAX_BATCH_CHANGES_LIMIT = 0;
/** Can create any account on the server. */
public static final String CREATE_ACCOUNT = "createAccount";