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 bt...@apache.org on 2019/11/28 02:12:22 UTC
[james-project] 05/23: JAMES-2989 Rework toString for MimePathImpl
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 95cb9dcf463e78782a6fd07d118bfb60d1ed8fc7
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Nov 25 11:22:57 2019 +0700
JAMES-2989 Rework toString for MimePathImpl
---
.../apache/james/mailbox/model/MimePathImpl.java | 17 ++++------------
.../james/mailbox/model/MimePathImplTest.java | 23 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MimePathImpl.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MimePathImpl.java
index 66c5fcf..0548429 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MimePathImpl.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MimePathImpl.java
@@ -28,7 +28,6 @@ public class MimePathImpl implements MessageResult.MimePath {
private final int[] positions;
public MimePathImpl(int[] positions) {
- super();
this.positions = positions;
}
@@ -52,17 +51,9 @@ public class MimePathImpl implements MessageResult.MimePath {
return Arrays.hashCode(positions);
}
- public String toString() {
- final StringBuilder builder = new StringBuilder("MIMEPath:");
- boolean isFirst = false;
- for (int position : positions) {
- if (isFirst) {
- isFirst = false;
- } else {
- builder.append('.');
- }
- builder.append(position);
- }
- return builder.toString();
+ @Override
+ public final String toString() {
+ return "MIMEPath:"
+ + Arrays.toString(positions);
}
}
\ No newline at end of file
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MimePathImplTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MimePathImplTest.java
index 0b1caf9..ff649d2 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MimePathImplTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MimePathImplTest.java
@@ -19,6 +19,8 @@
package org.apache.james.mailbox.model;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -29,4 +31,25 @@ class MimePathImplTest {
EqualsVerifier.forClass(MimePathImpl.class)
.verify();
}
+
+ @Test
+ void toStringWhenEmpty() {
+ int[] empty = {};
+ assertThat(new MimePathImpl(empty).toString())
+ .isEqualTo("MIMEPath:[]");
+ }
+
+ @Test
+ void toStringWhenSingle() {
+ int[] single = {1};
+ assertThat(new MimePathImpl(single).toString())
+ .isEqualTo("MIMEPath:[1]");
+ }
+
+ @Test
+ void toStringWhenMany() {
+ int[] many = {1, 2, 3};
+ assertThat(new MimePathImpl(many).toString())
+ .isEqualTo("MIMEPath:[1, 2, 3]");
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org