You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rc...@apache.org on 2020/08/10 02:47:41 UTC
[james-project] 11/23: [Refactoring] Migrate ExtensionFieldTest to
JUnit5
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 c34a15172944887f82325f33dfaf8e8ae7fb18d4
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Jul 31 14:11:28 2020 +0700
[Refactoring] Migrate ExtensionFieldTest to JUnit5
---
.../james/mdn/fields/ExtensionFieldTest.java | 52 ++++++++++++----------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/mdn/src/test/java/org/apache/james/mdn/fields/ExtensionFieldTest.java b/mdn/src/test/java/org/apache/james/mdn/fields/ExtensionFieldTest.java
index d487d5f..176eb60d 100644
--- a/mdn/src/test/java/org/apache/james/mdn/fields/ExtensionFieldTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/fields/ExtensionFieldTest.java
@@ -20,49 +20,53 @@
package org.apache.james.mdn.fields;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
-public class ExtensionFieldTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
+class ExtensionFieldTest {
@Test
- public void shouldMatchBeanContract() throws Exception {
+ void shouldMatchBeanContract() {
EqualsVerifier.forClass(ExtensionField.class)
.verify();
}
@Test
- public void shouldThrowOnNullFieldName() {
- expectedException.expect(NullPointerException.class);
-
- ExtensionField.builder().fieldName(null).rawValue("rawValue").build();
+ void shouldThrowOnNullFieldName() {
+ assertThatThrownBy(() -> ExtensionField.builder()
+ .fieldName(null)
+ .rawValue("rawValue")
+ .build())
+ .isInstanceOf(NullPointerException.class);
}
@Test
- public void shouldThrowOnNullRawValue() {
- expectedException.expect(NullPointerException.class);
-
- ExtensionField.builder().fieldName("name").rawValue(null).build();
+ void shouldThrowOnNullRawValue() {
+ assertThatThrownBy(() -> ExtensionField.builder()
+ .fieldName("name")
+ .rawValue(null)
+ .build())
+ .isInstanceOf(NullPointerException.class);
}
@Test
- public void shouldThrowOnMultilineName() {
- expectedException.expect(IllegalStateException.class);
-
- ExtensionField.builder().fieldName("name\nmultiline").rawValue("rawValue").build();
+ void shouldThrowOnMultilineName() {
+ assertThatThrownBy(() -> ExtensionField.builder()
+ .fieldName("name\nmultiline")
+ .rawValue("rawValue")
+ .build())
+ .isInstanceOf(IllegalStateException.class);
}
@Test
- public void formattedValueShouldDisplayNameAndRawValue() {
- assertThat(ExtensionField.builder().fieldName("name").rawValue("rawValue").build()
- .formattedValue())
+ void formattedValueShouldDisplayNameAndRawValue() {
+ assertThat(ExtensionField.builder()
+ .fieldName("name")
+ .rawValue("rawValue")
+ .build()
+ .formattedValue())
.isEqualTo("name: rawValue");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org