- completed moving "toAccounts" from List to Map

- created CustomerEvent superclass
- removed redundant CustomersNotFoundException
- added integration tests for customers
This commit is contained in:
Main
2016-02-11 21:47:48 +03:00
parent c0a9d6ed7d
commit 5c85418cc4
21 changed files with 131 additions and 63 deletions

View File

@@ -6,6 +6,8 @@ dependencies {
compile project(":accounts-query-side-web")
compile project(":accounts-command-side-web")
compile project(":transactions-command-side-web")
compile project(":customers-command-side-web")
compile project(":customers-query-side-web")
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"

View File

@@ -1,7 +1,9 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CommandSideWebAccountsConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.customers.CustomersCommandSideWebConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CommandSideWebTransactionsConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.CustomersQuerySideWebConfiguration;
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.QuerySideWebConfiguration;
import net.chrisrichardson.eventstore.jdbc.config.JdbcEventStoreConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -14,7 +16,7 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@Configuration
@Import({CommandSideWebAccountsConfiguration.class, CommandSideWebTransactionsConfiguration.class, JdbcEventStoreConfiguration.class, QuerySideWebConfiguration.class})
@Import({CommandSideWebAccountsConfiguration.class, CommandSideWebTransactionsConfiguration.class, JdbcEventStoreConfiguration.class, QuerySideWebConfiguration.class, CustomersQuerySideWebConfiguration.class, CustomersCommandSideWebConfiguration.class})
@EnableAutoConfiguration
@ComponentScan
public class BankingWebConfiguration {

View File

@@ -1,5 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CreateMoneyTransferRequest;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CreateMoneyTransferResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.accounts.GetAccountResponse;
@@ -71,6 +72,19 @@ public class BankingWebIntegrationTest {
}
@Test
public void shouldCreateCustomers() {
CustomerInfo customerInfo = generateCustomerInfo();
final CustomerResponse customerResponse = restTemplate.postForEntity(baseUrl("/customers"), customerInfo, CustomerResponse.class).getBody();
final String customerId = customerResponse.getId();
Assert.assertNotNull(customerId);
Assert.assertEquals(customerInfo, customerResponse.getCustomerInfo());
assertCustomerResponse(customerId, customerInfo);
}
private BigDecimal toCents(BigDecimal dollarAmount) {
return dollarAmount.multiply(new BigDecimal(100));
}
@@ -93,4 +107,38 @@ public class BankingWebIntegrationTest {
});
}
private void assertCustomerResponse(final String customerId, final CustomerInfo customerInfo) {
eventually(
new Producer<CustomerResponse>() {
@Override
public Observable<CustomerResponse> produce() {
return Observable.just(restTemplate.getForEntity(baseUrl("/customers/" + customerId), CustomerResponse.class).getBody());
}
},
new Verifier<CustomerResponse>() {
@Override
public void verify(CustomerResponse customerResponse) {
Assert.assertEquals(customerId, customerResponse.getId());
Assert.assertEquals(customerInfo, customerResponse.getCustomerInfo());
}
});
}
private CustomerInfo generateCustomerInfo() {
return new CustomerInfo(
new Name("John", "Doe"),
"current@email.com",
"000-00-0000",
"1-111-111-1111",
new Address("street 1",
"street 2",
"City",
"State",
"1111111")
);
}
private ToAccountInfo generateToAccountInfo() {
return new ToAccountInfo("11111111-11111111", "New Account", "John Doe");
}
}