mirror of
https://github.com/google/nomulus
synced 2026-09-18 22:14:23 +00:00
Refactor EppToolVerifier to accept chaining verify commands
We're doing this to allow several new tests:
- xml files (that exist today)
- xml files with substitutions
- xml content (maybe? Currently private. Caching the files seems more readable)
- no data at all
Instead of having only one interface
eppToolVerifier.verifySent("file1.xml", "file2.xml");
we're refactoring to allow:
eppToolVerifier
.verifySent("file1.xml")
.verifySentAny() // we don't care about this epps
.verifySent("file2.xml", substitutions)
.verifyNoMoreSent();
In this case we're checking that "exactly 3 EPPs were sent, where the 1st one has content from file1.xml, and the 3rd one has the content from file2.xml, after the given substitutions were applied"
This also updates EppToolCommandTestCase to have only one EppToolVerifier, and
always finish by checking verifyNoMoreSent, meaning that in every test - all
sent epps must be accounted for (verified or skiped)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177353887
This commit is contained in:
@@ -41,28 +41,31 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.tools.ServerSideCommand.Connection;
|
||||
import google.registry.tools.server.ToolsTestData;
|
||||
import java.io.IOException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Unit tests for {@link AllocateDomainCommand}. */
|
||||
public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCommand> {
|
||||
|
||||
@Mock
|
||||
Connection connection;
|
||||
private EppToolVerifier eppVerifier;
|
||||
|
||||
@Before
|
||||
public void init() throws IOException {
|
||||
command.setConnection(connection);
|
||||
eppVerifier = EppToolVerifier.create(command).expectClientId("TheRegistrar").expectSuperuser();
|
||||
createTld("tld", QUIET_PERIOD);
|
||||
createApplication("example-one.tld", "domain_create_sunrush.xml", "1-TLD");
|
||||
createApplication("example-two.tld", "domain_create_sunrush2.xml", "2-TLD");
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
eppVerifier.verifyNoMoreSent();
|
||||
}
|
||||
|
||||
private void createApplication(String name, String xmlFile, String repoId) throws IOException {
|
||||
DomainApplication application =
|
||||
persistResource(newDomainApplication(name)
|
||||
@@ -105,30 +108,25 @@ public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCom
|
||||
.build());
|
||||
}
|
||||
|
||||
private EppToolVerifier eppVerifier() {
|
||||
return new EppToolVerifier()
|
||||
.withConnection(connection)
|
||||
.withClientId("TheRegistrar")
|
||||
.asSuperuser();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
runCommand("--ids=1-TLD", "--force", "--superuser");
|
||||
// NB: These commands are sent as the sponsoring registrar, in this case "TheRegistrar".
|
||||
eppVerifier().verifySent("allocate_domain.xml");
|
||||
eppVerifier.verifySent("allocate_domain.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multiple() throws Exception {
|
||||
runCommand("--ids=1-TLD,2-TLD", "--force", "--superuser");
|
||||
eppVerifier().verifySent("allocate_domain.xml", "allocate_domain2.xml");
|
||||
eppVerifier
|
||||
.verifySent("allocate_domain.xml")
|
||||
.verifySent("allocate_domain2.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_dryRun() throws Exception {
|
||||
runCommand("--ids=1-TLD", "--dry_run", "--superuser");
|
||||
eppVerifier().asDryRun().verifySent("allocate_domain.xml");
|
||||
eppVerifier.expectDryRun().verifySent("allocate_domain.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user