james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [01/12] james-project git commit: JAMES-2543 change stupid usage of assertTrue and assertFalse to assertEquals and assertNotNull
Date Tue, 11 Sep 2018 09:06:37 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 1d073e4c0 -> bf95a1474


JAMES-2543 change stupid usage of assertTrue and assertFalse to assertEquals and assertNotNull


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c6318377
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c6318377
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c6318377

Branch: refs/heads/master
Commit: c6318377b63cf9723ba48783c2e0642d2dbb9f06
Parents: 1d073e4
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Thu Sep 6 17:21:30 2018 +0200
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Mon Sep 10 21:25:24 2018 +0200

----------------------------------------------------------------------
 .../org/apache/james/core/MailAddressTest.java     | 17 ++++++++---------
 .../mailbox/model/MailboxAnnotationKeyTest.java    |  2 +-
 .../HBaseMailboxSessionMapperFactoryTest.java      |  6 +++---
 .../mailbox/hbase/mail/HBaseMailboxMapperTest.java |  2 +-
 .../store/MailboxMessageResultImplTest.java        |  6 +++---
 .../protocols/pop3/POP3StartTlsResponseTest.java   |  4 ++--
 .../protocols/smtp/SMTPStartTlsResponseTest.java   |  4 ++--
 .../lib/AbstractStateMailetProcessorTest.java      |  2 +-
 8 files changed, 21 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/core/src/test/java/org/apache/james/core/MailAddressTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/core/MailAddressTest.java b/core/src/test/java/org/apache/james/core/MailAddressTest.java
index cf60ddd..e9e1e67 100644
--- a/core/src/test/java/org/apache/james/core/MailAddressTest.java
+++ b/core/src/test/java/org/apache/james/core/MailAddressTest.java
@@ -89,7 +89,7 @@ public class MailAddressTest {
 
         MailAddress a = new MailAddress(GOOD_ADDRESS);
         MailAddress b = new MailAddress(GOOD_ADDRESS);
-        assertThat(a.hashCode() == b.hashCode()).describedAs(a.hashCode() + " != " + b.hashCode()).isTrue();
+        assertThat(a.hashCode()).isEqualTo(b.hashCode());
     }
 
     /**
@@ -101,7 +101,7 @@ public class MailAddressTest {
     public void testMailAddressString() throws AddressException {
 
         MailAddress a = new MailAddress(GOOD_ADDRESS);
-        assertThat(GOOD_ADDRESS.equals(a.toString())).isTrue();
+        assertThat(GOOD_ADDRESS).isEqualTo(a.toString());
 
         for (String goodAddress : GOOD_ADDRESSES) {
             try {
@@ -158,7 +158,7 @@ public class MailAddressTest {
 
         try {
             MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
-            assertThat(a.getDomain().equals(GOOD_DOMAIN)).describedAs(a.getDomain() + " !=
" + GOOD_DOMAIN).isTrue();
+            assertThat(a.getDomain()).isEqualTo(GOOD_DOMAIN);
         } catch (AddressException e) {
             System.out.println("AddressException" + e.getMessage());
             assertThat(false).describedAs(e.getMessage()).isTrue();
@@ -173,7 +173,7 @@ public class MailAddressTest {
 
         try {
             MailAddress a = new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART));
-            assertThat(a.getLocalPart().equals(GOOD_LOCAL_PART)).describedAs(GOOD_LOCAL_PART
+ " != " + a.getLocalPart()).isTrue();
+            assertThat(a.getLocalPart()).isEqualTo(GOOD_LOCAL_PART);
         } catch (AddressException e) {
             System.out.println("AddressException" + e.getMessage());
             assertThat(false).describedAs(e.getMessage()).isTrue();
@@ -188,7 +188,7 @@ public class MailAddressTest {
 
         try {
             MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
-            assertThat(a.toString().equals(GOOD_ADDRESS)).describedAs(a.toString() + " !=
" + GOOD_ADDRESS).isTrue();
+            assertThat(a.toString()).isEqualTo(GOOD_ADDRESS);
         } catch (AddressException e) {
             System.out.println("AddressException" + e.getMessage());
             assertThat(false).describedAs(e.getMessage()).isTrue();
@@ -204,8 +204,8 @@ public class MailAddressTest {
         try {
             InternetAddress b = new InternetAddress(GOOD_ADDRESS);
             MailAddress a = new MailAddress(b);
-            assertThat(a.toInternetAddress().equals(b)).isTrue();
-            assertThat(a.toString().equals(GOOD_ADDRESS)).describedAs(a.toString() + " !=
" + GOOD_ADDRESS).isTrue();
+            assertThat(a.toInternetAddress()).isEqualTo(b);
+            assertThat(a.toString()).isEqualTo(GOOD_ADDRESS);
         } catch (AddressException e) {
             System.out.println("AddressException" + e.getMessage());
             assertThat(false).describedAs(e.getMessage()).isTrue();
@@ -223,8 +223,7 @@ public class MailAddressTest {
         MailAddress a = new MailAddress(GOOD_ADDRESS);
         MailAddress b = new MailAddress(GOOD_ADDRESS);
 
-        assertThat(a.equals(b)).describedAs(a.toString() + " != " + b.toString()).isTrue();
-        assertThat(a.equals(null)).describedAs(a.toString() + " != " + null).isFalse();
+        assertThat(a).isNotNull().isEqualTo(b);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAnnotationKeyTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAnnotationKeyTest.java
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAnnotationKeyTest.java
index a2e8b6b..4b5986e 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAnnotationKeyTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAnnotationKeyTest.java
@@ -80,7 +80,7 @@ public class MailboxAnnotationKeyTest {
         MailboxAnnotationKey annotationKey = new MailboxAnnotationKey("/private/comment");
         MailboxAnnotationKey anotherAnnotationKey = new MailboxAnnotationKey("/PRIVATE/COMMENT");
 
-        assertThat(annotationKey.equals(anotherAnnotationKey)).isTrue();
+        assertThat(annotationKey).isEqualTo(anotherAnnotationKey);
     }
 
     @Test(expected = IllegalArgumentException.class)

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
index a387445..f040d50 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
@@ -91,7 +91,7 @@ public class HBaseMailboxSessionMapperFactoryTest {
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf,
null, null, messageIdFactory);
         MessageMapper messageMapper = instance.createMessageMapper(session);
         assertThat(messageMapper).isNotNull();
-        assertThat(messageMapper instanceof MessageMapper).isTrue();
+        assertThat(messageMapper).isInstanceOf(MessageMapper.class);
     }
 
     /**
@@ -106,7 +106,7 @@ public class HBaseMailboxSessionMapperFactoryTest {
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf,
null, null, messageIdFactory);
         MailboxMapper mailboxMapper = instance.createMailboxMapper(session);
         assertThat(mailboxMapper).isNotNull();
-        assertThat(mailboxMapper instanceof MailboxMapper).isTrue();
+        assertThat(mailboxMapper).isInstanceOf(MailboxMapper.class);
     }
 
     /**
@@ -121,7 +121,7 @@ public class HBaseMailboxSessionMapperFactoryTest {
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf,
null, null, messageIdFactory);
         SubscriptionMapper subscriptionMapper = instance.createSubscriptionMapper(session);
         assertThat(subscriptionMapper).isNotNull();
-        assertThat(subscriptionMapper instanceof SubscriptionMapper).isTrue();
+        assertThat(subscriptionMapper).isInstanceOf(SubscriptionMapper.class);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
index 01349d2..4519e53 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
@@ -314,7 +314,7 @@ public class HBaseMailboxMapperTest {
                 bout.write(b);
             }
             String s = bout.toString();
-            assertThat(original.equals(s)).isTrue();
+            assertThat(original).isEqualTo(s);
         } finally {
             in.close();
             out.close();

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
index bb4a489..44637d7 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
@@ -62,7 +62,7 @@ public class MailboxMessageResultImplTest {
 
     @Test
     public void testEqualsNull() throws Exception {
-        assertThat(msgResultA.equals(null)).isFalse();
+        assertThat(msgResultA).isNotNull();
     }
 
 
@@ -124,8 +124,8 @@ public class MailboxMessageResultImplTest {
 
     @Test
     public void testNotEqualDiffValue() throws Exception {
-        assertThat(msgResultA.equals(msgResultC)).isFalse();
-        assertThat(msgResultC.equals(msgResultA)).isFalse();
+        assertThat(msgResultA).isNotEqualTo(msgResultC);
+        assertThat(msgResultC).isNotEqualTo(msgResultA);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
----------------------------------------------------------------------
diff --git a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
index 50a7801..20b2449 100644
--- a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
+++ b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
@@ -33,7 +33,7 @@ public class POP3StartTlsResponseTest {
     @Test
     public void testImmutable() {
         POP3StartTlsResponse response = new POP3StartTlsResponse(POP3Response.OK_RESPONSE);
-        assertThat(response instanceof StartTlsResponse).isTrue();
-        assertThat(response.immutable() instanceof StartTlsResponse).isTrue();
+        assertThat(response).isInstanceOf(StartTlsResponse.class);
+        assertThat(response.immutable()).isInstanceOf(StartTlsResponse.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
index a0a881a..112a338 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
@@ -32,7 +32,7 @@ public class SMTPStartTlsResponseTest {
     @Test
     public void testImmutable() {
         SMTPStartTlsResponse response = new SMTPStartTlsResponse("554", "Reject");
-        assertThat(response instanceof StartTlsResponse).isTrue();
-        assertThat(response.immutable() instanceof StartTlsResponse).isTrue();
+        assertThat(response).isInstanceOf(StartTlsResponse.class);
+        assertThat(response.immutable()).isInstanceOf(StartTlsResponse.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c6318377/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
index 9464bea..10d8e42 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
@@ -268,7 +268,7 @@ public abstract class AbstractStateMailetProcessorTest {
             public void afterMailet(Mailet m, String mailName, String state, long processTime,
Exception e) {
                 if (ExceptionThrowingMailet.class.equals(m.getClass())) {
                     // the name should be not the same as we have a part match
-                    assertThat(mail.getName().equals(mailName)).isFalse();
+                    assertThat(mail.getName()).isNotEqualTo(mailName);
                     assertThat(e).isNotNull();
                     assertEquals(Mail.ERROR, state);
                     latch.countDown();


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


Mime
View raw message