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/07/28 03:20:34 UTC

[james-project] 06/25: [Refactoring] Migrate StringUtilsTest to Junit 5

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 8bea2b450d7809d3f756319746404266493d17f3
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Jul 24 14:57:05 2020 +0700

    [Refactoring] Migrate StringUtilsTest to Junit 5
---
 .../org/apache/mailet/base/StringUtilsTest.java    | 31 +++++++++++-----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/mailet/base/src/test/java/org/apache/mailet/base/StringUtilsTest.java b/mailet/base/src/test/java/org/apache/mailet/base/StringUtilsTest.java
index 01636ae..4934457 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/StringUtilsTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/StringUtilsTest.java
@@ -19,45 +19,44 @@
 package org.apache.mailet.base;
 
 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 com.google.common.collect.ImmutableList;
 
-public class StringUtilsTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class StringUtilsTest {
 
     @Test
-    public void listToStringShouldThrowWhenListIsNull() {
-        expectedException.expect(NullPointerException.class);
-        StringUtils.listToString(null);
+    void listToStringShouldThrowWhenListIsNull() {
+        assertThatThrownBy(() -> StringUtils.listToString(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void listToStringShouldReturnOnlyBracketsWhenListIsEmpty() {
+    void listToStringShouldReturnOnlyBracketsWhenListIsEmpty() {
         String listToString = StringUtils.listToString(ImmutableList.<String>of());
+
         assertThat(listToString).isEqualTo("[]");
     }
 
     @Test
-    public void listToStringShouldReturnOneElementWhenListContainsOneElement() {
+    void listToStringShouldReturnOneElementWhenListContainsOneElement() {
         String listToString = StringUtils.listToString(ImmutableList.of("first"));
+
         assertThat(listToString).isEqualTo("[first]");
     }
 
     @Test
-    public void listToStringShouldReturnSeparatedElementsWhenListContainsMultipleElements() {
+    void listToStringShouldReturnSeparatedElementsWhenListContainsMultipleElements() {
         String listToString = StringUtils.listToString(ImmutableList.of("first", "second", "fourth"));
+
         assertThat(listToString).isEqualTo("[first, second, fourth]");
     }
 
     @Test
-    public void listToStringShouldThrowWhenListContainsANullElement() {
-        expectedException.expect(NullPointerException.class);
-        StringUtils.listToString(ImmutableList.of("first", null, "fourth"));
+    void listToStringShouldThrowWhenListContainsANullElement() {
+        assertThatThrownBy(() -> StringUtils.listToString(ImmutableList.of("first", null, "fourth")))
+            .isInstanceOf(NullPointerException.class);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org