mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Fix two nits in DotAppDomainInfo
1) By our convention, entity fields are package-private, not private. 2) Static analysis can't tell that checkArgumentNotNull prevents continuing with a null on the next line. Change the code to make a warning in eclipse go away. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121944468
This commit is contained in:
parent
b60ceda055
commit
758a4ac387
10 changed files with 88 additions and 99 deletions
|
@ -37,35 +37,35 @@ public class CreateAnchorTenantCommandTest
|
|||
public void testSuccess() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_suppliedPassword() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--superuser", "--password=foo",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant_password.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant_password.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleWordReason() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=\"anchor tenant test\"", "--contact=jd1234", "--domain_name=example.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant_multiple_word_reason.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant_multiple_word_reason.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_noReason() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--contact=jd1234", "--domain_name=example.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant_no_reason.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant_no_reason.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_feeStandard() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant_fee_standard.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant_fee_standard.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -78,7 +78,7 @@ public class CreateAnchorTenantCommandTest
|
|||
.build());
|
||||
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=premium.tld");
|
||||
verifySent("testdata/domain_create_anchor_tenant_fee_premium.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/domain_create_anchor_tenant_fee_premium.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CreateContactCommandTest
|
|||
"--fax=+1.7035555556",
|
||||
"--email=jdoe@example.com",
|
||||
"--password=2fooBAR");
|
||||
verifySent("testdata/contact_create_complete.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/contact_create_complete.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +53,7 @@ public class CreateContactCommandTest
|
|||
// Will never be the case, but tests that each field can be omitted.
|
||||
// Also tests the auto-gen password.
|
||||
runCommandForced("--client=NewRegistrar");
|
||||
verifySent("testdata/contact_create_minimal.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/contact_create_minimal.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,28 +25,28 @@ public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomain
|
|||
public void testSuccess() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
|
||||
"--reason=Test");
|
||||
verifySent("testdata/domain_delete.xml", false, false);
|
||||
new EppVerifier().verifySent("testdata/domain_delete.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleWordReason() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
|
||||
"--reason=\"Test test\"");
|
||||
verifySent("testdata/domain_delete_multiple_word_reason.xml", false, false);
|
||||
new EppVerifier().verifySent("testdata/domain_delete_multiple_word_reason.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_requestedByRegistrarFalse() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
|
||||
"--reason=Test", "--registrar_request=false");
|
||||
verifySent("testdata/domain_delete.xml", false, false);
|
||||
new EppVerifier().verifySent("testdata/domain_delete.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_requestedByRegistrarTrue() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
|
||||
"--reason=Test", "--registrar_request=true");
|
||||
verifySent("testdata/domain_delete_by_registrar.xml", false, false);
|
||||
new EppVerifier().verifySent("testdata/domain_delete_by_registrar.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -26,7 +26,7 @@ public class DomainApplicationInfoCommandTest
|
|||
public void testSuccess() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=landrush", "--id=123");
|
||||
verifySent("testdata/domain_info_landrush.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_info_landrush.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -34,7 +34,7 @@ public class DomainApplicationInfoCommandTest
|
|||
// Sunrush: phase=sunrise, subphase=landrush
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=sunrush", "--id=123");
|
||||
verifySent("testdata/domain_info_sunrush.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_info_sunrush.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -26,18 +24,15 @@ public class DomainCheckClaimsCommandTest extends EppToolCommandTestCase<DomainC
|
|||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld");
|
||||
verifySent("testdata/domain_check_claims.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check_claims.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleTlds() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check_claims.xml",
|
||||
"testdata/domain_check_claims_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_claims_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +42,7 @@ public class DomainCheckClaimsCommandTest extends EppToolCommandTestCase<DomainC
|
|||
"example.tld",
|
||||
"example2.tld",
|
||||
"example3.tld");
|
||||
verifySent("testdata/domain_check_claims_multiple.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check_claims_multiple.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,12 +53,9 @@ public class DomainCheckClaimsCommandTest extends EppToolCommandTestCase<DomainC
|
|||
"example2.tld",
|
||||
"example3.tld",
|
||||
"example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check_claims_multiple.xml",
|
||||
"testdata/domain_check_claims_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_claims_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -26,18 +24,15 @@ public class DomainCheckCommandTest extends EppToolCommandTestCase<DomainCheckCo
|
|||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld");
|
||||
verifySent("testdata/domain_check.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleTlds() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check.xml",
|
||||
"testdata/domain_check_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +42,7 @@ public class DomainCheckCommandTest extends EppToolCommandTestCase<DomainCheckCo
|
|||
"example.tld",
|
||||
"example2.tld",
|
||||
"example3.tld");
|
||||
verifySent("testdata/domain_check_multiple.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check_multiple.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,12 +53,9 @@ public class DomainCheckCommandTest extends EppToolCommandTestCase<DomainCheckCo
|
|||
"example2.tld",
|
||||
"example3.tld",
|
||||
"example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check_multiple.xml",
|
||||
"testdata/domain_check_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -26,18 +24,15 @@ public class DomainCheckFeeCommandTest extends EppToolCommandTestCase<DomainChec
|
|||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld");
|
||||
verifySent("testdata/domain_check_fee.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check_fee.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleTlds() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check_fee.xml",
|
||||
"testdata/domain_check_fee_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_fee_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +42,7 @@ public class DomainCheckFeeCommandTest extends EppToolCommandTestCase<DomainChec
|
|||
"example.tld",
|
||||
"example2.tld",
|
||||
"example3.tld");
|
||||
verifySent("testdata/domain_check_fee_multiple.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/domain_check_fee_multiple.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -58,12 +53,9 @@ public class DomainCheckFeeCommandTest extends EppToolCommandTestCase<DomainChec
|
|||
"example2.tld",
|
||||
"example3.tld",
|
||||
"example.tld2");
|
||||
verifySent(
|
||||
ImmutableList.of(
|
||||
eppVerifier().verifySent(
|
||||
"testdata/domain_check_fee_multiple.xml",
|
||||
"testdata/domain_check_fee_second_tld.xml"),
|
||||
false,
|
||||
false);
|
||||
"testdata/domain_check_fee_second_tld.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.createTlds;
|
|||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Arrays.binarySearch;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -64,29 +65,47 @@ public abstract class EppToolCommandTestCase<C extends EppToolCommand> extends C
|
|||
/** Subclasses can override this to perform additional initialization. */
|
||||
void initEppToolCommandTestCase() throws Exception {}
|
||||
|
||||
void verifySent(String fileToMatch, boolean dryRun, boolean superuser) throws Exception {
|
||||
ImmutableMap<String, ?> params = ImmutableMap.of(
|
||||
"clientIdentifier", "NewRegistrar",
|
||||
"superuser", superuser,
|
||||
"dryRun", dryRun);
|
||||
verify(connection)
|
||||
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), xml.capture());
|
||||
assertXmlEquals(readResourceUtf8(getClass(), fileToMatch), new String(xml.getValue(), UTF_8));
|
||||
/** Helper to get a new {@link EppVerifier} instance. */
|
||||
EppVerifier eppVerifier() {
|
||||
return new EppVerifier();
|
||||
}
|
||||
|
||||
void verifySent(List<String> filesToMatch, boolean dryRun, boolean superuser) throws Exception {
|
||||
/** Builder pattern class for verifying EPP commands sent to the server. */
|
||||
class EppVerifier {
|
||||
|
||||
String clientIdentifier = "NewRegistrar";
|
||||
boolean superuser = false;
|
||||
boolean dryRun = false;
|
||||
|
||||
EppVerifier setClientIdentifier(String clientIdentifier) {
|
||||
this.clientIdentifier = clientIdentifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
EppVerifier asSuperuser() {
|
||||
this.superuser = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
EppVerifier asDryRun() {
|
||||
this.dryRun = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
void verifySent(String... filesToMatch) throws Exception {
|
||||
ImmutableMap<String, ?> params = ImmutableMap.of(
|
||||
"clientIdentifier", "NewRegistrar",
|
||||
"clientIdentifier", clientIdentifier,
|
||||
"superuser", superuser,
|
||||
"dryRun", dryRun);
|
||||
verify(connection, times(filesToMatch.size()))
|
||||
verify(connection, times(filesToMatch.length))
|
||||
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), xml.capture());
|
||||
List<byte[]> capturedXml = xml.getAllValues();
|
||||
assertThat(filesToMatch).hasSize(capturedXml.size());
|
||||
assertThat(filesToMatch).hasLength(capturedXml.size());
|
||||
for (String fileToMatch : filesToMatch) {
|
||||
assertXmlEquals(
|
||||
readResourceUtf8(getClass(), fileToMatch),
|
||||
new String(capturedXml.get(filesToMatch.indexOf(fileToMatch)), UTF_8));
|
||||
new String(capturedXml.get(binarySearch(filesToMatch, fileToMatch)), UTF_8));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ package google.registry.tools;
|
|||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -40,19 +38,19 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
|
|||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--force", eppFile);
|
||||
verifySent("testdata/contact_create.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/contact_create.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_dryRun() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--dry_run", eppFile);
|
||||
verifySent("testdata/contact_create.xml", true, false);
|
||||
eppVerifier().asDryRun().verifySent("testdata/contact_create.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_withSuperuser() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "--superuser", "--force", eppFile);
|
||||
verifySent("testdata/contact_create.xml", false, true);
|
||||
eppVerifier().asSuperuser().verifySent("testdata/contact_create.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,7 +58,7 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
|
|||
inject.setStaticField(
|
||||
ExecuteEppCommand.class, "stdin", new ByteArrayInputStream(xmlInput.getBytes(UTF_8)));
|
||||
runCommand("--client=NewRegistrar", "--force");
|
||||
verifySent("testdata/contact_create.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/contact_create.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,10 +66,7 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
|
|||
String xmlInput2 = readResourceUtf8(ExecuteEppCommandTest.class, "testdata/domain_check.xml");
|
||||
String eppFile2 = writeToNamedTmpFile("eppFile2", xmlInput2);
|
||||
runCommand("--client=NewRegistrar", "--force", eppFile, eppFile2);
|
||||
verifySent(
|
||||
ImmutableList.of("testdata/contact_create.xml", "testdata/domain_check.xml"),
|
||||
false,
|
||||
false);
|
||||
eppVerifier().verifySent("testdata/contact_create.xml", "testdata/domain_check.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,35 +25,35 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
|||
public void testSuccess_applyOne() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||
verifySent("testdata/update_server_locks_apply_one.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/update_server_locks_apply_one.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleWordReason() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
|
||||
"--reason=\"Test this\"", "--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||
verifySent("testdata/update_server_locks_multiple_word_reason.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/update_server_locks_multiple_word_reason.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_removeOne() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--remove=serverRenewProhibited");
|
||||
verifySent("testdata/update_server_locks_remove_one.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/update_server_locks_remove_one.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_applyAll() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=all");
|
||||
verifySent("testdata/update_server_locks_apply_all.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/update_server_locks_apply_all.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_removeAll() throws Exception {
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--remove=all");
|
||||
verifySent("testdata/update_server_locks_remove_all.xml", false, false);
|
||||
eppVerifier().verifySent("testdata/update_server_locks_remove_all.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -123,5 +123,4 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
|||
runCommandForced("--client=NewRegistrar", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue