You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2020/11/18 02:30:19 UTC

[james-project] 03/07: JAMES-3444 Allow moving JMAP mailets in a local-delivery processor

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 d987d40135b128ca494e54c93cc3ab319e1c30cd
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Nov 13 17:02:44 2020 +0700

    JAMES-3444 Allow moving JMAP mailets in a local-delivery processor
---
 .../api/src/main/java/org/apache/mailet/Mail.java  |  18 ++++
 .../modules/server/CamelMailetContainerModule.java | 101 ++++++++++++++++-----
 .../server/CamelMailetContainerModuleTest.java     |   2 +-
 .../org/apache/james/jmap/draft/JMAPModule.java    |  30 ++++--
 .../james/jmap/draft/MailetPreconditionTest.java   |  49 ++++++----
 5 files changed, 148 insertions(+), 52 deletions(-)

diff --git a/mailet/api/src/main/java/org/apache/mailet/Mail.java b/mailet/api/src/main/java/org/apache/mailet/Mail.java
index 2250811..3b37521 100644
--- a/mailet/api/src/main/java/org/apache/mailet/Mail.java
+++ b/mailet/api/src/main/java/org/apache/mailet/Mail.java
@@ -78,10 +78,28 @@ import com.google.common.collect.ImmutableMap;
  * {@link #removeAllAttributes() all} attributes of a Mail instance.
  */
 public interface Mail extends Serializable, Cloneable {
+    /**
+     * "ghost" state applies to mail that should no longer be processed
+     */
     String GHOST = "ghost";
+    /**
+     * "root" state applies to mail entering mail processing
+     */
     String DEFAULT = "root";
+    /**
+     * "error" state applies to mail whose processing fails. This is the default
+     * way of handling errors.
+     */
     String ERROR = "error";
+    /**
+     * "transport" is commonly used for expressing decisions taken on an email
+     * (whether to relay it? Deliver it to local recipients? Etc...).
+     */
     String TRANSPORT = "transport";
+    /**
+     * "local-delivery" is commonly used operations to perform for local recipients upon receiving emails.
+     */
+    String LOCAL_DELIVERY = "local-delivery";
 
     AttributeName SMTP_AUTH_USER = AttributeName.of("org.apache.james.SMTPAuthUser");
     AttributeName MAILET_ERROR = AttributeName.of("org.apache.james.MailetError");
diff --git a/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
index 532c1cd..68c7d06 100644
--- a/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
+++ b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
@@ -19,10 +19,12 @@
 
 package org.apache.james.modules.server;
 
-import java.util.List;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Optional;
 import java.util.Set;
 import java.util.function.Predicate;
+import java.util.stream.Stream;
 
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.SimpleRegistry;
@@ -31,6 +33,7 @@ import org.apache.commons.configuration2.HierarchicalConfiguration;
 import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.ex.ConfigurationRuntimeException;
 import org.apache.commons.configuration2.tree.ImmutableNode;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.lifecycle.api.Startable;
 import org.apache.james.mailetcontainer.AutomaticallySentMailDetectorImpl;
 import org.apache.james.mailetcontainer.api.MailProcessor;
@@ -59,8 +62,13 @@ import org.apache.mailet.base.AutomaticallySentMailDetector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
@@ -73,7 +81,8 @@ public class CamelMailetContainerModule extends AbstractModule {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(CamelMailetContainerModule.class);
 
-    public static final TransportProcessorCheck.Impl BCC_Check = new TransportProcessorCheck.Impl(
+    public static final ProcessorsCheck.Impl BCC_Check = new ProcessorsCheck.Impl(
+        "transport",
         All.class,
         RemoveMimeHeader.class,
         pair -> pair.getMailet().getMailetConfig().getInitParameter("name").equals("bcc"),
@@ -101,7 +110,7 @@ public class CamelMailetContainerModule extends AbstractModule {
         Multibinder<InitializationOperation> initialisationOperations = Multibinder.newSetBinder(binder(), InitializationOperation.class);
         initialisationOperations.addBinding().to(MailetModuleInitializationOperation.class);
 
-        Multibinder<CamelMailetContainerModule.TransportProcessorCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.TransportProcessorCheck.class);
+        Multibinder<ProcessorsCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), ProcessorsCheck.class);
         transportProcessorChecks.addBinding().toInstance(BCC_Check);
     }
 
@@ -157,18 +166,18 @@ public class CamelMailetContainerModule extends AbstractModule {
         private final ConfigurationProvider configurationProvider;
         private final CamelCompositeProcessor camelCompositeProcessor;
         private final DefaultProcessorsConfigurationSupplier defaultProcessorsConfigurationSupplier;
-        private final Set<TransportProcessorCheck> transportProcessorCheckSet;
+        private final Set<ProcessorsCheck> processorsCheckSet;
         private final DefaultCamelContext camelContext;
 
         @Inject
         public MailetModuleInitializationOperation(ConfigurationProvider configurationProvider,
                                                    CamelCompositeProcessor camelCompositeProcessor,
-                                                   Set<TransportProcessorCheck> transportProcessorCheckSet,
+                                                   Set<ProcessorsCheck> processorsCheckSet,
                                                    DefaultProcessorsConfigurationSupplier defaultProcessorsConfigurationSupplier,
                                                    DefaultCamelContext camelContext) {
             this.configurationProvider = configurationProvider;
             this.camelCompositeProcessor = camelCompositeProcessor;
-            this.transportProcessorCheckSet = transportProcessorCheckSet;
+            this.processorsCheckSet = processorsCheckSet;
             this.defaultProcessorsConfigurationSupplier = defaultProcessorsConfigurationSupplier;
             this.camelContext = camelContext;
         }
@@ -197,15 +206,22 @@ public class CamelMailetContainerModule extends AbstractModule {
         }
 
         private void checkProcessors() throws ConfigurationException {
-            MailProcessor mailProcessor = Optional.ofNullable(camelCompositeProcessor.getProcessor("transport"))
-                .orElseThrow(() -> new RuntimeException("JMAP needs a transport processor"));
-            if (mailProcessor instanceof CamelMailetProcessor) {
-                List<MatcherMailetPair> matcherMailetPairs = ((CamelMailetProcessor) mailProcessor).getPairs();
-                for (TransportProcessorCheck check : transportProcessorCheckSet) {
-                    check.check(matcherMailetPairs);
-                }
-            } else {
-                throw new RuntimeException("Can not perform checks as transport processor is not an instance of " + MailProcessor.class);
+            ImmutableListMultimap<String, MatcherMailetPair> processors = Arrays.stream(camelCompositeProcessor.getProcessorStates())
+                .flatMap(state -> {
+                    MailProcessor processor = camelCompositeProcessor.getProcessor(state);
+                    if (processor instanceof CamelMailetProcessor) {
+                        CamelMailetProcessor camelProcessor = (CamelMailetProcessor) processor;
+                        return camelProcessor.getPairs().stream()
+                            .map(pair -> Pair.of(state, pair));
+                    } else {
+                        throw new RuntimeException("Can not perform checks as transport processor is not an instance of " + MailProcessor.class);
+                    }
+                })
+                .collect(Guavate.toImmutableListMultimap(
+                    Pair::getKey,
+                    Pair::getValue));
+            for (ProcessorsCheck check : processorsCheckSet) {
+                check.check(processors);
             }
         }
 
@@ -216,24 +232,55 @@ public class CamelMailetContainerModule extends AbstractModule {
     }
 
     @FunctionalInterface
-    public interface TransportProcessorCheck {
-        void check(List<MatcherMailetPair> pairs) throws ConfigurationException;
+    public interface ProcessorsCheck {
+        void check(Multimap<String, MatcherMailetPair> processors) throws ConfigurationException;
+
+        class Or implements ProcessorsCheck {
+            public static ProcessorsCheck of(ProcessorsCheck... checks) {
+                return new Or(ImmutableSet.copyOf(checks));
+            }
+
+            private final Set<ProcessorsCheck> checks;
+
+            public Or(Set<ProcessorsCheck> checks) {
+                Preconditions.checkArgument(checks.size() > 0);
+                this.checks = checks;
+            }
 
-        class Impl implements TransportProcessorCheck {
+            @Override
+            public void check(Multimap<String, MatcherMailetPair> processors) throws ConfigurationException {
+                ImmutableList<ConfigurationException> failures = checks.stream().flatMap(check -> {
+                    try {
+                        check.check(processors);
+                        return Stream.empty();
+                    } catch (ConfigurationException e) {
+                        return Stream.of(e);
+                    }
+                }).collect(Guavate.toImmutableList());
+
+                if (failures.size() == checks.size()) {
+                    throw failures.get(0);
+                }
+            }
+        }
+
+        class Impl implements ProcessorsCheck {
+            private final String processorName;
             private final Class<? extends Matcher> matcherClass;
             private final Class<? extends Mailet> mailetClass;
             private final Optional<Predicate<? super MatcherMailetPair>> additionalFilter;
             private final Optional<String> additionalErrorMessage;
 
-            public Impl(Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass) {
-                this(matcherClass, mailetClass, Optional.empty(), Optional.empty());
+            public Impl(String processorName, Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass) {
+                this(processorName, matcherClass, mailetClass, Optional.empty(), Optional.empty());
             }
 
-            public Impl(Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass, Predicate<? super MatcherMailetPair> additionalFilter, String additionalErrorMessage) {
-                this(matcherClass, mailetClass, Optional.of(additionalFilter), Optional.of(additionalErrorMessage));
+            public Impl(String processorName, Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass, Predicate<? super MatcherMailetPair> additionalFilter, String additionalErrorMessage) {
+                this(processorName, matcherClass, mailetClass, Optional.of(additionalFilter), Optional.of(additionalErrorMessage));
             }
 
-            private Impl(Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass, Optional<Predicate<? super MatcherMailetPair>> additionalFilter, Optional<String> additionalErrorMessage) {
+            private Impl(String processorName, Class<? extends Matcher> matcherClass, Class<? extends Mailet> mailetClass, Optional<Predicate<? super MatcherMailetPair>> additionalFilter, Optional<String> additionalErrorMessage) {
+                this.processorName = processorName;
                 this.matcherClass = matcherClass;
                 this.mailetClass = mailetClass;
                 this.additionalFilter = additionalFilter;
@@ -241,14 +288,18 @@ public class CamelMailetContainerModule extends AbstractModule {
             }
 
             @Override
-            public void check(List<MatcherMailetPair> pairs) throws ConfigurationException {
+            public void check(Multimap<String, MatcherMailetPair> processors) throws ConfigurationException {
+                Collection<MatcherMailetPair> pairs = processors.get(processorName);
+                if (pairs == null) {
+                    throw new ConfigurationException(processorName + " is missing");
+                }
                 Preconditions.checkNotNull(pairs);
                 pairs.stream()
                     .filter(pair -> pair.getMailet().getClass().equals(mailetClass))
                     .filter(pair -> pair.getMatcher().getClass().equals(matcherClass))
                     .filter(additionalFilter.orElse(any -> true))
                     .findAny()
-                    .orElseThrow(() -> new ConfigurationException("Missing " + mailetClass.getName() + " in mailets configuration (mailetcontainer -> processors -> transport). " +
+                    .orElseThrow(() -> new ConfigurationException("Missing " + mailetClass.getName() + " in mailets configuration (mailetcontainer -> processors -> " + processorName + "). " +
                         additionalErrorMessage.orElse("")));
             }
         }
diff --git a/server/container/guice/mailet/src/test/java/org/apache/james/modules/server/CamelMailetContainerModuleTest.java b/server/container/guice/mailet/src/test/java/org/apache/james/modules/server/CamelMailetContainerModuleTest.java
index c740f49..93468b5 100644
--- a/server/container/guice/mailet/src/test/java/org/apache/james/modules/server/CamelMailetContainerModuleTest.java
+++ b/server/container/guice/mailet/src/test/java/org/apache/james/modules/server/CamelMailetContainerModuleTest.java
@@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet;
 
 class CamelMailetContainerModuleTest {
 
-    public static final ImmutableSet<CamelMailetContainerModule.TransportProcessorCheck> NO_TRANSPORT_CHECKS = ImmutableSet.of();
+    public static final ImmutableSet<CamelMailetContainerModule.ProcessorsCheck> NO_TRANSPORT_CHECKS = ImmutableSet.of();
 
     @Test
     void getMailetContextConfigurationShouldReturnEmptyWhenNoContextSection() throws Exception {
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
index 7acbe92..934da8e 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
@@ -50,10 +50,12 @@ import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.modules.server.CamelMailetContainerModule;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;
+import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIsLocal;
 import org.apache.james.util.Port;
 import org.apache.james.util.html.HtmlTextExtractor;
 import org.apache.james.utils.PropertiesProvider;
+import org.apache.mailet.Mail;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -79,14 +81,26 @@ public class JMAPModule extends AbstractModule {
                 throw new RuntimeException(e);
             }
         };
-    public static final CamelMailetContainerModule.TransportProcessorCheck VACATION_MAILET_CHECK =
-        new CamelMailetContainerModule.TransportProcessorCheck.Impl(
+    public static final CamelMailetContainerModule.ProcessorsCheck VACATION_MAILET_CHECK =
+        CamelMailetContainerModule.ProcessorsCheck.Or.of(
+            new CamelMailetContainerModule.ProcessorsCheck.Impl(
+                Mail.TRANSPORT,
+                RecipientIsLocal.class,
+                VacationMailet.class),
+            new CamelMailetContainerModule.ProcessorsCheck.Impl(
+                Mail.LOCAL_DELIVERY,
+                All.class,
+                VacationMailet.class));
+    public static final CamelMailetContainerModule.ProcessorsCheck FILTERING_MAILET_CHECK =
+        CamelMailetContainerModule.ProcessorsCheck.Or.of(
+        new CamelMailetContainerModule.ProcessorsCheck.Impl(
+            Mail.TRANSPORT,
             RecipientIsLocal.class,
-            VacationMailet.class);
-    public static final CamelMailetContainerModule.TransportProcessorCheck FILTERING_MAILET_CHECK =
-        new CamelMailetContainerModule.TransportProcessorCheck.Impl(
-            RecipientIsLocal.class,
-            JMAPFiltering.class);
+            JMAPFiltering.class),
+        new CamelMailetContainerModule.ProcessorsCheck.Impl(
+            Mail.LOCAL_DELIVERY,
+            All.class,
+            JMAPFiltering.class));
 
     @Override
     protected void configure() {
@@ -104,7 +118,7 @@ public class JMAPModule extends AbstractModule {
         bind(HtmlTextExtractor.class).to(JsoupHtmlTextExtractor.class);
         Multibinder.newSetBinder(binder(), StartUpCheck.class).addBinding().to(RequiredCapabilitiesStartUpCheck.class);
 
-        Multibinder<CamelMailetContainerModule.TransportProcessorCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.TransportProcessorCheck.class);
+        Multibinder<CamelMailetContainerModule.ProcessorsCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.ProcessorsCheck.class);
         transportProcessorChecks.addBinding().toInstance(VACATION_MAILET_CHECK);
         transportProcessorChecks.addBinding().toInstance(FILTERING_MAILET_CHECK);
 
diff --git a/server/container/guice/protocols/jmap/src/test/java/org/apache/james/jmap/draft/MailetPreconditionTest.java b/server/container/guice/protocols/jmap/src/test/java/org/apache/james/jmap/draft/MailetPreconditionTest.java
index 228538c..7706911 100644
--- a/server/container/guice/protocols/jmap/src/test/java/org/apache/james/jmap/draft/MailetPreconditionTest.java
+++ b/server/container/guice/protocols/jmap/src/test/java/org/apache/james/jmap/draft/MailetPreconditionTest.java
@@ -38,6 +38,7 @@ import org.apache.mailet.base.test.FakeMailetConfig;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 
+import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.Lists;
 
 class MailetPreconditionTest {
@@ -49,7 +50,7 @@ class MailetPreconditionTest {
     class VacationMailetCheck {
         @Test
         void vacationMailetCheckShouldThrowOnEmptyList() {
-            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(Lists.newArrayList()))
+            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(ImmutableMultimap.of()))
                 .isInstanceOf(ConfigurationException.class);
         }
 
@@ -61,25 +62,29 @@ class MailetPreconditionTest {
 
         @Test
         void vacationMailetCheckShouldThrowOnWrongMatcher() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new All(), new VacationMailet(null, null, null, null, null)));
-
-            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(pairs))
+            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(ImmutableMultimap.of(
+                "transport", new MatcherMailetPair(new All(), new VacationMailet(null, null, null, null, null)))))
                 .isInstanceOf(ConfigurationException.class);
         }
 
         @Test
         void vacationMailetCheckShouldThrowOnWrongMailet() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new RecipientIsLocal(), new Null()));
-
-            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(pairs))
+            assertThatThrownBy(() -> JMAPModule.VACATION_MAILET_CHECK.check(ImmutableMultimap.of(
+                "transport", new MatcherMailetPair(new All(), new Null()))))
                 .isInstanceOf(ConfigurationException.class);
         }
 
         @Test
         void vacationMailetCheckShouldNotThrowIfValidPairPresent() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new RecipientIsLocal(), new VacationMailet(null, null, null, null, null)));
+            assertThatCode(() -> JMAPModule.VACATION_MAILET_CHECK.check(ImmutableMultimap.of(
+                "transport", new MatcherMailetPair(new RecipientIsLocal(), new VacationMailet(null, null, null, null, null)))))
+                .doesNotThrowAnyException();
+        }
 
-            assertThatCode(() -> JMAPModule.VACATION_MAILET_CHECK.check(pairs))
+        @Test
+        void vacationMailetCheckShouldSupportLocalDeliveryProcessor() {
+            assertThatCode(() -> JMAPModule.VACATION_MAILET_CHECK.check(ImmutableMultimap.of(
+                "local-delivery", new MatcherMailetPair(new All(), new VacationMailet(null, null, null, null, null)))))
                 .doesNotThrowAnyException();
         }
     }
@@ -88,7 +93,7 @@ class MailetPreconditionTest {
     class FilteringMailetCheck {
         @Test
         void filteringMailetCheckShouldThrowOnEmptyList() {
-            assertThatThrownBy(() -> JMAPModule.FILTERING_MAILET_CHECK.check(Lists.newArrayList()))
+            assertThatThrownBy(() -> JMAPModule.FILTERING_MAILET_CHECK.check(ImmutableMultimap.of()))
                 .isInstanceOf(ConfigurationException.class);
         }
 
@@ -100,7 +105,7 @@ class MailetPreconditionTest {
 
         @Test
         void filteringMailetCheckShouldThrowOnWrongMatcher() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new All(), new JMAPFiltering(null, null, null)));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("tansport", new MatcherMailetPair(new All(), new JMAPFiltering(null, null, null)));
 
             assertThatThrownBy(() -> JMAPModule.FILTERING_MAILET_CHECK.check(pairs))
                 .isInstanceOf(ConfigurationException.class);
@@ -108,7 +113,7 @@ class MailetPreconditionTest {
 
         @Test
         void filteringMailetCheckShouldThrowOnWrongMailet() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new RecipientIsLocal(), new Null()));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("tansport", new MatcherMailetPair(new All(), new Null()));
 
             assertThatThrownBy(() -> JMAPModule.FILTERING_MAILET_CHECK.check(pairs))
                 .isInstanceOf(ConfigurationException.class);
@@ -116,7 +121,15 @@ class MailetPreconditionTest {
 
         @Test
         void filteringMailetCheckShouldNotThrowIfValidPairPresent() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new RecipientIsLocal(), new JMAPFiltering(null, null, null)));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("transport", new MatcherMailetPair(new RecipientIsLocal(), new JMAPFiltering(null, null, null)));
+
+            assertThatCode(() -> JMAPModule.FILTERING_MAILET_CHECK.check(pairs))
+                .doesNotThrowAnyException();
+        }
+
+        @Test
+        void filteringMailetCheckShouldSupportLocalDeliveryProcessor() {
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("local-delivery", new MatcherMailetPair(new All(), new JMAPFiltering(null, null, null)));
 
             assertThatCode(() -> JMAPModule.FILTERING_MAILET_CHECK.check(pairs))
                 .doesNotThrowAnyException();
@@ -127,7 +140,7 @@ class MailetPreconditionTest {
     class BccCheck {
         @Test
         void bccMailetCheckShouldThrowOnEmptyList() {
-            assertThatThrownBy(() -> CamelMailetContainerModule.BCC_Check.check(Lists.newArrayList()))
+            assertThatThrownBy(() -> CamelMailetContainerModule.BCC_Check.check(ImmutableMultimap.of()))
                 .isInstanceOf(ConfigurationException.class);
         }
 
@@ -139,7 +152,7 @@ class MailetPreconditionTest {
 
         @Test
         void bccMailetCheckShouldThrowOnWrongMatcher() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new RecipientIsLocal(), new RemoveMimeHeader()));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("tansport", new MatcherMailetPair(new RecipientIsLocal(), new RemoveMimeHeader()));
 
             assertThatThrownBy(() -> CamelMailetContainerModule.BCC_Check.check(pairs))
                 .isInstanceOf(ConfigurationException.class);
@@ -147,7 +160,7 @@ class MailetPreconditionTest {
 
         @Test
         void bccMailetCheckShouldThrowOnWrongMailet() {
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new All(), new Null()));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("tansport", new MatcherMailetPair(new All(), new Null()));
 
             assertThatThrownBy(() -> CamelMailetContainerModule.BCC_Check.check(pairs))
                 .isInstanceOf(ConfigurationException.class);
@@ -162,7 +175,7 @@ class MailetPreconditionTest {
                 .setProperty("name", "bad")
                 .build());
 
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new All(), removeMimeHeader));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("tansport", new MatcherMailetPair(new All(), removeMimeHeader));
 
             assertThatThrownBy(() -> CamelMailetContainerModule.BCC_Check.check(pairs))
                 .isInstanceOf(ConfigurationException.class);
@@ -177,7 +190,7 @@ class MailetPreconditionTest {
                 .setProperty("name", BCC)
                 .build());
 
-            List<MatcherMailetPair> pairs = Lists.newArrayList(new MatcherMailetPair(new All(), removeMimeHeader));
+            ImmutableMultimap<String, MatcherMailetPair> pairs = ImmutableMultimap.of("transport", new MatcherMailetPair(new All(), removeMimeHeader));
             assertThatCode(() -> CamelMailetContainerModule.BCC_Check.check(pairs))
                 .doesNotThrowAnyException();
         }


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