This is an automated email from the ASF dual-hosted git repository.

matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d30cc4ac7d1d1d51a77d6c9d94d33c4ff663d4f3
Author: Rémi KOWALSKI <rkowal...@linagora.com>
AuthorDate: Tue Jan 28 11:34:33 2020 +0100

    Provide java method for getting the events in History
---
 .../org/apache/james/eventsourcing/EventSourcingSystemTest.scala | 4 ++--
 .../org/apache/james/eventsourcing/eventstore/History.scala      | 3 +++
 .../mailbox/quota/mailing/aggregates/UserQuotaThresholds.java    | 3 +--
 .../apache/james/jmap/api/filtering/impl/FilteringAggregate.java | 3 +--
 .../dlp/eventsourcing/aggregates/DLPDomainConfiguration.java     | 3 +--
 .../view/cassandra/configuration/ConfigurationAggregate.java     | 3 +--
 .../configuration/EventsourcingConfigurationManagementTest.java  | 9 ++-------
 .../james/task/eventsourcing/EventSourcingTaskManagerTest.java   | 8 +++-----
 8 files changed, 14 insertions(+), 22 deletions(-)

diff --git 
a/event-sourcing/event-sourcing-core/src/test/scala/org/apache/james/eventsourcing/EventSourcingSystemTest.scala
 
b/event-sourcing/event-sourcing-core/src/test/scala/org/apache/james/eventsourcing/EventSourcingSystemTest.scala
index 641d98a..948867a 100644
--- 
a/event-sourcing/event-sourcing-core/src/test/scala/org/apache/james/eventsourcing/EventSourcingSystemTest.scala
+++ 
b/event-sourcing/event-sourcing-core/src/test/scala/org/apache/james/eventsourcing/EventSourcingSystemTest.scala
@@ -95,7 +95,7 @@ trait EventSourcingSystemTest {
     val eventSourcingSystem = new 
EventSourcingSystem(Set(simpleDispatcher(eventStore)), Set(subscriber), 
eventStore)
     eventSourcingSystem.dispatch(new 
EventSourcingSystemTest.MyCommand(EventSourcingSystemTest.PAYLOAD_1))
     val expectedEvent = TestEvent(EventId.first, 
EventSourcingSystemTest.AGGREGATE_ID, EventSourcingSystemTest.PAYLOAD_1)
-    
assertThat(eventStore.getEventsOfAggregate(EventSourcingSystemTest.AGGREGATE_ID).getEvents.asJava).containsOnly(expectedEvent)
+    
assertThat(eventStore.getEventsOfAggregate(EventSourcingSystemTest.AGGREGATE_ID).getEventsJava).containsOnly(expectedEvent)
   }
 
   @Test
@@ -115,7 +115,7 @@ trait EventSourcingSystemTest {
     eventSourcingSystem.dispatch(new 
EventSourcingSystemTest.MyCommand(EventSourcingSystemTest.PAYLOAD_2))
     val expectedEvent1 = TestEvent(EventId.first, 
EventSourcingSystemTest.AGGREGATE_ID, EventSourcingSystemTest.PAYLOAD_1)
     val expectedEvent2 = TestEvent(expectedEvent1.eventId.next, 
EventSourcingSystemTest.AGGREGATE_ID, EventSourcingSystemTest.PAYLOAD_2)
-    
assertThat(eventStore.getEventsOfAggregate(EventSourcingSystemTest.AGGREGATE_ID).getEvents.asJava).containsOnly(expectedEvent1,
 expectedEvent2)
+    
assertThat(eventStore.getEventsOfAggregate(EventSourcingSystemTest.AGGREGATE_ID).getEventsJava).containsOnly(expectedEvent1,
 expectedEvent2)
   }
 
   @Test
diff --git 
a/event-sourcing/event-store-api/src/main/scala/org/apache/james/eventsourcing/eventstore/History.scala
 
b/event-sourcing/event-store-api/src/main/scala/org/apache/james/eventsourcing/eventstore/History.scala
index 8155056..ad03e82 100644
--- 
a/event-sourcing/event-store-api/src/main/scala/org/apache/james/eventsourcing/eventstore/History.scala
+++ 
b/event-sourcing/event-store-api/src/main/scala/org/apache/james/eventsourcing/eventstore/History.scala
@@ -21,6 +21,7 @@ package org.apache.james.eventsourcing.eventstore
 import org.apache.james.eventsourcing.{Event, EventId}
 
 import scala.annotation.varargs
+import scala.jdk.CollectionConverters._
 
 object History {
   def empty: History = new History(Nil)
@@ -49,6 +50,8 @@ final case class History private(events: List[Event]) {
 
   def getEvents:List[Event] = events
 
+  def getEventsJava:java.util.List[Event] = events.asJava
+
   def getNextEventId: EventId = getVersion
     .map(eventId => eventId.next)
     .getOrElse(EventId.first)
diff --git 
a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
 
b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
index 6838e9b..ba6725a 100644
--- 
a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
+++ 
b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/aggregates/UserQuotaThresholds.java
@@ -48,7 +48,6 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableList;
-import scala.jdk.javaapi.CollectionConverters;
 
 public class UserQuotaThresholds {
 
@@ -127,7 +126,7 @@ public class UserQuotaThresholds {
     private UserQuotaThresholds(Id aggregateId, History history) {
         this.aggregateId = aggregateId;
         this.history = history;
-        this.events = CollectionConverters.asJava(history.getEvents())
+        this.events = history.getEventsJava()
             .stream()
             .map(QuotaThresholdChangedEvent.class::cast)
             .collect(Collectors.toList());
diff --git 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/FilteringAggregate.java
 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/FilteringAggregate.java
index 4a52e1e..1a4772f 100644
--- 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/FilteringAggregate.java
+++ 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/FilteringAggregate.java
@@ -27,7 +27,6 @@ import org.apache.james.jmap.api.filtering.Rule;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
-import scala.jdk.javaapi.CollectionConverters;
 
 public class FilteringAggregate {
 
@@ -59,7 +58,7 @@ public class FilteringAggregate {
     private FilteringAggregate(FilteringAggregateId aggregateId, History 
history) {
         this.aggregateId = aggregateId;
         this.state = State.initial();
-        CollectionConverters.asJava(history.getEvents()).forEach(this::apply);
+        history.getEventsJava().forEach(this::apply);
         this.history = history;
     }
 
diff --git 
a/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/aggregates/DLPDomainConfiguration.java
 
b/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/aggregates/DLPDomainConfiguration.java
index 70d7a70..7aaa0df 100644
--- 
a/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/aggregates/DLPDomainConfiguration.java
+++ 
b/server/data/data-library/src/main/java/org/apache/james/dlp/eventsourcing/aggregates/DLPDomainConfiguration.java
@@ -37,7 +37,6 @@ import com.github.steveash.guavate.Guavate;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
-import scala.jdk.javaapi.CollectionConverters;
 
 public class DLPDomainConfiguration {
 
@@ -75,7 +74,7 @@ public class DLPDomainConfiguration {
     private DLPDomainConfiguration(DLPAggregateId aggregateId, History 
history) {
         this.aggregateId = aggregateId;
         this.state = State.initial();
-        CollectionConverters.asJava(history.getEvents()).forEach(this::apply);
+        history.getEventsJava().forEach(this::apply);
         this.history = history;
     }
 
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/ConfigurationAggregate.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/ConfigurationAggregate.java
index 5f95de3..50f5407 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/ConfigurationAggregate.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/ConfigurationAggregate.java
@@ -28,7 +28,6 @@ import org.apache.james.eventsourcing.eventstore.History;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
-import scala.jdk.javaapi.CollectionConverters;
 
 class ConfigurationAggregate {
 
@@ -66,7 +65,7 @@ class ConfigurationAggregate {
         this.history = history;
         this.state = State.initial();
 
-        CollectionConverters.asJava(history.getEvents()).forEach(this::apply);
+        history.getEventsJava().forEach(this::apply);
     }
 
     List<? extends Event> 
registerConfiguration(CassandraMailQueueViewConfiguration configuration) {
diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/EventsourcingConfigurationManagementTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/EventsourcingConfigurationManagementTest.java
index a4f10bf..1518a1d 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/EventsourcingConfigurationManagementTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/configuration/EventsourcingConfigurationManagementTest.java
@@ -24,17 +24,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.time.Duration;
-import java.util.List;
 
-import org.apache.james.eventsourcing.Event;
 import org.apache.james.eventsourcing.eventstore.EventStore;
 import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreExtension;
 import org.apache.james.eventsourcing.eventstore.cassandra.JsonEventSerializer;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-import scala.jdk.javaapi.CollectionConverters;
-
 class EventsourcingConfigurationManagementTest {
 
     @RegisterExtension
@@ -243,9 +239,8 @@ class EventsourcingConfigurationManagementTest {
         testee.registerConfiguration(FIRST_CONFIGURATION);
         testee.registerConfiguration(FIRST_CONFIGURATION);
 
-        scala.collection.immutable.List<Event> eventsStored = 
eventStore.getEventsOfAggregate(CONFIGURATION_AGGREGATE_ID)
-            .getEvents();
-        assertThat(CollectionConverters.asJava(eventsStored))
+        assertThat(eventStore.getEventsOfAggregate(CONFIGURATION_AGGREGATE_ID)
+            .getEventsJava())
             .hasSize(1);
     }
 }
\ No newline at end of file
diff --git 
a/server/task/task-memory/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java
 
b/server/task/task-memory/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java
index 1655171..dcc727c 100644
--- 
a/server/task/task-memory/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java
+++ 
b/server/task/task-memory/src/test/java/org/apache/james/task/eventsourcing/EventSourcingTaskManagerTest.java
@@ -41,8 +41,6 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-import scala.jdk.javaapi.CollectionConverters;
-
 @ExtendWith(CountDownLatchExtension.class)
 class EventSourcingTaskManagerTest implements TaskManagerContract {
     ConditionFactory CALMLY_AWAIT = Awaitility
@@ -81,7 +79,7 @@ class EventSourcingTaskManagerTest implements 
TaskManagerContract {
     void createdTaskShouldKeepOriginHostname() {
         TaskId taskId = taskManager.submit(new MemoryReferenceTask(() -> 
Task.Result.COMPLETED));
         TaskAggregateId aggregateId = new TaskAggregateId(taskId);
-        
assertThat(CollectionConverters.asJava(eventStore.getEventsOfAggregate(aggregateId).getEvents()))
+        
assertThat(eventStore.getEventsOfAggregate(aggregateId).getEventsJava())
                 .filteredOn(event -> event instanceof Created)
                 .extracting("hostname")
                 .containsOnly(HOSTNAME);
@@ -93,7 +91,7 @@ class EventSourcingTaskManagerTest implements 
TaskManagerContract {
         TaskAggregateId aggregateId = new TaskAggregateId(taskId);
 
         CALMLY_AWAIT.untilAsserted(() ->
-            
assertThat(CollectionConverters.asJava(eventStore.getEventsOfAggregate(aggregateId).getEvents()))
+            
assertThat(eventStore.getEventsOfAggregate(aggregateId).getEventsJava())
                 .filteredOn(event -> event instanceof Started)
                 .extracting("hostname")
                 .containsOnly(HOSTNAME));
@@ -109,7 +107,7 @@ class EventSourcingTaskManagerTest implements 
TaskManagerContract {
 
         TaskAggregateId aggregateId = new TaskAggregateId(taskId);
         CALMLY_AWAIT.untilAsserted(() ->
-            
assertThat(CollectionConverters.asJava(eventStore.getEventsOfAggregate(aggregateId).getEvents()))
+            
assertThat(eventStore.getEventsOfAggregate(aggregateId).getEventsJava())
                 .filteredOn(event -> event instanceof CancelRequested)
                 .extracting("hostname")
                 .containsOnly(HOSTNAME));


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

Reply via email to