-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce4d24e
commit 44f89aa
Showing
5 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
thoth-tck/src/main/java/fr/maif/eventsourcing/datastore/TestConsistentProjection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package fr.maif.eventsourcing.datastore; | ||
|
||
import akka.actor.ActorSystem; | ||
import fr.maif.projections.EventuallyConsistentProjection; | ||
import io.vavr.Tuple; | ||
import io.vavr.concurrent.Future; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
|
||
public class TestConsistentProjection { | ||
|
||
private int counter = 0; | ||
private final ActorSystem actorSystem; | ||
private final String bootstrapServer; | ||
private final TestEventFormat eventFormat; | ||
private final DataSource dataSource; | ||
|
||
public TestConsistentProjection( | ||
ActorSystem actorSystem, | ||
String bootstrapServer, | ||
TestEventFormat eventFormat, | ||
DataSource dataSource) { | ||
this.actorSystem = actorSystem; | ||
this.eventFormat = eventFormat; | ||
this.dataSource = dataSource; | ||
this.bootstrapServer =bootstrapServer; | ||
} | ||
|
||
|
||
public void init(String topic) { | ||
this.counter = 0; | ||
EventuallyConsistentProjection.create( | ||
ActorSystem.create(), | ||
"TestConsistentProjection", | ||
EventuallyConsistentProjection.Config.create(topic, "TestConsistentProjection", bootstrapServer), | ||
eventFormat, | ||
envelope -> | ||
Future.of(() -> { | ||
if (envelope.event instanceof TestEvent.SimpleEvent){ | ||
counter++; | ||
} | ||
return Tuple.empty(); | ||
}) | ||
|
||
).start(); | ||
} | ||
|
||
public int getCount() { | ||
return counter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters