SoftLayerTemplateOptions extends TemplateOptions implements Cloneable { public TemplateOptions domainName(String domainName) { checkNotNull(domainName, "domainName was null"); checkArgument(InternetDomainName.from(domainName).hasPublicSuffix(), "domainName %s has no public suffix", domainName); this.domainName = domainName; return this; }  @Override SoftLayerTemplateOptions clone(); @Override void copyTo(TemplateOptions to); TemplateOptions domainName(String domainName); String getDomainName(); @Override SoftLayerTemplateOptions blockOnPort(int port, int seconds); @Override SoftLayerTemplateOptions inboundPorts(int... ports); @Override SoftLayerTemplateOptions authorizePublicKey(String publicKey); @Override SoftLayerTemplateOptions installPrivateKey(String privateKey); @Override SoftLayerTemplateOptions userMetadata(Map<String, String> userMetadata); @Override SoftLayerTemplateOptions userMetadata(String key, String value); static final SoftLayerTemplateOptions NONE; }
@Test public void testDomainName() { TemplateOptions options = new SoftLayerTemplateOptions().domainName("me.com"); assertEquals(options.as(SoftLayerTemplateOptions.class).getDomainName(), "me.com"); }
@Test public void testDomainNameNullHasDecentMessage() { try { new SoftLayerTemplateOptions().domainName(null); fail("should NPE"); } catch (NullPointerException e) { assertEquals(e.getMessage(), "domainName was null"); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDomainNameIsInvalidThrowsIllegalArgument() { new SoftLayerTemplateOptions().domainName("foo"); }