Require that DNS writer be set on Registry entities

We ran into a bunch of prober deployment issues this past week when
attempting to spin up a new cluster because the newly created prober
TLDs had null values for the dnsWriter field. Given that VoidDnsWriter
exists, we can require that dnsWriter always be set, and have people
use that if DNS publishing is not required.

Also cleans up a bunch of related inconsistent exception messages and
tests not verifying said exception messages properly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154325830
This commit is contained in:
mcilwain 2017-04-26 11:58:09 -07:00 committed by Ben McIlwain
parent d7da112c19
commit d30f9411d8
11 changed files with 332 additions and 115 deletions

View file

@ -20,6 +20,7 @@ java_library(
] + glob(["**/testdata/*.xml"]),
deps = [
"//java/google/registry/config",
"//java/google/registry/dns/writer",
"//java/google/registry/flows",
"//java/google/registry/model",
"//java/google/registry/monitoring/metrics/contrib",

View file

@ -345,13 +345,13 @@ public class RegistryTest extends EntityTestCase {
@Test
public void testFailure_tldNeverSet() {
thrown.expect(IllegalArgumentException.class, "No registry TLD specified.");
thrown.expect(IllegalArgumentException.class, "No registry TLD specified");
new Registry.Builder().build();
}
@Test
public void testFailure_setTldStr_null() {
thrown.expect(IllegalArgumentException.class, "TLD must not be null.");
thrown.expect(IllegalArgumentException.class, "TLD must not be null");
new Registry.Builder().setTldStr(null);
}
@ -405,13 +405,13 @@ public class RegistryTest extends EntityTestCase {
@Test
public void testFailure_negativeCreateBillingCost() {
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative");
thrown.expect(IllegalArgumentException.class, "createBillingCost cannot be negative");
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42));
}
@Test
public void testFailure_negativeRestoreBillingCost() {
thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative");
thrown.expect(IllegalArgumentException.class, "restoreBillingCost cannot be negative");
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42));
}

View file

@ -38,6 +38,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.dns.writer.VoidDnsWriter;
import google.registry.model.pricing.StaticPremiumListPricingEngine;
import google.registry.model.registry.Registry;
import google.registry.model.registry.label.PremiumList.PremiumListEntry;
@ -95,6 +96,7 @@ public class PremiumListUtilsTest {
new Registry.Builder()
.setTldStr("ghost")
.setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME)
.setDnsWriter(VoidDnsWriter.NAME)
.build());
assertThat(Registry.get("ghost").getPremiumList()).isNull();
assertThat(getPremiumPrice("blah", Registry.get("ghost"))).isAbsent();