Merge "Stop relying on server-side settings for option-hexes."
diff --git a/java/com/google/gerrit/extensions/api/changes/CustomKeyedValuesInput.java b/java/com/google/gerrit/extensions/api/changes/CustomKeyedValuesInput.java
index a603328..740df21 100644
--- a/java/com/google/gerrit/extensions/api/changes/CustomKeyedValuesInput.java
+++ b/java/com/google/gerrit/extensions/api/changes/CustomKeyedValuesInput.java
@@ -14,21 +14,21 @@
package com.google.gerrit.extensions.api.changes;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import com.google.gerrit.extensions.restapi.DefaultInput;
+import java.util.Map;
+import java.util.Set;
public class CustomKeyedValuesInput {
- @DefaultInput public ImmutableMap<String, String> add;
- public ImmutableSet<String> remove;
+ @DefaultInput public Map<String, String> add;
+ public Set<String> remove;
public CustomKeyedValuesInput() {}
- public CustomKeyedValuesInput(ImmutableMap<String, String> add) {
+ public CustomKeyedValuesInput(Map<String, String> add) {
this.add = add;
}
- public CustomKeyedValuesInput(ImmutableMap<String, String> add, ImmutableSet<String> remove) {
+ public CustomKeyedValuesInput(Map<String, String> add, Set<String> remove) {
this(add);
this.remove = remove;
}
diff --git a/java/com/google/gerrit/server/change/CustomKeyedValuesUtil.java b/java/com/google/gerrit/server/change/CustomKeyedValuesUtil.java
index 04bc6e4..55b4d74 100644
--- a/java/com/google/gerrit/server/change/CustomKeyedValuesUtil.java
+++ b/java/com/google/gerrit/server/change/CustomKeyedValuesUtil.java
@@ -17,6 +17,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Map;
+import java.util.Set;
public class CustomKeyedValuesUtil {
public static class InvalidCustomKeyedValueException extends Exception {
@@ -35,7 +36,7 @@
}
}
- static ImmutableMap<String, String> extractCustomKeyedValues(ImmutableMap<String, String> input)
+ static ImmutableMap<String, String> extractCustomKeyedValues(Map<String, String> input)
throws InvalidCustomKeyedValueException {
if (input == null) {
return ImmutableMap.of();
@@ -57,7 +58,7 @@
return builder.build();
}
- static ImmutableSet<String> extractCustomKeys(ImmutableSet<String> input)
+ static ImmutableSet<String> extractCustomKeys(Set<String> input)
throws InvalidCustomKeyedValueException {
if (input == null) {
return ImmutableSet.of();
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/CustomKeyedValuesIT.java b/javatests/com/google/gerrit/acceptance/rest/change/CustomKeyedValuesIT.java
index 03722e6..3a1d909 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/CustomKeyedValuesIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/CustomKeyedValuesIT.java
@@ -27,9 +27,8 @@
import com.google.common.collect.Iterables;
import com.google.common.truth.MapSubject;
import com.google.gerrit.acceptance.AbstractDaemonTest;
-import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
-import com.google.gerrit.acceptance.UseClockStep;
+import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
import com.google.gerrit.extensions.api.changes.CustomKeyedValuesInput;
import com.google.gerrit.extensions.common.ChangeMessageInfo;
@@ -38,19 +37,29 @@
import com.google.inject.Inject;
import org.junit.Test;
-@NoHttpd
-@UseClockStep
public class CustomKeyedValuesIT extends AbstractDaemonTest {
@Inject private RequestScopeOperations requestScopeOperations;
@Test
public void getNoCustomKeyedValues() throws Exception {
- // Get on a change with no hashtags returns an empty list.
+ // Get on a change with no custom keyed values returns an empty list.
PushOneCommit.Result r = createChange();
assertThatGet(r).isEmpty();
}
@Test
+ public void parsesInputCorrectly() throws Exception {
+ PushOneCommit.Result r = createChange();
+ String endpoint = "/changes/" + r.getChangeId() + "/custom_keyed_values";
+ CustomKeyedValuesInput input = new CustomKeyedValuesInput();
+ input.add = ImmutableMap.of("key", "value");
+ RestResponse response = adminRestSession.post(endpoint, input);
+ response.assertOK();
+
+ assertThatGet(r).containsExactly("key", "value");
+ }
+
+ @Test
public void addSingleCustomKeyedValue() throws Exception {
PushOneCommit.Result r = createChange();
ChangeMessageInfo last = getLastMessage(r);