mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 08:52:12 +02:00
Add billing account map to Registrar entity
A CurrencyUnit-to-BillingAccountEntry map is persisted in the Registrar entity. It provides flexibility for billing systems that assign different account ids for accounts under different currencies of the same registrar. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151022753
This commit is contained in:
parent
ab9b7c613d
commit
d7e2009ddf
8 changed files with 225 additions and 39 deletions
|
@ -34,6 +34,7 @@ import google.registry.model.registrar.Registrar;
|
|||
import google.registry.testing.CertificateSamples;
|
||||
import google.registry.tools.ServerSideCommand.Connection;
|
||||
import java.io.IOException;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -345,6 +346,25 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
|||
assertThat(registrar.getBillingIdentifier()).isEqualTo(12345);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_billingAccountMap() throws Exception {
|
||||
runCommand(
|
||||
"--name=blobio",
|
||||
"--password=some_password",
|
||||
"--registrar_type=REAL",
|
||||
"--iana_id=8",
|
||||
"--billing_account_map=USD=abc123,JPY=789xyz",
|
||||
"--passcode=01234",
|
||||
"--icann_referral_email=foo@bar.test",
|
||||
"--force",
|
||||
"clientz");
|
||||
|
||||
Registrar registrar = Registrar.loadByClientId("clientz");
|
||||
assertThat(registrar).isNotNull();
|
||||
assertThat(registrar.getBillingAccountMap())
|
||||
.containsExactly(CurrencyUnit.USD, "abc123", CurrencyUnit.JPY, "789xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_streetAddress() throws Exception {
|
||||
runCommand(
|
||||
|
|
|
@ -33,6 +33,7 @@ import google.registry.model.registrar.Registrar.BillingMethod;
|
|||
import google.registry.model.registrar.Registrar.State;
|
||||
import google.registry.model.registrar.Registrar.Type;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
@ -203,6 +204,14 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
assertThat(loadByClientId("NewRegistrar").getBillingIdentifier()).isEqualTo(12345);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_billingAccountMap() throws Exception {
|
||||
assertThat(loadByClientId("NewRegistrar").getBillingAccountMap()).isEmpty();
|
||||
runCommand("--billing_account_map=USD=abc123,JPY=789xyz", "--force", "NewRegistrar");
|
||||
assertThat(loadByClientId("NewRegistrar").getBillingAccountMap())
|
||||
.containsExactly(CurrencyUnit.USD, "abc123", CurrencyUnit.JPY, "789xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_changeBillingMethodToBraintreeWhenBalanceIsZero() throws Exception {
|
||||
createTlds("xn--q9jyb4c");
|
||||
|
|
|
@ -18,8 +18,11 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.tools.params.KeyValueMapParameter.CurrencyUnitToStringMap;
|
||||
import google.registry.tools.params.KeyValueMapParameter.StringToIntegerMap;
|
||||
import google.registry.tools.params.KeyValueMapParameter.StringToStringMap;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.IllegalCurrencyException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -34,6 +37,7 @@ public class KeyValueMapParameterTest {
|
|||
|
||||
private final StringToStringMap stringToStringInstance = new StringToStringMap();
|
||||
private final StringToIntegerMap stringToIntegerInstance = new StringToIntegerMap();
|
||||
private final CurrencyUnitToStringMap currencyUnitToStringMap = new CurrencyUnitToStringMap();
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString_singleEntry() throws Exception {
|
||||
|
@ -47,6 +51,12 @@ public class KeyValueMapParameterTest {
|
|||
.isEqualTo(ImmutableMap.of("key", 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString_singleEntry() throws Exception {
|
||||
assertThat(currencyUnitToStringMap.convert("USD=123abc"))
|
||||
.isEqualTo(ImmutableMap.of(CurrencyUnit.USD, "123abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString() throws Exception {
|
||||
assertThat(stringToStringInstance.convert("key=foo,key2=bar"))
|
||||
|
@ -59,6 +69,12 @@ public class KeyValueMapParameterTest {
|
|||
.isEqualTo(ImmutableMap.of("key", 1, "key2", 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString() throws Exception {
|
||||
assertThat(currencyUnitToStringMap.convert("USD=123abc,JPY=xyz789"))
|
||||
.isEqualTo(ImmutableMap.of(CurrencyUnit.USD, "123abc", CurrencyUnit.JPY, "xyz789"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertStringToString_empty() throws Exception {
|
||||
assertThat(stringToStringInstance.convert("")).isEmpty();
|
||||
|
@ -69,12 +85,23 @@ public class KeyValueMapParameterTest {
|
|||
assertThat(stringToIntegerInstance.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertCurrencyUnitToString_empty() throws Exception {
|
||||
assertThat(currencyUnitToStringMap.convert("")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToInteger_badType() throws Exception {
|
||||
thrown.expect(NumberFormatException.class);
|
||||
stringToIntegerInstance.convert("key=1,key2=foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badType() throws Exception {
|
||||
thrown.expect(IllegalCurrencyException.class, "XYZ");
|
||||
currencyUnitToStringMap.convert("USD=123abc,XYZ=xyz789");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToString_badSeparator() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
@ -87,6 +114,12 @@ public class KeyValueMapParameterTest {
|
|||
stringToIntegerInstance.convert("key=1&key2=2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badSeparator() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
currencyUnitToStringMap.convert("USD=123abc&JPY=xyz789");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertStringToString_badFormat() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
@ -98,4 +131,11 @@ public class KeyValueMapParameterTest {
|
|||
thrown.expect(IllegalArgumentException.class);
|
||||
stringToIntegerInstance.convert("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_convertCurrencyUnitToString_badFormat() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
currencyUnitToStringMap.convert("foo");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue