You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/04/07 08:01:31 UTC
[james-project] 06/07: JAMES-3078 JMAP Get/Set filter should be
reactive
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 488ebd20d69c99492006750a5296d3b2343df361
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sun Apr 5 15:30:48 2020 +0700
JAMES-3078 JMAP Get/Set filter should be reactive
---
.../jmap/api/filtering/FilteringManagement.java | 10 ++--
.../impl/EventSourcingFilteringManagement.java | 4 +-
.../api/filtering/FilteringManagementContract.java | 21 +++++----
.../james/jmap/draft/methods/GetFilterMethod.java | 33 +++++--------
.../james/jmap/draft/methods/SetFilterMethod.java | 55 ++++++++++++----------
.../jmap/mailet/filter/JMAPFilteringExtension.java | 4 +-
.../jmap/mailet/filter/JMAPFilteringTest.java | 30 ++++++------
7 files changed, 80 insertions(+), 77 deletions(-)
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/FilteringManagement.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/FilteringManagement.java
index 6e780f9..3305ead 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/FilteringManagement.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/FilteringManagement.java
@@ -29,14 +29,14 @@ import com.google.common.collect.ImmutableList;
public interface FilteringManagement {
- void defineRulesForUser(Username username, List<Rule> rules);
+ Publisher<Void> defineRulesForUser(Username username, List<Rule> rules);
- default void defineRulesForUser(Username username, Rule... rules) {
- defineRulesForUser(username, Arrays.asList(rules));
+ default Publisher<Void> defineRulesForUser(Username username, Rule... rules) {
+ return defineRulesForUser(username, Arrays.asList(rules));
}
- default void clearRulesForUser(Username username) {
- defineRulesForUser(username, ImmutableList.of());
+ default Publisher<Void> clearRulesForUser(Username username) {
+ return defineRulesForUser(username, ImmutableList.of());
}
Publisher<Rule> listRulesForUser(Username username);
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java
index 429cc79..72af24d 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java
@@ -54,8 +54,8 @@ public class EventSourcingFilteringManagement implements FilteringManagement {
}
@Override
- public void defineRulesForUser(Username username, List<Rule> rules) {
- Mono.from(eventSourcingSystem.dispatch(new DefineRulesCommand(username, rules))).block();
+ public Publisher<Void> defineRulesForUser(Username username, List<Rule> rules) {
+ return eventSourcingSystem.dispatch(new DefineRulesCommand(username, rules));
}
@Override
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/FilteringManagementContract.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/FilteringManagementContract.java
index 7a355d4..6dcf8c6 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/FilteringManagementContract.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/FilteringManagementContract.java
@@ -36,6 +36,7 @@ import org.apache.james.jmap.api.filtering.impl.EventSourcingFilteringManagement
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
public interface FilteringManagementContract {
@@ -63,7 +64,7 @@ public interface FilteringManagementContract {
default void listingRulesShouldReturnDefinedRules(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- testee.defineRulesForUser(USERNAME, RULE_1, RULE_2);
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_1, RULE_2)).block();
assertThat(Flux.from(testee.listRulesForUser(USERNAME)).toStream())
.containsExactly(RULE_1, RULE_2);
@@ -73,8 +74,8 @@ public interface FilteringManagementContract {
default void listingRulesShouldReturnLastDefinedRules(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- testee.defineRulesForUser(USERNAME, RULE_1, RULE_2);
- testee.defineRulesForUser(USERNAME, RULE_2, RULE_1);
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_1, RULE_2)).block();
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_2, RULE_1)).block();
assertThat(Flux.from(testee.listRulesForUser(USERNAME)).toStream())
.containsExactly(RULE_2, RULE_1);
@@ -84,7 +85,7 @@ public interface FilteringManagementContract {
default void definingRulesShouldThrowWhenDuplicateRules(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- assertThatThrownBy(() -> testee.defineRulesForUser(USERNAME, RULE_1, RULE_1))
+ assertThatThrownBy(() -> Mono.from(testee.defineRulesForUser(USERNAME, RULE_1, RULE_1)).block())
.isInstanceOf(IllegalArgumentException.class);
}
@@ -92,7 +93,7 @@ public interface FilteringManagementContract {
default void definingRulesShouldThrowWhenNullUser(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- assertThatThrownBy(() -> testee.defineRulesForUser(null, RULE_1, RULE_1))
+ assertThatThrownBy(() -> Mono.from(testee.defineRulesForUser(null, RULE_1, RULE_1)).block())
.isInstanceOf(NullPointerException.class);
}
@@ -101,14 +102,14 @@ public interface FilteringManagementContract {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
List<Rule> rules = null;
- assertThatThrownBy(() -> testee.defineRulesForUser(USERNAME, rules))
+ assertThatThrownBy(() -> Mono.from(testee.defineRulesForUser(USERNAME, rules)).block())
.isInstanceOf(NullPointerException.class);
}
@Test
default void definingRulesShouldKeepOrdering(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- testee.defineRulesForUser(USERNAME, RULE_3, RULE_2, RULE_1);
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_3, RULE_2, RULE_1)).block();
assertThat(Flux.from(testee.listRulesForUser(USERNAME)).toStream())
.containsExactly(RULE_3, RULE_2, RULE_1);
@@ -118,8 +119,8 @@ public interface FilteringManagementContract {
default void definingEmptyRuleListShouldRemoveExistingRules(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- testee.defineRulesForUser(USERNAME, RULE_3, RULE_2, RULE_1);
- testee.clearRulesForUser(USERNAME);
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_3, RULE_2, RULE_1)).block();
+ Mono.from(testee.clearRulesForUser(USERNAME)).block();
assertThat(Flux.from(testee.listRulesForUser(USERNAME)).toStream()).isEmpty();
}
@@ -128,7 +129,7 @@ public interface FilteringManagementContract {
default void allFieldsAndComparatorShouldWellBeStored(EventStore eventStore) {
FilteringManagement testee = instantiateFilteringManagement(eventStore);
- testee.defineRulesForUser(USERNAME, RULE_FROM, RULE_RECIPIENT, RULE_SUBJECT, RULE_TO, RULE_1);
+ Mono.from(testee.defineRulesForUser(USERNAME, RULE_FROM, RULE_RECIPIENT, RULE_SUBJECT, RULE_TO, RULE_1)).block();
assertThat(Flux.from(testee.listRulesForUser(USERNAME)).toStream())
.containsExactly(RULE_FROM, RULE_RECIPIENT, RULE_SUBJECT, RULE_TO, RULE_1);
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetFilterMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetFilterMethod.java
index 618d862..6c1ca63 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetFilterMethod.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetFilterMethod.java
@@ -19,7 +19,7 @@
package org.apache.james.jmap.draft.methods;
-import java.util.stream.Stream;
+import static org.apache.james.util.ReactorUtils.context;
import javax.inject.Inject;
@@ -67,7 +67,7 @@ public class GetFilterMethod implements Method {
}
@Override
- public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) {
+ public Flux<JmapResponse> process(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) {
Preconditions.checkNotNull(request);
Preconditions.checkNotNull(methodCallId);
Preconditions.checkNotNull(mailboxSession);
@@ -75,26 +75,21 @@ public class GetFilterMethod implements Method {
GetFilterRequest filterRequest = (GetFilterRequest) request;
-
- return MDCBuilder.create()
- .addContext(MDCBuilder.ACTION, "GET_FILTER")
- .wrapArround(
- () -> metricFactory.runPublishingTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(),
- () -> process(methodCallId, mailboxSession, filterRequest)))
- .get();
+ return Flux.from(metricFactory.runPublishingTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(),
+ () -> process(methodCallId, mailboxSession, filterRequest)
+ .subscriberContext(context("GET_FILTER", MDCBuilder.of(MDCBuilder.ACTION, "GET_FILTER")))));
}
- private Stream<JmapResponse> process(MethodCallId methodCallId, MailboxSession mailboxSession, GetFilterRequest request) {
- try {
- return retrieveFilter(methodCallId, mailboxSession.getUser());
- } catch (Exception e) {
- LOGGER.warn("Failed to retrieve filter");
+ private Mono<JmapResponse> process(MethodCallId methodCallId, MailboxSession mailboxSession, GetFilterRequest request) {
+ return retrieveFilter(methodCallId, mailboxSession.getUser())
+ .onErrorResume(e -> {
+ LOGGER.warn("Failed to retrieve filter", e);
- return Stream.of(unKnownError(methodCallId));
- }
+ return Mono.just(unKnownError(methodCallId));
+ });
}
- private Stream<JmapResponse> retrieveFilter(MethodCallId methodCallId, Username username) {
+ private Mono<JmapResponse> retrieveFilter(MethodCallId methodCallId, Username username) {
return Flux.from(filteringManagement.listRulesForUser(username))
.collect(Guavate.toImmutableList())
.map(rules -> GetFilterResponse.builder()
@@ -104,9 +99,7 @@ public class GetFilterMethod implements Method {
.methodCallId(methodCallId)
.response(getFilterResponse)
.responseName(RESPONSE_NAME)
- .build())
- .flatMapMany(Mono::just)
- .toStream();
+ .build());
}
private JmapResponse unKnownError(MethodCallId methodCallId) {
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetFilterMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetFilterMethod.java
index b6e82d7..f0ac91a 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetFilterMethod.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetFilterMethod.java
@@ -19,11 +19,13 @@
package org.apache.james.jmap.draft.methods;
+import static org.apache.james.jmap.http.LoggingHelper.jmapAction;
+import static org.apache.james.util.ReactorUtils.context;
+
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import javax.inject.Inject;
@@ -38,13 +40,18 @@ import org.apache.james.jmap.draft.model.SetFilterResponse;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.util.MDCBuilder;
+import org.apache.james.util.ReactorUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.github.steveash.guavate.Guavate;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
public class SetFilterMethod implements Method {
public static class DuplicatedRuleException extends Exception {
@@ -102,7 +109,7 @@ public class SetFilterMethod implements Method {
}
@Override
- public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) {
+ public Flux<JmapResponse> process(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) {
Preconditions.checkNotNull(request);
Preconditions.checkNotNull(methodCallId);
Preconditions.checkNotNull(mailboxSession);
@@ -111,52 +118,50 @@ public class SetFilterMethod implements Method {
SetFilterRequest setFilterRequest = (SetFilterRequest) request;
- return MDCBuilder.create()
- .addContext(MDCBuilder.ACTION, "SET_FILTER")
- .addContext("update", setFilterRequest.getSingleton())
- .wrapArround(
- () -> metricFactory.runPublishingTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(),
- () -> process(methodCallId, mailboxSession, setFilterRequest)))
- .get();
+ return Flux.from(metricFactory.runPublishingTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(),
+ () -> process(methodCallId, mailboxSession, setFilterRequest)
+ .subscriberContext(jmapAction("SET_FILTER"))
+ .subscriberContext(context("SET_FILTER", MDCBuilder.of("update", setFilterRequest.getSingleton())))));
}
- private Stream<JmapResponse> process(MethodCallId methodCallId, MailboxSession mailboxSession, SetFilterRequest request) {
+ private Mono<JmapResponse> process(MethodCallId methodCallId, MailboxSession mailboxSession, SetFilterRequest request) {
try {
- return updateFilter(methodCallId, request, mailboxSession.getUser());
+ return updateFilter(methodCallId, request, mailboxSession.getUser())
+ .doOnEach(ReactorUtils.logOnError(e -> LOGGER.warn("Failed setting Rules", e)))
+ .onErrorResume(e -> Mono.just(unKnownError(methodCallId)));
} catch (MultipleMailboxIdException e) {
LOGGER.debug("Rule targeting several mailboxes", e);
- return Stream.of(multipleMailboxesError(methodCallId, e));
+ return Mono.just(multipleMailboxesError(methodCallId, e));
} catch (DuplicatedRuleException e) {
LOGGER.debug("Duplicated rules", e);
- return Stream.of(duplicatedIdsError(methodCallId, e));
- } catch (Exception e) {
+ return Mono.just(duplicatedIdsError(methodCallId, e));
+ } catch (Exception e) {
LOGGER.warn("Failed setting Rules", e);
- return Stream.of(unKnownError(methodCallId));
+ return Mono.just(unKnownError(methodCallId));
}
}
- private Stream<JmapResponse> updateFilter(MethodCallId methodCallId, SetFilterRequest request, Username username) throws DuplicatedRuleException, MultipleMailboxIdException {
+ private Mono<JmapResponse> updateFilter(MethodCallId methodCallId, SetFilterRequest request, Username username) throws DuplicatedRuleException, MultipleMailboxIdException {
ImmutableList<Rule> rules = request.getSingleton().stream()
.map(JmapRuleDTO::toRule)
- .collect(ImmutableList.toImmutableList());
+ .collect(Guavate.toImmutableList());
ensureNoDuplicatedRules(rules);
ensureNoMultipleMailboxesRules(rules);
- filteringManagement.defineRulesForUser(username, rules);
-
- return Stream.of(JmapResponse.builder()
- .methodCallId(methodCallId)
- .responseName(RESPONSE_NAME)
- .response(SetFilterResponse.updated())
- .build());
+ return Mono.from(filteringManagement.defineRulesForUser(username, rules))
+ .thenReturn(JmapResponse.builder()
+ .methodCallId(methodCallId)
+ .responseName(RESPONSE_NAME)
+ .response(SetFilterResponse.updated())
+ .build());
}
private void ensureNoMultipleMailboxesRules(ImmutableList<Rule> rules) throws MultipleMailboxIdException {
ImmutableList<Rule.Id> idWithMultipleMailboxes = rules.stream()
.filter(rule -> rule.getAction().getAppendInMailboxes().getMailboxIds().size() > 1)
.map(Rule::getId)
- .collect(ImmutableList.toImmutableList());
+ .collect(Guavate.toImmutableList());
if (!idWithMultipleMailboxes.isEmpty()) {
throw new MultipleMailboxIdException(idWithMultipleMailboxes);
diff --git a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringExtension.java b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringExtension.java
index 4232100..6ad8f2e 100644
--- a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringExtension.java
+++ b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringExtension.java
@@ -53,6 +53,8 @@ import org.junit.jupiter.api.extension.ParameterResolver;
import com.google.common.collect.ImmutableList;
+import reactor.core.publisher.Mono;
+
public class JMAPFilteringExtension implements BeforeEachCallback, ParameterResolver {
private static final DomainList NO_DOMAIN_LIST = null;
@@ -114,7 +116,7 @@ public class JMAPFilteringExtension implements BeforeEachCallback, ParameterReso
.build())
.collect(ImmutableList.toImmutableList());
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME, rules);
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME, rules)).block();
}
public FakeMail asMail(MimeMessageBuilder mimeMessageBuilder) throws MessagingException {
diff --git a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
index b28d8e1..27d503a 100644
--- a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
+++ b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
@@ -80,6 +80,8 @@ import com.github.fge.lambdas.Throwing;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+import reactor.core.publisher.Mono;
+
@ExtendWith(JMAPFilteringExtension.class)
class JMAPFilteringTest {
@@ -692,7 +694,7 @@ class JMAPFilteringTest {
MailboxId mailbox2Id = testSystem.createMailbox(RECIPIENT_1_USERNAME, "RECIPIENT_1_MAILBOX_2");
MailboxId mailbox3Id = testSystem.createMailbox(RECIPIENT_1_USERNAME, "RECIPIENT_1_MAILBOX_3");
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
@@ -710,7 +712,7 @@ class JMAPFilteringTest {
.name("rule 3")
.condition(Rule.Condition.of(TO, EXACTLY_EQUALS, USER_3_ADDRESS))
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(mailbox3Id.serialize())))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.addFrom(USER_2_ADDRESS)
@@ -729,7 +731,7 @@ class JMAPFilteringTest {
MailboxId mailbox2Id = testSystem.createMailbox(RECIPIENT_1_USERNAME, "RECIPIENT_1_MAILBOX_2");
MailboxId mailbox3Id = testSystem.createMailbox(RECIPIENT_1_USERNAME, "RECIPIENT_1_MAILBOX_3");
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
@@ -738,7 +740,7 @@ class JMAPFilteringTest {
mailbox3Id.serialize(),
mailbox2Id.serialize(),
mailbox1Id.serialize()))))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.setSubject(UNSCRAMBLED_SUBJECT));
@@ -753,7 +755,7 @@ class JMAPFilteringTest {
void rulesWithEmptyMailboxIdsShouldBeSkept(JMAPFilteringTestSystem testSystem) throws Exception {
MailboxId mailbox1Id = testSystem.createMailbox(RECIPIENT_1_USERNAME, "RECIPIENT_1_MAILBOX_1");
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
@@ -766,7 +768,7 @@ class JMAPFilteringTest {
.condition(Rule.Condition.of(SUBJECT, CONTAINS, UNSCRAMBLED_SUBJECT))
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(ImmutableList.of(
mailbox1Id.serialize()))))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.setSubject(UNSCRAMBLED_SUBJECT));
@@ -822,13 +824,13 @@ class JMAPFilteringTest {
@Test
void serviceShouldNotThrowWhenUnknownMailboxId(JMAPFilteringTestSystem testSystem) throws Exception {
String unknownMailboxId = "4242";
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
.condition(Rule.Condition.of(FROM, CONTAINS, FRED_MARTIN_FULLNAME))
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(unknownMailboxId)))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.addFrom(FRED_MARTIN_FULL_SCRAMBLED_ADDRESS));
@@ -840,13 +842,13 @@ class JMAPFilteringTest {
@Test
void mailDirectiveShouldNotBeSetWhenUnknownMailboxId(JMAPFilteringTestSystem testSystem) throws Exception {
String unknownMailboxId = "4242";
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
.condition(Rule.Condition.of(FROM, CONTAINS, FRED_MARTIN_FULLNAME))
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(unknownMailboxId)))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.addFrom(FRED_MARTIN_FULL_SCRAMBLED_ADDRESS));
@@ -860,7 +862,7 @@ class JMAPFilteringTest {
@Test
void rulesWithInvalidMailboxIdsShouldBeSkept(JMAPFilteringTestSystem testSystem) throws Exception {
String unknownMailboxId = "4242";
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
@@ -873,7 +875,7 @@ class JMAPFilteringTest {
.condition(Rule.Condition.of(FROM, CONTAINS, FRED_MARTIN_FULLNAME))
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(
testSystem.getRecipient1MailboxId().serialize())))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.addFrom(FRED_MARTIN_FULL_SCRAMBLED_ADDRESS));
@@ -888,7 +890,7 @@ class JMAPFilteringTest {
void rulesWithMultipleMailboxIdsShouldFallbackWhenInvalidFirstMailboxId(JMAPFilteringTestSystem testSystem) throws Exception {
String unknownMailboxId = "4242";
- testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
Rule.builder()
.id(Rule.Id.of("1"))
.name("rule 1")
@@ -896,7 +898,7 @@ class JMAPFilteringTest {
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(
unknownMailboxId,
testSystem.getRecipient1MailboxId().serialize())))
- .build());
+ .build())).block();
FakeMail mail = testSystem.asMail(mimeMessageBuilder()
.addFrom(FRED_MARTIN_FULL_SCRAMBLED_ADDRESS));
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org