Changed to use the Eventuate Java Client
Simplified Spring MVC code since it supports CompletableFuture
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
|
||||
import net.chrisrichardson.eventstore.Aggregate;
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Aggregate;
|
||||
|
||||
import io.eventuate.Event;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class AccountChangedEvent implements Event {
|
||||
protected BigDecimal amount;
|
||||
protected EntityIdentifier transactionId;
|
||||
protected String transactionId;
|
||||
|
||||
public AccountChangedEvent(BigDecimal amount, EntityIdentifier transactionId) {
|
||||
public AccountChangedEvent(BigDecimal amount, String transactionId) {
|
||||
this.amount = amount;
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class AccountChangedEvent implements Event {
|
||||
public AccountChangedEvent() {
|
||||
}
|
||||
|
||||
public EntityIdentifier getTransactionId() {
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
|
||||
import net.chrisrichardson.eventstore.Aggregate;
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
import io.eventuate.Aggregate;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class AccountCreditedEvent extends AccountChangedEvent {
|
||||
private AccountCreditedEvent() {
|
||||
}
|
||||
|
||||
public AccountCreditedEvent(BigDecimal amount, EntityIdentifier transactionId) {
|
||||
public AccountCreditedEvent(BigDecimal amount, String transactionId) {
|
||||
super(amount, transactionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
|
||||
import net.chrisrichardson.eventstore.Aggregate;
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Aggregate;
|
||||
|
||||
import io.eventuate.Event;
|
||||
|
||||
public class AccountDebitFailedDueToInsufficientFundsEvent implements Event {
|
||||
private EntityIdentifier transactionId;
|
||||
private String transactionId;
|
||||
|
||||
private AccountDebitFailedDueToInsufficientFundsEvent() {
|
||||
}
|
||||
|
||||
public AccountDebitFailedDueToInsufficientFundsEvent(EntityIdentifier transactionId) {
|
||||
public AccountDebitFailedDueToInsufficientFundsEvent(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public EntityIdentifier getTransactionId() {
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
|
||||
import net.chrisrichardson.eventstore.Aggregate;
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
import io.eventuate.Aggregate;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class AccountDebitedEvent extends AccountChangedEvent {
|
||||
private AccountDebitedEvent() {
|
||||
}
|
||||
|
||||
public AccountDebitedEvent(BigDecimal amount, EntityIdentifier transactionId) {
|
||||
public AccountDebitedEvent(BigDecimal amount, String transactionId) {
|
||||
super(amount, transactionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
|
||||
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Event;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@net.chrisrichardson.eventstore.EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.Account")
|
||||
@io.eventuate.EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.Account")
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts;
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Event;
|
||||
|
||||
public class CreditRecordedEvent implements Event {
|
||||
private TransferDetails details;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
// import io.eventuate.Event;
|
||||
|
||||
import io.eventuate.Event;
|
||||
|
||||
public class DebitRecordedEvent implements Event {
|
||||
private TransferDetails details;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Event;
|
||||
|
||||
public class FailedDebitRecordedEvent implements Event {
|
||||
private TransferDetails details;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
|
||||
|
||||
import net.chrisrichardson.eventstore.Event;
|
||||
import io.eventuate.Event;
|
||||
|
||||
public class MoneyTransferCreatedEvent implements Event {
|
||||
private TransferDetails details;
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
|
||||
/*
|
||||
case class TransferDetails(fromAccountId : EntityIdentifier, toAccountId : EntityIdentifier, amount : BigDecimal)
|
||||
case class TransferDetails(fromAccountId : String, toAccountId : String, amount : BigDecimal)
|
||||
*/
|
||||
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TransferDetails {
|
||||
|
||||
private EntityIdentifier fromAccountId;
|
||||
private EntityIdentifier toAccountId;
|
||||
private String fromAccountId;
|
||||
private String toAccountId;
|
||||
private BigDecimal amount;
|
||||
|
||||
private TransferDetails() {
|
||||
}
|
||||
|
||||
public TransferDetails(EntityIdentifier fromAccountId, EntityIdentifier toAccountId, BigDecimal amount) {
|
||||
public TransferDetails(String fromAccountId, String toAccountId, BigDecimal amount) {
|
||||
this.fromAccountId = fromAccountId;
|
||||
this.toAccountId = toAccountId;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public EntityIdentifier getFromAccountId() {
|
||||
public String getFromAccountId() {
|
||||
return fromAccountId;
|
||||
}
|
||||
|
||||
public EntityIdentifier getToAccountId() {
|
||||
public String getToAccountId() {
|
||||
return toAccountId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@net.chrisrichardson.eventstore.EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransfer")
|
||||
@io.eventuate.EventEntity(entity="net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransfer")
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions;
|
||||
@@ -1,9 +1,8 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.common.accounts;
|
||||
|
||||
|
||||
import io.eventuate.javaclient.commonimpl.JSonMapper;
|
||||
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.AccountOpenedEvent;
|
||||
import net.chrisrichardson.eventstore.json.EventStoreCommonObjectMapping;
|
||||
import net.chrisrichardson.utils.json.JSonMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -14,10 +13,10 @@ public class AccountOpenEventSerializationTest {
|
||||
@Test
|
||||
public void shouldSerde() {
|
||||
AccountOpenedEvent event = new AccountOpenedEvent(new BigDecimal(55));
|
||||
String json = JSonMapper.toJson(event, EventStoreCommonObjectMapping.getObjectMapper());
|
||||
String json = JSonMapper.toJson(event);
|
||||
System.out.println("json=" + json);
|
||||
|
||||
AccountOpenedEvent event2 = JSonMapper.fromJSon(AccountOpenedEvent.class, json, EventStoreCommonObjectMapping.getObjectMapper());
|
||||
AccountOpenedEvent event2 = JSonMapper.fromJson(json, AccountOpenedEvent.class);
|
||||
|
||||
Assert.assertEquals(event.getInitialBalance(), event2.getInitialBalance());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user