Validate EAP currency in Registry build

Verify that the currency of all entries in the EAP fee schedule map matches
that of the registry object itself.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124967612
This commit is contained in:
mmuller 2016-06-15 10:43:23 -07:00 committed by Ben McIlwain
parent ec39f15a23
commit 5a4877805b
3 changed files with 30 additions and 8 deletions

View file

@ -826,15 +826,19 @@ public class Registry extends ImmutableObject implements Buildable {
checkArgument(
instance.getServerStatusChangeCost().getCurrencyUnit().equals(instance.currency),
"Server status change cost must be in the registry's currency");
Predicate<Money> currencyCheck = new Predicate<Money>(){
@Override
public boolean apply(Money money) {
return money.getCurrencyUnit().equals(instance.currency);
}};
checkArgument(
Iterables.all(
instance.getRenewBillingCostTransitions().values(),
new Predicate<Money>(){
@Override
public boolean apply(Money money) {
return money.getCurrencyUnit().equals(instance.currency);
}}),
instance.getRenewBillingCostTransitions().values(), currencyCheck),
"Renew cost must be in the registry's currency");
checkArgument(
Iterables.all(
instance.eapFeeSchedule.toValueMap().values(), currencyCheck),
"All EAP fees must be in the registry's currency");
checkArgumentNotNull(
instance.pricingEngineClassName, "All registries must have a configured pricing engine");
instance.tldStrId = tldName;