- fixed the tests

- updated eventuate-client version
- fixed api-gateway and common module's dependencies
This commit is contained in:
Main
2016-08-10 23:39:00 +03:00
parent 12e46582cd
commit 5f8475d675
11 changed files with 100 additions and 44 deletions

View File

@@ -11,28 +11,40 @@ import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transa
import java.math.BigDecimal;
import java.util.concurrent.CompletableFuture;
@EventSubscriber(id="accountEventHandlers")
public class AccountWorkflow {
@EventSubscriber(id = "accountEventHandlers")
public class AccountWorkflow {
@EventHandlerMethod
public CompletableFuture<?> debitAccount(EventHandlerContext<MoneyTransferCreatedEvent> ctx) {
MoneyTransferCreatedEvent event = ctx.getEvent();
BigDecimal amount = event.getDetails().getAmount();
String transactionId = ctx.getEntityId();
@EventHandlerMethod
public CompletableFuture<?> debitAccount(EventHandlerContext<MoneyTransferCreatedEvent> ctx) {
MoneyTransferCreatedEvent event = ctx.getEvent();
BigDecimal amount = event.getDetails().getAmount();
String transactionId = ctx.getEntityId();
String fromAccountId = event.getDetails().getFromAccountId();
String fromAccountId = event.getDetails().getFromAccountId();
return ctx.update(Account.class, fromAccountId, new DebitAccountCommand(amount, transactionId));
}
return ctx.update(Account.class, fromAccountId, new DebitAccountCommand(amount, transactionId)).handle((x, e) -> {
if (e != null) {
e.printStackTrace();
}
return x;
}
);
}
@EventHandlerMethod
public CompletableFuture<EntityWithIdAndVersion<Account>> creditAccount(EventHandlerContext<DebitRecordedEvent> ctx) {
DebitRecordedEvent event = ctx.getEvent();
BigDecimal amount = event.getDetails().getAmount();
String fromAccountId = event.getDetails().getToAccountId();
String transactionId = ctx.getEntityId();
@EventHandlerMethod
public CompletableFuture<EntityWithIdAndVersion<Account>> creditAccount(EventHandlerContext<DebitRecordedEvent> ctx) {
DebitRecordedEvent event = ctx.getEvent();
BigDecimal amount = event.getDetails().getAmount();
String fromAccountId = event.getDetails().getToAccountId();
String transactionId = ctx.getEntityId();
return ctx.update(Account.class, fromAccountId, new CreditAccountCommand(amount, transactionId));
}
return ctx.update(Account.class, fromAccountId, new CreditAccountCommand(amount, transactionId)).handle((x, e) -> {
if (e != null) {
e.printStackTrace();
}
return x;
}
);
}
}