[jira] [Commented] (JAMES-2637) Webadmin CRUD for RRT aliases

2019-01-08 Thread Rene Cordier (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16737932#comment-16737932
 ] 

Rene Cordier commented on JAMES-2637:
-

**First PR part (PUT route for aliases routes) : 
[https://github.com/linagora/james-project/pull/2089.] The rest will follow up 
in a later PR

> Webadmin CRUD for RRT aliases
> -
>
> Key: JAMES-2637
> URL: https://issues.apache.org/jira/browse/JAMES-2637
> Project: James Server
>  Issue Type: New Feature
>  Components: RRT, webadmin
>Reporter: Tellier Benoit
>Priority: Major
>
> We should be able to update aliases using the webadmin protocol
> Here is the proposed API:
> {code:java}
> PUT /address/aliases/b...@domain.tld/sources/bob-al...@domain.tld
> Adds a `bob-alias` alias pointing to `b...@domain.tld` main mail address
> 204
> 400 if the alias source (`bob-al...@domain.tld`) is contained in 
> UsersRepository
> 400 if source or destination domain is not handled by James
> No content
> {code}
> (implement PUT in a separate pull request as this is an emergency?)
> {code:java}
> GET /address/aliases
> Returns the mailAddresses having aliases configured.
> 200
> ["b...@domain.tld", "ced...@domain.tld"]
> {code}
> {code:java}
> DELETE /address/aliases/b...@domain.tld/sources/bob-al...@domain.tld
> Deletes the `bob-alias` alias pointing to `b...@domain.tld` main mail address
> 204
> No content
> {code}
> {code:java}
> GET /address/aliases/b...@domain.tld
> Will return all the aliases pointing to b...@domain.tld main mail address
> 200
> [
> {"source":"bob-al...@domain.tld"},
> ...
> ]
> {code}
> Create a `AliasRoutes` class in `/server/protocols/webadmin/webadmin-data` 
> and the corresponding tests using the MemoryRecipientRewriteTable.
> Have a look to `ForwardsRoutes` for guidance



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Comment Edited] (JAMES-2637) Webadmin CRUD for RRT aliases

2019-01-08 Thread Rene Cordier (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16737932#comment-16737932
 ] 

Rene Cordier edited comment on JAMES-2637 at 1/9/19 7:39 AM:
-

First PR part (PUT route for aliases routes) : 
[https://github.com/linagora/james-project/pull/2089.] The rest will follow up 
in a later PR


was (Author: rcordier):
**First PR part (PUT route for aliases routes) : 
[https://github.com/linagora/james-project/pull/2089.] The rest will follow up 
in a later PR

> Webadmin CRUD for RRT aliases
> -
>
> Key: JAMES-2637
> URL: https://issues.apache.org/jira/browse/JAMES-2637
> Project: James Server
>  Issue Type: New Feature
>  Components: RRT, webadmin
>Reporter: Tellier Benoit
>Priority: Major
>
> We should be able to update aliases using the webadmin protocol
> Here is the proposed API:
> {code:java}
> PUT /address/aliases/b...@domain.tld/sources/bob-al...@domain.tld
> Adds a `bob-alias` alias pointing to `b...@domain.tld` main mail address
> 204
> 400 if the alias source (`bob-al...@domain.tld`) is contained in 
> UsersRepository
> 400 if source or destination domain is not handled by James
> No content
> {code}
> (implement PUT in a separate pull request as this is an emergency?)
> {code:java}
> GET /address/aliases
> Returns the mailAddresses having aliases configured.
> 200
> ["b...@domain.tld", "ced...@domain.tld"]
> {code}
> {code:java}
> DELETE /address/aliases/b...@domain.tld/sources/bob-al...@domain.tld
> Deletes the `bob-alias` alias pointing to `b...@domain.tld` main mail address
> 204
> No content
> {code}
> {code:java}
> GET /address/aliases/b...@domain.tld
> Will return all the aliases pointing to b...@domain.tld main mail address
> 200
> [
> {"source":"bob-al...@domain.tld"},
> ...
> ]
> {code}
> Create a `AliasRoutes` class in `/server/protocols/webadmin/webadmin-data` 
> and the corresponding tests using the MemoryRecipientRewriteTable.
> Have a look to `ForwardsRoutes` for guidance



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Updated] (MAILBOX-372) EventBus error handling

2019-01-08 Thread JIRA


 [ 
https://issues.apache.org/jira/browse/MAILBOX-372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Trần Tiến Đức updated MAILBOX-372:
--
Description: 
MailboxListener should get retried upon exceptions.

Write EventBusContract test to demonstrate MailboxListener get retired. => over 
contract that could be optional contract

Implement this retry logic in the InVmDelivery + RabbitMQ eventbus with a 
hardcoded maxRetry constant + exponential backoff.

 

Then try it with RabbitMQEventBus

 

A timeout on listener execution is more related to at least once/at most once 
delivery concerns of the RabbitMQEventBus
 The event bus should retry upon exceptions, with a max retry + exponential 
backoff. That maxRetries ensures bugs do not trigger infinite loops.
 We need a dead letter equivalent for audit/rescheduling purposes.

  was:
MailboxListener should get retried upon exceptions.

Write EventBusContract test to demonstrate MailboxListener get retired. => over 
contract that could be optional contract

Implement this retry logic in the InVmDelivery + RabbitMQ eventbus with a 
hardcoded maxRetry constant + exponential backoff.

 

A timeout on listener execution is more related to at least once/at most once 
delivery concerns of the RabbitMQEventBus
The event bus should retry upon exceptions, with a max retry + exponential 
backoff. That maxRetries ensures bugs do not trigger infinite loops.
We need a dead letter equivalent for audit/rescheduling purposes.


> EventBus error handling
> ---
>
> Key: MAILBOX-372
> URL: https://issues.apache.org/jira/browse/MAILBOX-372
> Project: James Mailbox
>  Issue Type: New Feature
>Reporter: Trần Tiến Đức
>Priority: Major
>
> MailboxListener should get retried upon exceptions.
> Write EventBusContract test to demonstrate MailboxListener get retired. => 
> over contract that could be optional contract
> Implement this retry logic in the InVmDelivery + RabbitMQ eventbus with a 
> hardcoded maxRetry constant + exponential backoff.
>  
> Then try it with RabbitMQEventBus
>  
> A timeout on listener execution is more related to at least once/at most once 
> delivery concerns of the RabbitMQEventBus
>  The event bus should retry upon exceptions, with a max retry + exponential 
> backoff. That maxRetries ensures bugs do not trigger infinite loops.
>  We need a dead letter equivalent for audit/rescheduling purposes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Closed] (MAILBOX-366) Events should have an eventId

2019-01-08 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/MAILBOX-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit closed MAILBOX-366.
--

> Events should have an eventId
> -
>
> Key: MAILBOX-366
> URL: https://issues.apache.org/jira/browse/MAILBOX-366
> Project: James Mailbox
>  Issue Type: New Feature
>Reporter: Tellier Benoit
>Priority: Major
> Fix For: 3.3.0
>
>
> Backed by a UUID randomly generated.
> This needs to be serialized and deserialized.
> Upon Listener execution, we need to pop eventId in the MDC. -> this can be 
> used later on for correlation with the dead letter



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Resolved] (MAILBOX-366) Events should have an eventId

2019-01-08 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/MAILBOX-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit resolved MAILBOX-366.

   Resolution: Fixed
Fix Version/s: 3.3.0

https://github.com/linagora/james-project/pull/2067 solved this

> Events should have an eventId
> -
>
> Key: MAILBOX-366
> URL: https://issues.apache.org/jira/browse/MAILBOX-366
> Project: James Mailbox
>  Issue Type: New Feature
>Reporter: Tellier Benoit
>Priority: Major
> Fix For: 3.3.0
>
>
> Backed by a UUID randomly generated.
> This needs to be serialized and deserialized.
> Upon Listener execution, we need to pop eventId in the MDC. -> this can be 
> used later on for correlation with the dead letter



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[2/3] james-project git commit: MAILBOX-366 Events should carry an EventId

2019-01-08 Thread btellier
http://git-wip-us.apache.org/repos/asf/james-project/blob/60919d85/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
index 4ce097d..9a81746 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.event.json;
 
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
+import static org.apache.james.event.json.SerializerFixture.EVENT_ID;
 import static org.apache.james.event.json.SerializerFixture.EVENT_SERIALIZER;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -48,6 +49,7 @@ class QuotaUsageUpdatedEventSerializationTest {
 .build();
 private static final Instant INSTANT = 
Instant.parse("2018-11-13T12:00:55Z");
 private final MailboxListener.QuotaUsageUpdatedEvent 
eventWithUserContainsUsername = new MailboxListener.QuotaUsageUpdatedEvent(
+EVENT_ID,
 User.fromUsername("onlyUsername"),
 QUOTA_ROOT,
 QUOTA_COUNT,
@@ -56,6 +58,7 @@ class QuotaUsageUpdatedEventSerializationTest {
 private final String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
 "\"time\":\"2018-11-13T12:00:55Z\"," +
@@ -81,6 +84,7 @@ class QuotaUsageUpdatedEventSerializationTest {
 String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "
\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
 "\"time\":\"2018-11-13T12:00:55Z\"," +
@@ -97,11 +101,12 @@ class QuotaUsageUpdatedEventSerializationTest {
 String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "\"time\":\"2018-11-13T12:00:55Z\"," +
 "
\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
 "\"user\":\"onlyUsername\"" +
-"}" +
+"}" +
 "}";
 
 assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
@@ -113,11 +118,12 @@ class QuotaUsageUpdatedEventSerializationTest {
 String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "\"time\":\"2018-11-13T12:00:55Z\"," +
 "
\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
 "\"user\":\"onlyUsername\"" +
-"}" +
+"}" +
 "}";
 
 assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
@@ -129,11 +135,12 @@ class QuotaUsageUpdatedEventSerializationTest {
 String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "
\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," +
 "
\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
 "\"user\":\"user\"" +
-"}" +
+"}" +
 "}";
 
 assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
@@ -145,6 +152,7 @@ class QuotaUsageUpdatedEventSerializationTest {
 String quotaUsageUpdatedEvent =
 "{" +
 "\"QuotaUsageUpdatedEvent\":{" +
+"\"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
 "\"quotaRoot\":\"foo\"," +
 "
\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," +
 "\"time\":\"\"," +

http://git-wip-us.apache.org/repos/asf/james-project/blob/60919d85/mailbox/event/json/src/test/ja

[3/3] james-project git commit: MAILBOX-366 Events should carry an EventId

2019-01-08 Thread btellier
MAILBOX-366 Events should carry an EventId


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

Branch: refs/heads/master
Commit: 60919d8591622d2f53365cdb2d2db5138e6a7065
Parents: a4533f0
Author: Benoit Tellier 
Authored: Tue Dec 25 08:43:23 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 15:43:14 2019 +0700

--
 .../java/org/apache/james/mailbox/Event.java|   2 +
 .../apache/james/mailbox/MailboxListener.java   |  96 +--
 .../apache/james/mailbox/MessageMoveEvent.java  |  24 +++-
 .../james/mailbox/MailboxListenerTest.java  |  36 +++---
 .../james/mailbox/events/EventBusContract.java  |  11 +-
 .../james/event/json/EventSerializer.scala  |  54 ++---
 .../event/json/AddedSerializationTest.java  |  45 ++-
 .../event/json/ExpungedSerializationTest.java   |  34 +-
 .../json/FlagsUpdatedSerializationTest.java |  30 -
 ...MailboxACLUpdatedEventSerializationTest.java |  31 -
 .../json/MailboxAddedSerializationTest.java |  26 -
 .../json/MailboxDeletionSerializationTest.java  |  33 +-
 .../json/MailboxRenamedSerializationTest.java   |  34 +-
 .../json/MessageMoveEventSerializationTest.java |  33 ++
 ...QuotaUsageUpdatedEventSerializationTest.java |  14 ++-
 .../james/event/json/SerializerFixture.java |   5 +
 .../james/event/json/dtos/EventIdTest.java  |  65 +++
 .../QuotaThresholdConfigurationChangesTest.java | 105 ++---
 .../QuotaThresholdMailingIntegrationTest.java   | 117 ++-
 .../ElasticSearchQuotaMailboxListenerTest.java  |   2 +
 .../json/QuotaRatioToElasticSearchJsonTest.java |   5 +-
 .../spamassassin/SpamAssassinListenerTest.java  |   2 +
 .../mailbox/store/StoreMailboxManager.java  |   4 +
 .../mailbox/store/StoreMessageIdManager.java|   4 +
 .../mailbox/store/StoreMessageManager.java  |   6 +
 .../james/mailbox/store/StoreRightManager.java  |   2 +
 .../james/mailbox/store/event/EventFactory.java |  82 -
 .../quota/ListeningCurrentQuotaUpdater.java |   2 +
 .../store/MessageIdManagerTestSystem.java   |   1 +
 .../DefaultDelegatingMailboxListenerTest.java   |  25 ++--
 .../event/MailboxAnnotationListenerTest.java|   4 +-
 .../base/MailboxEventAnalyserTest.java  |  10 +-
 .../processor/base/SelectedMailboxImplTest.java |   1 +
 33 files changed, 660 insertions(+), 285 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/60919d85/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
--
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
index 8658653..bb26f1e 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
@@ -78,4 +78,6 @@ public interface Event {
 User getUser();
 
 boolean isNoop();
+
+EventId getEventId();
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/60919d85/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 9e66023..7eb3709 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -77,13 +77,15 @@ public interface MailboxListener {
 }
 
 class QuotaUsageUpdatedEvent implements QuotaEvent {
+private final EventId eventId;
 private final User user;
 private final QuotaRoot quotaRoot;
 private final Quota countQuota;
 private final Quota sizeQuota;
 private final Instant instant;
 
-public QuotaUsageUpdatedEvent(User user, QuotaRoot quotaRoot, 
Quota countQuota, Quota sizeQuota, Instant instant) {
+public QuotaUsageUpdatedEvent(EventId eventId, User user, QuotaRoot 
quotaRoot, Quota countQuota, Quota sizeQuota, Instant 
instant) {
+this.eventId = eventId;
 this.user = user;
 this.quotaRoot = quotaRoot;
 this.countQuota = countQuota;
@@ -119,11 +121,17 @@ public interface MailboxListener {
 }
 
 @Override
+public EventId getEventId() {
+return eventId;
+}
+
+@Override
 public final boolean equals(Object o) {
 if 

[1/3] james-project git commit: MAILBOX-366 Create an EventId POJO

2019-01-08 Thread btellier
Repository: james-project
Updated Branches:
  refs/heads/master d5ff60a73 -> 60919d859


MAILBOX-366 Create an EventId POJO


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

Branch: refs/heads/master
Commit: a4533f07038608f3cbcc34d190560f92d2ad5774
Parents: d5ff60a
Author: Benoit Tellier 
Authored: Tue Dec 25 08:42:08 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 15:09:34 2019 +0700

--
 .../java/org/apache/james/mailbox/Event.java| 53 
 .../org/apache/james/mailbox/EventTest.java | 43 
 2 files changed, 96 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/a4533f07/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
--
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
index 67ba616..8658653 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
@@ -18,10 +18,63 @@
  /
 package org.apache.james.mailbox;
 
+import java.util.Objects;
+import java.util.UUID;
+
 import org.apache.james.core.User;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+
 public interface Event {
 
+class EventId {
+public static EventId of(UUID uuid) {
+return new EventId(uuid);
+}
+
+public static EventId random() {
+return new EventId(UUID.randomUUID());
+}
+
+public static EventId of(String serialized) {
+return of(UUID.fromString(serialized));
+}
+
+private final UUID id;
+
+private EventId(UUID id) {
+Preconditions.checkNotNull(id);
+this.id = id;
+}
+
+public UUID getId() {
+return id;
+}
+
+@Override
+public final boolean equals(Object o) {
+if (o instanceof EventId) {
+EventId eventId = (EventId) o;
+
+return Objects.equals(this.id, eventId.id);
+}
+return false;
+}
+
+@Override
+public final int hashCode() {
+return Objects.hash(id);
+}
+
+@Override
+public String toString() {
+return MoreObjects.toStringHelper(this)
+.add("id", id)
+.toString();
+}
+}
+
 User getUser();
 
 boolean isNoop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a4533f07/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
--
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
new file mode 100644
index 000..62e6399
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
@@ -0,0 +1,43 @@
+/
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information*
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the*
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *  *
+ *   http://www.apache.org/licenses/LICENSE-2.0 *
+ *  *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
+ * KIND, either express or implied.  See the License for the*
+ * specific language governing permissions and limitations  *
+ * under the License.   *
+ /
+
+package org.apache.james.mailbox;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class EventTest {
+private static final UUID UUID_1 = 
UUID.fromString("6

[jira] [Commented] (JAMES-2641) Replace MailboxDispatcher & Delegating listener by the new event bus

2019-01-08 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736863#comment-16736863
 ] 

Tellier Benoit commented on JAMES-2641:
---

As a first steap, https://github.com/linagora/james-project/pull/2081  
JAMES-2641 Remove MailboxEventDispatcher

> Replace MailboxDispatcher & Delegating listener by the new event bus
> 
>
> Key: JAMES-2641
> URL: https://issues.apache.org/jira/browse/JAMES-2641
> Project: James Server
>  Issue Type: Improvement
>Reporter: Trần Tiến Đức
>Priority: Major
>
> You will make James use APIs defined in new EventBus instead than the 
> previous one.
> You will remove:
>  - `MailboxListenerSupport API`
>  - `MailboxEventDispatcher` class
>  - `DelegatingMailboxListener` & sub classes
> Rather than calling Mailbox Support, call the EventBus
> Note that:
>  - EventBus initialization should never be done in the MailboxManager (a 
> ready to use EventBus should be passed to it).
> This can be done in 2 steps:
>  - Keeping the MailboxManager as a proxy
>  - Then in a second PR directly calling the EventBus
> **edited**
> improvement: `MailboxEventDisplatcher` exposes some convenience methods for 
> easily creating events. We need, as part of `EventFactory` to propose 
> builders for Mailbox events.
> Note that as part of this effort, we need to get rid of the 
> MailboxEventDispatcher whose last responsibility is "not firing noop events". 
> We need to move the `isNoop()` method to the Event API in order to be able to 
> filter our noop event without having knowledge of the event details. 
> Filtering noop should then be a responsibility of the EventBus (and as a 
> temporary step of the DelegatingMailboxListener). In order to filter noop in 
> an agnostic way, we need to add a `isnoop()` method in the event bus.
> Once these 2 preliminary steps are done we can:
>  - Remove the `MailboxEventDispatcher` (event emition can then directly be 
> done on top of the delegatingListener/EventBus=
>  - Replace the DelegatingListener by the EventBus.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (MAILBOX-359) Scala Event JSON DTOs

2019-01-08 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/MAILBOX-359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736861#comment-16736861
 ] 

Tellier Benoit commented on MAILBOX-359:


https://github.com/linagora/james-project/pull/2058 MAILBOX-359 EventFactory 
should expose builders for events

Following 
https://github.com/linagora/james-project/pull/2045#discussion_r242102511 here 
are builders in EventFactory for Mailbox Events.

This is part of a larger refactoring whose step 2 gonna feature **Dispatcher** 
removal: Event emitters will directly emit their events using these builders on 
the DelegatingListener, which will later be the EventBus...

> Scala Event JSON DTOs
> -
>
> Key: MAILBOX-359
> URL: https://issues.apache.org/jira/browse/MAILBOX-359
> Project: James Mailbox
>  Issue Type: New Feature
>  Components: events
>Reporter: Tellier Benoit
>Priority: Major
> Fix For: 3.3.0
>
>
> Objective:
>  - Have an extensive, `Event` serialization system based on this POC 
> https://github.com/linagora/james-project/pull/1978
> You will introduce tests & serialization for MailboxEvent : `Added Expunged 
> FlagsUpdated MailboxRenamed MailboxDeletion MailboxAdded` in a separate maven 
> module (`mailbox/events/json`)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (JAMES-2636) RecipientRewriteTable should be able to store 'alias:' mapping prefix

2019-01-08 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736864#comment-16736864
 ] 

Tellier Benoit commented on JAMES-2636:
---

https://github.com/linagora/james-project/pull/2078 contributed some minor API 
improvments

> RecipientRewriteTable should be able to store 'alias:' mapping prefix
> -
>
> Key: JAMES-2636
> URL: https://issues.apache.org/jira/browse/JAMES-2636
> Project: James Server
>  Issue Type: New Feature
>  Components: RRT
>Reporter: Tellier Benoit
>Priority: Major
>
> We would like to keep the intent in our redirection component, hence we have 
> to introduce a new kind of Mapping Type: `Alias`.
>  - Add it to the Type enumeration - and update the corresponding tests.
>  - Modify the RecipientRewriteTable class so that I can add - remove alias 
> mappings - and update the corresponding tests (CRUD).
> new `Alias` type should be located in `org.apache.james.rrt.lib.Mapping.Type`



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (MAILBOX-367) Create a 'publish-only' RabbitMQEventBus

2019-01-08 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/MAILBOX-367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736862#comment-16736862
 ] 

Tellier Benoit commented on MAILBOX-367:


https://github.com/linagora/james-project/pull/2082 MAILBOX-367 Publish 
RabbitMQ EventBus

- Regarding EventBus registration support APIs throw `NotImplemented exceptions`
- Publishing all incoming events
- Publishing test 

Some pending remarks will lead to further work.

> Create a 'publish-only' RabbitMQEventBus
> 
>
> Key: MAILBOX-367
> URL: https://issues.apache.org/jira/browse/MAILBOX-367
> Project: James Mailbox
>  Issue Type: Improvement
>Reporter: Trần Tiến Đức
>Priority: Major
>
> Start the implementation of the RabbitMQEventBus in `mailbox/events/rabbitmq` 
> using the API defined in MAILBOX-364
> - Regarding EventBus registration support APIs throw `NotImplemented 
> exceptions`
>  - Upon start, use the RabbitMQ channel pool and creat a `mailboxEvent` 
> exchange on rabbit MQ
>  - Then reusing work of MAILBOX-359 publish all incoming events on that 
> exchange.
> To test your work, connect a single instance of RabbitMQEventBus, create a 
> queue bounded to the exchange. Ensure that upon events, you end up with a 
> message in that queue.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (MAILBOX-359) Scala Event JSON DTOs

2019-01-08 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/MAILBOX-359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736860#comment-16736860
 ] 

Tellier Benoit commented on MAILBOX-359:


https://github.com/linagora/james-project/pull/2064 MAILBOX-359 Use 
composability to reduce JSON event serialization tests

> Scala Event JSON DTOs
> -
>
> Key: MAILBOX-359
> URL: https://issues.apache.org/jira/browse/MAILBOX-359
> Project: James Mailbox
>  Issue Type: New Feature
>  Components: events
>Reporter: Tellier Benoit
>Priority: Major
> Fix For: 3.3.0
>
>
> Objective:
>  - Have an extensive, `Event` serialization system based on this POC 
> https://github.com/linagora/james-project/pull/1978
> You will introduce tests & serialization for MailboxEvent : `Added Expunged 
> FlagsUpdated MailboxRenamed MailboxDeletion MailboxAdded` in a separate maven 
> module (`mailbox/events/json`)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[18/47] james-project git commit: MAILBOX-359 ReIndent QuotaUsageUpdatedEventSerializationTest

2019-01-08 Thread btellier
MAILBOX-359 ReIndent QuotaUsageUpdatedEventSerializationTest


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

Branch: refs/heads/master
Commit: 4d6a372213fef7194a9cfa2840336f96d6769126
Parents: 0781849
Author: Benoit Tellier 
Authored: Mon Jan 7 18:10:40 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:53 2019 +0700

--
 ...QuotaUsageUpdatedEventSerializationTest.java | 88 ++--
 1 file changed, 44 insertions(+), 44 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/4d6a3722/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
index 608bee3..4ce097d 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
@@ -55,14 +55,14 @@ class QuotaUsageUpdatedEventSerializationTest {
 INSTANT);
 private final String quotaUsageUpdatedEvent =
 "{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
-"\"time\":\"2018-11-13T12:00:55Z\"," +
-"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
-"\"user\":\"onlyUsername\"" +
-"}" +
-"}";
+"\"QuotaUsageUpdatedEvent\":{" +
+"\"quotaRoot\":\"foo\"," +
+"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
+"\"time\":\"2018-11-13T12:00:55Z\"," +
+"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," 
+
+"\"user\":\"onlyUsername\"" +
+"}" +
+"}";
 
 @Test
 void fromJsonShouldReturnQuotaEvent() {
@@ -80,13 +80,13 @@ class QuotaUsageUpdatedEventSerializationTest {
 void fromJsonShouldThrowResultWhenUserIsMissing() {
 String quotaUsageUpdatedEvent =
 "{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
-"\"time\":\"2018-11-13T12:00:55Z\"," +
-"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}" +
-"}" +
-"}";
+"\"QuotaUsageUpdatedEvent\":{" +
+"\"quotaRoot\":\"foo\"," +
+"
\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
+"\"time\":\"2018-11-13T12:00:55Z\"," +
+"
\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}" +
+"}" +
+"}";
 
 assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
 .isInstanceOf(NoSuchElementException.class);
@@ -96,13 +96,13 @@ class QuotaUsageUpdatedEventSerializationTest {
 void fromJsonShouldThrowWhenCountQuotaIsMissing() {
 String quotaUsageUpdatedEvent =
 "{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-"\"time\":\"2018-11-13T12:00:55Z\"," +
-"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," 
+
-"\"user\":\"onlyUsername\"" +
-"}" +
-"}";
+"\"QuotaUsageUpdatedEvent\":{" +
+"\"quotaRoot\":\"foo\"," +
+"\"time\":\"2018-11-13T12:00:55Z\"," +
+"
\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
+"\"user\":\"onlyUsername\"" +
+"}" +
+"}";
 
 assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
 .isInstanceOf(NoSuchElementException.class);
@@ -112,13 +112,13 @@ class QuotaUsageUpdatedEventSerializationTest {
 void fromJsonShouldThrowWhenSizeQuotaIsMissing() {
 String quotaUsageUpdatedEvent =
 "{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-"\"time\":\"2018-11-13T12:00:55Z\"," +
-"\"countQuota\":{\"used\":12,\"li

[03/47] james-project git commit: MAILBOX-359 Factorize tests for UpdatedFlags ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for UpdatedFlags ser-deserialization


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

Branch: refs/heads/master
Commit: b458e40508df877d7d87724073a6f2ba6f380e0d
Parents: 5383b12
Author: Benoit Tellier 
Authored: Mon Dec 24 15:34:47 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../json/FlagsUpdatedSerializationTest.java | 143 ---
 .../james/event/json/dtos/UpdatedFlagsTest.java |  92 
 2 files changed, 92 insertions(+), 143 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/b458e405/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
index 12874ee..0fee8a15 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
@@ -296,148 +296,5 @@ class FlagsUpdatedSerializationTest {
 "}").get())
 .isInstanceOf(NoSuchElementException.class);
 }
-
-@Nested
-class DeserializationErrorOnUpdatedFlags {
-@Nested
-class DeserializationErrorOnMoqSeq {
-
-@Test
-void flagsUpdatedShouldThrowWhenMoqSeqIsAString() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"FlagsUpdated\": {" +
-"\"path\": {" +
-"  \"namespace\": 482," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"sessionId\": 42," +
-"\"updatedFlags\": [" +
-"  {" +
-"\"uid\": 123456," +
-"\"modSeq\": \"35\"," +
-"\"oldFlags\": 
{\"systemFlags\":[\"Deleted\",\"Seen\"],\"userFlags\":[\"Old Flag 1\"]}," +
-"\"newFlags\": 
{\"systemFlags\":[\"Answered\",\"Draft\"],\"userFlags\":[\"New Flag 1\"]}" +
-"  }" +
-"]," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void flagsUpdatedShouldThrowWhenMoqSeqIsNull() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"FlagsUpdated\": {" +
-"\"path\": {" +
-"  \"namespace\": 482," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"sessionId\": 42," +
-"\"updatedFlags\": [" +
-"  {" +
-"\"uid\": 123456," +
-"\"modSeq\": null," +
-"\"oldFlags\": 
{\"systemFlags\":[\"Deleted\",\"Seen\"],\"userFlags\":[\"Old Flag 1\"]}," +
-"\"newFlags\": 
{\"systemFlags\":[\"Answered\",\"Draft\"],\"userFlags\":[\"New Flag 1\"]}" +
-"  }" +
-"]," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void flagsUpdatedShouldThrowWhenMoqSeqIsNotALongNumber() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"FlagsUpdated\": {" +
-"\"path\": {" +
-"  \"namespace\": 482," +
-"  \"user\": \"user\"," 

[40/47] james-project git commit: JAMES-2631 ReIndent InMemoryHostSystem

2019-01-08 Thread btellier
JAMES-2631 ReIndent InMemoryHostSystem


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

Branch: refs/heads/master
Commit: 9cdf4ba815bcbd06d2d332018e59b2f76d67739f
Parents: 185810d
Author: Benoit Tellier 
Authored: Mon Jan 7 15:16:25 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:46:16 2019 +0700

--
 .../inmemory/host/InMemoryHostSystem.java   | 223 ++-
 1 file changed, 112 insertions(+), 111 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/9cdf4ba8/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
--
diff --git 
a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
 
b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index aa8bc22..3e4f238 100644
--- 
a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ 
b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -1,111 +1,112 @@
-/
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information*
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the*
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *  *
- *   http://www.apache.org/licenses/LICENSE-2.0 *
- *  *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
- * KIND, either express or implied.  See the License for the*
- * specific language governing permissions and limitations  *
- * under the License.   *
- /
-
-package org.apache.james.mpt.imapmailbox.inmemory.host;
-
-import org.apache.james.core.quota.QuotaCount;
-import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.imap.api.process.ImapProcessor;
-import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
-import org.apache.james.imap.main.DefaultImapDecoderFactory;
-import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxSessionUtil;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
-import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
-import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.StoreSubscriptionManager;
-import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
-import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
-import org.apache.james.mailbox.store.quota.StoreQuotaManager;
-import org.apache.james.metrics.logger.DefaultMetricFactory;
-import org.apache.james.mpt.api.ImapFeatures;
-import org.apache.james.mpt.api.ImapFeatures.Feature;
-import org.apache.james.mpt.host.JamesImapHostSystem;
-
-public class InMemoryHostSystem extends JamesImapHostSystem {
-
-private static final ImapFeatures SUPPORTED_FEATURES = 
ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
-Feature.MOVE_SUPPORT,
-Feature.USER_FLAGS_SUPPORT,
-Feature.QUOTA_SUPPORT,
-Feature.ANNOTATION_SUPPORT,
-Feature.MOD_SEQ_SEARCH);
-
-private StoreMailboxManager mailboxManager;
-private InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager;
-
-public static JamesImapHostSystem build() throws Exception {
-return new InMemoryHostSystem();
-}
-
-@Ov

[08/47] james-project git commit: MAILBOX-359 Factorize tests for MailboxPath ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for MailboxPath ser-deserialization


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

Branch: refs/heads/master
Commit: 70a4fd59c5220489f1c0adff2bdadae64d49d22b
Parents: e64e8e1
Author: Benoit Tellier 
Authored: Mon Dec 24 13:52:24 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  | 267 +--
 .../event/json/ExpungedSerializationTest.java   | 266 +--
 .../json/FlagsUpdatedSerializationTest.java | 286 ++--
 ...MailboxACLUpdatedEventSerializationTest.java | 211 +
 .../json/MailboxAddedSerializationTest.java | 141 --
 .../json/MailboxDeletionSerializationTest.java  | 176 +--
 .../json/MailboxRenamedSerializationTest.java   | 457 +--
 .../james/event/json/dtos/MailboxPathTest.java  | 177 +++
 8 files changed, 296 insertions(+), 1685 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/70a4fd59/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 3af5c28..d71b9e8 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -21,7 +21,6 @@ package org.apache.james.event.json;
 
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
 import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static org.apache.james.mailbox.model.MailboxConstants.USER_NAMESPACE;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
@@ -398,117 +397,6 @@ class AddedSerializationTest {
 }
 
 @Nested
-class NullOrEmptyNameSpaceInMailboxPath {
-
-@Test
-void addedShouldBeWellDeSerializedWhenNullNameSpace() {
-assertThat(EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isEqualTo(DEFAULT_ADDED_EVENT);
-}
-
-@Test
-void addedShouldBeWellDeSerializedWhenEmptyNameSpace() {
-assertThat(EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isEqualTo(DEFAULT_ADDED_EVENT);
-}
-}
-
-@Nested
-class NullUserInMailboxPath {
-private fi

[01/47] james-project git commit: MAILBOX-359 Factorize tests for SessionId ser-deserialization

2019-01-08 Thread btellier
Repository: james-project
Updated Branches:
  refs/heads/master 76374191d -> d5ff60a73


MAILBOX-359 Factorize tests for SessionId ser-deserialization


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

Branch: refs/heads/master
Commit: 8ca8a33073360917a2d0f3aa2ba2a440d05023fe
Parents: 7637419
Author: Benoit Tellier 
Authored: Mon Dec 24 12:59:52 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:56 2019 +0700

--
 .../james/event/json/EventSerializer.scala  |  4 +-
 .../event/json/AddedSerializationTest.java  | 72 ++-
 .../event/json/ExpungedSerializationTest.java   | 72 ++-
 .../json/FlagsUpdatedSerializationTest.java | 76 ++--
 ...MailboxACLUpdatedEventSerializationTest.java | 56 ++-
 .../json/MailboxAddedSerializationTest.java | 34 -
 .../json/MailboxDeletionSerializationTest.java  | 54 ++
 .../json/MailboxRenamedSerializationTest.java   | 38 ++
 .../james/event/json/dtos/SessionIdTest.java| 65 +
 9 files changed, 94 insertions(+), 377 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/8ca8a330/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
--
diff --git 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index af2785e..6418425 100644
--- 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -35,7 +35,7 @@ import play.api.libs.json.{JsError, JsNull, JsNumber, 
JsObject, JsResult, JsStri
 
 import scala.collection.JavaConverters._
 
-private sealed trait Event {
+sealed trait Event {
   def toJava: JavaEvent
 }
 
@@ -190,7 +190,7 @@ private object ScalaConverter {
   }
 }
 
-private class JsonSerialize(mailboxIdFactory: MailboxId.Factory, 
messageIdFactory: MessageId.Factory) {
+class JsonSerialize(mailboxIdFactory: MailboxId.Factory, messageIdFactory: 
MessageId.Factory) {
   implicit val systemFlagsWrites: Writes[SystemFlag] = Writes.enumNameWrites
   implicit val userWriters: Writes[User] = (user: User) => 
JsString(user.asString)
   implicit val quotaRootWrites: Writes[QuotaRoot] = quotaRoot => 
JsString(quotaRoot.getValue)

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ca8a330/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index a96de11..82afcd2 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -510,72 +510,10 @@ class AddedSerializationTest {
 
 @Nested
 class DeserializationErrors {
-
-@Nested
-class DeserializationErrorOnSessionId {
-@Test
-void addedShouldThrowWhenMissingSessionId() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-

[35/47] james-project git commit: JAMES-2636 Remove serial UID from ErrorMappingException

2019-01-08 Thread btellier
JAMES-2636 Remove serial UID from ErrorMappingException


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

Branch: refs/heads/master
Commit: 305c321de80329c358527407a81e6286806a2b44
Parents: 4e2bd7f
Author: Benoit Tellier 
Authored: Fri Jan 4 10:07:23 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:45:33 2019 +0700

--
 .../main/java/org/apache/james/rrt/api/RecipientRewriteTable.java  | 2 --
 1 file changed, 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/305c321d/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
--
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
index bbcece6..7efc0bd 100644
--- 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
+++ 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
@@ -35,8 +35,6 @@ import com.google.common.base.Preconditions;
  */
 public interface RecipientRewriteTable {
 class ErrorMappingException extends Exception {
-private static final long serialVersionUID = 2348752938798L;
-
 public ErrorMappingException(String string) {
 super(string);
 }


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



[41/47] james-project git commit: JAMES-2641 Remove MailboxEventDispatcher

2019-01-08 Thread btellier
http://git-wip-us.apache.org/repos/asf/james-project/blob/31ed391c/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
index 6ec668d..4b5e994 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
@@ -65,8 +65,8 @@ import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
 import org.apache.james.mailbox.store.event.EventFactory;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -133,36 +133,25 @@ public class StoreMessageManager implements 
org.apache.james.mailbox.MessageMana
 private static final Logger LOG = 
LoggerFactory.getLogger(StoreMessageManager.class);
 
 private final EnumSet 
messageCapabilities;
-
+private final DelegatingMailboxListener delegatingMailboxListener;
 private final Mailbox mailbox;
-
-private final MailboxEventDispatcher dispatcher;
-
 private final MailboxSessionMapperFactory mapperFactory;
-
 private final MessageSearchIndex index;
-
 private final StoreRightManager storeRightManager;
-
 private final QuotaManager quotaManager;
-
 private final QuotaRootResolver quotaRootResolver;
-
 private final MailboxPathLocker locker;
-
 private final MessageParser messageParser;
-
 private final Factory messageIdFactory;
-
-private BatchSizes batchSizes = BatchSizes.defaultValues();
+private final BatchSizes batchSizes;
 
-public StoreMessageManager(EnumSet 
messageCapabilities, MailboxSessionMapperFactory mapperFactory, 
MessageSearchIndex index, MailboxEventDispatcher dispatcher,
+public StoreMessageManager(EnumSet 
messageCapabilities, MailboxSessionMapperFactory mapperFactory, 
MessageSearchIndex index, DelegatingMailboxListener delegatingMailboxListener,
MailboxPathLocker locker, Mailbox mailbox,
QuotaManager quotaManager, QuotaRootResolver 
quotaRootResolver, MessageParser messageParser, MessageId.Factory 
messageIdFactory, BatchSizes batchSizes,
StoreRightManager storeRightManager) {
 this.messageCapabilities = messageCapabilities;
+this.delegatingMailboxListener = delegatingMailboxListener;
 this.mailbox = mailbox;
-this.dispatcher = dispatcher;
 this.mapperFactory = mapperFactory;
 this.index = index;
 this.locker = locker;
@@ -188,15 +177,6 @@ public class StoreMessageManager implements 
org.apache.james.mailbox.MessageMana
 }
 
 /**
- * Return the {@link MailboxEventDispatcher} for this Mailbox
- * 
- * @return dispatcher
- */
-protected MailboxEventDispatcher getDispatcher() {
-return dispatcher;
-}
-
-/**
  * Return the underlying {@link Mailbox}
  * 
  * @return mailbox
@@ -276,7 +256,7 @@ public class StoreMessageManager implements 
org.apache.james.mailbox.MessageMana
 }
 Map uids = deleteMarkedInMailbox(set, 
mailboxSession);
 
-dispatcher.event(EventFactory.expunged()
+delegatingMailboxListener.event(EventFactory.expunged()
 .mailboxSession(mailboxSession)
 .mailbox(getMailboxEntity())
 .metaData(ImmutableSortedMap.copyOf(uids))
@@ -422,7 +402,7 @@ public class StoreMessageManager implements 
org.apache.james.mailbox.MessageMana
 
 Mailbox mailbox = getMailboxEntity();
 MailboxMessage copy = copyMessage(message);
-dispatcher.event(EventFactory.added()
+delegatingMailboxListener.event(EventFactory.added()
 .mailboxSession(mailboxSession)
 .mailbox(mailbox)
 .addMessage(copy)
@@ -583,7 +563,7 @@ public class StoreMessageManager implements 
org.apache.james.mailbox.MessageMana
 Iterator it = messageMapper.execute(() -> 
messageMapper.updateFlags(getMailboxEntity(), new FlagsUpdateCalculator(flags, 
flagsUpdateMode), set));
 List updatedFlags = 
Iterators.toStream(it).collect(Guavate.toImmutableList());
 
-dispatcher.event(EventFactory.flagsUpdated()
+delegatingMailboxListener.ev

[42/47] james-project git commit: JAMES-2641 Remove MailboxEventDispatcher

2019-01-08 Thread btellier
JAMES-2641 Remove MailboxEventDispatcher

Let's emmit on the Delegating listener


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

Branch: refs/heads/master
Commit: 31ed391c7b4594b102ab74bc76eca31bd80ae95e
Parents: 9cdf4ba
Author: Benoit Tellier 
Authored: Mon Jan 7 11:55:18 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:46:33 2019 +0700

--
 .../cassandra/CassandraMailboxManager.java  |  7 +--
 .../cassandra/CassandraMessageManager.java  |  8 ++--
 .../CassandraCombinationManagerTest.java|  5 +--
 .../CassandraCombinationManagerTestSystem.java  |  6 +--
 .../CassandraMailboxManagerProvider.java|  9 ++--
 ...CassandraMessageIdManagerSideEffectTest.java |  6 +--
 .../CassandraMessageIdManagerStorageTest.java   |  5 +--
 .../CassandraMessageIdManagerTestSystem.java| 10 ++---
 .../cassandra/CassandraTestSystemFixture.java   | 11 +++--
 .../CassandraMailboxManagerAttachmentTest.java  |  8 ++--
 .../ElasticSearchIntegrationTest.java   |  2 +-
 .../james/mailbox/jpa/JPAMailboxManager.java|  4 +-
 .../james/mailbox/jpa/JPAMessageManager.java|  6 +--
 .../jpa/openjpa/OpenJPAMailboxManager.java  |  6 +--
 .../jpa/openjpa/OpenJPAMessageManager.java  |  6 +--
 .../resources/META-INF/spring/mailbox-jpa.xml   |  5 +--
 .../mailbox/jpa/JpaMailboxManagerProvider.java  |  6 +--
 .../search/LuceneMessageSearchIndexTest.java|  2 +-
 .../META-INF/spring/mailbox-maildir.xml |  5 +--
 .../maildir/MaildirMailboxManagerProvider.java  |  7 +--
 .../inmemory/InMemoryMailboxManager.java|  8 ++--
 .../inmemory/InMemoryMessageManager.java|  6 +--
 .../META-INF/spring/mailbox-memory.xml  |  7 ++-
 .../InMemoryMailboxManagerAttachmentTest.java   |  8 ++--
 .../manager/InMemoryIntegrationResources.java   | 13 ++
 .../InMemoryMessageIdManagerSideEffectTest.java | 12 +++--
 .../search/SimpleMessageSearchIndexTest.java|  2 +-
 .../main/resources/META-INF/spring/quota.xml|  2 +-
 .../META-INF/spring/spring-mailbox.xml  |  6 +--
 .../mailbox/store/StoreMailboxManager.java  | 23 +++---
 .../mailbox/store/StoreMessageIdManager.java| 18 
 .../mailbox/store/StoreMessageManager.java  | 46 ++--
 .../james/mailbox/store/StoreRightManager.java  | 12 ++---
 .../store/event/MailboxEventDispatcher.java | 41 -
 .../quota/ListeningCurrentQuotaUpdater.java | 12 ++---
 .../AbstractMessageIdManagerSideEffectTest.java |  6 +--
 .../store/MessageIdManagerTestSystem.java   |  2 +-
 .../mailbox/store/StoreMailboxManagerTest.java  |  6 +--
 .../mailbox/store/StoreRightManagerTest.java|  9 ++--
 .../quota/ListeningCurrentQuotaUpdaterTest.java |  4 +-
 .../cassandra/host/CassandraHostSystem.java |  8 ++--
 .../inmemory/host/InMemoryHostSystem.java   |  2 +-
 .../mpt/imapmailbox/jpa/host/JPAHostSystem.java |  9 ++--
 .../host/LuceneSearchHostSystem.java|  7 +--
 .../maildir/host/MaildirHostSystem.java |  7 +--
 .../modules/mailbox/CassandraMailboxModule.java |  2 -
 .../modules/mailbox/MemoryMailboxModule.java|  2 -
 .../META-INF/org/apache/james/spring-server.xml |  4 --
 48 files changed, 134 insertions(+), 274 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/31ed391c/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
--
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
index 09c4c31..f963706 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
@@ -36,7 +36,6 @@ import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreMessageManager;
 import org.apache.james.mailbox.store.StoreRightManager;
 import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
@@ -61,8 +60,7 @@ public class CassandraMailboxManager extends 
StoreMailboxManager {
 @Inject
 public CassandraMailboxManager(CassandraMailbox

[30/47] james-project git commit: MAILBOX-364 EventFactory methods can be statics

2019-01-08 Thread btellier
MAILBOX-364 EventFactory methods can be statics


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

Branch: refs/heads/master
Commit: 4eb79904c6c01b7cc087fb92df2a956f5a0c99cf
Parents: 2713b4d
Author: Benoit Tellier 
Authored: Wed Dec 19 14:02:14 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../spamassassin/SpamAssassinListenerTest.java  |  4 ++--
 .../james/mailbox/store/event/EventFactory.java | 16 ++---
 .../store/event/MailboxEventDispatcher.java | 25 +---
 .../event/MailboxAnnotationListenerTest.java|  2 +-
 .../base/MailboxEventAnalyserTest.java  | 16 ++---
 .../processor/base/SelectedMailboxImplTest.java |  2 +-
 6 files changed, 30 insertions(+), 35 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/4eb79904/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
--
diff --git 
a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
 
b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
index ff0db16..a46d836 100644
--- 
a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
+++ 
b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
@@ -232,7 +232,7 @@ public class SpamAssassinListenerTest {
 public void 
eventShouldCallSpamAssassinHamLearningWhenTheMessageIsAddedInInbox() throws 
Exception {
 SimpleMailboxMessage message = createMessage(inbox);
 
-MailboxListener.Added addedEvent = new EventFactory().added()
+MailboxListener.Added addedEvent = EventFactory.added()
 .mailboxSession(MAILBOX_SESSION)
 .mailbox(inbox)
 .addMessage(message)
@@ -247,7 +247,7 @@ public class SpamAssassinListenerTest {
 public void 
eventShouldNotCallSpamAssassinHamLearningWhenTheMessageIsAddedInAMailboxOtherThanInbox()
 throws Exception {
 SimpleMailboxMessage message = createMessage(mailbox1);
 
-MailboxListener.Added addedEvent = new EventFactory().added()
+MailboxListener.Added addedEvent = EventFactory.added()
 .mailboxSession(MAILBOX_SESSION)
 .mailbox(mailbox1)
 .addMessage(message)

http://git-wip-us.apache.org/repos/asf/james-project/blob/4eb79904/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 1c0a477..c581816 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -300,35 +300,35 @@ public class EventFactory {
 }
 }
 
-public AddedBuilder added() {
+public static AddedBuilder added() {
 return new AddedBuilder();
 }
 
-public ExpungedBuilder expunged() {
+public static ExpungedBuilder expunged() {
 return new ExpungedBuilder();
 }
 
-public FlagsUpdatedBuilder flagsUpdated() {
+public static FlagsUpdatedBuilder flagsUpdated() {
 return new FlagsUpdatedBuilder();
 }
 
-public MailboxRenamedBuilder mailboxRenamed() {
+public static MailboxRenamedBuilder mailboxRenamed() {
 return new MailboxRenamedBuilder();
 }
 
-public MailboxDeletionBuilder mailboxDeleted() {
+public static MailboxDeletionBuilder mailboxDeleted() {
 return new MailboxDeletionBuilder();
 }
 
-public MailboxAddedBuilder mailboxAdded() {
+public static MailboxAddedBuilder mailboxAdded() {
 return new MailboxAddedBuilder();
 }
 
-public MailboxAclUpdatedBuilder aclUpdated() {
+public static MailboxAclUpdatedBuilder aclUpdated() {
 return new MailboxAclUpdatedBuilder();
 }
 
-public MessageMoveEvent.Builder moved() {
+public static MessageMoveEvent.Builder moved() {
 return MessageMoveEvent.builder();
 }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/4eb79904/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java

[46/47] james-project git commit: MAILBOX-367 EventBusContract should use real event pojo

2019-01-08 Thread btellier
MAILBOX-367 EventBusContract should use real event pojo

To avoid scala serialization error happens on mock event while running
rabbitmq eventbus


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

Branch: refs/heads/master
Commit: a15bd7053d351ff3210ca3fee6a155a4a4c1ae01
Parents: 0502ae1
Author: datph 
Authored: Mon Jan 7 10:24:59 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:47:47 2019 +0700

--
 .../james/mailbox/events/EventBusContract.java  | 51 +++-
 1 file changed, 28 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/a15bd705/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
index 236ee75..23743a5 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
@@ -38,6 +38,7 @@ import java.util.concurrent.CountDownLatch;
 import org.apache.james.core.User;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;
@@ -47,7 +48,11 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSortedMap;
 
 public interface EventBusContract {
-MailboxListener.MailboxEvent event = 
mock(MailboxListener.MailboxEvent.class);
+MailboxListener.MailboxEvent EVENT = new MailboxListener.MailboxAdded(
+MailboxSession.SessionId.of(42),
+User.fromUsername("user"),
+new MailboxPath(MailboxConstants.USER_NAMESPACE, "user", 
"mailboxName"),
+TestId.of(18));
 
 class GroupA extends Group {}
 
@@ -73,7 +78,7 @@ public interface EventBusContract {
 
 eventBus().register(listener, new GroupA());
 
-eventBus().dispatch(event, NO_KEYS).block();
+eventBus().dispatch(EVENT, NO_KEYS).block();
 
 verify(listener, times(1)).event(any());
 }
@@ -109,7 +114,7 @@ public interface EventBusContract {
 
 eventBus().register(listener, new GroupA());
 
-assertThatCode(() -> eventBus().dispatch(event, NO_KEYS).block())
+assertThatCode(() -> eventBus().dispatch(EVENT, NO_KEYS).block())
 .doesNotThrowAnyException();
 }
 
@@ -120,7 +125,7 @@ public interface EventBusContract {
 
 eventBus().register(listener, KEY_1);
 
-assertThatCode(() -> eventBus().dispatch(event, NO_KEYS).block())
+assertThatCode(() -> eventBus().dispatch(EVENT, NO_KEYS).block())
 .doesNotThrowAnyException();
 }
 
@@ -131,7 +136,7 @@ public interface EventBusContract {
 eventBus().register(listener, new GroupA());
 eventBus().register(listener2, new GroupB());
 
-eventBus().dispatch(event, NO_KEYS).block();
+eventBus().dispatch(EVENT, NO_KEYS).block();
 
 verify(listener, times(1)).event(any());
 verify(listener2, times(1)).event(any());
@@ -144,7 +149,7 @@ public interface EventBusContract {
 
 registration.unregister();
 
-eventBus().dispatch(event, NO_KEYS).block();
+eventBus().dispatch(EVENT, NO_KEYS).block();
 verifyZeroInteractions(listener);
 }
 
@@ -188,7 +193,7 @@ public interface EventBusContract {
 eventBus().register(listener, new GroupA()).unregister();
 eventBus().register(listener, new GroupA());
 
-eventBus().dispatch(event, NO_KEYS).block();
+eventBus().dispatch(EVENT, NO_KEYS).block();
 
 verify(listener, times(1)).event(any());
 }
@@ -198,7 +203,7 @@ public interface EventBusContract {
 MailboxListener listener = newListener();
 eventBus().register(listener, KEY_1);
 
-eventBus().dispatch(event, NO_KEYS).block();
+eventBus().dispatch(EVENT, NO_KEYS).block();
 
 verifyZeroInteractions(listener);
 }
@@ -208,7 +213,7 @@ public interface EventBusContract {
 MailboxListener listener = newListener();
 eventBus().register(listener, KEY_1);
 
-eventBus().dispatch(event, ImmutableSet.of(KEY_2)).block();
+eventBus().dispatch(EVENT, ImmutableSet.of(KEY_2)).block();
 
 verifyZeroInteractions(

[39/47] james-project git commit: JAMES-2641 Remove MailboxEventDispatcher extra methods

2019-01-08 Thread btellier
JAMES-2641 Remove MailboxEventDispatcher extra methods

Callers should use directly the builders and call the `event` method

This transform the MailboxEventDispatcher into a useless wrapper around
the delegatingMailboxListener that is now easier to remove.


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

Branch: refs/heads/master
Commit: 185810d05bdea16ada99d4e5f5f94b18c546b87c
Parents: b4d9035
Author: Benoit Tellier 
Authored: Mon Jan 7 11:26:31 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:46:02 2019 +0700

--
 .../mailbox/store/StoreMailboxManager.java  |  28 +++-
 .../mailbox/store/StoreMessageIdManager.java|  35 -
 .../mailbox/store/StoreMessageManager.java  |  80 +++---
 .../james/mailbox/store/StoreRightManager.java  |  13 +-
 .../james/mailbox/store/event/EventFactory.java |  17 +-
 .../store/event/MailboxEventDispatcher.java | 157 +--
 .../quota/ListeningCurrentQuotaUpdater.java |  28 ++--
 .../store/MessageIdManagerTestSystem.java   |   7 +-
 8 files changed, 156 insertions(+), 209 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/185810d0/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index f86b20b..c281068 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -69,6 +69,7 @@ import org.apache.james.mailbox.model.search.MailboxQuery;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.EventFactory;
 import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
@@ -524,7 +525,10 @@ public class StoreMailboxManager implements MailboxManager 
{
 try {
 mapper.execute(Mapper.toTransaction(() -> 
mailboxIds.add(mapper.save(m;
 // notify listeners
-dispatcher.mailboxAdded(mailboxSession, m);
+dispatcher.event(EventFactory.mailboxAdded()
+.mailboxSession(mailboxSession)
+.mailbox(m)
+.build());
 } catch (MailboxExistsException e) {
 LOGGER.info("{} mailbox was created concurrently", 
m.generateAssociatedPath());
 }
@@ -568,7 +572,13 @@ public class StoreMailboxManager implements MailboxManager 
{
 // mailbox once we remove it
 SimpleMailbox m = new SimpleMailbox(mailbox);
 mailboxMapper.delete(mailbox);
-dispatcher.mailboxDeleted(session, mailbox, quotaRoot, 
QuotaCount.count(messageCount), QuotaSize.size(totalSize));
+dispatcher.event(EventFactory.mailboxDeleted()
+.mailboxSession(session)
+.mailbox(mailbox)
+.quotaRoot(quotaRoot)
+.quotaCount(QuotaCount.count(messageCount))
+.quotaSize(QuotaSize.size(totalSize))
+.build());
 return m;
 });
 
@@ -607,7 +617,12 @@ public class StoreMailboxManager implements MailboxManager 
{
 mailbox.setName(to.getName());
 mapper.save(mailbox);
 
-dispatcher.mailboxRenamed(session, from, mailbox);
+dispatcher.event(EventFactory.mailboxRenamed()
+.mailboxSession(session)
+.mailboxId(mailbox.getMailboxId())
+.oldPath(from)
+.newPath(to)
+.build());
 
 // rename submailboxes
 MailboxPath children = new MailboxPath(from.getNamespace(), 
from.getUser(), from.getName() + getDelimiter() + "%");
@@ -619,7 +634,12 @@ public class StoreMailboxManager implements MailboxManager 
{
 MailboxPath fromPath = new MailboxPath(children, 
subOriginalName);
 sub.setName(subNewName);
 mapper.save(sub);
-dispatcher.mailboxRenamed(session, f

[38/47] james-project git commit: JAMES-2641 AbstractMessageIdManagerSideEffectTest should not rely on mock assertions

2019-01-08 Thread btellier
JAMES-2641 AbstractMessageIdManagerSideEffectTest should not rely on mock 
assertions

This makes change harder to test and depends heavily on the underlying 
implementation


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

Branch: refs/heads/master
Commit: b4d9035a67a06592c2ecd57d89c8f34146a4f998
Parents: 8a21cb5
Author: Benoit Tellier 
Authored: Mon Jan 7 11:24:41 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:46:01 2019 +0700

--
 .../AbstractMessageIdManagerSideEffectTest.java | 146 +++
 1 file changed, 86 insertions(+), 60 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/b4d9035a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
--
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
index e98bd59..f1f2c2f 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
@@ -22,12 +22,7 @@ package org.apache.james.mailbox.store;
 import static org.apache.james.mailbox.fixture.MailboxFixture.ALICE;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-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 java.util.List;
@@ -36,11 +31,13 @@ import javax.mail.Flags;
 
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageManager.FlagsUpdateMode;
+import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
@@ -53,14 +50,18 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
+import org.apache.james.mailbox.util.EventCollector;
+import org.assertj.core.api.AbstractListAssert;
+import org.assertj.core.api.ObjectAssert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSortedMap;
 
 public abstract class AbstractMessageIdManagerSideEffectTest {
 private static final Quota OVER_QUOTA = 
Quota.builder()
@@ -70,28 +71,31 @@ public abstract class 
AbstractMessageIdManagerSideEffectTest {
 private static final MessageUid messageUid1 = MessageUid.of(111);
 private static final MessageUid messageUid2 = MessageUid.of(113);
 
-public static final Flags FLAGS = new Flags();
+private static final Flags FLAGS = new Flags();
+private static final MailboxSession SESSION = 
MailboxSessionUtil.create("any");
 
 @Rule
 public ExpectedException expectedException = ExpectedException.none();
 
 private MessageIdManager messageIdManager;
-private MailboxEventDispatcher dispatcher;
 private MailboxSession session;
 private Mailbox mailbox1;
 private Mailbox mailbox2;
 private Mailbox mailbox3;
 private QuotaManager quotaManager;
 private MessageIdManagerTestSystem testingData;
+private EventCollector eventCollector;
+private DefaultDelegatingMailboxListener delegatingMailboxListener;
 
 protected abstract MessageIdManagerTestSystem 
createTestSystem(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) 
throws Exception;

[45/47] james-project git commit: MAILBOX-367 Factorise RabbitMQ constants

2019-01-08 Thread btellier
MAILBOX-367 Factorise RabbitMQ constants


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

Branch: refs/heads/master
Commit: 0502ae1fbbecefec9bd16fcf3172c8467229058f
Parents: 31ed391
Author: datph 
Authored: Mon Jan 7 09:24:26 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:47:47 2019 +0700

--
 .../james/backend/rabbitmq/Constants.java   | 41 
 .../backend/rabbitmq/RabbitMQClusterTest.java   | 20 +-
 .../james/backend/rabbitmq/RabbitMQFixture.java | 30 ++
 .../james/backend/rabbitmq/RabbitMQTest.java| 18 -
 .../james/queue/rabbitmq/RabbitClient.java  | 24 ++--
 5 files changed, 82 insertions(+), 51 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/0502ae1f/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/Constants.java
--
diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/Constants.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/Constants.java
new file mode 100644
index 000..4fc2410
--- /dev/null
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/Constants.java
@@ -0,0 +1,41 @@
+/
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information*
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the*
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *  *
+ *   http://www.apache.org/licenses/LICENSE-2.0 *
+ *  *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
+ * KIND, either express or implied.  See the License for the*
+ * specific language governing permissions and limitations  *
+ * under the License.   *
+ /
+
+package org.apache.james.backend.rabbitmq;
+
+import com.google.common.collect.ImmutableMap;
+import com.rabbitmq.client.AMQP;
+
+public interface Constants {
+boolean DURABLE = true;
+boolean AUTO_DELETE = true;
+boolean EXCLUSIVE = true;
+
+boolean AUTO_ACK = true;
+boolean MULTIPLE = true;
+
+String EMPTY_ROUTING_KEY = "";
+boolean REQUEUE = true;
+
+String DIRECT_EXCHANGE = "direct";
+
+AMQP.BasicProperties NO_PROPERTIES = new AMQP.BasicProperties();
+
+ImmutableMap NO_ARGUMENTS = ImmutableMap.of();
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0502ae1f/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQClusterTest.java
--
diff --git 
a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQClusterTest.java
 
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQClusterTest.java
index 1b2496d..348d3ff 100644
--- 
a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQClusterTest.java
+++ 
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQClusterTest.java
@@ -18,12 +18,12 @@
  /
 package org.apache.james.backend.rabbitmq;
 
-import static org.apache.james.backend.rabbitmq.RabbitMQFixture.AUTO_DELETE;
-import static org.apache.james.backend.rabbitmq.RabbitMQFixture.DIRECT;
-import static org.apache.james.backend.rabbitmq.RabbitMQFixture.DURABLE;
+import static org.apache.james.backend.rabbitmq.Constants.AUTO_DELETE;
+import static org.apache.james.backend.rabbitmq.Constants.DIRECT_EXCHANGE;
+import static org.apache.james.backend.rabbitmq.Constants.DURABLE;
+import static org.apache.james.backend.rabbitmq.Constants.EXCLUSIVE;
+import static org.apache.james.backend.rabbitmq.Constants.NO_PROPERTIES;
 import static org.apache.james.backend.rabbitmq.RabbitMQFixture.EXCHANGE_NAME;
-import static org.apache.james.backend.rabbitmq.RabbitMQFixture.EXCLUS

[47/47] james-project git commit: Adding LICENSE for project

2019-01-08 Thread btellier
Adding LICENSE for project


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

Branch: refs/heads/master
Commit: d5ff60a7376b94e2f6514f829d9aaab75b6a6fb6
Parents: b1e241c
Author: Trần Tiến Đức 
Authored: Sun Jan 6 13:42:54 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:51:54 2019 +0700

--
 LICENSE | 176 +++
 1 file changed, 176 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ff60a7/LICENSE
--
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000..d9a10c0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,176 @@
+ Apache License
+   Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+  "License" shall mean the terms and conditions for use, reproduction,
+  and distribution as defined by Sections 1 through 9 of this document.
+
+  "Licensor" shall mean the copyright owner or entity authorized by
+  the copyright owner that is granting the License.
+
+  "Legal Entity" shall mean the union of the acting entity and all
+  other entities that control, are controlled by, or are under common
+  control with that entity. For the purposes of this definition,
+  "control" means (i) the power, direct or indirect, to cause the
+  direction or management of such entity, whether by contract or
+  otherwise, or (ii) ownership of fifty percent (50%) or more of the
+  outstanding shares, or (iii) beneficial ownership of such entity.
+
+  "You" (or "Your") shall mean an individual or Legal Entity
+  exercising permissions granted by this License.
+
+  "Source" form shall mean the preferred form for making modifications,
+  including but not limited to software source code, documentation
+  source, and configuration files.
+
+  "Object" form shall mean any form resulting from mechanical
+  transformation or translation of a Source form, including but
+  not limited to compiled object code, generated documentation,
+  and conversions to other media types.
+
+  "Work" shall mean the work of authorship, whether in Source or
+  Object form, made available under the License, as indicated by a
+  copyright notice that is included in or attached to the work
+  (an example is provided in the Appendix below).
+
+  "Derivative Works" shall mean any work, whether in Source or Object
+  form, that is based on (or derived from) the Work and for which the
+  editorial revisions, annotations, elaborations, or other modifications
+  represent, as a whole, an original work of authorship. For the purposes
+  of this License, Derivative Works shall not include works that remain
+  separable from, or merely link (or bind by name) to the interfaces of,
+  the Work and Derivative Works thereof.
+
+  "Contribution" shall mean any work of authorship, including
+  the original version of the Work and any modifications or additions
+  to that Work or Derivative Works thereof, that is intentionally
+  submitted to Licensor for inclusion in the Work by the copyright owner
+  or by an individual or Legal Entity authorized to submit on behalf of
+  the copyright owner. For the purposes of this definition, "submitted"
+  means any form of electronic, verbal, or written communication sent
+  to the Licensor or its representatives, including but not limited to
+  communication on electronic mailing lists, source code control systems,
+  and issue tracking systems that are managed by, or on behalf of, the
+  Licensor for the purpose of discussing and improving the Work, but
+  excluding communication that is conspicuously marked or otherwise
+  designated in writing by the copyright owner as "Not a Contribution."
+
+  "Contributor" shall mean Licensor and any individual or Legal Entity
+  on behalf of whom a Contribution has been received by Licensor and
+  subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+  this License, each Contributor hereby grants to You a perpetual,
+  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+  copyright license to reproduce, prepare Derivative Works of,
+  publicly display, publicly perform, sublicense, and distribute the
+ 

[44/47] james-project git commit: MAILBOX-367 Add mockito timeouts in EventBus contracts

2019-01-08 Thread btellier
MAILBOX-367 Add mockito timeouts in EventBus contracts

This allow asynchronous EventBus implementations
EventBusContract should also use verify no interaction in time window


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

Branch: refs/heads/master
Commit: f1ac8368ac641c7d5bc819a878ac725c649cdb27
Parents: a15bd70
Author: datph 
Authored: Mon Jan 7 10:27:25 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:47:47 2019 +0700

--
 .../james/mailbox/events/EventBusContract.java  | 56 
 1 file changed, 34 insertions(+), 22 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/f1ac8368/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
index 23743a5..465ed77 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusContract.java
@@ -23,16 +23,17 @@ import static 
org.assertj.core.api.Assertions.assertThatCode;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertTimeout;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.after;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import java.time.Duration;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.james.core.User;
@@ -44,6 +45,7 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;
 import org.junit.jupiter.api.Test;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSortedMap;
 
@@ -58,11 +60,14 @@ public interface EventBusContract {
 
 class GroupB extends Group {}
 
+int ONE_SECOND = 1000;
+int FIVE_HUNDRED_MS = 500;
 MailboxId ID_1 = TestId.of(18);
 MailboxId ID_2 = TestId.of(24);
 ImmutableSet NO_KEYS = ImmutableSet.of();
 MailboxIdRegistrationKey KEY_1 = new MailboxIdRegistrationKey(ID_1);
 MailboxIdRegistrationKey KEY_2 = new MailboxIdRegistrationKey(ID_2);
+List> ALL_GROUPS = ImmutableList.of(GroupA.class, 
GroupB.class);
 
 EventBus eventBus();
 
@@ -80,7 +85,7 @@ public interface EventBusContract {
 
 eventBus().dispatch(EVENT, NO_KEYS).block();
 
-verify(listener, times(1)).event(any());
+verify(listener, timeout(ONE_SECOND).times(1)).event(any());
 }
 
 @Test
@@ -138,8 +143,8 @@ public interface EventBusContract {
 
 eventBus().dispatch(EVENT, NO_KEYS).block();
 
-verify(listener, times(1)).event(any());
-verify(listener2, times(1)).event(any());
+verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+verify(listener2, timeout(ONE_SECOND).times(1)).event(any());
 }
 
 @Test
@@ -150,7 +155,8 @@ public interface EventBusContract {
 registration.unregister();
 
 eventBus().dispatch(EVENT, NO_KEYS).block();
-verifyZeroInteractions(listener);
+verify(listener, after(FIVE_HUNDRED_MS).never())
+.event(any());
 }
 
 @Test
@@ -195,7 +201,7 @@ public interface EventBusContract {
 
 eventBus().dispatch(EVENT, NO_KEYS).block();
 
-verify(listener, times(1)).event(any());
+verify(listener, timeout(ONE_SECOND).times(1)).event(any());
 }
 
 @Test
@@ -205,7 +211,8 @@ public interface EventBusContract {
 
 eventBus().dispatch(EVENT, NO_KEYS).block();
 
-verifyZeroInteractions(listener);
+verify(listener, after(FIVE_HUNDRED_MS).never())
+.event(any());
 }
 
 @Test
@@ -215,7 +222,8 @@ public interface EventBusContract {
 
 eventBus().dispatch(EVENT, ImmutableSet.of(KEY_2)).block();
 
-verifyZeroInteractions(listener);
+verify(listener, after(FIVE_HUNDRED_MS).never())
+.event(any());
 }
 
 @Test
@@ -225,7 +233,7 @@ public inter

[43/47] james-project git commit: MAILBOX-367 RabbitMQEvenBus should publish events

2019-01-08 Thread btellier
MAILBOX-367 RabbitMQEvenBus should publish events


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

Branch: refs/heads/master
Commit: b1e241c4dc8e39174efa12eb400cd2a2f0cc633b
Parents: f1ac836
Author: datph 
Authored: Mon Jan 7 10:33:37 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:47:47 2019 +0700

--
 .../backend/rabbitmq/RabbitMQExtension.java |   9 +-
 mailbox/event/event-rabbitmq/pom.xml| 101 
 .../james/mailbox/events/RabbitMQEventBus.java  |  89 ++
 .../events/RabbitMQEventBusPublishingTest.java  | 121 +++
 mailbox/pom.xml |   1 +
 pom.xml |   7 +-
 6 files changed, 325 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/b1e241c4/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQExtension.java
--
diff --git 
a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQExtension.java
 
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQExtension.java
index d6d2ead..a64c95f 100644
--- 
a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQExtension.java
+++ 
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQExtension.java
@@ -43,6 +43,7 @@ public class RabbitMQExtension implements BeforeAllCallback, 
BeforeEachCallback,
 
 private DockerRabbitMQ rabbitMQ;
 private SimpleChannelPool simpleChannelPool;
+private RabbitMQConnectionFactory connectionFactory;
 
 @Override
 public void beforeAll(ExtensionContext context) {
@@ -52,7 +53,7 @@ public class RabbitMQExtension implements BeforeAllCallback, 
BeforeEachCallback,
 
 @Override
 public void beforeEach(ExtensionContext extensionContext) throws Exception 
{
-RabbitMQConnectionFactory connectionFactory = 
createRabbitConnectionFactory();
+connectionFactory = createRabbitConnectionFactory();
 this.simpleChannelPool = new SimpleChannelPool(connectionFactory);
 }
 
@@ -84,6 +85,10 @@ public class RabbitMQExtension implements BeforeAllCallback, 
BeforeEachCallback,
 return rabbitMQ;
 }
 
+public RabbitMQConnectionFactory getConnectionFactory() {
+return connectionFactory;
+}
+
 private RabbitMQConnectionFactory createRabbitConnectionFactory() throws 
URISyntaxException {
 RabbitMQConfiguration rabbitMQConfiguration = 
RabbitMQConfiguration.builder()
 .amqpUri(rabbitMQ.amqpUri())
@@ -98,4 +103,4 @@ public class RabbitMQExtension implements BeforeAllCallback, 
BeforeEachCallback,
 rabbitMQConfiguration,
 new 
AsyncRetryExecutor(Executors.newSingleThreadScheduledExecutor(threadFactory)));
 }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/b1e241c4/mailbox/event/event-rabbitmq/pom.xml
--
diff --git a/mailbox/event/event-rabbitmq/pom.xml 
b/mailbox/event/event-rabbitmq/pom.xml
new file mode 100644
index 000..c671468
--- /dev/null
+++ b/mailbox/event/event-rabbitmq/pom.xml
@@ -0,0 +1,101 @@
+
+
+http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+4.0.0
+
+
+apache-james-mailbox
+org.apache.james
+3.3.0-SNAPSHOT
+../../pom.xml
+
+
+apache-james-mailbox-event-rabbitmq
+Apache James :: Mailbox :: Event :: RabbitMQ implementation
+RabbitMQ implementation for the eventbus API
+
+
+
+${project.groupId}
+apache-james-backends-rabbitmq
+
+
+${project.groupId}
+apache-james-backends-rabbitmq
+test
+test-jar
+
+
+${project.groupId}
+apache-james-mailbox-api
+
+
+${project.groupId}
+apache-james-mailbox-api
+test
+test-jar
+
+
+${project.groupId}
+apache-james-mailbox-event-json
+
+
+${james.groupId}
+james-server-testing
+test
+
+
+com.jayway.awaitility
+awaitility
+test
+
+
+io.projectreactor
+   

[29/47] james-project git commit: MAILBOX-359 Remove MailboxEventDispatcher::ofMailboxListener

2019-01-08 Thread btellier
MAILBOX-359 Remove MailboxEventDispatcher::ofMailboxListener


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

Branch: refs/heads/master
Commit: 1371fad66676f151dd349c6075b36823e3f488cc
Parents: 4eb7990
Author: Benoit Tellier 
Authored: Thu Dec 20 11:32:16 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../cassandra/CassandraCombinationManagerTest.java  |  8 
 .../cassandra/CassandraMessageIdManagerStorageTest.java |  8 
 .../mailbox/store/event/MailboxEventDispatcher.java | 12 +---
 .../james/mailbox/store/MailboxEventDispatcherTest.java |  5 -
 4 files changed, 13 insertions(+), 20 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/1371fad6/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
--
diff --git 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
index f20e7fc..b2d0850 100644
--- 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
+++ 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
@@ -19,14 +19,12 @@
 
 package org.apache.james.mailbox.cassandra;
 
-import static org.mockito.Mockito.mock;
-
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.cassandra.mail.MailboxAggregateModule;
 import org.apache.james.mailbox.store.AbstractCombinationManagerTest;
 import org.apache.james.mailbox.store.CombinationManagerTestSystem;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.quota.NoQuotaManager;
 import org.junit.After;
@@ -64,7 +62,9 @@ public class CassandraCombinationManagerTest extends 
AbstractCombinationManagerT
 
 @Override
 public CombinationManagerTestSystem createTestingData() throws Exception {
-return 
CassandraCombinationManagerTestSystem.createTestingData(cassandra, new 
NoQuotaManager(), 
MailboxEventDispatcher.ofListener(mock(MailboxListener.class)));
+DefaultDelegatingMailboxListener mailboxListener = new 
DefaultDelegatingMailboxListener();
+MailboxEventDispatcher mailboxEventDispatcher = new 
MailboxEventDispatcher(mailboxListener);
+return 
CassandraCombinationManagerTestSystem.createTestingData(cassandra, new 
NoQuotaManager(), mailboxEventDispatcher);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1371fad6/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java
--
diff --git 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java
 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java
index ae35def..6b9a519 100644
--- 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java
+++ 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java
@@ -19,14 +19,12 @@
 
 package org.apache.james.mailbox.cassandra;
 
-import static org.mockito.Mockito.mock;
-
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.cassandra.mail.MailboxAggregateModule;
 import org.apache.james.mailbox.store.AbstractMessageIdManagerStorageTest;
 import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.quota.NoQuotaManager;
 import org.junit.After;
@@ -64,6 +62,8 @@ public class CassandraMessageIdManagerStorageTest extends 
AbstractMessageIdManag
 
 @Override
 protected MessageIdManagerTestSystem createTestingData() throws Exception {
-return 
CassandraMessageIdManagerTestSystem.createTestingData(

[28/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for MailboxRenamed event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for MailboxRenamed event


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

Branch: refs/heads/master
Commit: b5608ad26ee9b306e5d9ee97e7aa5d15bf11f529
Parents: 098dbe4
Author: Benoit Tellier 
Authored: Wed Dec 19 13:52:52 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 39 +---
 .../store/event/MailboxEventDispatcher.java |  7 +++-
 2 files changed, 39 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/b5608ad2/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index de9ed6e..cc8a2f6 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -242,6 +242,37 @@ public class EventFactory {
 }
 }
 
+public static class MailboxRenamedBuilder extends 
MailboxEventBuilder {
+private MailboxPath newPath;
+
+@Override
+protected MailboxRenamedBuilder backReference() {
+return this;
+}
+
+public MailboxRenamedBuilder newPath(MailboxPath newPath) {
+this.newPath = newPath;
+return this;
+}
+
+public MailboxRenamedBuilder oldPath(MailboxPath oldPath) {
+this.path = oldPath;
+return this;
+}
+
+public MailboxListener.MailboxRenamed build() {
+mailboxEventChecks();
+Preconditions.checkState(path != null, "Field `newPath` is 
compulsory");
+
+return new MailboxListener.MailboxRenamed(
+sessionId,
+user,
+path,
+mailboxId,
+newPath);
+}
+}
+
 public static class FlagsUpdatedBuilder extends 
MailboxEventBuilder {
 private final ImmutableList.Builder updatedFlags;
 
@@ -285,12 +316,8 @@ public class EventFactory {
 return new FlagsUpdatedBuilder();
 }
 
-public MailboxListener.MailboxRenamed mailboxRenamed(MailboxSession 
session, MailboxPath from, Mailbox to) {
-return mailboxRenamed(session.getSessionId(), session.getUser(), from, 
to);
-}
-
-public MailboxListener.MailboxRenamed 
mailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath from, 
Mailbox to) {
-return new MailboxListener.MailboxRenamed(sessionId, user, from, 
to.getMailboxId(), to.generateAssociatedPath());
+public MailboxRenamedBuilder mailboxRenamed() {
+return new MailboxRenamedBuilder();
 }
 
 public MailboxDeletionBuilder mailboxDeleted() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/b5608ad2/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index da360d5..e7a8a4f 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -149,7 +149,12 @@ public class MailboxEventDispatcher {
  * MailboxListener will get triggered then
  */
 public void mailboxRenamed(MailboxSession session, MailboxPath from, 
Mailbox to) {
-event(eventFactory.mailboxRenamed(session, from, to));
+event(eventFactory.mailboxRenamed()
+.mailboxSession(session)
+.mailboxId(to.getMailboxId())
+.oldPath(from)
+.newPath(to.generateAssociatedPath())
+.build());
 }
 
 /**


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



[34/47] james-project git commit: JAMES-2636 Enhence RRT API getMapping methods

2019-01-08 Thread btellier
JAMES-2636 Enhence RRT API getMapping methods

The difference between them was subtil (resolved/unresolved) and prooved
to be confusing. Hence I propose a better method naming for solving this
issue.


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

Branch: refs/heads/master
Commit: 4e2bd7fdaa77e405e55b929b658f8cff139b4098
Parents: 887f3c5
Author: Benoit Tellier 
Authored: Fri Jan 4 09:51:01 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:45:33 2019 +0700

--
 .../james/rrt/api/RecipientRewriteTable.java|  4 +-
 .../CassandraRecipientRewriteTable.java |  2 +-
 .../rrt/file/XMLRecipientRewriteTable.java  |  2 +-
 .../rrt/file/XMLRecipientRewriteTableTest.java  |  4 +-
 .../rrt/jdbc/JDBCRecipientRewriteTable.java |  6 +--
 .../james/rrt/jpa/JPARecipientRewriteTable.java |  6 +--
 .../rrt/lib/AbstractRecipientRewriteTable.java  |  4 +-
 .../lib/RecipientRewriteTableManagement.java|  2 +-
 .../user/lib/AbstractJamesUsersRepository.java  |  6 +--
 .../lib/AbstractRecipientRewriteTableTest.java  | 48 ++--
 .../james/rrt/lib/RewriteTablesStepdefs.java|  6 +--
 .../rrt/memory/MemoryRecipientRewriteTable.java |  2 +-
 .../mailets/RecipientRewriteTableProcessor.java |  2 +-
 .../transport/matchers/IsSenderInRRTLoop.java   |  2 +-
 .../RecipientRewriteTableProcessorTest.java | 10 ++--
 .../smtpserver/fastfail/ValidRcptHandler.java   |  2 +-
 .../webadmin/routes/DomainMappingsRoutes.java   |  2 +-
 .../james/webadmin/routes/ForwardRoutes.java|  2 +-
 .../james/webadmin/routes/GroupsRoutes.java |  2 +-
 .../routes/DomainMappingsRoutesTest.java|  8 ++--
 .../webadmin/routes/ForwardRoutesTest.java  |  4 +-
 .../james/webadmin/routes/GroupsRoutesTest.java |  4 +-
 22 files changed, 65 insertions(+), 65 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/4e2bd7fd/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
--
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
index 5c85ed7..bbcece6 100644
--- 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
+++ 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
@@ -88,7 +88,7 @@ public interface RecipientRewriteTable {
  * @throws ErrorMappingException
  * get thrown if an error mapping was found
  */
-Mappings getMappings(String user, Domain domain) throws 
ErrorMappingException, RecipientRewriteTableException;
+Mappings getResolvedMappings(String user, Domain domain) throws 
ErrorMappingException, RecipientRewriteTableException;
 
 /**
  * Return the explicit mapping stored for the given user and domain. Return
@@ -97,7 +97,7 @@ public interface RecipientRewriteTable {
  * @return the collection which holds the mappings.
  * @throws RecipientRewriteTableException
  */
-Mappings getUserDomainMappings(MappingSource source) throws 
RecipientRewriteTableException;
+Mappings getStoredMappings(MappingSource source) throws 
RecipientRewriteTableException;
 
 /**
  * Return a Map which holds all mappings. The key is the user@domain and 
the

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e2bd7fd/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
--
diff --git 
a/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
 
b/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
index 9df03c8..ffefd98 100644
--- 
a/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
+++ 
b/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
@@ -113,7 +113,7 @@ public class CassandraRecipientRewriteTable extends 
AbstractRecipientRewriteTabl
 }
 
 @Override
-public Mappings getUserDomainMappings(MappingSource source) {
+public Mappings getStoredMappings(MappingSource source) {
 return retrieveMappings(source)
 .orElse(null);
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e2bd7fd/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLReci

[25/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for Expunged event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for Expunged event


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

Branch: refs/heads/master
Commit: 2c46d620f1687b4ec7d72a0c137e384eac1f3038
Parents: e829c8e
Author: Benoit Tellier 
Authored: Wed Dec 19 13:35:05 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 38 ++--
 .../store/event/MailboxEventDispatcher.java |  6 +++-
 2 files changed, 33 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/2c46d620/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index cd8a38c..0205560 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.store.event;
 
 import java.util.Collection;
-import java.util.Map;
 
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
@@ -43,6 +42,7 @@ import 
org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import com.github.steveash.guavate.Guavate;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSortedMap;
 
 public class EventFactory {
 public abstract static class MailboxEventBuilder {
@@ -124,6 +124,12 @@ public class EventFactory {
 this.metaData.addAll(metaData);
 return backReference();
 }
+
+protected ImmutableSortedMap 
metaDataAsMap() {
+return metaData.build()
+.stream()
+
.collect(Guavate.toImmutableSortedMap(MessageMetaData::getUid));
+}
 }
 
 public static class AddedBuilder extends 
MessageMetaDataEventBuilder {
@@ -140,9 +146,25 @@ public class EventFactory {
 user,
 path,
 mailboxId,
-metaData.build()
-.stream()
-
.collect(Guavate.toImmutableSortedMap(MessageMetaData::getUid)));
+metaDataAsMap());
+}
+}
+
+public static class ExpungedBuilder extends 
MessageMetaDataEventBuilder {
+@Override
+protected ExpungedBuilder backReference() {
+return this;
+}
+
+public MailboxListener.Expunged build() {
+mailboxEventChecks();
+
+return new MailboxListener.Expunged(
+sessionId,
+user,
+path,
+mailboxId,
+metaDataAsMap());
 }
 }
 
@@ -229,12 +251,8 @@ public class EventFactory {
 return new AddedBuilder();
 }
 
-public MailboxListener.Expunged expunged(MailboxSession session,  
Map uids, Mailbox mailbox) {
-return expunged(session.getSessionId(), session.getUser(), uids, 
mailbox);
-}
-
-public MailboxListener.Expunged expunged(MailboxSession.SessionId 
sessionId, User user, Map uids, Mailbox mailbox) {
-return new MailboxListener.Expunged(sessionId, user, 
mailbox.generateAssociatedPath(), mailbox.getMailboxId(), uids);
+public ExpungedBuilder expunged() {
+return new ExpungedBuilder();
 }
 
 public FlagsUpdatedBuilder flagsUpdated() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/2c46d620/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index 6684b8a..122394f 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -114,7 +114,11 @@ public class MailboxEventDispatcher {
  * @param mailbox The mailbox
  */
 public void expunged(MailboxSession session,  Map uids, Mailbox mailbox) {
-event(eventFactory.expunged(session, uids, mailbox));
+event(eventFactory.expu

[24/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for MailboxAdded event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for MailboxAdded event


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

Branch: refs/heads/master
Commit: 8550ce9d2668a11f7371e3a5f21849306a007d5b
Parents: 4d6a372
Author: Benoit Tellier 
Authored: Wed Dec 19 11:26:09 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 57 +---
 .../store/event/MailboxEventDispatcher.java |  5 +-
 2 files changed, 55 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/8550ce9d/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 4dfd76c..13c6f9d 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -41,7 +41,56 @@ import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+import com.google.common.base.Preconditions;
+
 public class EventFactory {
+public static class MailboxAddedBuilder {
+private MailboxPath path;
+private MailboxId mailboxId;
+private User user;
+private MailboxSession.SessionId sessionId;
+
+public MailboxAddedBuilder mailbox(Mailbox mailbox) {
+path(mailbox.generateAssociatedPath());
+mailboxId(mailbox.getMailboxId());
+return this;
+}
+
+public MailboxAddedBuilder mailboxSession(MailboxSession 
mailboxSession) {
+user(mailboxSession.getUser());
+sessionId(mailboxSession.getSessionId());
+return this;
+}
+
+public MailboxAddedBuilder mailboxId(MailboxId mailboxId) {
+this.mailboxId = mailboxId;
+return this;
+}
+
+public MailboxAddedBuilder path(MailboxPath path) {
+this.path = path;
+return this;
+}
+
+public MailboxAddedBuilder user(User user) {
+this.user = user;
+return this;
+}
+
+public MailboxAddedBuilder sessionId(MailboxSession.SessionId 
sessionId) {
+this.sessionId = sessionId;
+return this;
+}
+
+public MailboxListener.MailboxAdded build() {
+Preconditions.checkState(user != null, "Field `user` is 
compulsory");
+Preconditions.checkState(mailboxId != null, "Field `mailboxId` is 
compulsory");
+Preconditions.checkState(path != null, "Field `path` is 
compulsory");
+Preconditions.checkState(sessionId != null, "Field `sessionId` is 
compulsory");
+
+return new MailboxListener.MailboxAdded(sessionId, user, path, 
mailboxId);
+}
+}
 
 public MailboxListener.Added added(MailboxSession session, 
SortedMap uids, Mailbox mailbox) {
 return added(session.getSessionId(), session.getUser(), uids, mailbox);
@@ -81,12 +130,8 @@ public class EventFactory {
 return new MailboxListener.MailboxDeletion(sessionId, user, 
mailbox.generateAssociatedPath(), quotaRoot, deletedMessageCount, 
totalDeletedSize, mailbox.getMailboxId());
 }
 
-public MailboxListener.MailboxAdded mailboxAdded(MailboxSession session, 
Mailbox mailbox) {
-return mailboxAdded(session.getSessionId(), session.getUser(), 
mailbox);
-}
-
-public MailboxListener.MailboxAdded mailboxAdded(MailboxSession.SessionId 
sessionId, User user, Mailbox mailbox) {
-return new MailboxListener.MailboxAdded(sessionId, user, 
mailbox.generateAssociatedPath(), mailbox.getMailboxId());
+public MailboxAddedBuilder mailboxAdded() {
+return new MailboxAddedBuilder();
 }
 
 public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession 
session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/8550ce9d/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
 
b/mailbox/store/src/main/java/org/apache/j

[17/47] james-project git commit: MAILBOX-359 Remove a unused method

2019-01-08 Thread btellier
MAILBOX-359 Remove a unused method


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

Branch: refs/heads/master
Commit: 7776d2af983b7209ccf663e773b032c39c969a6c
Parents: 6f8cb22
Author: Benoit Tellier 
Authored: Mon Jan 7 18:00:53 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:52 2019 +0700

--
 .../scala/org/apache/james/event/json/EventSerializer.scala | 5 -
 1 file changed, 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7776d2af/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
--
diff --git 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index 6daf248..3d63c76 100644
--- 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -115,11 +115,6 @@ private object ScalaConverter {
 aclDiff = ACLDiff.fromJava(event.getAclDiff),
 mailboxId = event.getMailboxId)
 
-  private def toScala[T <: QuotaValue[T]](java: JavaQuota[T]): DTOs.Quota[T] = 
DTOs.Quota(
-used = java.getUsed,
-limit = java.getLimit,
-limits = java.getLimitByScope.asScala.toMap)
-
   private def toScala(event: JavaMailboxAdded): DTO.MailboxAdded = 
DTO.MailboxAdded(
 mailboxPath = MailboxPath.fromJava(event.getMailboxPath),
 mailboxId = event.getMailboxId,


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



[05/47] james-project git commit: MAILBOX-359 Factorize tests for User ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for User ser-deserialization


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

Branch: refs/heads/master
Commit: 21eff0689931e3c454d2dfbc91b82473ee80c440
Parents: 8ca8a33
Author: Benoit Tellier 
Authored: Mon Dec 24 13:11:31 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  |  71 +---
 .../event/json/ExpungedSerializationTest.java   |  71 +---
 .../json/FlagsUpdatedSerializationTest.java |  75 +
 ...MailboxACLUpdatedEventSerializationTest.java |  54 +--
 .../json/MailboxAddedSerializationTest.java |  34 
 .../json/MailboxDeletionSerializationTest.java  |  53 +-
 .../json/MailboxRenamedSerializationTest.java   |  60 +--
 .../json/MessageMoveEventSerializationTest.java |  84 --
 ...QuotaUsageUpdatedEventSerializationTest.java | 161 +--
 .../james/event/json/dtos/SessionIdTest.java|   4 +-
 .../apache/james/event/json/dtos/UserTest.java  |  90 +++
 11 files changed, 156 insertions(+), 601 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/21eff068/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 82afcd2..a299389 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -539,12 +539,10 @@ class AddedSerializationTest {
 .isInstanceOf(NoSuchElementException.class);
 }
 
-@Nested
-class DeserializationErrorOnUser {
-@Test
-void addedShouldThrowWhenMissingUser() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
+@Test
+void addedShouldThrowWhenMissingUser() {
+assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
+"{" +
 "  \"Added\": {" +
 "\"path\": {" +
 "  \"namespace\": \"#private\"," +
@@ -568,67 +566,6 @@ class AddedSerializationTest {
 "  }" +
 "}").get())
 .isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void addedShouldThrowWhenUserIsNotAString() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": 596" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void addedShouldThrowWhenUserIsNotWellFormatted() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-   

[13/47] james-project git commit: MAILBOX-359 Factorize tests for Quota ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for Quota ser-deserialization


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

Branch: refs/heads/master
Commit: 0a16e7ca716984a3111cffd3c7a32a48b5c31268
Parents: 38ebe82
Author: Benoit Tellier 
Authored: Mon Dec 24 16:31:11 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:20 2019 +0700

--
 .../json/MailboxDeletionSerializationTest.java  | 144 +-
 ...QuotaUsageUpdatedEventSerializationTest.java | 451 ++-
 .../james/event/json/dtos/QuotaCountTest.java   | 205 +
 .../james/event/json/dtos/QuotaSizeTest.java| 199 
 4 files changed, 438 insertions(+), 561 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/0a16e7ca/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
index 313dc33..b601f48 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
@@ -88,86 +88,6 @@ class MailboxDeletionSerializationTest {
 }
 
 @Nested
-class NullQuotaCountInDeletedMessageCount {
-private final MailboxListener.MailboxDeletion 
unlimitedQuotaCountDeletedMessageEvent = new MailboxListener.MailboxDeletion(
-SESSION_ID,
-USER,
-MAILBOX_PATH,
-QUOTA_ROOT,
-QuotaCount.unlimited(),
-TOTAL_DELETED_SIZE,
-MAILBOX_ID);
-private final String nullQuotaCountInDeletedMessageCountEventJson =
-"{" +
-"  \"MailboxDeletion\":{" +
-"\"sessionId\":3652," +
-"\"user\":\"user\"," +
-"\"path\":{" +
-"  \"namespace\":\"#private\"," +
-"  \"user\":\"user\"," +
-"  \"name\":\"mailboxName\"" +
-"}," +
-"\"quotaRoot\":\"user@domain\"," +
-"\"deletedMessageCount\":null," +
-"\"totalDeletedSize\":100," +
-"\"mailboxId\":\"789\"" +
-"  }" +
-"}";
-
-@Test
-void mailboxAddedShouldBeWellSerializedWhenNullQuotaCount() {
-
assertThatJson(EVENT_SERIALIZER.toJson(unlimitedQuotaCountDeletedMessageEvent))
-.isEqualTo(nullQuotaCountInDeletedMessageCountEventJson);
-}
-
-@Test
-void mailboxAddedShouldBeWellDeSerializedWhenNullQuotaCount() {
-
assertThat(EVENT_SERIALIZER.fromJson(nullQuotaCountInDeletedMessageCountEventJson).get())
-.isEqualTo(unlimitedQuotaCountDeletedMessageEvent);
-}
-}
-
-@Nested
-class NullQuotaSizeInTotalDeletedSize {
-private final MailboxListener.MailboxDeletion 
unlimitedQuotaSizeDeletedSizeEvent = new MailboxListener.MailboxDeletion(
-SESSION_ID,
-USER,
-MAILBOX_PATH,
-QUOTA_ROOT,
-DELETED_MESSAGE_COUNT,
-QuotaSize.unlimited(),
-MAILBOX_ID);
-private final String nullQuotaSizeInTotalDeletedMessageEventJson =
-"{" +
-"  \"MailboxDeletion\":{" +
-"\"sessionId\":3652," +
-"\"user\":\"user\"," +
-"\"path\":{" +
-"  \"namespace\":\"#private\"," +
-"  \"user\":\"user\"," +
-"  \"name\":\"mailboxName\"" +
-"}," +
-"\"quotaRoot\":\"user@domain\"," +
-"\"deletedMessageCount\":60," +
-"\"totalDeletedSize\":null," +
-"\"mailboxId\":\"789\"" +
-"  }" +
-"}";
-
-@Test
-void mailboxAddedShouldBeWellSerializedWhenNullQuotaSize() {
-
assertThatJson(EVENT_SERIALIZER.toJson(unlimitedQuotaSizeDeletedSizeEvent))
-.isEqualTo(nullQuotaSizeInTotalDeletedMessageEventJson);
-}
-
-@Test
-void mailboxAddedShouldBeWellDeSerializedWhenNullQuotaSize() {
-
assertThat(EVENT_SERIALIZER.fromJson(nullQuotaSizeInTotalDeletedMessageEventJson).get())
-.isEqualTo(unlimitedQuotaSizeDeletedSizeEvent);
- 

[22/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for MailboxDeletion event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for MailboxDeletion event


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

Branch: refs/heads/master
Commit: 7ceb951cba15df620a63f28d5dfd313527aaa430
Parents: 886ad16
Author: Benoit Tellier 
Authored: Wed Dec 19 12:03:00 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 53 +++-
 .../store/event/MailboxEventDispatcher.java |  8 ++-
 .../event/MailboxAnnotationListenerTest.java| 18 +++
 3 files changed, 56 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7ceb951c/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index e87f967..a05e561 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -51,7 +51,7 @@ public class EventFactory {
 protected User user;
 protected MailboxSession.SessionId sessionId;
 
-abstract T backReference();
+protected abstract T backReference();
 
 public T mailbox(Mailbox mailbox) {
 path(mailbox.generateAssociatedPath());
@@ -85,7 +85,7 @@ public class EventFactory {
 return backReference();
 }
 
-void mailboxEventChecks() {
+protected void mailboxEventChecks() {
 Preconditions.checkState(user != null, "Field `user` is 
compulsory");
 Preconditions.checkState(mailboxId != null, "Field `mailboxId` is 
compulsory");
 Preconditions.checkState(path != null, "Field `path` is 
compulsory");
@@ -95,7 +95,7 @@ public class EventFactory {
 
 public static class MailboxAddedBuilder extends 
MailboxEventBuilder {
 @Override
-MailboxAddedBuilder backReference() {
+protected MailboxAddedBuilder backReference() {
 return this;
 }
 
@@ -106,6 +106,41 @@ public class EventFactory {
 }
 }
 
+public static class MailboxDeletionBuilder extends 
MailboxEventBuilder {
+private QuotaRoot quotaRoot;
+private QuotaCount deletedMessageCount;
+private QuotaSize totalDeletedSize;
+
+@Override
+protected MailboxDeletionBuilder backReference() {
+return this;
+}
+
+public MailboxDeletionBuilder quotaRoot(QuotaRoot quotaRoot) {
+this.quotaRoot = quotaRoot;
+return this;
+}
+
+public MailboxDeletionBuilder deletedMessageCount(QuotaCount 
deletedMessageCount) {
+this.deletedMessageCount = deletedMessageCount;
+return this;
+}
+
+public MailboxDeletionBuilder totalDeletedSize(QuotaSize 
totalDeletedSize) {
+this.totalDeletedSize = totalDeletedSize;
+return this;
+}
+
+public MailboxListener.MailboxDeletion build() {
+mailboxEventChecks();
+Preconditions.checkState(quotaRoot != null, "Field `quotaRoot` is 
compulsory");
+Preconditions.checkState(deletedMessageCount != null, "Field 
`deletedMessageCount` is compulsory");
+Preconditions.checkState(totalDeletedSize != null, "Field 
`totalDeletedSize` is compulsory");
+
+return new MailboxListener.MailboxDeletion(sessionId, user, path, 
quotaRoot, deletedMessageCount, totalDeletedSize, mailboxId);
+}
+}
+
 public static class FlagsUpdatedBuilder extends 
MailboxEventBuilder {
 private final ImmutableList.Builder updatedFlags;
 
@@ -124,7 +159,7 @@ public class EventFactory {
 }
 
 @Override
-FlagsUpdatedBuilder backReference() {
+protected FlagsUpdatedBuilder backReference() {
 return this;
 }
 
@@ -165,14 +200,8 @@ public class EventFactory {
 return new MailboxListener.MailboxRenamed(sessionId, user, from, 
to.getMailboxId(), to.generateAssociatedPath());
 }
 
-public MailboxListener.MailboxDeletion mailboxDeleted(MailboxSession 
session, Mailbox mailbox, QuotaRoot quotaRoot,
-  QuotaCount 
deletedMessageCount, QuotaSize totalDeletedSize) {
-return mailboxDeleted(session.getSessionId(), session.getUs

[09/47] james-project git commit: MAILBOX-359 Factorize tests for MailboxId ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for MailboxId ser-deserialization


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

Branch: refs/heads/master
Commit: e64e8e1d24cc0473ce37771acda398d77504fa18
Parents: 21eff06
Author: Benoit Tellier 
Authored: Mon Dec 24 13:23:08 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  |  71 +--
 .../event/json/ExpungedSerializationTest.java   |  71 +--
 .../json/FlagsUpdatedSerializationTest.java |  75 +---
 ...MailboxACLUpdatedEventSerializationTest.java | 183 +++
 .../json/MailboxAddedSerializationTest.java |  51 --
 .../json/MailboxDeletionSerializationTest.java  |  53 +-
 .../json/MailboxRenamedSerializationTest.java   |  33 +---
 .../james/event/json/dtos/MailboxIdTest.java|  71 +++
 8 files changed, 158 insertions(+), 450 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/e64e8e1d/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index a299389..3af5c28 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -568,78 +568,16 @@ class AddedSerializationTest {
 .isInstanceOf(NoSuchElementException.class);
 }
 
-@Nested
-class DeserializationErrorOnMailboxId {
-@Test
-void addedShouldThrowWhenMissingMailboxId() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void addedShouldThrowWhenNullMailboxId() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": null," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void addedShouldThrowWhenMailboxIdIsANumber() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-

[23/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for FlagsUpdated event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for FlagsUpdated event


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

Branch: refs/heads/master
Commit: 886ad168872a4cc894c45fa4cb1e0b5b40e1c182
Parents: 8550ce9
Author: Benoit Tellier 
Authored: Wed Dec 19 11:51:43 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java |  87 ++
 .../store/event/MailboxEventDispatcher.java |   8 +-
 .../base/MailboxEventAnalyserTest.java  | 120 +--
 3 files changed, 130 insertions(+), 85 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/886ad168/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 13c6f9d..e87f967 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.store.event;
 
 import java.util.Collection;
-import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 
@@ -41,57 +40,103 @@ import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+import com.github.steveash.guavate.Guavate;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
 
 public class EventFactory {
-public static class MailboxAddedBuilder {
-private MailboxPath path;
-private MailboxId mailboxId;
-private User user;
-private MailboxSession.SessionId sessionId;
+public abstract static class MailboxEventBuilder {
+protected MailboxPath path;
+protected MailboxId mailboxId;
+protected User user;
+protected MailboxSession.SessionId sessionId;
 
-public MailboxAddedBuilder mailbox(Mailbox mailbox) {
+abstract T backReference();
+
+public T mailbox(Mailbox mailbox) {
 path(mailbox.generateAssociatedPath());
 mailboxId(mailbox.getMailboxId());
-return this;
+return backReference();
 }
 
-public MailboxAddedBuilder mailboxSession(MailboxSession 
mailboxSession) {
+public T mailboxSession(MailboxSession mailboxSession) {
 user(mailboxSession.getUser());
 sessionId(mailboxSession.getSessionId());
-return this;
+return backReference();
 }
 
-public MailboxAddedBuilder mailboxId(MailboxId mailboxId) {
+public T mailboxId(MailboxId mailboxId) {
 this.mailboxId = mailboxId;
-return this;
+return backReference();
 }
 
-public MailboxAddedBuilder path(MailboxPath path) {
+public T path(MailboxPath path) {
 this.path = path;
-return this;
+return backReference();
 }
 
-public MailboxAddedBuilder user(User user) {
+public T user(User user) {
 this.user = user;
-return this;
+return backReference();
 }
 
-public MailboxAddedBuilder sessionId(MailboxSession.SessionId 
sessionId) {
+public T sessionId(MailboxSession.SessionId sessionId) {
 this.sessionId = sessionId;
-return this;
+return backReference();
 }
 
-public MailboxListener.MailboxAdded build() {
+void mailboxEventChecks() {
 Preconditions.checkState(user != null, "Field `user` is 
compulsory");
 Preconditions.checkState(mailboxId != null, "Field `mailboxId` is 
compulsory");
 Preconditions.checkState(path != null, "Field `path` is 
compulsory");
 Preconditions.checkState(sessionId != null, "Field `sessionId` is 
compulsory");
+}
+}
+
+public static class MailboxAddedBuilder extends 
MailboxEventBuilder {
+@Override
+MailboxAddedBuilder backReference() {
+return this;
+}
+
+public MailboxListener.MailboxAdded build() {
+mailboxEventChecks();
 
 return new MailboxListener.MailboxAdded(sessionId, user, path, 
mailboxId);
 }
 }
 
+public static class Fla

[27/47] james-project git commit: MAILBOX-364 EventFactory should rather link LessageMoveEvent.Builder

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should rather link LessageMoveEvent.Builder


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

Branch: refs/heads/master
Commit: 2713b4d9eea46e5a96078e54b59bfb0d7e67eab7
Parents: b5608ad
Author: Benoit Tellier 
Authored: Wed Dec 19 13:56:42 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../apache/james/mailbox/store/event/EventFactory.java  | 12 ++--
 .../mailbox/store/event/MailboxEventDispatcher.java |  6 +-
 2 files changed, 7 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/2713b4d9/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index cc8a2f6..1c0a477 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.store.event;
 
-import java.util.Collection;
-
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
@@ -31,9 +29,7 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.MessageMetaData;
-import org.apache.james.mailbox.model.MessageMoves;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -332,11 +328,7 @@ public class EventFactory {
 return new MailboxAclUpdatedBuilder();
 }
 
-public MessageMoveEvent moved(MailboxSession session, MessageMoves 
messageMoves, Collection messageIds) {
-return MessageMoveEvent.builder()
-.user(session.getUser())
-.messageMoves(messageMoves)
-.messageId(messageIds)
-.build();
+public MessageMoveEvent.Builder moved() {
+return MessageMoveEvent.builder();
 }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/2713b4d9/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index e7a8a4f..d161338 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -192,7 +192,11 @@ public class MailboxEventDispatcher {
 }
 
 public void moved(MailboxSession session, MessageMoves messageMoves, 
Collection messageIds) {
-event(eventFactory.moved(session, messageMoves, messageIds));
+event(eventFactory.moved()
+.session(session)
+.messageMoves(messageMoves)
+.messageId(messageIds)
+.build());
 }
 
 public void quota(User user, QuotaRoot quotaRoot, Quota 
countQuota, Quota sizeQuota) {


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



[37/47] james-project git commit: JAMES-2641 Remove MailboxEventDispatcher tests

2019-01-08 Thread btellier
JAMES-2641 Remove MailboxEventDispatcher tests

This class is going to be removed later in that PR


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

Branch: refs/heads/master
Commit: 8a21cb571ba553f89e731378668f33a659d6edbe
Parents: 305c321
Author: Benoit Tellier 
Authored: Mon Jan 7 11:22:43 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:46:01 2019 +0700

--
 .../store/MailboxEventDispatcherTest.java   | 352 ---
 1 file changed, 352 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/8a21cb57/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
--
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
deleted file mode 100644
index 24f5cab..000
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information*
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the*
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *  *
- *   http://www.apache.org/licenses/LICENSE-2.0 *
- *  *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
- * KIND, either express or implied.  See the License for the*
- * specific language governing permissions and limitations  *
- * under the License.   *
- /
-
-package org.apache.james.mailbox.store;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import javax.mail.Flags;
-
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MailboxSessionUtil;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.model.TestId;
-import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.apache.james.mailbox.util.EventCollector;
-import org.assertj.core.api.Condition;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableList;
-
-public class MailboxEventDispatcherTest {
-private static final MailboxSession.SessionId SESSION_ID = 
MailboxSession.SessionId.of(10);
-private static final int MOD_SEQ = -1;
-public static final Condition INSTANCE_OF_EVENT_FLAGS_UPDATED = new 
Condition() {
-@Override
-public boolean matches(Event event) {
-return event instanceof MailboxListener.FlagsUpdated;
-}
-};
-public static final TestId MAILBOX_ID = TestId.of(147L);
-public static final int UID_VALIDITY = 145;
-
-private MailboxEventDispatcher dispatcher;
-private EventCollector collector;
-private MessageResult result;
-private Mailbox mailbox;
-
-private MailboxSession session = MailboxSessionUtil.create("test", 
SESSION_ID);
-
-@Before
-public void setUp() throws Exception {
-collector = new EventCollector();
-
-DefaultDelegatingMailboxListener mailboxListener = new 
DefaultDelegatingMailboxListener();
-mailboxListener.addGlobalListener(collector, session);
-dispatcher = new MailboxEventDispatcher(mailboxListener);
-result = moc

[31/47] james-project git commit: MAILBOX-364 MailboxEvent builders should use staged builders

2019-01-08 Thread btellier
MAILBOX-364 MailboxEvent builders should use staged builders

We can leverage stage sharing through generics. Note that also uncouple stages 
from
each others (to define stage 1, I don't need to know stage 2, only the builder 
method defining the
stage chain needs that) which is a very nice benefit!

Note that alternative choices are implemented using default methods.


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

Branch: refs/heads/master
Commit: 7097446f95c933ce0508a3d200b097b50e246268
Parents: def6258
Author: Benoit Tellier 
Authored: Thu Jan 3 11:42:16 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:41:11 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 421 ++-
 .../store/event/MailboxEventDispatcher.java |  16 +-
 .../event/MailboxAnnotationListenerTest.java|   6 +-
 .../base/MailboxEventAnalyserTest.java  |  12 +-
 .../processor/base/SelectedMailboxImplTest.java |   2 +-
 5 files changed, 247 insertions(+), 210 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7097446f/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index c581816..5695c6f 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -41,291 +41,328 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSortedMap;
 
 public class EventFactory {
-public abstract static class MailboxEventBuilder {
-protected MailboxPath path;
-protected MailboxId mailboxId;
-protected User user;
-protected MailboxSession.SessionId sessionId;
-
-protected abstract T backReference();
-
-public T mailbox(Mailbox mailbox) {
-path(mailbox.generateAssociatedPath());
-mailboxId(mailbox.getMailboxId());
-return backReference();
-}
+@FunctionalInterface
+public interface RequireUser {
+T user(User user);
+}
 
-public T mailboxSession(MailboxSession mailboxSession) {
-user(mailboxSession.getUser());
-sessionId(mailboxSession.getSessionId());
-return backReference();
-}
+@FunctionalInterface
+public interface RequireSessionId {
+T sessionId(MailboxSession.SessionId sessionId);
+}
 
-public T mailboxId(MailboxId mailboxId) {
-this.mailboxId = mailboxId;
-return backReference();
+@FunctionalInterface
+public interface RequireSession extends 
RequireUser> {
+default T mailboxSession(MailboxSession session) {
+return user(session.getUser())
+.sessionId(session.getSessionId());
 }
+}
 
-public T path(MailboxPath path) {
-this.path = path;
-return backReference();
-}
+@FunctionalInterface
+public interface RequireMailboxId {
+T mailboxId(MailboxId mailboxId);
+}
 
-public T user(User user) {
-this.user = user;
-return backReference();
-}
+@FunctionalInterface
+public interface RequirePath {
+T mailboxPath(MailboxPath path);
+}
 
-public T sessionId(MailboxSession.SessionId sessionId) {
-this.sessionId = sessionId;
-return backReference();
+@FunctionalInterface
+public interface RequireMailbox extends 
RequireMailboxId> {
+default T mailbox(Mailbox mailbox) {
+return mailboxId(mailbox.getMailboxId())
+.mailboxPath(mailbox.generateAssociatedPath());
 }
+}
 
-protected void mailboxEventChecks() {
-Preconditions.checkState(user != null, "Field `user` is 
compulsory");
-Preconditions.checkState(mailboxId != null, "Field `mailboxId` is 
compulsory");
-Preconditions.checkState(path != null, "Field `path` is 
compulsory");
-Preconditions.checkState(sessionId != null, "Field `sessionId` is 
compulsory");
-}
+@FunctionalInterface
+public interface RequireNewPath {
+T newPath(MailboxPath path);
 }
 
-public abstract static class MessageMetaDataEventBuilder extends MailboxEventBuilder {
-protected final

[21/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for Added event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for Added event


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

Branch: refs/heads/master
Commit: e829c8edacc3839992bef750774cccdd08ee4378
Parents: 7ceb951
Author: Benoit Tellier 
Authored: Wed Dec 19 13:31:29 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../spamassassin/SpamAssassinListenerTest.java  | 22 ---
 .../james/mailbox/store/event/EventFactory.java | 63 +---
 .../store/event/MailboxEventDispatcher.java |  6 +-
 .../base/MailboxEventAnalyserTest.java  | 22 +++
 .../processor/base/SelectedMailboxImplTest.java | 14 ++---
 5 files changed, 85 insertions(+), 42 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/e829c8ed/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
--
diff --git 
a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
 
b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
index 0496ac5..ff0db16 100644
--- 
a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
+++ 
b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
@@ -37,7 +37,6 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageMoveEvent;
-import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
@@ -58,14 +57,10 @@ import 
org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableSortedMap;
-
 public class SpamAssassinListenerTest {
-
 public static final String USER = "user";
 private static final MailboxSession MAILBOX_SESSION = 
MailboxSessionUtil.create(USER);
 private static final int UID_VALIDITY = 43;
-private static final MessageUid UID = MessageUid.of(45);
 private static final TestMessageId MESSAGE_ID = TestMessageId.of(45);
 
 private SpamAssassin spamAssassin;
@@ -237,9 +232,11 @@ public class SpamAssassinListenerTest {
 public void 
eventShouldCallSpamAssassinHamLearningWhenTheMessageIsAddedInInbox() throws 
Exception {
 SimpleMailboxMessage message = createMessage(inbox);
 
-ImmutableSortedMap sortedMap = 
ImmutableSortedMap.of(UID, message.metaData());
-MailboxListener.Added addedEvent = new EventFactory().added(
-MAILBOX_SESSION, sortedMap, inbox);
+MailboxListener.Added addedEvent = new EventFactory().added()
+.mailboxSession(MAILBOX_SESSION)
+.mailbox(inbox)
+.addMessage(message)
+.build();
 
 listener.event(addedEvent);
 
@@ -250,10 +247,11 @@ public class SpamAssassinListenerTest {
 public void 
eventShouldNotCallSpamAssassinHamLearningWhenTheMessageIsAddedInAMailboxOtherThanInbox()
 throws Exception {
 SimpleMailboxMessage message = createMessage(mailbox1);
 
-MailboxListener.Added addedEvent = new EventFactory().added(
-MAILBOX_SESSION,
-ImmutableSortedMap.of(UID, message.metaData()),
-mailbox1);
+MailboxListener.Added addedEvent = new EventFactory().added()
+.mailboxSession(MAILBOX_SESSION)
+.mailbox(mailbox1)
+.addMessage(message)
+.build();
 
 listener.event(addedEvent);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e829c8ed/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index a05e561..cd8a38c 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -21,7 +21,6 @@ package org.apache.james.mailbox.store.event;
 
 impo

[19/47] james-project git commit: MAILBOX-359 Improving QuotaScope coverage

2019-01-08 Thread btellier
MAILBOX-359 Improving QuotaScope coverage


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

Branch: refs/heads/master
Commit: 07818491e7884bd671b141bdfb7a301e58efcd04
Parents: 7776d2a
Author: Benoit Tellier 
Authored: Mon Jan 7 18:07:12 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:53 2019 +0700

--
 .../james/event/json/dtos/QuotaCountTest.java | 18 ++
 1 file changed, 18 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/07818491/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/QuotaCountTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/QuotaCountTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/QuotaCountTest.java
index 88adaa6..e203cc6 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/QuotaCountTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/QuotaCountTest.java
@@ -22,6 +22,7 @@ package org.apache.james.event.json.dtos;
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
 import static org.apache.james.event.json.SerializerFixture.DTO_JSON_SERIALIZE;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.event.json.DTOs;
@@ -202,4 +203,21 @@ class QuotaCountTest {
 }
 }
 }
+
+@Nested
+class UnknownQuotaScope {
+private final String json = 
"{\"used\":12,\"limit\":100,\"limits\":{\"Invalid\":100}}";
+
+@Test
+void fromJsonShouldThrowOnInvalidScope() {
+assertThatThrownBy(() -> 
DTO_JSON_SERIALIZE.quotaCReads().reads(Json.parse(json)).get().toJava())
+.isInstanceOf(IllegalArgumentException.class);
+}
+
+@Test
+void scopesShouldBeString() {
+
assertThat(DTO_JSON_SERIALIZE.quotaScopeReads().reads(Json.parse("3")))
+.isInstanceOf(JsError.class);
+}
+}
 }


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



[14/47] james-project git commit: MAILBOX-359 Use a fixture for the serializers

2019-01-08 Thread btellier
MAILBOX-359 Use a fixture for the serializers


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

Branch: refs/heads/master
Commit: 38ebe82603cb19909f1c1e074c34e963b513ad34
Parents: 19710d4
Author: Benoit Tellier 
Authored: Mon Dec 24 16:06:21 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:20 2019 +0700

--
 .../event/json/AddedSerializationTest.java  |  3 +-
 .../event/json/ExpungedSerializationTest.java   |  3 +-
 .../json/FlagsUpdatedSerializationTest.java |  4 +-
 ...MailboxACLUpdatedEventSerializationTest.java | 89 +---
 .../json/MailboxAddedSerializationTest.java |  7 +-
 .../json/MailboxDeletionSerializationTest.java  |  4 +-
 .../json/MailboxRenamedSerializationTest.java   |  4 +-
 .../json/MessageMoveEventSerializationTest.java |  3 +-
 ...QuotaUsageUpdatedEventSerializationTest.java |  6 +-
 .../james/event/json/SerializerFixture.java | 28 ++
 .../james/event/json/dtos/ACLDiffTest.java  | 55 
 .../apache/james/event/json/dtos/FlagsTest.java | 56 ++--
 .../james/event/json/dtos/MailboxIdTest.java| 20 ++---
 .../james/event/json/dtos/MailboxPathTest.java  | 31 +++
 .../james/event/json/dtos/MessageIdTest.java| 17 ++--
 .../event/json/dtos/MessageMetaDataTest.java| 44 +-
 .../james/event/json/dtos/MessageUidTest.java   | 16 ++--
 .../james/event/json/dtos/QuotaRootTest.java| 31 +++
 .../james/event/json/dtos/SessionIdTest.java| 19 ++---
 .../james/event/json/dtos/UpdatedFlagsTest.java | 16 ++--
 .../apache/james/event/json/dtos/UserTest.java  | 29 +++
 21 files changed, 191 insertions(+), 294 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/38ebe826/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 327d5ba..7760523 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.event.json;
 
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
+import static org.apache.james.event.json.SerializerFixture.EVENT_SERIALIZER;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
@@ -92,8 +93,6 @@ class AddedSerializationTest {
 "  }" +
 "}";
 
-private static final EventSerializer EVENT_SERIALIZER = new 
EventSerializer(new TestId.Factory(), new TestMessageId.Factory());
-
 @Test
 void addedShouldBeWellSerialized() {
 assertThatJson(EVENT_SERIALIZER.toJson(DEFAULT_ADDED_EVENT))

http://git-wip-us.apache.org/repos/asf/james-project/blob/38ebe826/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
index 0e46b59..85e0365 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.event.json;
 
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
+import static org.apache.james.event.json.SerializerFixture.EVENT_SERIALIZER;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
@@ -92,8 +93,6 @@ class ExpungedSerializationTest {
 "  }" +
 "}";
 
-private static final EventSerializer EVENT_SERIALIZER = new 
EventSerializer(new TestId.Factory(), new TestMessageId.Factory());
-
 @Test
 void expungedShouldBeWellSerialized() {
 assertThatJson(EVENT_SERIALIZER.toJson(DEFAULT_EXPUNGED_EVENT))

http://git-wip-us.apache.org/repos/asf/james-project/blob/38ebe826/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/j

[10/47] james-project git commit: MAILBOX-359 Re-arrange QuotaUsageUpdatedEventSerializationTest

2019-01-08 Thread btellier
MAILBOX-359 Re-arrange QuotaUsageUpdatedEventSerializationTest

WithTime success case is strictly equivalent to the success case


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

Branch: refs/heads/master
Commit: 5383b12ebd3a1f020f67782f239a5ebc04bcee92
Parents: c6aebcc
Author: Benoit Tellier 
Authored: Mon Dec 24 15:25:59 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 ...QuotaUsageUpdatedEventSerializationTest.java | 81 +++-
 1 file changed, 26 insertions(+), 55 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/5383b12e/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
index af95172..f0cbe7f 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
@@ -51,19 +51,6 @@ class QuotaUsageUpdatedEventSerializationTest {
 .computedLimit(QuotaSize.size(1))
 .build();
 private static final Instant INSTANT = 
Instant.parse("2018-11-13T12:00:55Z");
-private static final MailboxListener.QuotaUsageUpdatedEvent 
DEFAULT_QUOTA_EVENT =
-new MailboxListener.QuotaUsageUpdatedEvent(USER, QUOTA_ROOT, 
QUOTA_COUNT, QUOTA_SIZE, INSTANT);
-
-private static final String DEFAULT_QUOTA_EVENT_JSON =
-"{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{}}," +
-"\"time\":\"2018-11-13T12:00:55Z\"," +
-"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
-"\"user\":\"user\"" +
-"}" +
-"}";
 
 private static final EventSerializer EVENT_SERIALIZER = new 
EventSerializer(new TestId.Factory(), new TestMessageId.Factory());
 
@@ -540,52 +527,36 @@ class QuotaUsageUpdatedEventSerializationTest {
 }
 }
 
-@Nested
-class WithTime {
-
-@Test
-void toJsonShouldReturnSerializedJsonEventWhenTimeIsValid() {
-assertThatJson(EVENT_SERIALIZER.toJson(DEFAULT_QUOTA_EVENT))
-.isEqualTo(DEFAULT_QUOTA_EVENT_JSON);
-}
-
-@Test
-void fromJsonShouldReturnDeSerializedEventWhenTimeIsValid() {
-
assertThat(EVENT_SERIALIZER.fromJson(DEFAULT_QUOTA_EVENT_JSON).get())
-.isEqualTo(DEFAULT_QUOTA_EVENT);
-}
-
-@Test
-void fromJsonShouldThrowResultWhenTimeIsNull() {
-String quotaUsageUpdatedEvent =
-"{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-
"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," +
-
"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
-"\"user\":\"user\"" +
-"}" +
+@Test
+void fromJsonShouldThrowResultWhenTimeIsNull() {
+String quotaUsageUpdatedEvent =
+"{" +
+"\"QuotaUsageUpdatedEvent\":{" +
+"\"quotaRoot\":\"foo\"," +
+
"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," +
+"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," 
+
+"\"user\":\"user\"" +
+"}" +
 "}";
 
-assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
-.isInstanceOf(NoSuchElementException.class);
-}
+assertThatThrownBy(() -> 
EVENT_SERIALIZER.fromJson(quotaUsageUpdatedEvent).get())
+.isInstanceOf(NoSuchElementException.class);
+}
 
-@Test
-void fromJsonShouldThrowResultWhenTimeIsEmpty() {
-String quotaUsageUpdatedEvent =
-"{" +
-"\"QuotaUsageUpdatedEvent\":{" +
-"\"quotaRoot\":\"foo\"," +
-
"\"countQuota\":{\"used\":12,\"limit\":100,\"limits\":{\"Domain\":100}}," +
-"\"time\":\"\"," +
-
"\"sizeQuota\":{\"used\":1234,\"limit\":1,\"limits\":{}}," +
-

[11/47] james-project git commit: MAILBOX-359 Factorize tests for MessageMetaData ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for MessageMetaData ser-deserialization


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

Branch: refs/heads/master
Commit: c6aebcc7dc82fdd6012cbae4e38d137a01bfddba
Parents: ba9ff0d
Author: Benoit Tellier 
Authored: Mon Dec 24 15:17:44 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  | 595 +-
 .../event/json/ExpungedSerializationTest.java   | 596 +--
 .../james/event/json/dtos/MessageIdTest.java|  71 +++
 .../event/json/dtos/MessageMetaDataTest.java| 348 +++
 4 files changed, 461 insertions(+), 1149 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/c6aebcc7/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 8246e77..327d5ba 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -139,112 +139,6 @@ class AddedSerializationTest {
 }
 
 @Nested
-class WithInternalDate {
-
-@Test
-void addedShouldDeserializeWhenInternalDateIsInGoodISOFormat() {
-SortedMap added = 
ImmutableSortedMap.of(
-MESSAGE_UID, new MessageMetaData(MESSAGE_UID, MOD_SEQ, FLAGS, 
SIZE, Date.from(Instant.parse("2018-12-14T09:41:51Z")), MESSAGE_ID));
-MailboxListener.Added eventRoundToMillis = new 
MailboxListener.Added(SESSION_ID, USER, MAILBOX_PATH, MAILBOX_ID, added);
-
-assertThat(EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51+00:00\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isEqualTo(eventRoundToMillis);
-}
-
-@Test
-void addedShouldDeserializeWhenInternalDateIsMissingMilliSeconds() {
-SortedMap added = 
ImmutableSortedMap.of(
-MESSAGE_UID, new MessageMetaData(MESSAGE_UID, MOD_SEQ, FLAGS, 
SIZE, Date.from(Instant.parse("2018-12-14T09:41:51Z")), MESSAGE_ID));
-MailboxListener.Added eventRoundToMillis = new 
MailboxListener.Added(SESSION_ID, USER, MAILBOX_PATH, MAILBOX_ID, added);
-
-assertThat(EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " +
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isEqualTo(eventRoundToMillis);
- 

[33/47] james-project git commit: JAMES-2636 Wildcard definition needs to be covered by MappingSource

2019-01-08 Thread btellier
JAMES-2636 Wildcard definition needs to be covered by MappingSource

This constant was only used by tests and made the API confusing.
Refactoring this was easy.


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

Branch: refs/heads/master
Commit: 9a4ce2fb37396bb9d4ae43f41206e664447351a5
Parents: 5392ad9
Author: Benoit Tellier 
Authored: Fri Jan 4 09:39:08 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:45:33 2019 +0700

--
 .../james/rrt/api/RecipientRewriteTable.java| 21 
 .../james/rrt/lib/RewriteTablesStepdefs.java| 13 +---
 2 files changed, 10 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/9a4ce2fb/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
--
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
index cba17a4..fed9ea0 100644
--- 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
+++ 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
@@ -35,27 +35,6 @@ import com.google.common.base.Preconditions;
  */
 public interface RecipientRewriteTable {
 
-interface Domains {
-
-Domain WILDCARD = new Domain(RecipientRewriteTable.WILDCARD) {
-
-@Override
-public String name() {
-throw new IllegalStateException();
-}
-
-@Override
-public String toString() {
-return "Domain : * (Wildcard)";
-}
-};
-}
-
-/**
- * The wildcard used for alias domain mappings
- */
-String WILDCARD = "*";
-
 void addMapping(MappingSource source, Mapping mapping) throws 
RecipientRewriteTableException;
 
 void removeMapping(MappingSource source, Mapping mapping) throws 
RecipientRewriteTableException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/9a4ce2fb/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
--
diff --git 
a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
 
b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
index a2e83b7..6c59812 100644
--- 
a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
+++ 
b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java
@@ -24,7 +24,6 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.List;
 
 import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 
@@ -56,6 +55,10 @@ public class RewriteTablesStepdefs {
 @Given("store \"([^\"]*)\" address mapping for user \"([^\"]*)\" at domain 
\"([^\"]*)\"")
 public void storeAddressMappingForUserAtDomain(String address, String 
user, String domain) throws Throwable {
 MappingSource source = MappingSource.fromUser(user, domain);
+storeAddressMappingForUserAtDomain(address, source);
+}
+
+private void storeAddressMappingForUserAtDomain(String address, 
MappingSource source) throws RecipientRewriteTableException {
 rewriteTable.addAddressMapping(source, address);
 }
 
@@ -67,7 +70,7 @@ public class RewriteTablesStepdefs {
 
 @Given("store \"([^\"]*)\" address mapping as wildcard for domain 
\"([^\"]*)\"")
 public void storeAddressMappingAsWildcardAtDomain(String address, String 
domain) throws Throwable {
-storeAddressMappingForUserAtDomain(address, 
RecipientRewriteTable.WILDCARD, domain);
+storeAddressMappingForUserAtDomain(address, 
MappingSource.fromDomain(Domain.of(domain)));
 }
 
 @Given("store \"([^\"]*)\" alias domain mapping for domain \"([^\"]*)\"")
@@ -106,6 +109,10 @@ public class RewriteTablesStepdefs {
 @When("user \"([^\"]*)\" at domain \"([^\"]*)\" removes a address mapping 
\"([^\"]*)\"")
 public void userAtDomainRemovesAddressMapping(String user, String domain, 
String address) throws Throwable {
 MappingSource source = MappingSource.fromUser(user, domain);
+userAtDomainRemovesAddressMapping(address, source);
+}

[36/47] james-project git commit: JAMES-2636 Reorder RecipientRewriteTable API order

2019-01-08 Thread btellier
JAMES-2636 Reorder RecipientRewriteTable API order

Classes go first, then constants, then methods. Note that I inlined a
short method that was not related to the API. This avoids poluting the API
with useless methods


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

Branch: refs/heads/master
Commit: 887f3c5aa9d4f31cfeedee54d2ebf37f0f77e8ea
Parents: 9a4ce2f
Author: Benoit Tellier 
Authored: Fri Jan 4 09:43:42 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:45:33 2019 +0700

--
 .../james/rrt/api/RecipientRewriteTable.java| 48 
 1 file changed, 19 insertions(+), 29 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/887f3c5a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
--
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
index fed9ea0..5c85ed7 100644
--- 
a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
+++ 
b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
@@ -34,6 +34,24 @@ import com.google.common.base.Preconditions;
  * Interface which should be implemented of classes which map recipients.
  */
 public interface RecipientRewriteTable {
+class ErrorMappingException extends Exception {
+private static final long serialVersionUID = 2348752938798L;
+
+public ErrorMappingException(String string) {
+super(string);
+}
+}
+
+class TooManyMappingException extends ErrorMappingException {
+public TooManyMappingException(String string) {
+super(string);
+}
+}
+
+EnumSet listSourcesSupportedType = EnumSet.of(
+Mapping.Type.Group,
+Mapping.Type.Forward,
+Mapping.Type.Address);
 
 void addMapping(MappingSource source, Mapping mapping) throws 
RecipientRewriteTableException;
 
@@ -91,7 +109,7 @@ public interface RecipientRewriteTable {
 Map getAllMappings() throws 
RecipientRewriteTableException;
 
 default List listSources(Mapping mapping) throws 
RecipientRewriteTableException {
-Preconditions.checkArgument(supportsSourceListing(mapping),
+
Preconditions.checkArgument(listSourcesSupportedType.contains(mapping.getType()),
 String.format("Not supported mapping of type %s", 
mapping.getType()));
 
 return getAllMappings().entrySet().stream()
@@ -99,32 +117,4 @@ public interface RecipientRewriteTable {
 .map(Map.Entry::getKey)
 .collect(Guavate.toImmutableList());
 }
-
-EnumSet listSourcesSupportedType = EnumSet.of(
-Mapping.Type.Group,
-Mapping.Type.Forward,
-Mapping.Type.Address);
-
-default boolean supportsSourceListing(Mapping mapping) {
-return listSourcesSupportedType.contains(
-mapping.getType());
-}
-
-class ErrorMappingException extends Exception {
-
-private static final long serialVersionUID = 2348752938798L;
-
-public ErrorMappingException(String string) {
-super(string);
-}
-
-}
-
-class TooManyMappingException extends ErrorMappingException {
-
-public TooManyMappingException(String string) {
-super(string);
-}
-
-}
 }


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



[07/47] james-project git commit: MAILBOX-359 Factorize tests for MailboxPath ser-deserialization

2019-01-08 Thread btellier
http://git-wip-us.apache.org/repos/asf/james-project/blob/70a4fd59/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/MailboxPathTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/MailboxPathTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/MailboxPathTest.java
new file mode 100644
index 000..613f5a9
--- /dev/null
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/dtos/MailboxPathTest.java
@@ -0,0 +1,177 @@
+/
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information*
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the*
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *  *
+ *   http://www.apache.org/licenses/LICENSE-2.0 *
+ *  *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY   *
+ * KIND, either express or implied.  See the License for the*
+ * specific language governing permissions and limitations  *
+ * under the License.   *
+ /
+
+package org.apache.james.event.json.dtos;
+
+import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.event.json.DTOs;
+import org.apache.james.event.json.JsonSerialize;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.TestId;
+import org.apache.james.mailbox.model.TestMessageId;
+import org.junit.jupiter.api.Test;
+
+import play.api.libs.json.JsError;
+import play.api.libs.json.Json;
+
+class MailboxPathTest {
+private static final String MAILBOX_NAME = "mailboxName";
+private static final MailboxPath MAILBOX_PATH = new 
MailboxPath(MailboxConstants.USER_NAMESPACE, "user", MAILBOX_NAME);
+private static final JsonSerialize JSON_SERIALIZE = new JsonSerialize(new 
TestId.Factory(), new TestMessageId.Factory());
+
+@Test
+void mailboxPathShouldBeWellSerialized() {
+
assertThatJson(JSON_SERIALIZE.mailboxPathWrites().writes(DTOs.MailboxPath$.MODULE$.fromJava(MAILBOX_PATH)).toString())
+.isEqualTo(
+"{" +
+"  \"namespace\":\"#private\"," +
+"  \"user\":\"user\"," +
+"  \"name\":\"mailboxName\"" +
+"}");
+}
+
+@Test
+void mailboxPathWithNullUserShouldBeWellSerialized() {
+
assertThatJson(JSON_SERIALIZE.mailboxPathWrites().writes(DTOs.MailboxPath$.MODULE$.fromJava(
+new MailboxPath(MailboxConstants.USER_NAMESPACE, null, 
MAILBOX_NAME))).toString())
+.isEqualTo(
+"{" +
+"  \"namespace\":\"#private\"," +
+"  \"name\":\"mailboxName\"" +
+"}");
+}
+
+@Test
+void mailboxPathWithEmptyNamespaceShouldBeWellSerialized() {
+
assertThatJson(JSON_SERIALIZE.mailboxPathWrites().writes(DTOs.MailboxPath$.MODULE$.fromJava(
+new MailboxPath("", "user", MAILBOX_NAME))).toString())
+.isEqualTo(
+"{" +
+"  \"namespace\":\"#private\"," +
+"  \"user\":\"user\"," +
+"  \"name\":\"mailboxName\"" +
+"}");
+}
+
+@Test
+void mailboxPathWithShouldBeWellDeSerialized() {
+assertThat(JSON_SERIALIZE.mailboxPathReads().reads(Json.parse("{" +
+"  \"namespace\":\"#private\"," +
+"  \"user\":\"user\"," +
+"  \"name\":\"mailboxName\"" +
+"}")).get())
+.isEqualTo(DTOs.MailboxPath$.MODULE$.fromJava(
+new MailboxPath(MailboxConstants.USER_NAMESPACE, "user", 
MAILBOX_NAME)));
+}
+
+@Test
+void mailboxPathWithNullUserShouldBeWellDeSerialized() {
+assertThat(JSON_SERIALIZE.mailboxPathReads().reads(Json.parse("{" +
+"  \"namespace\":\"#private\"," +
+"  \"user\":null," +
+"  \"name\":\"mailboxName\"" +
+"}")).get())
+.isEqualTo(DTOs.MailboxPath$.MODULE$.fromJava(
+new MailboxPath(MailboxConstants.USER_NAMESPACE, null, 
MAILBOX_NAME)));
+}
+
+@Test
+

[04/47] james-project git commit: MAILBOX-359 Factorize tests for Flags ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for Flags ser-deserialization


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

Branch: refs/heads/master
Commit: 5d365c14313a6179b00eb0cdca3d19b637e007eb
Parents: d7910fc
Author: Benoit Tellier 
Authored: Mon Dec 24 14:40:58 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  | 372 +-
 .../event/json/ExpungedSerializationTest.java   | 372 +-
 .../json/FlagsUpdatedSerializationTest.java | 488 +--
 .../apache/james/event/json/dtos/FlagsTest.java | 240 +
 4 files changed, 263 insertions(+), 1209 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/5d365c14/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index d71b9e8..61ce957 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -20,7 +20,6 @@
 package org.apache.james.event.json;
 
 import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
@@ -140,157 +139,6 @@ class AddedSerializationTest {
 }
 
 @Nested
-class WithFlags {
-
-@Nested
-class WithEmptyFlags {
-private final Flags emptyFlags = new FlagsBuilder().build();
-private final MailboxListener.Added emptyFlagsAddedEvent = new 
MailboxListener.Added(SESSION_ID, USER, MAILBOX_PATH, MAILBOX_ID,
-ImmutableSortedMap.of(
-MESSAGE_UID,
-new MessageMetaData(MESSAGE_UID, MOD_SEQ, emptyFlags, 
SIZE, Date.from(INSTANT), MESSAGE_ID)));
-
-private final String emptyFlagsAddedEventJson =
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"mailboxName\"" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": 123456," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[], " +
-"  \"userFlags\":[]}," +
-"\"size\": 45,  " +
-"\"internalDate\": \"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}";
-
-@Test
-void addedShouldBeWellSerializedWhenEmptyFlags() {
-assertThatJson(EVENT_SERIALIZER.toJson(emptyFlagsAddedEvent))
-.isEqualTo(emptyFlagsAddedEventJson);
-}
-
-@Test
-void addedShouldBeWellDeSerializedWhenEmptyFlags() {
-
assertThat(EVENT_SERIALIZER.fromJson(emptyFlagsAddedEventJson).get())
-.isEqualTo(emptyFlagsAddedEvent);
-}
-}
-
-@Nested
-class WithOnlyUserFlags {
-private final Flags onlyUserFlags = new FlagsBuilder()
-.add("Custom 1", "Custom 2", "")
-.build();
-private final MailboxListener.Added onlyUserFlagsAddedEvent = new 
MailboxListener.Added(SESSION_ID, USER, MAILBOX_PATH, MAILBOX_ID,
-ImmutableSortedMap.of(
-MESSAGE_UID,
-new MessageMetaData(MESSAGE_UID, MOD_SEQ, onlyUserFlags, 
SIZE, Date.from(INSTANT), MESSAGE_ID)));
-
-private final String userOnlyFlagsAddedEventJson =
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": \"

[16/47] james-project git commit: MAILBOX-359 Use val to avoid too much class instanciations

2019-01-08 Thread btellier
MAILBOX-359 Use val to avoid too much class instanciations


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

Branch: refs/heads/master
Commit: 6f8cb2291c5747105df6fc2689726f9da8a746bf
Parents: 0cdd567
Author: Benoit Tellier 
Authored: Tue Dec 25 15:59:19 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:38 2019 +0700

--
 .../org/apache/james/event/json/EventSerializer.scala  | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/6f8cb229/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
--
diff --git 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index 3628e37..6daf248 100644
--- 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -311,17 +311,16 @@ class JsonSerialize(mailboxIdFactory: MailboxId.Factory, 
messageIdFactory: Messa
 def fromJson(json: String): JsResult[Event] = 
Json.fromJson[Event](Json.parse(json))
   }
 
-  def toJson(event: JavaEvent): String = new 
EventSerializerPrivateWrapper().toJson(ScalaConverter.toScala(event))
-  def fromJson(json: String): JsResult[JavaEvent] = new 
EventSerializerPrivateWrapper().fromJson(json)
+  private val eventSerializerPrivateWrapper = new 
EventSerializerPrivateWrapper()
+  def toJson(event: JavaEvent): String = 
eventSerializerPrivateWrapper.toJson(ScalaConverter.toScala(event))
+  def fromJson(json: String): JsResult[JavaEvent] = 
eventSerializerPrivateWrapper.fromJson(json)
 .map(event => event.toJava)
 }
 
 class EventSerializer(mailboxIdFactory: MailboxId.Factory, messageIdFactory: 
MessageId.Factory) {
-  def toJson(event: JavaEvent): String = new JsonSerialize(mailboxIdFactory, 
messageIdFactory).toJson(event)
+  private val jsonSerialize = new JsonSerialize(mailboxIdFactory, 
messageIdFactory)
 
-  def fromJson(json: String): JsResult[JavaEvent] = {
-new JsonSerialize(mailboxIdFactory, messageIdFactory)
-  .fromJson(json)
-  }
+  def toJson(event: JavaEvent): String = jsonSerialize.toJson(event)
+  def fromJson(json: String): JsResult[JavaEvent] = 
jsonSerialize.fromJson(json)
 }
 


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



[26/47] james-project git commit: MAILBOX-364 EventFactory should expose a builder for MailboxAclUpdated event

2019-01-08 Thread btellier
MAILBOX-364 EventFactory should expose a builder for MailboxAclUpdated event


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

Branch: refs/heads/master
Commit: 098dbe44341d4d34099d1dd33dc6962a6ecb564e
Parents: 2c46d62
Author: Benoit Tellier 
Authored: Wed Dec 19 13:46:24 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../james/mailbox/store/event/EventFactory.java | 34 
 .../store/event/MailboxEventDispatcher.java |  7 +++-
 2 files changed, 34 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/098dbe44/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 0205560..de9ed6e 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -168,6 +168,32 @@ public class EventFactory {
 }
 }
 
+public static class MailboxAclUpdatedBuilder extends 
MailboxEventBuilder {
+private ACLDiff aclDiff;
+
+public MailboxAclUpdatedBuilder aclDiff(ACLDiff aclDiff) {
+this.aclDiff = aclDiff;
+return this;
+}
+
+@Override
+protected MailboxAclUpdatedBuilder backReference() {
+return this;
+}
+
+public MailboxListener.MailboxACLUpdated build() {
+Preconditions.checkState(aclDiff != null, "Field `aclDiff` is 
compulsory");
+mailboxEventChecks();
+
+return new MailboxListener.MailboxACLUpdated(
+sessionId,
+user,
+path,
+aclDiff,
+mailboxId);
+}
+}
+
 public static class MailboxAddedBuilder extends 
MailboxEventBuilder {
 @Override
 protected MailboxAddedBuilder backReference() {
@@ -275,12 +301,8 @@ public class EventFactory {
 return new MailboxAddedBuilder();
 }
 
-public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession 
session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
-return aclUpdated(session.getSessionId(), session.getUser(), 
mailboxPath, aclDiff, mailboxId);
-}
-
-public MailboxListener.MailboxACLUpdated 
aclUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath 
mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
-return new MailboxListener.MailboxACLUpdated(sessionId, user, 
mailboxPath, aclDiff, mailboxId);
+public MailboxAclUpdatedBuilder aclUpdated() {
+return new MailboxAclUpdatedBuilder();
 }
 
 public MessageMoveEvent moved(MailboxSession session, MessageMoves 
messageMoves, Collection messageIds) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/098dbe44/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index 122394f..da360d5 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -178,7 +178,12 @@ public class MailboxEventDispatcher {
 }
 
 public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, 
ACLDiff aclDiff, MailboxId mailboxId) {
-event(eventFactory.aclUpdated(session, mailboxPath, aclDiff, 
mailboxId));
+event(eventFactory.aclUpdated()
+.mailboxSession(session)
+.path(mailboxPath)
+.mailboxId(mailboxId)
+.aclDiff(aclDiff)
+.build());
 }
 
 public void moved(MailboxSession session, MessageMoves messageMoves, 
Collection messageIds) {


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



[20/47] james-project git commit: MAILBOX-359 MaildirMailboxMapper should return the mailboxId on persisted mailboxes

2019-01-08 Thread btellier
MAILBOX-359 MaildirMailboxMapper should return the mailboxId on persisted 
mailboxes


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

Branch: refs/heads/master
Commit: def6258ebe8491c4caeafcac0b3c51e655e366a2
Parents: 1371fad
Author: Benoit Tellier 
Authored: Thu Dec 20 13:14:06 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:40:28 2019 +0700

--
 .../org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/def6258e/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
--
diff --git 
a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
 
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
index 173aba6..abf51f7 100644
--- 
a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
+++ 
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
@@ -231,6 +231,7 @@ public class MaildirMailboxMapper extends 
NonTransactionalMapper implements Mail
 try {
 folder.setUidValidity(mailbox.getUidValidity());
 folder.setMailboxId(maildirId);
+mailbox.setMailboxId(maildirId);
 } catch (IOException ioe) {
 throw new MailboxException("Failed to save Mailbox " + 
mailbox, ioe);
 


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



[32/47] james-project git commit: MAILBOX-364 Builder for QuotaUsageUpdatedEvent

2019-01-08 Thread btellier
MAILBOX-364 Builder for QuotaUsageUpdatedEvent


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

Branch: refs/heads/master
Commit: 5392ad98b35860b26a63fd8e7b7bcbe256da8966
Parents: 7097446
Author: Benoit Tellier 
Authored: Thu Jan 3 13:46:21 2019 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:41:11 2019 +0700

--
 .../QuotaThresholdConfigurationChangesTest.java | 206 ++---
 .../QuotaThresholdMailingIntegrationTest.java   | 223 ---
 .../ElasticSearchQuotaMailboxListenerTest.java  |  10 +-
 .../json/QuotaRatioToElasticSearchJsonTest.java |  34 +--
 .../james/mailbox/store/event/EventFactory.java |  48 +++-
 5 files changed, 444 insertions(+), 77 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/5392ad98/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
--
diff --git 
a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
 
b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
index 87d720d..3114c65 100644
--- 
a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
+++ 
b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
@@ -29,10 +29,10 @@ import static 
org.apache.james.mailbox.quota.model.QuotaThresholdFixture.mailetC
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.eventsourcing.eventstore.EventStore;
-import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
 import 
org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
+import org.apache.james.mailbox.store.event.EventFactory;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.junit.jupiter.api.Test;
 
@@ -56,13 +56,25 @@ public interface QuotaThresholdConfigurationChangesTest {
 FakeMailContext mailetContext = mailetContext();
 QuotaThresholdListenersTestSystem testee = new 
QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
-
-testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, 
Counts._40_PERCENT, Sizes._55_PERCENT, NOW));
+testee.event(EventFactory.quotaUpdated()
+.user(BOB_USER)
+.quotaRoot(QUOTAROOT)
+.quotaCount(Counts._40_PERCENT)
+.quotaSize(Sizes._55_PERCENT)
+.instant(NOW)
+.build());
 
 testee = new QuotaThresholdListenersTestSystem(mailetContext, store, 
CONFIGURATION_75);
 
 mailetContext.resetSentMails();
-testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, 
Counts._40_PERCENT, Sizes._55_PERCENT, NOW));
+
+testee.event(EventFactory.quotaUpdated()
+.user(BOB_USER)
+.quotaRoot(QUOTAROOT)
+.quotaCount(Counts._40_PERCENT)
+.quotaSize(Sizes._55_PERCENT)
+.instant(NOW)
+.build());
 
 assertThat(mailetContext.getSentMails()).isEmpty();
 }
@@ -72,12 +84,25 @@ public interface QuotaThresholdConfigurationChangesTest {
 FakeMailContext mailetContext = mailetContext();
 QuotaThresholdListenersTestSystem testee = new 
QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75);
 
-testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, 
Counts._40_PERCENT, Sizes._92_PERCENT, NOW));
+testee.event(EventFactory.quotaUpdated()
+.user(BOB_USER)
+.quotaRoot(QUOTAROOT)
+.quotaCount(Counts._40_PERCENT)
+.quotaSize(Sizes._92_PERCENT)
+.instant(NOW)
+.build());
 
 testee = new QuotaThresholdListenersTestSystem(mailetContext, store, 
CONFIGURATION_50);
 
 mailetContext.resetSentMails();
-testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, 
Counts._40_PERCENT, Sizes._92_PERCENT, NOW));
+
+testee.event(EventFactory.quotaUpdated()
+.user(BOB_USER)
+.quotaRoot(QUOTAROOT)
+.quotaCount(Counts._40_PERCENT)
+.quotaSize(Sizes._92_PERCENT)
+.instant(NOW)
+.build());

[12/47] james-project git commit: MAILBOX-359 Factorize tests for MessageUid ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for MessageUid ser-deserialization


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

Branch: refs/heads/master
Commit: ba9ff0d6c6d67cafb5e58f5feb0eb64a27632599
Parents: 5d365c1
Author: Benoit Tellier 
Authored: Mon Dec 24 14:44:04 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../event/json/AddedSerializationTest.java  | 43 +-
 .../event/json/ExpungedSerializationTest.java   | 43 +-
 .../json/FlagsUpdatedSerializationTest.java | 83 
 .../james/event/json/dtos/MessageUidTest.java   | 65 +++
 4 files changed, 73 insertions(+), 161 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/ba9ff0d6/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 61ce957..8246e77 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -379,43 +379,10 @@ class AddedSerializationTest {
 .isInstanceOf(NoSuchElementException.class);
 }
 
-@Nested
-class DeserializationErrorOnMessageUid {
-
-@Test
-void addedShouldThrowWhenMessageUidIsAString() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"Added\": {" +
-"\"path\": {" +
-"  \"namespace\": \"#private\"," +
-"  \"user\": \"user\"," +
-"  \"name\": null" +
-"}," +
-"\"mailboxId\": \"18\"," +
-"\"added\": {" +
-"  \"123456\": {" +
-"\"uid\": \"123456\"," +
-"\"modSeq\": 35," +
-"\"flags\": {" +
-"  \"systemFlags\":[\"Answered\",\"Draft\"], " 
+
-"  \"userFlags\":[\"User Custom Flag\"]}," +
-"\"size\": 45,  " +
-"\"internalDate\": 
\"2018-12-14T09:41:51.541Z\"," +
-"\"messageId\": \"42\"" +
-"  }" +
-"}," +
-"\"sessionId\": 42," +
-"\"user\": \"user\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void addedShouldThrowWhenMessageUidIsNull() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
+@Test
+void addedShouldThrowWhenMessageUidIsMissing() {
+assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
+"{" +
 "  \"Added\": {" +
 "\"path\": {" +
 "  \"namespace\": \"#private\"," +
@@ -425,7 +392,6 @@ class AddedSerializationTest {
 "\"mailboxId\": \"18\"," +
 "\"added\": {" +
 "  \"123456\": {" +
-"\"uid\": null," +
 "\"modSeq\": 35," +
 "\"flags\": {" +
 "  \"systemFlags\":[\"Answered\",\"Draft\"], " 
+
@@ -440,7 +406,6 @@ class AddedSerializationTest {
 "  }" +
 "}").get())
 .isInstanceOf(NoSuchElementException.class);
-}
 }
 
 @Nested

http://git-wip-us.apache.org/repos/asf/james-project/blob/ba9ff0d6/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/even

[02/47] james-project git commit: MAILBOX-359 Factorize tests for ACLDiffTest ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for ACLDiffTest ser-deserialization


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

Branch: refs/heads/master
Commit: 19710d410fc1274b8cdaaeba93b0715a3a22cb31
Parents: b458e40
Author: Benoit Tellier 
Authored: Mon Dec 24 15:58:44 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 ...MailboxACLUpdatedEventSerializationTest.java | 402 ---
 .../james/event/json/dtos/ACLDiffTest.java  | 108 +
 2 files changed, 108 insertions(+), 402 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/19710d41/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
index 7176c91..a4cefb3 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
@@ -29,7 +29,6 @@ import org.apache.james.core.User;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.acl.ACLDiff;
-import org.apache.james.mailbox.exception.UnsupportedRightException;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -38,8 +37,6 @@ import org.apache.james.mailbox.model.TestMessageId;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 
-import com.fasterxml.jackson.core.JsonParseException;
-
 class MailboxACLUpdatedEventSerializationTest {
 
 private static final User USER = User.fromUsername("user");
@@ -230,405 +227,6 @@ class MailboxACLUpdatedEventSerializationTest {
 .isInstanceOf(NoSuchElementException.class);
 }
 
-@Nested
-class DeserializationErrorOnOldACL {
-
-@Test
-void mailboxACLUpdatedShouldThrowWhenMissingOldACLinACLDiff() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"MailboxACLUpdated\":{" +
-"\"mailboxPath\":{" +
-"   \"namespace\":\"#private\"," +
-"   \"name\":\"mailboxName\"" +
-"  }," +
-"\"aclDiff\":{" +
-"   \"newACL\":{\"$any\":\"ar\"}}," +
-"\"mailboxId\":\"23\"," +
-"\"sessionId\":6," +
-"\"user\":\"user\"" +
-"   }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Nested
-class DeserializationErrorOnOldACLEntryKey {
-
-@Test
-void 
mailboxACLUpdatedShouldThrowWhenNotIncludedNameInEntryKey() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"MailboxACLUpdated\":{" +
-"\"mailboxPath\":{" +
-"   \"namespace\":\"#private\"," +
-"   \"user\":\"bob\"," +
-"   \"name\":\"mailboxName\"" +
-"  }," +
-"\"aclDiff\":{" +
-"   \"oldACL\":{\"$\":\"ar\"}}," +
-"   \"newACL\":{}," +
-"\"mailboxId\":\"23\"," +
-"\"sessionId\":6," +
-"\"user\":\"user\"" +
-"   }" +
-"}").get())
-.isInstanceOf(IllegalStateException.class);
-}
-
-@Test
-void 
mailboxACLUpdatedShouldThrowWhenNameInEntryKeyIsNotString() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"MailboxACLUpdated\":{" +
-"\"mailboxPath\":{" +
-"   \"namespace\":\"#private\"," +
-"   \"user\":\"bob\"," +
-"

[15/47] james-project git commit: MAILBOX-359 Switch Scala Event trait back to private

2019-01-08 Thread btellier
MAILBOX-359 Switch Scala Event trait back to private

This needs to be done by wrapping all references to this trait as private


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

Branch: refs/heads/master
Commit: 0cdd567c3a5ef35dbf1b6a21547ec5e8a6c85cad
Parents: 0a16e7c
Author: Benoit Tellier 
Authored: Tue Dec 25 15:47:22 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:39:29 2019 +0700

--
 .../apache/james/event/json/EventSerializer.scala   | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/0cdd567c/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
--
diff --git 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index 6418425..3628e37 100644
--- 
a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ 
b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -35,7 +35,7 @@ import play.api.libs.json.{JsError, JsNull, JsNumber, 
JsObject, JsResult, JsStri
 
 import scala.collection.JavaConverters._
 
-sealed trait Event {
+private sealed trait Event {
   def toJava: JavaEvent
 }
 
@@ -304,20 +304,24 @@ class JsonSerialize(mailboxIdFactory: MailboxId.Factory, 
messageIdFactory: Messa
   implicit val messageMetaDataReads: Reads[DTOs.MessageMetaData] = 
Json.reads[DTOs.MessageMetaData]
   implicit val updatedFlagsReads: Reads[DTOs.UpdatedFlags] = 
Json.reads[DTOs.UpdatedFlags]
 
-  implicit val eventOFormat: OFormat[Event] = derived.oformat()
+  private class EventSerializerPrivateWrapper {
+implicit val eventOFormat: OFormat[Event] = derived.oformat()
 
-  def toJson(event: Event): String = Json.toJson(event).toString()
+def toJson(event: Event): String = Json.toJson(event).toString()
+def fromJson(json: String): JsResult[Event] = 
Json.fromJson[Event](Json.parse(json))
+  }
 
-  def fromJson(json: String): JsResult[Event] = 
Json.fromJson[Event](Json.parse(json))
+  def toJson(event: JavaEvent): String = new 
EventSerializerPrivateWrapper().toJson(ScalaConverter.toScala(event))
+  def fromJson(json: String): JsResult[JavaEvent] = new 
EventSerializerPrivateWrapper().fromJson(json)
+.map(event => event.toJava)
 }
 
 class EventSerializer(mailboxIdFactory: MailboxId.Factory, messageIdFactory: 
MessageId.Factory) {
-  def toJson(event: JavaEvent): String = new JsonSerialize(mailboxIdFactory, 
messageIdFactory).toJson(ScalaConverter.toScala(event))
+  def toJson(event: JavaEvent): String = new JsonSerialize(mailboxIdFactory, 
messageIdFactory).toJson(event)
 
   def fromJson(json: String): JsResult[JavaEvent] = {
 new JsonSerialize(mailboxIdFactory, messageIdFactory)
   .fromJson(json)
-  .map(event => event.toJava)
   }
 }
 


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



[06/47] james-project git commit: MAILBOX-359 Factorize tests for QuotaRoot ser-deserialization

2019-01-08 Thread btellier
MAILBOX-359 Factorize tests for QuotaRoot ser-deserialization


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

Branch: refs/heads/master
Commit: d7910fcb001416800b401e8b6ba477652a36464c
Parents: 70a4fd5
Author: Benoit Tellier 
Authored: Mon Dec 24 14:10:17 2018 +0700
Committer: Benoit Tellier 
Committed: Tue Jan 8 14:37:57 2019 +0700

--
 .../json/MailboxDeletionSerializationTest.java  | 93 +---
 ...QuotaUsageUpdatedEventSerializationTest.java | 88 --
 .../james/event/json/dtos/QuotaRootTest.java| 92 +++
 3 files changed, 96 insertions(+), 177 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/d7910fcb/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
--
diff --git 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
index f0f9f66..1f76c5b 100644
--- 
a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
+++ 
b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
@@ -90,46 +90,6 @@ class MailboxDeletionSerializationTest {
 }
 
 @Nested
-class EmptyQuotaRoot {
-private final MailboxListener.MailboxDeletion emptyQuotaRootEvent = 
new MailboxListener.MailboxDeletion(
-SESSION_ID,
-USER,
-MAILBOX_PATH,
-QuotaRoot.quotaRoot("", Optional.empty()),
-DELETED_MESSAGE_COUNT,
-TOTAL_DELETED_SIZE,
-MAILBOX_ID);
-private final String nullUserMailboxEventJson =
-"{" +
-"  \"MailboxDeletion\":{" +
-"\"sessionId\":3652," +
-"\"user\":\"user\"," +
-"\"path\":{" +
-"  \"namespace\":\"#private\"," +
-"  \"user\":\"user\"," +
-"  \"name\":\"mailboxName\"" +
-"}," +
-"\"quotaRoot\":\"\"," +
-"\"deletedMessageCount\":60," +
-"\"totalDeletedSize\":100," +
-"\"mailboxId\":\"789\"" +
-"  }" +
-"}";
-
-@Test
-void mailboxAddedShouldBeWellSerializedWhenEmptyQuotaRoot() {
-assertThatJson(EVENT_SERIALIZER.toJson(emptyQuotaRootEvent))
-.isEqualTo(nullUserMailboxEventJson);
-}
-
-@Test
-void mailboxAddedShouldBeWellDeSerializedWhenEmptyQuotaRoot() {
-
assertThat(EVENT_SERIALIZER.fromJson(nullUserMailboxEventJson).get())
-.isEqualTo(emptyQuotaRootEvent);
-}
-}
-
-@Nested
 class NullQuotaCountInDeletedMessageCount {
 private final MailboxListener.MailboxDeletion 
unlimitedQuotaCountDeletedMessageEvent = new MailboxListener.MailboxDeletion(
 SESSION_ID,
@@ -251,53 +211,10 @@ class MailboxDeletionSerializationTest {
 .isInstanceOf(NoSuchElementException.class);
 }
 
-@Nested
-class DeserializationErrorOnQuotaRoot {
-@Test
-void mailboxAddedShouldThrowWhenMissingQuotaRoot() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"MailboxDeletion\":{" +
-"\"sessionId\":3652," +
-"\"user\":\"user\"," +
-"\"path\":{" +
-"  \"namespace\":\"#private\"," +
-"  \"user\":\"user\"," +
-"  \"name\":\"mailboxName\"" +
-"}," +
-"\"deletedMessageCount\":60," +
-"\"totalDeletedSize\":100," +
-"\"mailboxId\":\"789\"" +
-"  }" +
-"}").get())
-.isInstanceOf(NoSuchElementException.class);
-}
-
-@Test
-void mailboxAddedShouldThrowWhenNullQuotaRoot() {
-assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
-"{" +
-"  \"MailboxDeletion\":{" +
-"\"sessionId\":3652," +
-"\"user\":\"user\"," +
-"\"path\":{" +
-"  \"namespace\":\"#private\"," +
-"