Misc changes

This commit is contained in:
Chris Richardson
2016-08-05 15:14:51 -07:00
parent f1d97ac49c
commit 1e40b2a591
3 changed files with 26 additions and 16 deletions

View File

@@ -15,7 +15,7 @@ import java.util.concurrent.CompletableFuture;
public class AccountWorkflow { public class AccountWorkflow {
@EventHandlerMethod @EventHandlerMethod
public CompletableFuture<EntityWithIdAndVersion<Account>> debitAccount(EventHandlerContext<MoneyTransferCreatedEvent> ctx) { public CompletableFuture<?> debitAccount(EventHandlerContext<MoneyTransferCreatedEvent> ctx) {
MoneyTransferCreatedEvent event = ctx.getEvent(); MoneyTransferCreatedEvent event = ctx.getEvent();
BigDecimal amount = event.getDetails().getAmount(); BigDecimal amount = event.getDetails().getAmount();
String transactionId = ctx.getEntityId(); String transactionId = ctx.getEntityId();

View File

@@ -1,5 +1,5 @@
apigateway: apigateway:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./api-gateway-service/build/libs:/app - ./api-gateway-service/build/libs:/app
@@ -19,7 +19,7 @@ apigateway:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
accountscommandside: accountscommandside:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./accounts-command-side-service/build/libs:/app - ./accounts-command-side-service/build/libs:/app
@@ -31,7 +31,7 @@ accountscommandside:
EVENTUATE_API_KEY_SECRET: EVENTUATE_API_KEY_SECRET:
transactionscommandside: transactionscommandside:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./transactions-command-side-service/build/libs:/app - ./transactions-command-side-service/build/libs:/app
@@ -44,7 +44,7 @@ transactionscommandside:
accountsqueryside: accountsqueryside:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./accounts-query-side-service/build/libs:/app - ./accounts-query-side-service/build/libs:/app
@@ -59,7 +59,7 @@ accountsqueryside:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
customerscommandside: customerscommandside:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./customers-command-side-service/build/libs:/app - ./customers-command-side-service/build/libs:/app
@@ -71,7 +71,7 @@ customerscommandside:
EVENTUATE_API_KEY_SECRET: EVENTUATE_API_KEY_SECRET:
customersqueryside: customersqueryside:
image: java:8 image: java:openjdk-8u91-jdk
working_dir: /app working_dir: /app
volumes: volumes:
- ./customers-query-side-service/build/libs:/app - ./customers-query-side-service/build/libs:/app

View File

@@ -28,10 +28,12 @@ import javax.annotation.PostConstruct;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import static net.chrisrichardson.eventstorestore.javaexamples.testutil.TestUtil.eventually; import static net.chrisrichardson.eventstorestore.javaexamples.testutil.TestUtil.eventually;
import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateCustomerInfo; import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateCustomerInfo;
import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateToAccountInfo; import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateToAccountInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@@ -106,10 +108,18 @@ public class BankingWebIntegrationTest {
new ParameterizedTypeReference<List<AccountTransactionInfo>>() {}).getBody(); new ParameterizedTypeReference<List<AccountTransactionInfo>>() {}).getBody();
assertTrue(transactionInfoList.stream().filter(ti -> ti.getTransactionId().equals(moneyTransfer.getMoneyTransferId()) && Optional<AccountTransactionInfo> first = transactionInfoList.stream().filter(ti -> ti.getTransactionId().equals(moneyTransfer.getMoneyTransferId())).findFirst();
ti.getFromAccountId().equals(fromAccountId) &&
ti.getToAccountId().equals(toAccountId) && assertTrue(first.isPresent());
ti.getAmount() == toCents(amountToTransfer).longValue()).findFirst().isPresent());
AccountTransactionInfo ti = first.get();
assertEquals(fromAccountId, ti.getFromAccountId());
assertEquals(toAccountId, ti.getToAccountId());
assertEquals(toAccountId, ti.getToAccountId());
assertEquals(fromAccountId, ti.getFromAccountId());
assertEquals(toCents(amountToTransfer).longValue(), ti.getAmount());
} }
@Test @Test
@@ -121,7 +131,7 @@ public class BankingWebIntegrationTest {
final String customerId = customerResponse.getId(); final String customerId = customerResponse.getId();
Assert.assertNotNull(customerId); Assert.assertNotNull(customerId);
Assert.assertEquals(customerInfo, customerResponse.getCustomerInfo()); assertEquals(customerInfo, customerResponse.getCustomerInfo());
customersTestUtils.assertCustomerResponse(customerId, customerInfo); customersTestUtils.assertCustomerResponse(customerId, customerInfo);
@@ -153,7 +163,7 @@ public class BankingWebIntegrationTest {
final String customerId = customerResponse.getId(); final String customerId = customerResponse.getId();
Assert.assertNotNull(customerId); Assert.assertNotNull(customerId);
Assert.assertEquals(customerInfo, customerResponse.getCustomerInfo()); assertEquals(customerInfo, customerResponse.getCustomerInfo());
customersTestUtils.assertCustomerResponse(customerId, customerInfo); customersTestUtils.assertCustomerResponse(customerId, customerInfo);
@@ -188,8 +198,8 @@ public class BankingWebIntegrationTest {
new Verifier<GetAccountResponse>() { new Verifier<GetAccountResponse>() {
@Override @Override
public void verify(GetAccountResponse accountInfo) { public void verify(GetAccountResponse accountInfo) {
Assert.assertEquals(fromAccountId, accountInfo.getAccountId()); assertEquals(fromAccountId, accountInfo.getAccountId());
Assert.assertEquals(inCents, accountInfo.getBalance()); assertEquals(inCents, accountInfo.getBalance());
} }
}); });
} }
@@ -208,7 +218,7 @@ public class BankingWebIntegrationTest {
new Verifier<QuerySideCustomer>() { new Verifier<QuerySideCustomer>() {
@Override @Override
public void verify(QuerySideCustomer customerResponse) { public void verify(QuerySideCustomer customerResponse) {
Assert.assertEquals(customerId, customerResponse.getId()); assertEquals(customerId, customerResponse.getId());
assertTrue(customerResponse.getToAccounts().values().stream().anyMatch(t -> t.equals(toAccountInfo))); assertTrue(customerResponse.getToAccounts().values().stream().anyMatch(t -> t.equals(toAccountInfo)));
} }
}); });