Repository: james-project
Updated Branches:
  refs/heads/master 8bfefda83 -> a999bd604


JAMES-2527 implements the FilteringManagementContract with a Cassandra Event 
Store


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

Branch: refs/heads/master
Commit: 8659a18e06da878c1c90552c43d63e7536aa6699
Parents: 8bfefda
Author: Matthieu Baechler <[email protected]>
Authored: Wed Aug 22 17:46:24 2018 +0200
Committer: Matthieu Baechler <[email protected]>
Committed: Fri Aug 24 11:19:23 2018 +0200

----------------------------------------------------------------------
 event-sourcing/event-store-cassandra/pom.xml    |   4 +
 .../cassandra/JsonEventSerializer.java          |   2 +
 server/data/data-jmap-cassandra/pom.xml         |  30 +++++-
 .../FilteringRuleSetDefineDTOModule.java        |  52 ++++++++++
 .../filtering/FilteringRuleSetDefinedDTO.java   | 102 +++++++++++++++++++
 .../james/jmap/cassandra/filtering/RuleDTO.java |  87 ++++++++++++++++
 ...draEventSourcingFilteringManagementTest.java |  28 +++++
 .../filtering/CassandraFilteringExtension.java  |  31 ++++++
 .../src/test/resources/logback-test.xml         |  28 +++++
 server/data/data-jmap/pom.xml                   |   6 ++
 .../jmap/api/filtering/impl/RuleSetDefined.java |   2 +-
 .../filtering/FilteringManagementContract.java  |  42 ++++----
 .../EventSourcingFilteringManagementTest.java   |  32 ------
 ...oryEventSourcingFilteringManagementTest.java |  29 ++++++
 14 files changed, 418 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/event-sourcing/event-store-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/pom.xml 
b/event-sourcing/event-store-cassandra/pom.xml
index 64b6e12..dc2c100 100644
--- a/event-sourcing/event-store-cassandra/pom.xml
+++ b/event-sourcing/event-store-cassandra/pom.xml
@@ -85,6 +85,10 @@
         </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.datatype</groupId>
+            <artifactId>jackson-datatype-guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.datatype</groupId>
             <artifactId>jackson-datatype-jdk8</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializer.java
----------------------------------------------------------------------
diff --git 
a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializer.java
 
b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializer.java
index dea4a5e..189eeec 100644
--- 
a/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializer.java
+++ 
b/event-sourcing/event-store-cassandra/src/main/java/org/apache/james/eventsourcing/eventstore/cassandra/JsonEventSerializer.java
@@ -35,6 +35,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.guava.GuavaModule;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
 import com.github.steveash.guavate.Guavate;
 import com.google.common.collect.ImmutableSet;
@@ -54,6 +55,7 @@ public class JsonEventSerializer {
     public JsonEventSerializer(Set<EventDTOModule> modules) {
         objectMapper = new ObjectMapper();
         objectMapper.registerModule(new Jdk8Module());
+        objectMapper.registerModule(new GuavaModule());
         objectMapper.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
 
         typeToModule = modules.stream()

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/pom.xml 
b/server/data/data-jmap-cassandra/pom.xml
index 115ff7a..e9f4e85 100644
--- a/server/data/data-jmap-cassandra/pom.xml
+++ b/server/data/data-jmap-cassandra/pom.xml
@@ -46,6 +46,16 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>event-sourcing-event-store-cassandra</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>event-sourcing-event-store-cassandra</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-data-jmap</artifactId>
         </dependency>
         <dependency>
@@ -55,6 +65,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
@@ -63,11 +78,6 @@
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
@@ -78,6 +88,16 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
new file mode 100644
index 0000000..9a59fa6
--- /dev/null
+++ 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefineDTOModule.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import org.apache.james.eventsourcing.Event;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
+import org.apache.james.jmap.api.filtering.impl.RuleSetDefined;
+
+import com.google.common.base.Preconditions;
+
+public class FilteringRuleSetDefineDTOModule implements EventDTOModule {
+    private static final String FILTERING_RULE_SET_DEFINED = 
"filtering-rule-set-defined";
+
+    @Override
+    public String getType() {
+        return FILTERING_RULE_SET_DEFINED;
+    }
+
+    @Override
+    public Class<? extends EventDTO> getDTOClass() {
+        return FilteringRuleSetDefinedDTO.class;
+    }
+
+    @Override
+    public Class<? extends Event> getEventClass() {
+        return RuleSetDefined.class;
+    }
+
+    @Override
+    public EventDTO toDTO(Event event) {
+        Preconditions.checkArgument(event instanceof RuleSetDefined);
+        return FilteringRuleSetDefinedDTO.from((RuleSetDefined) event, 
FILTERING_RULE_SET_DEFINED);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
new file mode 100644
index 0000000..c2357f9
--- /dev/null
+++ 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/FilteringRuleSetDefinedDTO.java
@@ -0,0 +1,102 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import java.util.Objects;
+
+import org.apache.james.eventsourcing.Event;
+import org.apache.james.eventsourcing.EventId;
+import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTO;
+import org.apache.james.jmap.api.filtering.impl.FilteringAggregateId;
+import org.apache.james.jmap.api.filtering.impl.RuleSetDefined;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableList;
+
+public class FilteringRuleSetDefinedDTO implements EventDTO {
+
+    public static EventDTO from(RuleSetDefined event, String type) {
+        return new FilteringRuleSetDefinedDTO(
+            type, event.eventId().serialize(),
+            event.getAggregateId().asAggregateKey(),
+            RuleDTO.from(event.getRules()));
+    }
+
+    private final String type;
+    private final int eventId;
+    private final String aggregateId;
+    private final ImmutableList<RuleDTO> rules;
+
+    @JsonCreator
+    public FilteringRuleSetDefinedDTO(@JsonProperty("type") String type,
+                                     @JsonProperty("eventId") int eventId,
+                                     @JsonProperty("aggregateId") String 
aggregateId,
+                                     @JsonProperty("rules") 
ImmutableList<RuleDTO> rules) {
+        this.type = type;
+        this.eventId = eventId;
+        this.aggregateId = aggregateId;
+        this.rules = rules;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public int getEventId() {
+        return eventId;
+    }
+
+    public String getAggregateId() {
+        return aggregateId;
+    }
+
+    public ImmutableList<RuleDTO> getRules() {
+        return rules;
+    }
+
+    @JsonIgnore
+    @Override
+    public Event toEvent() {
+        return new RuleSetDefined(
+            FilteringAggregateId.parse(aggregateId),
+            EventId.fromSerialized(eventId),
+            RuleDTO.toRules(rules));
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof FilteringRuleSetDefinedDTO) {
+            FilteringRuleSetDefinedDTO that = (FilteringRuleSetDefinedDTO) o;
+
+            return Objects.equals(this.eventId, that.eventId)
+                && Objects.equals(this.type, that.type)
+                && Objects.equals(this.aggregateId, that.aggregateId)
+                && Objects.equals(this.rules, that.rules);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(type, eventId, aggregateId, rules);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
new file mode 100644
index 0000000..a361465
--- /dev/null
+++ 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
@@ -0,0 +1,87 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.james.jmap.api.filtering.Rule;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+public class RuleDTO {
+
+    public static ImmutableList<Rule> toRules(List<RuleDTO> ruleDTOList) {
+        Preconditions.checkNotNull(ruleDTOList);
+        return ruleDTOList.stream()
+                .map(dto -> Rule.of(dto.getId()))
+                .collect(ImmutableList.toImmutableList());
+    }
+
+    public static ImmutableList<RuleDTO> from(List<Rule> rules) {
+        Preconditions.checkNotNull(rules);
+        return rules.stream()
+            .map(RuleDTO::from)
+            .collect(ImmutableList.toImmutableList());
+    }
+
+    public static RuleDTO from(Rule rule) {
+        return new RuleDTO(rule.getId());
+    }
+
+    private final String id;
+
+    @JsonCreator
+    public RuleDTO(@JsonProperty("id") String id) {
+        Preconditions.checkNotNull(id);
+
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof RuleDTO) {
+            RuleDTO ruleDTO = (RuleDTO) o;
+
+            return Objects.equals(this.id, ruleDTO.id);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(id);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("id", id)
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementTest.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementTest.java
 
b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementTest.java
new file mode 100644
index 0000000..61cf8e8
--- /dev/null
+++ 
b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementTest.java
@@ -0,0 +1,28 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import org.apache.james.jmap.api.filtering.FilteringManagementContract;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(CassandraFilteringExtension.class)
+public class CassandraEventSourcingFilteringManagementTest implements 
FilteringManagementContract {
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
 
b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
new file mode 100644
index 0000000..522b45f
--- /dev/null
+++ 
b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringExtension.java
@@ -0,0 +1,31 @@
+/****************************************************************
+ * 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.jmap.cassandra.filtering;
+
+import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraGenericEventStoreExtension;
+
+import com.google.common.collect.ImmutableSet;
+
+public class CassandraFilteringExtension extends 
CassandraGenericEventStoreExtension {
+    public CassandraFilteringExtension() {
+        super(ImmutableSet.of(
+            new FilteringRuleSetDefineDTOModule()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap-cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap-cassandra/src/test/resources/logback-test.xml 
b/server/data/data-jmap-cassandra/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..fe43bd9
--- /dev/null
+++ b/server/data/data-jmap-cassandra/src/test/resources/logback-test.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+        <contextListener 
class="ch.qos.logback.classic.jul.LevelChangePropagator">
+                <resetJUL>true</resetJUL>
+        </contextListener>
+
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+                <encoder>
+                        <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - 
%msg%n%rEx</pattern>
+                        <immediateFlush>false</immediateFlush>
+                </encoder>
+        </appender>
+
+        <root level="WARN">
+                <appender-ref ref="CONSOLE" />
+        </root>
+
+
+        <logger name="org.apache.james" level="WARN" >
+                <appender-ref ref="CONSOLE" />
+        </logger>
+
+        <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" 
level="DEBUG" >
+                <appender-ref ref="CONSOLE" />
+        </logger>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/pom.xml b/server/data/data-jmap/pom.xml
index 169120b..ab5742c 100644
--- a/server/data/data-jmap/pom.xml
+++ b/server/data/data-jmap/pom.xml
@@ -51,6 +51,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>event-sourcing-event-store-memory</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/RuleSetDefined.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/RuleSetDefined.java
 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/RuleSetDefined.java
index dacba35..a607369 100644
--- 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/RuleSetDefined.java
+++ 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/RuleSetDefined.java
@@ -35,7 +35,7 @@ public class RuleSetDefined implements Event {
     private final EventId eventId;
     private final ImmutableList<Rule> rules;
 
-    RuleSetDefined(FilteringAggregateId aggregateId, EventId eventId, 
ImmutableList<Rule> rules) {
+    public RuleSetDefined(FilteringAggregateId aggregateId, EventId eventId, 
ImmutableList<Rule> rules) {
         this.aggregateId = aggregateId;
         this.eventId = eventId;
         this.rules = rules;

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/FilteringManagementContract.java
----------------------------------------------------------------------
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 21718e8..dd2f773 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
@@ -22,6 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.core.User;
+import org.apache.james.eventsourcing.eventstore.EventStore;
+import 
org.apache.james.jmap.api.filtering.impl.EventSourcingFilteringManagement;
 import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -33,72 +35,74 @@ public interface FilteringManagementContract {
     Rule RULE_2 = Rule.of("2");
     Rule RULE_3 = Rule.of("3");
 
-    FilteringManagement instanciateFilteringManagement();
+    default FilteringManagement instanciateFilteringManagement(EventStore 
eventStore) {
+        return new EventSourcingFilteringManagement(eventStore);
+    }
 
     @Test
-    default void listingRulesForUnknownUserShouldReturnEmptyList() {
+    default void listingRulesForUnknownUserShouldReturnEmptyList(EventStore 
eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        
assertThat(instanciateFilteringManagement().listRulesForUser(user)).isEmpty();
+        
assertThat(instanciateFilteringManagement(eventStore).listRulesForUser(user)).isEmpty();
     }
 
     @Test
-    default void listingRulesShouldThrowWhenNullUser() {
+    default void listingRulesShouldThrowWhenNullUser(EventStore eventStore) {
         User user = null;
-        assertThatThrownBy(() -> 
instanciateFilteringManagement().listRulesForUser(user)).isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(() -> 
instanciateFilteringManagement(eventStore).listRulesForUser(user)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    default void listingRulesShouldReturnDefinedRules() {
+    default void listingRulesShouldReturnDefinedRules(EventStore eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         testee.defineRulesForUser(user, ImmutableList.of(RULE_1, RULE_2));
         assertThat(testee.listRulesForUser(user)).containsExactly(RULE_1, 
RULE_2);
     }
 
     @Test
-    default void listingRulesShouldReturnLastDefinedRules() {
+    default void listingRulesShouldReturnLastDefinedRules(EventStore 
eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         testee.defineRulesForUser(user, ImmutableList.of(RULE_1, RULE_2));
         testee.defineRulesForUser(user, ImmutableList.of(RULE_2, RULE_1));
         assertThat(testee.listRulesForUser(user)).containsExactly(RULE_2, 
RULE_1);
     }
 
     @Test
-    default void definingRulesShouldThrowWhenDuplicateRules() {
+    default void definingRulesShouldThrowWhenDuplicateRules(EventStore 
eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         assertThatThrownBy(() -> testee.defineRulesForUser(user, 
ImmutableList.of(RULE_1, RULE_1)))
             .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    default void definingRulesShouldThrowWhenNullUser() {
-        FilteringManagement testee = instanciateFilteringManagement();
+    default void definingRulesShouldThrowWhenNullUser(EventStore eventStore) {
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         assertThatThrownBy(() -> testee.defineRulesForUser(null, 
ImmutableList.of(RULE_1, RULE_1)))
             .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    default void definingRulesShouldThrowWhenNullRuleList() {
+    default void definingRulesShouldThrowWhenNullRuleList(EventStore 
eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         assertThatThrownBy(() -> testee.defineRulesForUser(user, null))
             .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    default void definingRulesShouldKeepOrdering() {
+    default void definingRulesShouldKeepOrdering(EventStore eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         testee.defineRulesForUser(user, ImmutableList.of(RULE_3, RULE_2, 
RULE_1));
         assertThat(testee.listRulesForUser(user)).containsExactly(RULE_3, 
RULE_2, RULE_1);
     }
 
     @Test
-    default void definingEmptyRuleListShouldRemoveExistingRules() {
+    default void definingEmptyRuleListShouldRemoveExistingRules(EventStore 
eventStore) {
         User user = User.fromUsername(BART_SIMPSON_CARTOON);
-        FilteringManagement testee = instanciateFilteringManagement();
+        FilteringManagement testee = 
instanciateFilteringManagement(eventStore);
         testee.defineRulesForUser(user, ImmutableList.of(RULE_3, RULE_2, 
RULE_1));
         testee.defineRulesForUser(user, ImmutableList.of());
         assertThat(testee.listRulesForUser(user)).isEmpty();

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagementTest.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagementTest.java
 
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagementTest.java
deleted file mode 100644
index 45120c3..0000000
--- 
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagementTest.java
+++ /dev/null
@@ -1,32 +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.jmap.api.filtering.impl;
-
-import org.apache.james.eventsourcing.eventstore.memory.InMemoryEventStore;
-import org.apache.james.jmap.api.filtering.FilteringManagement;
-import org.apache.james.jmap.api.filtering.FilteringManagementContract;
-
-public class EventSourcingFilteringManagementTest implements 
FilteringManagementContract {
-
-    @Override
-    public FilteringManagement instanciateFilteringManagement() {
-        return new EventSourcingFilteringManagement(new InMemoryEventStore());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8659a18e/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/InMemoryEventSourcingFilteringManagementTest.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/InMemoryEventSourcingFilteringManagementTest.java
 
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/InMemoryEventSourcingFilteringManagementTest.java
new file mode 100644
index 0000000..39dffe7
--- /dev/null
+++ 
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/filtering/impl/InMemoryEventSourcingFilteringManagementTest.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.jmap.api.filtering.impl;
+
+import 
org.apache.james.eventsourcing.eventstore.memory.InMemoryEventStoreExtension;
+import org.apache.james.jmap.api.filtering.FilteringManagementContract;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(InMemoryEventStoreExtension.class)
+public class InMemoryEventSourcingFilteringManagementTest implements 
FilteringManagementContract {
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to