diff --git a/java/google/registry/model/registrar/Registrar.java b/java/google/registry/model/registrar/Registrar.java index e69d3b140..7dc4f3677 100644 --- a/java/google/registry/model/registrar/Registrar.java +++ b/java/google/registry/model/registrar/Registrar.java @@ -698,8 +698,8 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable ImmutableMap.Builder billingAccountMapBuilder = new ImmutableMap.Builder<>(); for (Map.Entry entry : billingAccountMap.entrySet()) { - CurrencyUnit key = entry.getKey(); - billingAccountMapBuilder.put(key, new BillingAccountEntry(key, entry.getValue())); + billingAccountMapBuilder.put( + entry.getKey(), new BillingAccountEntry(entry.getKey(), entry.getValue())); } getInstance().billingAccountMap = billingAccountMapBuilder.build(); } diff --git a/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java b/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java index 39123cd60..3c88eca62 100644 --- a/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java +++ b/java/google/registry/tools/CreateOrUpdateRegistrarCommand.java @@ -47,6 +47,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -182,7 +183,8 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand { description = "Registrar Billing Account key-value pairs (formatted as key=value[,key=value...]), " + "where key is a currency unit (USD, JPY, etc) and value is the registrar's billing " - + "account id for that currency.", + + "account id for that currency. During update, only the pairs that need updating need " + + "to be provided.", converter = CurrencyUnitToStringMap.class, validateWith = CurrencyUnitToStringMap.class ) @@ -354,7 +356,12 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand { builder.setBillingIdentifier(billingId.orNull()); } if (billingAccountMap != null) { - builder.setBillingAccountMap(billingAccountMap); + LinkedHashMap newBillingAccountMap = new LinkedHashMap<>(); + if (oldRegistrar != null && oldRegistrar.getBillingAccountMap() != null) { + newBillingAccountMap.putAll(oldRegistrar.getBillingAccountMap()); + } + newBillingAccountMap.putAll(billingAccountMap); + builder.setBillingAccountMap(newBillingAccountMap); } if (billingMethod != null) { if (oldRegistrar != null && !billingMethod.equals(oldRegistrar.getBillingMethod())) { diff --git a/javatests/google/registry/tools/UpdateRegistrarCommandTest.java b/javatests/google/registry/tools/UpdateRegistrarCommandTest.java index aabf08a9f..6d1b29763 100644 --- a/javatests/google/registry/tools/UpdateRegistrarCommandTest.java +++ b/javatests/google/registry/tools/UpdateRegistrarCommandTest.java @@ -26,6 +26,7 @@ import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.ParameterException; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import google.registry.model.billing.RegistrarBillingEntry; import google.registry.model.registrar.Registrar; @@ -225,6 +226,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase