mirror of
https://github.com/google/nomulus.git
synced 2025-05-20 11:19:35 +02:00
Move thrown.expect() right before the throwing statement
aka regexing for fun and profit. This also makes sure that there are no statements after the throwing statement, since these would be dead code. There were a surprising number of places with assertions after the throw, and none of these are actually triggered in tests ever. When I found these, I replaced them with try/catch/rethrow which makes the assertions actually happen: before: // This is the ExceptionRule that checks EppException marshaling thrown.expect(FooException.class); doThrowingThing(); assertSomething(); // Dead code! after: try { doThrowingThing(); assertWithMessage("...").fail(); } catch (FooException e) { assertSomething(); // For EppExceptions: assertAboutEppExceptins().that(e).marshalsToXml(); } To make this work, I added EppExceptionSubject. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135793407
This commit is contained in:
parent
cb8320ff40
commit
f3a0b78145
62 changed files with 519 additions and 450 deletions
|
@ -150,48 +150,47 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
|||
|
||||
@Test
|
||||
public void testFailure_noSuchMessage() throws Exception {
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(
|
||||
MessageDoesNotExistException.class,
|
||||
String.format("(1-3-EXAMPLE-4-%d)", MESSAGE_ID));
|
||||
assertTransactionalFlow(true);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidId_wrongNumberOfComponents() throws Exception {
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
setEppInput("poll_ack_invalid_id.xml");
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidId_stringInsteadOfNumeric() throws Exception {
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
setEppInput("poll_ack_invalid_string_id.xml");
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidEppResourceClassId() throws Exception {
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
setEppInput("poll_ack_invalid_eppresource_id.xml");
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(InvalidMessageIdException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingId() throws Exception {
|
||||
thrown.expect(MissingMessageIdException.class);
|
||||
setEppInput("poll_ack_missing_id.xml");
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(MissingMessageIdException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_differentRegistrar() throws Exception {
|
||||
thrown.expect(NotAuthorizedToAckMessageException.class);
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setId(MESSAGE_ID)
|
||||
|
@ -201,14 +200,12 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
|||
.setParent(createHistoryEntryForEppResource(domain))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(NotAuthorizedToAckMessageException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_messageInFuture() throws Exception {
|
||||
thrown.expect(
|
||||
MessageDoesNotExistException.class,
|
||||
String.format("(1-3-EXAMPLE-4-%d)", MESSAGE_ID));
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setId(MESSAGE_ID)
|
||||
|
@ -218,6 +215,9 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
|||
.setParent(createHistoryEntryForEppResource(domain))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
thrown.expect(
|
||||
MessageDoesNotExistException.class,
|
||||
String.format("(1-3-EXAMPLE-4-%d)", MESSAGE_ID));
|
||||
runFlow();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue