This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 5e22e05b4340ad7dab271b8ff2f5b76968f8f24e Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Fri Jul 31 11:58:49 2020 +0700 [Refactoring] Migrate MDNReportTest to JUnit5 --- .../java/org/apache/james/mdn/MDNReportTest.java | 48 ++++++++++------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java b/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java index cc8ffaa..e7f0b3e 100644 --- a/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java +++ b/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java @@ -20,6 +20,7 @@ package org.apache.james.mdn; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Optional; @@ -36,38 +37,32 @@ import org.apache.james.mdn.fields.Text; import org.apache.james.mdn.modifier.DispositionModifier; import org.apache.james.mdn.sending.mode.DispositionSendingMode; import org.apache.james.mdn.type.DispositionType; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; import nl.jqno.equalsverifier.EqualsVerifier; -public class MDNReportTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class MDNReportTest { @Test - public void shouldMatchBeanContact() { + void shouldMatchBeanContact() { EqualsVerifier.forClass(MDNReport.class) .verify(); } @Test - public void generateMDNReportThrowOnNullDisposition() { - expectedException.expect(IllegalStateException.class); - - MDNReport.builder() - .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build()) - .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build()) - .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build()) - .build(); + void generateMDNReportThrowOnNullDisposition() { + assertThatThrownBy(() -> MDNReport.builder() + .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build()) + .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build()) + .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build()) + .build()) + .isInstanceOf(IllegalStateException.class); } @Test - public void generateMDNReportShouldThrowWhenMissingFinalField() { + void generateMDNReportShouldThrowWhenMissingFinalField() { Disposition disposition = Disposition.builder() .actionMode(DispositionActionMode.Automatic) .sendingMode(DispositionSendingMode.Automatic) @@ -76,18 +71,17 @@ public class MDNReportTest { .addModifier(DispositionModifier.Failed) .build(); - expectedException.expect(IllegalStateException.class); - - MDNReport.builder() - .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build()) - .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build()) - .originalMessageIdField(new OriginalMessageId("original_message_id")) - .dispositionField(disposition) - .build(); + assertThatThrownBy(() -> MDNReport.builder() + .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build()) + .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build()) + .originalMessageIdField(new OriginalMessageId("original_message_id")) + .dispositionField(disposition) + .build()) + .isInstanceOf(IllegalStateException.class); } @Test - public void shouldBuildWithMinimalSubset() { + void shouldBuildWithMinimalSubset() { Disposition disposition = Disposition.builder() .actionMode(DispositionActionMode.Automatic) .sendingMode(DispositionSendingMode.Automatic) @@ -107,7 +101,7 @@ public class MDNReportTest { } @Test - public void shouldBuildWithMaximalSubset() { + void shouldBuildWithMaximalSubset() { Disposition disposition = Disposition.builder() .actionMode(DispositionActionMode.Automatic) .sendingMode(DispositionSendingMode.Automatic) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org