Add assertTldsExist(Iterable<String>) to check multiple TLDs at once

This is better than calling assertTldExists() inside a for loop because you can throw a single exception reporting all bad TLDs at once rather than only getting as far as the first failure.  And then it's also a one-liner instead of 3 lines.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152412876
This commit is contained in:
nickfelt 2017-04-06 12:28:15 -07:00 committed by Ben McIlwain
parent 783033c261
commit 5081d780dc
8 changed files with 31 additions and 28 deletions

View file

@ -16,7 +16,7 @@ package google.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.EppResourceUtils.queryNotDeleted;
import static google.registry.model.registry.Registries.assertTldExists;
import static google.registry.model.registry.Registries.assertTldsExist;
import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.POST;
@ -68,9 +68,7 @@ public final class ListDomainsAction extends ListObjectsAction<DomainResource> {
@Override
public ImmutableSet<DomainResource> loadObjects() {
checkArgument(!tlds.isEmpty(), "Must specify TLDs to query");
for (String tld : tlds) {
assertTldExists(tld);
}
assertTldsExist(tlds);
ImmutableSortedSet.Builder<DomainResource> builder =
new ImmutableSortedSet.Builder<DomainResource>(COMPARATOR);
for (List<String> batch : Lists.partition(tlds.asList(), MAX_NUM_SUBQUERIES)) {