diff --git a/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/accounts/AccountQuerySideIntegrationTest.java b/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/accounts/AccountQuerySideIntegrationTest.java index 98b7073..b2047fa 100644 --- a/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/accounts/AccountQuerySideIntegrationTest.java +++ b/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/accounts/AccountQuerySideIntegrationTest.java @@ -1,7 +1,6 @@ package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts; import io.eventuate.EntityWithIdAndVersion; -import io.eventuate.EntityWithMetadata; import io.eventuate.EventuateAggregateStore; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.Account; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.AccountService; @@ -9,8 +8,6 @@ import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.t import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransferService; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.TransferState; import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.TransferDetails; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.Producer; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.Verifier; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import rx.Observable; import java.math.BigDecimal; @@ -30,39 +26,39 @@ import static net.chrisrichardson.eventstorestore.javaexamples.testutil.TestUtil @IntegrationTest public class AccountQuerySideIntegrationTest { - @Autowired - private AccountService accountService; + @Autowired + private AccountService accountService; - @Autowired - private MoneyTransferService moneyTransferService; + @Autowired + private MoneyTransferService moneyTransferService; - @Autowired - private EventuateAggregateStore eventStore; + @Autowired + private EventuateAggregateStore eventStore; - @Autowired - private AccountQueryService accountQueryService; + @Autowired + private AccountQueryService accountQueryService; - @Test - public void shouldUpdateQuerySide() throws Exception { + @Test + public void shouldUpdateQuerySide() throws Exception { - final EntityWithIdAndVersion fromAccount = await(accountService.openAccount("00000000-00000000", "My Account", new BigDecimal(150), "")); + final EntityWithIdAndVersion fromAccount = await(accountService.openAccount("00000000-00000000", "My Account", new BigDecimal(150), "")); - final EntityWithIdAndVersion toAccount = await(accountService.openAccount("00000000-00000000", "My Account", new BigDecimal(300), "")); + final EntityWithIdAndVersion toAccount = await(accountService.openAccount("00000000-00000000", "My Account", new BigDecimal(300), "")); - final EntityWithIdAndVersion transaction = await( - moneyTransferService.transferMoney(new TransferDetails(fromAccount.getEntityId(), - toAccount.getEntityId(), - new BigDecimal(80)))); + final EntityWithIdAndVersion transaction = await( + moneyTransferService.transferMoney(new TransferDetails(fromAccount.getEntityId(), + toAccount.getEntityId(), + new BigDecimal(80)))); - eventually( - () -> eventStore.find(MoneyTransfer.class, transaction.getEntityId()), - updatedTransaction -> Assert.assertEquals(TransferState.COMPLETED, updatedTransaction.getEntity().getState())); + eventually( + () -> eventStore.find(MoneyTransfer.class, transaction.getEntityId()), + updatedTransaction -> Assert.assertEquals(TransferState.COMPLETED, updatedTransaction.getEntity().getState())); - eventually( - () -> accountQueryService.findByAccountId(fromAccount.getEntityId()), - accountInfo -> Assert.assertEquals(70*100, accountInfo.getBalance())); - eventually( - () -> accountQueryService.findByAccountId(toAccount.getEntityId()), - accountInfo -> Assert.assertEquals(380*100, accountInfo.getBalance())); - } + eventually( + () -> accountQueryService.findByAccountId(fromAccount.getEntityId()), + accountInfo -> Assert.assertEquals(70 * 100, accountInfo.getBalance())); + eventually( + () -> accountQueryService.findByAccountId(toAccount.getEntityId()), + accountInfo -> Assert.assertEquals(380 * 100, accountInfo.getBalance())); + } } diff --git a/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/customers/CustomerQuerySideIntegrationTest.java b/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/customers/CustomerQuerySideIntegrationTest.java index 56aa2d7..84c6c08 100644 --- a/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/customers/CustomerQuerySideIntegrationTest.java +++ b/java-spring/backend-integration-tests/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/queryside/customers/CustomerQuerySideIntegrationTest.java @@ -19,10 +19,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.concurrent.CompletableFuture; +import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo; +import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateToAccountInfo; import static net.chrisrichardson.eventstorestore.javaexamples.testutil.TestUtil.await; 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.generateToAccountInfo; /** * Created by Main on 10.02.2016. diff --git a/java-spring/customers-command-side-backend/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/commandside/customers/CustomerTest.java b/java-spring/customers-command-side-backend/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/commandside/customers/CustomerTest.java index c33f78e..36f2871 100644 --- a/java-spring/customers-command-side-backend/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/commandside/customers/CustomerTest.java +++ b/java-spring/customers-command-side-backend/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/backend/commandside/customers/CustomerTest.java @@ -8,7 +8,7 @@ import org.junit.Test; import java.util.List; -import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateCustomerInfo; +import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo; public class CustomerTest { @@ -26,4 +26,6 @@ public class CustomerTest { customer.applyEvent(events.get(0)); Assert.assertEquals(customerInfo, customer.getCustomerInfo()); } + + } diff --git a/java-spring/customers-command-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersCommandSideServiceIntegrationTest.java b/java-spring/customers-command-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersCommandSideServiceIntegrationTest.java index 33af652..2062000 100644 --- a/java-spring/customers-command-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersCommandSideServiceIntegrationTest.java +++ b/java-spring/customers-command-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersCommandSideServiceIntegrationTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.client.RestTemplate; -import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateCustomerInfo; +import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = CustomersCommandSideServiceTestConfiguration.class) diff --git a/java-spring/customers-query-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersQuerySideServiceIntegrationTest.java b/java-spring/customers-query-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersQuerySideServiceIntegrationTest.java index 6eab807..bb7b602 100644 --- a/java-spring/customers-query-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersQuerySideServiceIntegrationTest.java +++ b/java-spring/customers-query-side-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/CustomersQuerySideServiceIntegrationTest.java @@ -1,9 +1,7 @@ package net.chrisrichardson.eventstore.javaexamples.banking.web; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.Producer; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.Verifier; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils; +import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,8 +16,7 @@ import rx.Observable; import javax.annotation.PostConstruct; -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.CustomersTestUtils.generateCustomerInfo; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = CustomersQuerySideServiceTestConfiguration.class) diff --git a/java-spring/e2e-test/src/test/java/net/chrisrichardson/eventstore/examples/bank/web/EndToEndTest.java b/java-spring/e2e-test/src/test/java/net/chrisrichardson/eventstore/examples/bank/web/EndToEndTest.java index 9590df5..1917d54 100644 --- a/java-spring/e2e-test/src/test/java/net/chrisrichardson/eventstore/examples/bank/web/EndToEndTest.java +++ b/java-spring/e2e-test/src/test/java/net/chrisrichardson/eventstore/examples/bank/web/EndToEndTest.java @@ -3,8 +3,11 @@ package net.chrisrichardson.eventstore.examples.bank.web; import net.chrisrichardson.eventstorestore.javaexamples.testutil.AbstractRestAPITest; import net.chrisrichardson.eventstorestore.javaexamples.testutil.AuthenticatedRestTemplate; +import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils; import org.springframework.web.client.RestTemplate; +import javax.annotation.PostConstruct; + public class EndToEndTest extends AbstractRestAPITest { private String getenv(String name, String defaultValue) { @@ -12,10 +15,22 @@ public class EndToEndTest extends AbstractRestAPITest { return x == null ? defaultValue : x; } + CustomersTestUtils customersTestUtils; + + @PostConstruct + private void init() { + customersTestUtils = new CustomersTestUtils(restTemplate, baseUrl("/customers/")); + } + public String baseUrl(String path) { return "http://" + getenv("SERVICE_HOST", "localhost") + ":" + 8080 + "/" + path; } + @Override + public CustomersTestUtils getCustomersTestUtils() { + return customersTestUtils; + } + RestTemplate restTemplate = new RestTemplate(); @Override diff --git a/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingAuthTest.java b/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingAuthTest.java index 0a28156..28dd511 100644 --- a/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingAuthTest.java +++ b/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingAuthTest.java @@ -4,7 +4,7 @@ import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.Cust import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerResponse; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.AuthRequest; -import net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils; +import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,7 +18,7 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.PostConstruct; -import static net.chrisrichardson.eventstorestore.javaexamples.testutil.customers.CustomersTestUtils.generateCustomerInfo; +import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo; /** * Created by Main on 15.02.2016. diff --git a/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingWebIntegrationTest.java b/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingWebIntegrationTest.java index 6d45e55..dfd1f3d 100644 --- a/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingWebIntegrationTest.java +++ b/java-spring/monolithic-service/src/test/java/net/chrisrichardson/eventstore/javaexamples/banking/web/BankingWebIntegrationTest.java @@ -2,6 +2,7 @@ package net.chrisrichardson.eventstore.javaexamples.banking.web; import net.chrisrichardson.eventstorestore.javaexamples.testutil.AbstractRestAPITest; import net.chrisrichardson.eventstorestore.javaexamples.testutil.AuthenticatedRestTemplate; +import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -11,6 +12,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.client.RestTemplate; +import javax.annotation.PostConstruct; + @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = BankingWebTestConfiguration.class) @WebAppConfiguration @@ -20,11 +23,23 @@ public class BankingWebIntegrationTest extends AbstractRestAPITest { @Value("${local.server.port}") private int port; + CustomersTestUtils customersTestUtils; + + @PostConstruct + private void init() { + customersTestUtils = new CustomersTestUtils(restTemplate, baseUrl("/customers/")); + } + @Override public String baseUrl(String path) { return "http://localhost:" + port + "/" + path; } + @Override + public CustomersTestUtils getCustomersTestUtils() { + return customersTestUtils; + } + @Autowired RestTemplate restTemplate; diff --git a/java-spring/testutil/src/main/java/net/chrisrichardson/eventstorestore/javaexamples/testutil/AbstractRestAPITest.java b/java-spring/testutil/src/main/java/net/chrisrichardson/eventstorestore/javaexamples/testutil/AbstractRestAPITest.java index 6dfc6b6..00d52ba 100644 --- a/java-spring/testutil/src/main/java/net/chrisrichardson/eventstorestore/javaexamples/testutil/AbstractRestAPITest.java +++ b/java-spring/testutil/src/main/java/net/chrisrichardson/eventstorestore/javaexamples/testutil/AbstractRestAPITest.java @@ -12,14 +12,10 @@ import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.C import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.CreateMoneyTransferResponse; import org.junit.Assert; import org.junit.Test; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; import org.springframework.web.client.RestTemplate; import java.math.BigDecimal; import java.util.Arrays; -import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture;