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 2017/08/16 09:45:38 UTC

[05/18] james-project git commit: JAMES-2107 Run IntelliJ inspection: "Convert to lambas"

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/BroadcastDelegatingMailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/BroadcastDelegatingMailboxListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/BroadcastDelegatingMailboxListenerTest.java
index d61bf63..547ab39 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/BroadcastDelegatingMailboxListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/BroadcastDelegatingMailboxListenerTest.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.store.event.distributed;
 
 import static org.assertj.core.api.Assertions.assertThat;
-
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -37,8 +36,6 @@ import org.apache.james.mailbox.store.publisher.Topic;
 import org.apache.james.mailbox.util.EventCollector;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 public class BroadcastDelegatingMailboxListenerTest {
 
@@ -72,13 +69,11 @@ public class BroadcastDelegatingMailboxListenerTest {
 
     @Test
     public void eventWithNoRegisteredListenersShouldWork() throws Exception {
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedEventSerializer.serializeEvent(event))
+            .thenReturn(BYTES);
+
         broadcastDelegatingMailboxListener.event(event);
+
         verify(mockedEventSerializer).serializeEvent(event);
         verify(mockedPublisher).publish(TOPIC, BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
@@ -87,13 +82,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void eventWithMailboxRegisteredListenerShouldWork() throws Exception {
         broadcastDelegatingMailboxListener.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
+
         broadcastDelegatingMailboxListener.event(event);
+
         assertThat(mailboxEventCollector.getEvents()).isEmpty();
         verify(mockedEventSerializer).serializeEvent(event);
         verify(mockedPublisher).publish(TOPIC, BYTES);
@@ -103,14 +95,11 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void eventWithEachRegisteredListenerShouldWork() throws Exception {
         broadcastDelegatingMailboxListener.addGlobalListener(eachEventCollector, mailboxSession);
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
+
         broadcastDelegatingMailboxListener.event(event);
         assertThat(eachEventCollector.getEvents()).isEmpty();
+
         verify(mockedEventSerializer).serializeEvent(event);
         verify(mockedPublisher).publish(TOPIC, BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
@@ -119,13 +108,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void eventWithOnceRegisteredListenerShouldWork() throws Exception {
         broadcastDelegatingMailboxListener.addGlobalListener(onceEventCollector, mailboxSession);
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
+
         broadcastDelegatingMailboxListener.event(event);
+
         assertThat(onceEventCollector.getEvents()).containsOnly(event);
         verify(mockedEventSerializer).serializeEvent(event);
         verify(mockedPublisher).publish(TOPIC, BYTES);
@@ -134,13 +120,10 @@ public class BroadcastDelegatingMailboxListenerTest {
 
     @Test
     public void receiveSerializedEventShouldWorkWithNoRegisteredListeners() throws Exception {
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
     }
@@ -148,13 +131,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void receiveSerializedEventShouldWorkWithMailboxRegisteredListeners() throws Exception {
         broadcastDelegatingMailboxListener.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
@@ -163,13 +143,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void receiveSerializedEventShouldWorkWithEachRegisteredListeners() throws Exception {
         broadcastDelegatingMailboxListener.addGlobalListener(eachEventCollector, mailboxSession);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
         assertThat(eachEventCollector.getEvents()).containsOnly(event);
@@ -178,13 +155,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     @Test
     public void receiveSerializedEventShouldWorkWithOnceRegisteredListeners() throws Exception {
         broadcastDelegatingMailboxListener.addGlobalListener(onceEventCollector, mailboxSession);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
         assertThat(onceEventCollector.getEvents()).isEmpty();
@@ -194,13 +168,10 @@ public class BroadcastDelegatingMailboxListenerTest {
     public void deletionDistantEventsShouldBeWellHandled() throws Exception {
         final MailboxListener.Event event = new MailboxListener.MailboxDeletion(mailboxSession, MAILBOX_PATH);
         broadcastDelegatingMailboxListener.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
@@ -214,14 +185,11 @@ public class BroadcastDelegatingMailboxListenerTest {
                 return MAILBOX_PATH_NEW;
             }
         };
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
+
         broadcastDelegatingMailboxListener.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         broadcastDelegatingMailboxListener.receiveSerializedEvent(BYTES);
+
         verify(mockedEventSerializer).deSerializeEvent(BYTES);
         verifyNoMoreInteractions(mockedEventSerializer, mockedPublisher);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/DistantMailboxPathRegisterTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/DistantMailboxPathRegisterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/DistantMailboxPathRegisterTest.java
index 2227a79..896e9c3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/DistantMailboxPathRegisterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/DistantMailboxPathRegisterTest.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.store.event.distributed;
 
 import static org.assertj.core.api.Assertions.assertThat;
-
 import static org.assertj.core.api.Assertions.fail;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
@@ -29,20 +28,20 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-import com.google.common.collect.Sets;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.publisher.Topic;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.Sets;
+
 public class DistantMailboxPathRegisterTest {
 
     private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", "user", "name");
@@ -66,13 +65,8 @@ public class DistantMailboxPathRegisterTest {
 
     @Test
     public void getTopicsShouldWork() {
-        final HashSet<String> result = Sets.newHashSet(TOPIC);
-        when(mockedMapper.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<String>>() {
-            @Override
-            public Set<String> answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return result;
-            }
-        });
+        final Set<Topic> result = Sets.newHashSet(new Topic(TOPIC));
+        when(mockedMapper.getTopics(MAILBOX_PATH)).thenReturn(result);
         assertThat(register.getTopics(MAILBOX_PATH)).isEqualTo(result);
     }
 
@@ -255,18 +249,15 @@ public class DistantMailboxPathRegisterTest {
         final long increments = 100;
         ExecutorService executorService = Executors.newFixedThreadPool(numTask);
         for (int i = 0; i < numTask; i++) {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int j = 0;
-                        while (j < increments) {
-                            register.register(MAILBOX_PATH);
-                            j++;
-                        }
-                    } catch (Exception e) {
-                        fail("Exception caught in thread", e);
+            executorService.submit(() -> {
+                try {
+                    int j = 0;
+                    while (j < increments) {
+                        register.register(MAILBOX_PATH);
+                        j++;
                     }
+                } catch (Exception e) {
+                    fail("Exception caught in thread", e);
                 }
             });
         }
@@ -284,18 +275,15 @@ public class DistantMailboxPathRegisterTest {
         }
         ExecutorService executorService = Executors.newFixedThreadPool(numTask);
         for (int i = 0; i < numTask; i++) {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int j = 0;
-                        while (j < increments) {
-                            register.unregister(MAILBOX_PATH);
-                            j++;
-                        }
-                    } catch (Exception e) {
-                        fail("Exception caught in thread", e);
+            executorService.submit(() -> {
+                try {
+                    int j = 0;
+                    while (j < increments) {
+                        register.unregister(MAILBOX_PATH);
+                        j++;
                     }
+                } catch (Exception e) {
+                    fail("Exception caught in thread", e);
                 }
             });
         }
@@ -313,32 +301,26 @@ public class DistantMailboxPathRegisterTest {
         }
         ExecutorService executorService = Executors.newFixedThreadPool(2* numTask);
         for (int i = 0; i < numTask; i++) {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int j = 0;
-                        while (j < increments) {
-                            register.register(MAILBOX_PATH);
-                            j++;
-                        }
-                    } catch (Exception e) {
-                        fail("Exception caught in thread", e);
+            executorService.submit(() -> {
+                try {
+                    int j = 0;
+                    while (j < increments) {
+                        register.register(MAILBOX_PATH);
+                        j++;
                     }
+                } catch (Exception e) {
+                    fail("Exception caught in thread", e);
                 }
             });
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        int j = 0;
-                        while (j < increments) {
-                            register.unregister(MAILBOX_PATH);
-                            j++;
-                        }
-                    } catch (Exception e) {
-                        fail("Exception caught in thread", e);
+            executorService.submit(() -> {
+                try {
+                    int j = 0;
+                    while (j < increments) {
+                        register.unregister(MAILBOX_PATH);
+                        j++;
                     }
+                } catch (Exception e) {
+                    fail("Exception caught in thread", e);
                 }
             });
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/RegisteredDelegatingMailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/RegisteredDelegatingMailboxListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/RegisteredDelegatingMailboxListenerTest.java
index 438bc97..c01eda6 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/RegisteredDelegatingMailboxListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/distributed/RegisteredDelegatingMailboxListenerTest.java
@@ -20,14 +20,12 @@
 package org.apache.james.mailbox.store.event.distributed;
 
 import static org.assertj.core.api.Assertions.assertThat;
-
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-import com.google.common.collect.Sets;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -40,10 +38,8 @@ import org.apache.james.mailbox.store.publisher.Topic;
 import org.apache.james.mailbox.util.EventCollector;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
-import java.util.Set;
+import com.google.common.collect.Sets;
 
 public class RegisteredDelegatingMailboxListenerTest {
 
@@ -82,18 +78,8 @@ public class RegisteredDelegatingMailboxListenerTest {
     public void eventShouldBeLocallyDeliveredIfThereIsNoOtherRegisteredServers() throws Exception {
         testee.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         verify(mockedMailboxPathRegister).register(MAILBOX_PATH);
-        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<Topic>>() {
-            @Override
-            public Set<Topic> answer(InvocationOnMock invocation) throws Throwable {
-                return Sets.newHashSet(TOPIC);
-            }
-        });
-        when(mockedMailboxPathRegister.getLocalTopic()).thenAnswer(new Answer<Topic>() {
-            @Override
-            public Topic answer(InvocationOnMock invocation) throws Throwable {
-                return TOPIC;
-            }
-        });
+        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenReturn(Sets.newHashSet(TOPIC));
+        when(mockedMailboxPathRegister.getLocalTopic()).thenReturn(TOPIC);
         testee.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister, times(2)).getLocalTopic();
@@ -107,24 +93,9 @@ public class RegisteredDelegatingMailboxListenerTest {
     public void eventShouldBeRemotelySent() throws Exception {
         testee.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         verify(mockedMailboxPathRegister).register(MAILBOX_PATH);
-        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<Topic>>() {
-            @Override
-            public Set<Topic> answer(InvocationOnMock invocation) throws Throwable {
-                return Sets.newHashSet(TOPIC, TOPIC_2);
-            }
-        });
-        when(mockedMailboxPathRegister.getLocalTopic()).thenAnswer(new Answer<Topic>() {
-            @Override
-            public Topic answer(InvocationOnMock invocation) throws Throwable {
-                return TOPIC;
-            }
-        });
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenReturn(Sets.newHashSet(TOPIC, TOPIC_2));
+        when(mockedMailboxPathRegister.getLocalTopic()).thenReturn(TOPIC);
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
         testee.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister, times(2)).getLocalTopic();
@@ -140,18 +111,8 @@ public class RegisteredDelegatingMailboxListenerTest {
     public void onceListenersShouldBeTriggered() throws Exception {
         MailboxListener.Event event = new MailboxListener.Event(mailboxSession, MAILBOX_PATH) {};
         testee.addGlobalListener(onceEventCollector, mailboxSession);
-        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<Topic>>() {
-            @Override
-            public Set<Topic> answer(InvocationOnMock invocation) throws Throwable {
-                return Sets.newHashSet(TOPIC);
-            }
-        });
-        when(mockedMailboxPathRegister.getLocalTopic()).thenAnswer(new Answer<Topic>() {
-            @Override
-            public Topic answer(InvocationOnMock invocation) throws Throwable {
-                return TOPIC;
-            }
-        });
+        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenReturn(Sets.newHashSet(TOPIC));
+        when(mockedMailboxPathRegister.getLocalTopic()).thenReturn(TOPIC);
         testee.event(event);
         assertThat(onceEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister, times(2)).getLocalTopic();
@@ -170,12 +131,7 @@ public class RegisteredDelegatingMailboxListenerTest {
     public void distantEventShouldBeLocallyDelivered() throws Exception {
         testee.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         verify(mockedMailboxPathRegister).register(MAILBOX_PATH);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
         testee.receiveSerializedEvent(BYTES);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister).getLocalTopic();
@@ -189,12 +145,7 @@ public class RegisteredDelegatingMailboxListenerTest {
     @Test
     public void distantEventShouldNotBeDeliveredToOnceGlobalListeners() throws Exception {
         testee.addGlobalListener(onceEventCollector, mailboxSession);
-        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenAnswer(new Answer<MailboxListener.Event>() {
-            @Override
-            public MailboxListener.Event answer(InvocationOnMock invocation) throws Throwable {
-                return event;
-            }
-        });
+        when(mockedEventSerializer.deSerializeEvent(BYTES)).thenReturn(event);
         testee.receiveSerializedEvent(BYTES);
         assertThat(onceEventCollector.getEvents()).isEmpty();
         verify(mockedMailboxPathRegister).getLocalTopic();
@@ -209,24 +160,9 @@ public class RegisteredDelegatingMailboxListenerTest {
         MailboxListener.Event event = new MailboxListener.MailboxDeletion(mailboxSession, MAILBOX_PATH);
         testee.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         verify(mockedMailboxPathRegister).register(MAILBOX_PATH);
-        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<Topic>>() {
-            @Override
-            public Set<Topic> answer(InvocationOnMock invocation) throws Throwable {
-                return Sets.newHashSet(TOPIC, TOPIC_2);
-            }
-        });
-        when(mockedMailboxPathRegister.getLocalTopic()).thenAnswer(new Answer<Topic>() {
-            @Override
-            public Topic answer(InvocationOnMock invocation) throws Throwable {
-                return TOPIC;
-            }
-        });
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenReturn(Sets.newHashSet(TOPIC, TOPIC_2));
+        when(mockedMailboxPathRegister.getLocalTopic()).thenReturn(TOPIC);
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
         testee.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister, times(2)).getLocalTopic();
@@ -249,24 +185,9 @@ public class RegisteredDelegatingMailboxListenerTest {
         };
         testee.addListener(MAILBOX_PATH, mailboxEventCollector, mailboxSession);
         verify(mockedMailboxPathRegister).register(MAILBOX_PATH);
-        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenAnswer(new Answer<Set<Topic>>() {
-            @Override
-            public Set<Topic> answer(InvocationOnMock invocation) throws Throwable {
-                return Sets.newHashSet(TOPIC, TOPIC_2);
-            }
-        });
-        when(mockedMailboxPathRegister.getLocalTopic()).thenAnswer(new Answer<Topic>() {
-            @Override
-            public Topic answer(InvocationOnMock invocation) throws Throwable {
-                return TOPIC;
-            }
-        });
-        when(mockedEventSerializer.serializeEvent(event)).thenAnswer(new Answer<byte[]>() {
-            @Override
-            public byte[] answer(InvocationOnMock invocation) throws Throwable {
-                return BYTES;
-            }
-        });
+        when(mockedMailboxPathRegister.getTopics(MAILBOX_PATH)).thenReturn(Sets.newHashSet(TOPIC, TOPIC_2));
+        when(mockedMailboxPathRegister.getLocalTopic()).thenReturn(TOPIC);
+        when(mockedEventSerializer.serializeEvent(event)).thenReturn(BYTES);
         testee.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event);
         verify(mockedMailboxPathRegister, times(2)).getLocalTopic();

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
index 5590f12..74c6e85 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
@@ -25,7 +25,6 @@ import java.util.List;
 
 import org.apache.james.mailbox.model.MailboxId;
 
-import com.google.common.base.Function;
 import com.google.common.base.Objects;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Lists;
@@ -35,13 +34,10 @@ public class ListMailboxAssert {
     private final List<Mailbox> actual;
 
     private final List<InnerMailbox> mailboxtoInnerMailbox(List<Mailbox> mailboxes) {
-        return FluentIterable.from(mailboxes).transform(new Function<Mailbox, InnerMailbox>() {
-            @Override
-            public InnerMailbox apply(Mailbox input) {
-                return new InnerMailbox(input.getMailboxId(), input.getUser(), input.getName(), input.getNamespace());
-            }
-            
-        }).toList();
+        return FluentIterable.from(mailboxes)
+            .transform(mailbox ->
+                new InnerMailbox(mailbox.getMailboxId(), mailbox.getUser(), mailbox.getName(), mailbox.getNamespace()))
+            .toList();
     }
 
     private ListMailboxAssert(List<Mailbox> actual) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
index 7772ea1..ccb34f2 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
@@ -30,7 +30,6 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
 
-import com.google.common.base.Function;
 import com.google.common.base.Objects;
 import com.google.common.base.Throwables;
 import com.google.common.collect.FluentIterable;
@@ -40,18 +39,14 @@ public class ListMessageAssert {
     private final List<MailboxMessage> actual;
 
     private final List<InnerMessage> messageToInnerMessage(List<MailboxMessage> messages) {
-        return FluentIterable.from(messages).transform(new Function<MailboxMessage, InnerMessage>() {
-            @Override
-            public InnerMessage apply(MailboxMessage input) {
-                try {
-                    return new InnerMessage(input.getMessageId(), input.getUid(), input.getMailboxId(), input.getInternalDate(), input.getBodyOctets(), 
-                            input.getFullContentOctets(), input.getMediaType(), input.getSubType(), IOUtils.toString(input.getFullContent()));
-                } catch (IOException e) {
-                    Throwables.propagate(e);
-                    return null;
-                }
+        return FluentIterable.from(messages).transform(message -> {
+            try {
+                return new InnerMessage(message.getMessageId(), message.getUid(), message.getMailboxId(), message.getInternalDate(), message.getBodyOctets(),
+                        message.getFullContentOctets(), message.getMediaType(), message.getSubType(), IOUtils.toString(message.getFullContent()));
+            } catch (IOException e) {
+                Throwables.propagate(e);
+                return null;
             }
-            
         }).toList();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
index 4c22bdd..7d974ff 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
@@ -35,12 +35,7 @@ public class ListMessagePropertiesAssert {
     }
 
     private final Function<Property, InnerProperty> propertyToInnerProperty() {
-        return new Function<Property, InnerProperty>() {
-            @Override
-            public InnerProperty apply(Property input) {
-                return new InnerProperty(input.getNamespace(), input.getLocalName(), input.getValue());
-            }
-        };
+        return property -> new InnerProperty(property.getNamespace(), property.getLocalName(), property.getValue());
     }
 
     public static ListMessagePropertiesAssert assertProperties(List<Property> actual) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
index cb3ba8b..9a51f12 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
@@ -680,15 +680,11 @@ public abstract class MessageIdMapperTest {
 
         int threadCount = 2;
         int updateCount = 10;
-        assertThat(new ConcurrentTestRunner(threadCount, updateCount, new ConcurrentTestRunner.BiConsumer() {
-            @Override
-            public void consume(int threadNumber, int step) throws Exception {
-                sut.setFlags(message1.getMessageId(),
-                    ImmutableList.of(message1.getMailboxId()),
-                    new Flags("custom-" + threadNumber + "-" + step),
-                    FlagsUpdateMode.ADD);
-            }
-        }).run()
+        assertThat(new ConcurrentTestRunner(threadCount, updateCount,
+            (threadNumber, step) -> sut.setFlags(message1.getMessageId(),
+                ImmutableList.of(message1.getMailboxId()),
+                new Flags("custom-" + threadNumber + "-" + step),
+                FlagsUpdateMode.ADD)).run()
             .awaitTermination(1, TimeUnit.MINUTES))
             .isTrue();
 
@@ -705,9 +701,8 @@ public abstract class MessageIdMapperTest {
 
         final int threadCount = 4;
         final int updateCount = 20;
-        assertThat(new ConcurrentTestRunner(threadCount, updateCount, new ConcurrentTestRunner.BiConsumer() {
-            @Override
-            public void consume(int threadNumber, int step) throws Exception {
+        assertThat(new ConcurrentTestRunner(threadCount, updateCount,
+            (threadNumber, step) -> {
                 if (step  < updateCount / 2) {
                     sut.setFlags(message1.getMessageId(),
                         ImmutableList.of(message1.getMailboxId()),
@@ -719,8 +714,7 @@ public abstract class MessageIdMapperTest {
                         new Flags("custom-" + threadNumber + "-" + (updateCount - step - 1)),
                         FlagsUpdateMode.REMOVE);
                 }
-            }
-        }).run()
+            }).run()
             .awaitTermination(1, TimeUnit.MINUTES))
             .isTrue();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
index 215a846..29c5591 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
@@ -806,14 +806,10 @@ public abstract class MessageMapperTest {
 
         int threadCount = 2;
         int updateCount = 10;
-        assertThat(new ConcurrentTestRunner(threadCount, updateCount, new ConcurrentTestRunner.BiConsumer() {
-            @Override
-            public void consume(int threadNumber, int step) throws Exception {
-                messageMapper.updateFlags(benwaInboxMailbox,
-                    new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
-                    MessageRange.one(message1.getUid()));
-            }
-        }).run()
+        assertThat(new ConcurrentTestRunner(threadCount, updateCount,
+            (threadNumber, step) -> messageMapper.updateFlags(benwaInboxMailbox,
+                new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
+                MessageRange.one(message1.getUid()))).run()
             .awaitTermination(1, TimeUnit.MINUTES))
             .isTrue();
 
@@ -830,9 +826,8 @@ public abstract class MessageMapperTest {
 
         final int threadCount = 4;
         final int updateCount = 20;
-        assertThat(new ConcurrentTestRunner(threadCount, updateCount, new ConcurrentTestRunner.BiConsumer() {
-            @Override
-            public void consume(int threadNumber, int step) throws Exception {
+        assertThat(new ConcurrentTestRunner(threadCount, updateCount,
+            (threadNumber, step) -> {
                 if (step  < updateCount / 2) {
                     messageMapper.updateFlags(benwaInboxMailbox,
                         new FlagsUpdateCalculator(new Flags("custom-" + threadNumber + "-" + step), FlagsUpdateMode.ADD),
@@ -843,8 +838,7 @@ public abstract class MessageMapperTest {
                             FlagsUpdateMode.REMOVE),
                         MessageRange.one(message1.getUid()));
                 }
-            }
-        }).run()
+            }).run()
             .awaitTermination(1, TimeUnit.MINUTES))
             .isTrue();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolverTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolverTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolverTest.java
index d9be76e..c6c6218 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolverTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolverTest.java
@@ -23,8 +23,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.List;
-
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.QuotaRoot;
@@ -33,8 +31,6 @@ import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 import com.google.common.collect.Lists;
 
@@ -74,18 +70,8 @@ public class DefaultQuotaRootResolverTest {
     @Test
     public void retrieveAssociatedMailboxesShouldWork() throws Exception {
         final MailboxMapper mockedMapper = mock(MailboxMapper.class);
-        when(mockedFactory.getMailboxMapper(null)).thenAnswer(new Answer<MailboxMapper>() {
-            @Override
-            public MailboxMapper answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return mockedMapper;
-            }
-        });
-        when(mockedMapper.findMailboxWithPathLike(PATH_LIKE)).thenAnswer(new Answer<List<SimpleMailbox>>() {
-            @Override
-            public List<SimpleMailbox> answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Lists.newArrayList(MAILBOX, MAILBOX_2);
-            }
-        });
+        when(mockedFactory.getMailboxMapper(null)).thenReturn(mockedMapper);
+        when(mockedMapper.findMailboxWithPathLike(PATH_LIKE)).thenReturn(Lists.newArrayList(MAILBOX, MAILBOX_2));
         assertThat(testee.retrieveAssociatedMailboxes(QUOTA_ROOT, null)).containsOnly(MAILBOX_PATH, MAILBOX_PATH_2);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
index c1a03e3..625a8e1 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
@@ -27,15 +27,12 @@ import static org.mockito.Mockito.when;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 public class QuotaCheckerTest {
 
@@ -54,72 +51,27 @@ public class QuotaCheckerTest {
 
     @Test
     public void quotaCheckerShouldNotThrowOnRegularQuotas() throws MailboxException {
-        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenAnswer(new Answer<QuotaRoot>() {
-            @Override
-            public QuotaRoot answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QUOTA_ROOT;
-            }
-        });
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(10, 100);
-            }
-        });
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(100, 1000);
-            }
-        });
+        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
+        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, 100));
+        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, 1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, mockedQuotaRootResolver, MAILBOX);
         assertThat(quotaChecker.tryAddition(0, 0)).isTrue();
     }
 
     @Test
     public void quotaCheckerShouldNotThrowOnRegularModifiedQuotas() throws MailboxException {
-        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenAnswer(new Answer<QuotaRoot>() {
-            @Override
-            public QuotaRoot answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QUOTA_ROOT;
-            }
-        });
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(10, 100);
-            }
-        });
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(100, 1000);
-            }
-        });
+        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
+        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, 100));
+        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, 1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, mockedQuotaRootResolver, MAILBOX);
         assertThat(quotaChecker.tryAddition(89, 899)).isTrue();
     }
 
     @Test
     public void quotaCheckerShouldNotThrowOnReachedMaximumQuotas() throws MailboxException {
-        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenAnswer(new Answer<QuotaRoot>() {
-            @Override
-            public QuotaRoot answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QUOTA_ROOT;
-            }
-        });
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(10, 100);
-            }
-        });
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-            @Override
-            public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return QuotaImpl.quota(100, 1000);
-            }
-        });
+        when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
+        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, 100));
+        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, 1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, mockedQuotaRootResolver, MAILBOX);
         assertThat(quotaChecker.tryAddition(90, 900)).isTrue();
     }
@@ -128,24 +80,9 @@ public class QuotaCheckerTest {
     public void quotaCheckerShouldThrowOnExceededMessages() throws MailboxException {
         QuotaChecker quotaChecker;
         try {
-            when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenAnswer(new Answer<QuotaRoot>() {
-                @Override
-                public QuotaRoot answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QUOTA_ROOT;
-                }
-            });
-            when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-                @Override
-                public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QuotaImpl.quota(10, 100);
-                }
-            });
-            when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-                @Override
-                public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QuotaImpl.quota(100, 1000);
-                }
-            });
+            when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
+            when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, 100));
+            when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, 1000));
             quotaChecker = new QuotaChecker(mockedQuotaManager, mockedQuotaRootResolver, MAILBOX);
         } catch(Exception e) {
             fail("Exception caught : ", e);
@@ -158,24 +95,9 @@ public class QuotaCheckerTest {
     public void quotaCheckerShouldThrowOnExceededStorage() throws MailboxException {
         QuotaChecker quotaChecker;
         try {
-            when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenAnswer(new Answer<QuotaRoot>() {
-                @Override
-                public QuotaRoot answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QUOTA_ROOT;
-                }
-            });
-            when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-                @Override
-                public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QuotaImpl.quota(10, 100);
-                }
-            });
-            when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenAnswer(new Answer<Quota>() {
-                @Override
-                public Quota answer(InvocationOnMock invocationOnMock) throws Throwable {
-                    return QuotaImpl.quota(100, 1000);
-                }
-            });
+            when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
+            when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, 100));
+            when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, 1000));
             quotaChecker = new QuotaChecker(mockedQuotaManager, mockedQuotaRootResolver, MAILBOX);
         } catch(Exception e) {
             fail("Exception caught : ", e);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
index c7c6ccc..a73a34e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.store.quota;
 
 import static org.assertj.core.api.Assertions.assertThat;
-
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
@@ -32,8 +31,6 @@ import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 public class StoreQuotaManagerTest {
 
@@ -52,47 +49,23 @@ public class StoreQuotaManagerTest {
 
     @Test
     public void getMessageQuotaShouldWorkWithNumericValues() throws Exception {
-        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 360L;
-            }
-        });
-        when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 36L;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(360L);
+        when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(36L);
         assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, 360));
     }
 
     @Test
     public void getStorageQuotaShouldWorkWithNumericValues() throws Exception {
-        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 360L;
-            }
-        });
-        when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 36L;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(360L);
+        when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(36L);
         assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, 360));
     }
 
     @Test
     public void getStorageQuotaShouldNotCalculateCurrentQuotaWhenUnlimited() throws Exception {
         testee.setCalculateWhenUnlimited(false);
-        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Quota.UNLIMITED;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(Quota.UNLIMITED);
+
         assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(Quota.UNKNOWN, Quota.UNLIMITED));
         verify(mockedCurrentQuotaManager, never()).getCurrentStorage(quotaRoot);
     }
@@ -100,12 +73,8 @@ public class StoreQuotaManagerTest {
     @Test
     public void getMessageQuotaShouldNotCalculateCurrentQuotaWhenUnlimited() throws Exception {
         testee.setCalculateWhenUnlimited(false);
-        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Quota.UNLIMITED;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(Quota.UNLIMITED);
+
         assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(Quota.UNKNOWN, Quota.UNLIMITED));
         verify(mockedCurrentQuotaManager, never()).getCurrentMessageCount(quotaRoot);
     }
@@ -113,36 +82,18 @@ public class StoreQuotaManagerTest {
     @Test
     public void getStorageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
         testee.setCalculateWhenUnlimited(true);
-        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Quota.UNLIMITED;
-            }
-        });
-        when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 36L;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(Quota.UNLIMITED);
+        when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(36L);
+
         assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, Quota.UNLIMITED));
     }
 
     @Test
     public void getMessageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
         testee.setCalculateWhenUnlimited(true);
-        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Quota.UNLIMITED;
-            }
-        });
-        when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).then(new Answer<Long>() {
-            @Override
-            public Long answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return 36L;
-            }
-        });
+        when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(Quota.UNLIMITED);
+        when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(36L);
+
         assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, Quota.UNLIMITED));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
index 45db8bf..e36f2e5 100644
--- a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
+++ b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
@@ -37,7 +37,6 @@ import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.mock.MockMailboxManager;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
@@ -54,7 +53,8 @@ import org.slf4j.LoggerFactory;
  *
  */
 public class MailboxCopierTest {
-    
+
+    public static final boolean AUTHENTIC = true;
     /**
      * The instance for the test mailboxCopier.
      */
@@ -161,18 +161,9 @@ public class MailboxCopierTest {
         MessageParser messageParser = new MessageParser();
 
         return new StoreMailboxManager(
-            new InMemoryMailboxSessionMapperFactory(), 
-            new Authenticator() {
-                public boolean isAuthentic(String userid, CharSequence passwd) {
-                    return true;
-                }
-            },
-            new Authorizator() {
-                @Override
-                public AuthorizationState canLoginAsOtherUser(String userId, String otherUserId) {
-                    return AuthorizationState.NOT_ADMIN;
-                }
-            },
+            new InMemoryMailboxSessionMapperFactory(),
+            (userid, passwd) -> AUTHENTIC,
+            (userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
             aclResolver,
             groupMembershipResolver,
             messageParser,

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java b/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java
index 495e4bf..330e5cc 100644
--- a/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java
+++ b/mailbox/tool/src/test/java/org/apache/james/mailbox/indexer/ReIndexerImplTest.java
@@ -26,8 +26,6 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-import java.util.Iterator;
-
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -47,8 +45,6 @@ import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.assertj.core.util.Lists;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 import org.slf4j.Logger;
 
 import com.google.common.collect.ImmutableList;
@@ -74,42 +70,23 @@ public class ReIndexerImplTest {
     @Test
     public void test() throws Exception {
         final MockMailboxSession mockMailboxSession = new MockMailboxSession("re-indexing");
-        when(mailboxManager.createSystemSession(any(String.class), any(Logger.class))).thenAnswer(new Answer<MailboxSession>() {
-            @Override
-            public MailboxSession answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return mockMailboxSession;
-            }
-        });
+        when(mailboxManager.createSystemSession(any(String.class), any(Logger.class)))
+            .thenReturn(mockMailboxSession);
         final MessageMapper messageMapper = mock(MessageMapper.class);
         final MailboxMapper mailboxMapper = mock(MailboxMapper.class);
-        when(mailboxSessionMapperFactory.getMessageMapper(any(MailboxSession.class))).thenAnswer(new Answer<MessageMapper>() {
-            @Override
-            public MessageMapper answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return messageMapper;
-            }
-        });
-        when(mailboxSessionMapperFactory.getMailboxMapper(any(MailboxSession.class))).thenAnswer(new Answer<MailboxMapper>() {
-            @Override
-            public MailboxMapper answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return mailboxMapper;
-            }
-        });
+        when(mailboxSessionMapperFactory.getMessageMapper(any(MailboxSession.class)))
+            .thenReturn(messageMapper);
+        when(mailboxSessionMapperFactory.getMailboxMapper(any(MailboxSession.class)))
+            .thenReturn(mailboxMapper);
         final MailboxMessage message = new MessageBuilder().build();
         final SimpleMailbox mailbox = new SimpleMailbox(INBOX, 42);
         mailbox.setMailboxId(message.getMailboxId());
-        when(mailboxMapper.findMailboxByPath(INBOX)).thenAnswer(new Answer<Mailbox>() {
-            @Override
-            public Mailbox answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return mailbox;
-            }
-        });
-        when(messageMapper.findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT)).thenAnswer(new Answer<Iterator<MailboxMessage>>() {
-            @Override
-            public Iterator<MailboxMessage> answer(InvocationOnMock invocationOnMock) throws Throwable {
-                return Lists.newArrayList(message).iterator();
-            }
-        });
+        when(mailboxMapper.findMailboxByPath(INBOX)).thenReturn(mailbox);
+        when(messageMapper.findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
+            .thenReturn(Lists.newArrayList(message).iterator());
+
         reIndexer.reIndex(INBOX);
+
         verify(mailboxManager).createSystemSession(any(String.class), any(Logger.class));
         verify(mailboxSessionMapperFactory).getMailboxMapper(mockMailboxSession);
         verify(mailboxSessionMapperFactory).getMessageMapper(mockMailboxSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
index 791c2ed..d261a04 100644
--- a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
+++ b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
@@ -18,10 +18,10 @@
  ****************************************************************/
 
 package org.apache.mailet;
+
 import java.util.Collection;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
@@ -30,13 +30,6 @@ import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Multimap;
 
 public class PerRecipientHeaders {
-    public static final Function<Header, String> GET_HEADER_NAME = new Function<Header, String>() {
-        @Override
-        public String apply(Header input) {
-            return input.getName();
-        }
-    };
-
     private Multimap<MailAddress, Header> headersByRecipient;
 
     public PerRecipientHeaders() {
@@ -53,7 +46,7 @@ public class PerRecipientHeaders {
 
     public Collection<String> getHeaderNamesForRecipient(MailAddress recipient) {
         return FluentIterable.from(headersByRecipient.get(recipient))
-            .transform(GET_HEADER_NAME)
+            .transform(Header::getName)
             .toSet();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java b/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
index e0a9069..5b5ee9a 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
@@ -25,32 +25,23 @@ import org.apache.mailet.MailetConfig;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 
 public class MailetPipelineLogging {
 
     public static void logBeginOfMailetProcess(final Mailet mailet, final Mail mail) {
         getLogger(mailet)
-        .transform(new Function<Logger, Boolean>() {
-
-            @Override
-            public Boolean apply(Logger logger) {
-                logger.debug("Entering mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
-                return true;
-            }
+        .transform(logger -> {
+            logger.debug("Entering mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
+            return true;
         });
     }
 
     public static void logEndOfMailetProcess(final Mailet mailet, final Mail mail) {
         getLogger(mailet)
-            .transform(new Function<Logger, Boolean>() {
-
-                @Override
-                public Boolean apply(Logger logger) {
-                    logger.debug("End of mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
-                    return true;
-                }
+            .transform(logger -> {
+                logger.debug("End of mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
+                return true;
             });
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/base/src/test/java/org/apache/mailet/base/test/MimeMessageBuilder.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/MimeMessageBuilder.java b/mailet/base/src/test/java/org/apache/mailet/base/test/MimeMessageBuilder.java
index f00d9c9..043aa1a 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/MimeMessageBuilder.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/MimeMessageBuilder.java
@@ -176,14 +176,11 @@ public class MimeMessageBuilder {
         }
     }
 
-    public static final Function<String, InternetAddress> TO_INTERNET_ADDRESS = new Function<String, InternetAddress>() {
-        @Override
-        public InternetAddress apply(String input) {
-            try {
-                return new InternetAddress(input);
-            } catch (AddressException e) {
-                throw Throwables.propagate(e);
-            }
+    public static final Function<String, InternetAddress> TO_INTERNET_ADDRESS = value -> {
+        try {
+            return new InternetAddress(value);
+        } catch (AddressException e) {
+            throw Throwables.propagate(e);
         }
     };
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/AbstractMailetdocsReport.java
----------------------------------------------------------------------
diff --git a/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/AbstractMailetdocsReport.java b/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/AbstractMailetdocsReport.java
index d1bd780..3630bfa 100644
--- a/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/AbstractMailetdocsReport.java
+++ b/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/AbstractMailetdocsReport.java
@@ -19,7 +19,6 @@
 
 package org.apache.james.mailet;
 
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Locale;
@@ -148,13 +147,7 @@ public abstract class AbstractMailetdocsReport extends AbstractMavenReport {
         
         final List<MailetMatcherDescriptor> descriptors = buildDescriptors(this.project);
         
-        Collections.sort(descriptors, new Comparator<MailetMatcherDescriptor>() {
-
-            public int compare(MailetMatcherDescriptor one, MailetMatcherDescriptor two) {
-                return one.getName().compareTo(two.getName());
-            }
-
-        });
+        descriptors.sort(Comparator.comparing(MailetMatcherDescriptor::getName));
         logDescriptors(descriptors);
         return descriptors;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/DefaultDescriptorsExtractor.java
----------------------------------------------------------------------
diff --git a/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/DefaultDescriptorsExtractor.java b/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/DefaultDescriptorsExtractor.java
index eb9881e..9f1da32 100644
--- a/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/DefaultDescriptorsExtractor.java
+++ b/mailet/mailetdocs-maven-plugin/src/main/java/org/apache/james/mailet/DefaultDescriptorsExtractor.java
@@ -39,10 +39,8 @@ import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.thoughtworks.qdox.JavaDocBuilder;
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.JavaClass;
 
 /**
@@ -196,14 +194,8 @@ public class DefaultDescriptorsExtractor {
 
     private boolean isExperimental(JavaClass javaClass) {
         return FluentIterable.of(javaClass.getAnnotations())
-            .anyMatch(new Predicate<Annotation>() {
-
-                @Override
-                public boolean apply(Annotation annotation) {
-                    return annotation.getType().getValue()
-                            .equals(Experimental.class.getName());
-                }
-            });
+            .anyMatch(annotation -> annotation.getType().getValue()
+                    .equals(Experimental.class.getName()));
     }
 
     private void handleInfoLoadFailure(Log log, String nameOfClass,

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
index 52c3410..f5496b7 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
@@ -27,7 +27,6 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 
-import com.google.common.base.Function;
 import com.google.common.base.Throwables;
 import com.google.common.collect.FluentIterable;
 
@@ -38,22 +37,19 @@ import com.google.common.collect.FluentIterable;
  */
 public class RecipientToLowerCase extends GenericMailet{
 
-    public static final Function<MailAddress, MailAddress> TO_LOWERCASE = new Function<MailAddress, MailAddress>() {
-        @Override
-        public MailAddress apply(MailAddress input) {
-            try {
-                return new MailAddress(input.asString().toLowerCase(Locale.US));
-            } catch (AddressException e) {
-                throw Throwables.propagate(e);
-            }
-        }
-    };
-
     @Override
     public void service(Mail mail) throws MessagingException {
         mail.setRecipients(FluentIterable.from(mail.getRecipients())
-            .transform(TO_LOWERCASE)
+            .transform(this::toLowerCase)
             .toList());
     }
 
+    private MailAddress toLowerCase(MailAddress mailAddress) {
+        try {
+            return new MailAddress(mailAddress.asString().toLowerCase(Locale.US));
+        } catch (AddressException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
index 2d22205..ea45cb2 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
@@ -39,7 +39,6 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 
-import com.google.common.base.Function;
 import com.google.common.base.Splitter;
 import com.google.common.base.Throwables;
 import com.google.common.collect.FluentIterable;
@@ -70,17 +69,6 @@ import com.google.common.collect.ImmutableList;
 @Experimental
 public class UseHeaderRecipients extends GenericMailet {
 
-    public static final Function<Mailbox, MailAddress> TO_MAIL_ADDRESS = new Function<Mailbox, MailAddress>() {
-        @Override
-        public MailAddress apply(Mailbox input) {
-            try {
-                return new MailAddress(input.getAddress());
-            } catch (AddressException e) {
-                throw Throwables.propagate(e);
-            }
-        }
-    };
-
     /**
      * Controls certain log messages
      */
@@ -190,10 +178,18 @@ public class UseHeaderRecipients extends GenericMailet {
         }
 
         return FluentIterable.from(mailboxList.build())
-            .transform(TO_MAIL_ADDRESS)
+            .transform(this::toMailAddress)
             .toList();
     }
 
+    private MailAddress toMailAddress(Mailbox mailbox) {
+        try {
+            return new MailAddress(mailbox.getAddress());
+        } catch (AddressException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
     private Collection<Mailbox> convertAddressToMailboxCollection(Address address) {
         if (address instanceof Mailbox) {
             return ImmutableList.of((Mailbox) address);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
index 75086ba..fb78101 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
@@ -25,9 +25,7 @@ import javax.mail.internet.AddressException;
 
 import org.apache.mailet.MailAddress;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import com.google.common.base.Throwables;
@@ -39,20 +37,12 @@ public class MailAddressCollectionReader {
         Preconditions.checkArgument(!Strings.isNullOrEmpty(condition));
         return FluentIterable.from(Splitter.onPattern("(,| |\t)")
             .split(condition))
-            .filter(new Predicate<String>() {
-                @Override
-                public boolean apply(String s) {
-                    return !Strings.isNullOrEmpty(s);
-                }
-            })
-            .transform(new Function<String, MailAddress>() {
-                @Override
-                public MailAddress apply(String s) {
-                    try {
-                        return new MailAddress(s);
-                    } catch (AddressException e) {
-                        throw Throwables.propagate(e);
-                    }
+            .filter(s -> !Strings.isNullOrEmpty(s))
+            .transform(s -> {
+                try {
+                    return new MailAddress(s);
+                } catch (AddressException e) {
+                    throw Throwables.propagate(e);
                 }
             }).toSet();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
index db88e69..b062cb7 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
@@ -25,19 +25,11 @@ import java.util.Collection;
 
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
-import org.assertj.core.api.iterable.Extractor;
 import org.junit.Before;
 import org.junit.Test;
 
 public class RecipientToLowerCaseTest {
 
-    public static final Extractor<MailAddress, String> AS_STRING = new Extractor<MailAddress, String>() {
-        @Override
-        public String extract(MailAddress mailAddress) {
-            return mailAddress.asString();
-        }
-    };
-
     private RecipientToLowerCase testee;
 
     @Before
@@ -56,7 +48,7 @@ public class RecipientToLowerCaseTest {
         Collection<MailAddress> recipients = fakeMail.getRecipients();
 
         assertThat(recipients)
-            .extracting(AS_STRING)
+            .extracting(MailAddress::asString)
             .containsOnly("thienan1234@gmail.com");
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
index 1ded296..e402b3b 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
@@ -54,7 +54,6 @@ import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 
 public class StripAttachmentTest {
@@ -239,13 +238,7 @@ public class StripAttachmentTest {
 
     private String retrieveFilenameStartingWith(Collection<String> savedAttachments, final String filename) {
         return FluentIterable.from(savedAttachments)
-                .filter(new Predicate<String>() {
-
-                    @Override
-                    public boolean apply(String attachmentFilename) {
-                        return attachmentFilename.startsWith(filename);
-                    }
-                })
+                .filter(attachmentFilename -> attachmentFilename.startsWith(filename))
                 .first()
                 .get();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
index 9c65851..0edd5e4 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/session/ExternalSession.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 import java.nio.charset.Charset;
-import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.NotImplementedException;
@@ -130,13 +129,10 @@ public final class ExternalSession implements Session {
         Awaitility
             .waitAtMost(Duration.ONE_MINUTE)
             .pollDelay(new Duration(10, TimeUnit.MILLISECONDS))
-            .until(new Callable<Boolean>() {
-                @Override
-                public Boolean call() throws Exception {
-                    int read = socket.read(readBuffer);
-                    status.setValue(read);
-                    return read != 0;
-                }
+            .until(() -> {
+                int read = socket.read(readBuffer);
+                status.setValue(read);
+                return read != 0;
             });
         if (status.intValue() == -1) {
             monitor.debug("Error reading, got -1");

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/HaveSpaceTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/HaveSpaceTest.java b/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/HaveSpaceTest.java
index ccf49c7..d4110dc 100644
--- a/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/HaveSpaceTest.java
+++ b/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/HaveSpaceTest.java
@@ -21,9 +21,7 @@ package org.apache.james.mpt.testsuite;
 
 import java.util.Locale;
 
-import org.apache.james.mpt.api.HostSystem;
 import org.apache.james.mpt.host.ManageSieveHostSystem;
-import org.apache.james.mpt.script.GenericSimpleScriptedTestProtocol.PrepareCommand;
 import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
 import org.junit.After;
 import org.junit.Before;
@@ -46,12 +44,8 @@ public abstract class HaveSpaceTest {
         simpleScriptedTestProtocol = new SimpleScriptedTestProtocol("/org/apache/james/managesieve/scripts/", hostSystem)
                 .withUser(USER, PASSWORD)
                 .withLocale(Locale.US)
-                .withPreparedCommand(new PrepareCommand<HostSystem>() {
-                    @Override
-                    public void prepare(HostSystem system) throws Exception {
-                        ((ManageSieveHostSystem) system).setMaxQuota(USER, 50);
-                    }
-                });
+                .withPreparedCommand(system ->
+                    ((ManageSieveHostSystem) system).setMaxQuota(USER, 50));
     }
     
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
----------------------------------------------------------------------
diff --git a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
index 068da08..0bb351e 100644
--- a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
+++ b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
@@ -26,7 +26,6 @@ import java.util.Queue;
 import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.james.protocols.api.future.FutureResponse;
-import org.apache.james.protocols.api.future.FutureResponse.ResponseListener;
 
 
 /**
@@ -113,14 +112,12 @@ public abstract class AbstractProtocolTransport implements ProtocolTransport{
         return !(response instanceof FutureResponse) || ((FutureResponse) response).isReady();
     }
     
-    private void addDequeuerListener(Response response, final ProtocolSession session) {
-        ((FutureResponse) response).addListener(new ResponseListener() {
-                
-            public void onResponse(FutureResponse response) {
+    private void addDequeuerListener(Response responseFuture, final ProtocolSession session) {
+        ((FutureResponse) responseFuture).addListener(
+            response -> {
                 writeResponseToClient(response, session);
                 writeQueuedResponses(session);
-            }
-        });
+            });
     }
     
     /**


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