Merge commit 'a217f1b1e6ba53fc90c12507672395ca20920672'

* commit 'a217f1b1e6ba53fc90c12507672395ca20920672':
  Enhanced curl commands Fixed SpringFox/SwaggerUI issue with CustomerController
  Ignore test failures when EVENTUATE_API_KEY_ID etc is not set
  Ignore test failures when EVENTUATE_API_KEY_ID etc is not set
  - updated e2e-tests - added new services to docker configuration
This commit is contained in:
Andrew Revinsky (DART)
2016-02-15 17:15:28 +03:00
10 changed files with 141 additions and 21 deletions

View File

@@ -18,6 +18,5 @@ dependencies {
}
test {
ignoreFailures true
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
}

View File

@@ -18,5 +18,5 @@ dependencies {
}
test {
ignoreFailures true
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
}

View File

@@ -13,10 +13,4 @@ dependencies {
compile "net.chrisrichardson.eventstore.client:eventstore-http-stomp-client_2.10:$eventStoreClientVersion"
testCompile "org.springframework.boot:spring-boot-starter-test"
}
run {
environment 'EVENTUATE_API_KEY_ID', '20CAXGPA3DE56WXO2SFBUDGZ9'
environment 'EVENTUATE_API_KEY_SECRET', 'gU6n78drWCIgkgzVStvI3BhV3MfzDyjWKCN7p0PBimI'
environment 'SPRING_DATA_MONGODB_URI', 'mongodb://198.50.218.51/mydb'
}
}

View File

@@ -31,9 +31,9 @@ public class CustomerController {
}
@RequestMapping(value = "/{id}/toaccounts", method = RequestMethod.POST)
public Observable<ResponseEntity<?>> addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) {
public Observable<String> addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) {
return customerService.addToAccount(id, request)
.map(entityAndEventInfo -> ResponseEntity.ok().build());
.map(entityAndEventInfo -> entityAndEventInfo.entityVersion().asString());
}
}

View File

@@ -18,10 +18,6 @@ dependencies {
}
test {
ignoreFailures true
environment 'EVENTUATE_API_KEY_ID', '20CAXGPA3DE56WXO2SFBUDGZ9'
environment 'EVENTUATE_API_KEY_SECRET', 'gU6n78drWCIgkgzVStvI3BhV3MfzDyjWKCN7p0PBimI'
environment 'SPRING_DATA_MONGODB_URI', 'mongodb://198.50.218.51/mydb'
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
}

View File

@@ -38,6 +38,33 @@ accountsqueryside:
EVENTUATE_API_KEY_SECRET:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
customerscommandside:
image: java:8
working_dir: /app
volumes:
- ./customers-command-side-service/build/libs:/app
command: java -jar /app/customers-command-side-service.jar
ports:
- "8083:8080"
environment:
EVENTUATE_API_KEY_ID:
EVENTUATE_API_KEY_SECRET:
customersqueryside:
image: java:8
working_dir: /app
volumes:
- ./customers-query-side-service/build/libs:/app
command: java -jar /app/customers-query-side-service.jar
ports:
- "8084:8080"
links:
- mongodb
environment:
EVENTUATE_API_KEY_ID:
EVENTUATE_API_KEY_SECRET:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
mongodb:
image: mongo:3.0.4
hostname: mongodb

View File

@@ -1,6 +1,10 @@
package net.chrisrichardson.eventstore.examples.bank.web;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.Address;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.Name;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CreateAccountRequest;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CreateAccountResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CreateMoneyTransferRequest;
@@ -40,6 +44,13 @@ public class EndToEndTest {
private String transactionsCommandSideBaseUrl(String path) {
return makeBaseUrl(8082, path);
}
private String customersCommandSideBaseUrl(String path) {
return makeBaseUrl(8083, path);
}
private String customersQuerySideBaseUrl(String path) {
return makeBaseUrl(8084, path);
}
RestTemplate restTemplate = new RestTemplate();
@@ -54,7 +65,8 @@ public class EndToEndTest {
@Test
public void shouldCreateAccountsAndTransferMoney() {
public void shouldCreateCustomerAndAccountsAndTransferMoney() {
CustomerInfo customerInfo = generateCustomerInfo();
BigDecimal initialFromAccountBalance = new BigDecimal(500);
BigDecimal initialToAccountBalance = new BigDecimal(100);
@@ -63,10 +75,16 @@ public class EndToEndTest {
BigDecimal finalFromAccountBalance = initialFromAccountBalance.subtract(amountToTransfer);
BigDecimal finalToAccountBalance = initialToAccountBalance.add(amountToTransfer);
final CreateAccountResponse fromAccount = restTemplate.postForEntity(accountsCommandSideBaseUrl("/accounts"), new CreateAccountRequest("00000000-00000000", "My #1 Account", initialFromAccountBalance), CreateAccountResponse.class).getBody();
final CustomerResponse customerResponse = restTemplate.postForEntity(customersCommandSideBaseUrl("/customers"),customerInfo, CustomerResponse.class).getBody();
final String customerId = customerResponse.getId();
assertCustomerResponse(customerId, customerInfo);
final CreateAccountResponse fromAccount = restTemplate.postForEntity(accountsCommandSideBaseUrl("/accounts"), new CreateAccountRequest(customerId, "My #1 Account", initialFromAccountBalance), CreateAccountResponse.class).getBody();
final String fromAccountId = fromAccount.getAccountId();
CreateAccountResponse toAccount = restTemplate.postForEntity(accountsCommandSideBaseUrl("/accounts"), new CreateAccountRequest("00000000-00000000", "My #2 Account", initialToAccountBalance), CreateAccountResponse.class).getBody();
CreateAccountResponse toAccount = restTemplate.postForEntity(accountsCommandSideBaseUrl("/accounts"), new CreateAccountRequest(customerId, "My #2 Account", initialToAccountBalance), CreateAccountResponse.class).getBody();
String toAccountId = toAccount.getAccountId();
Assert.assertNotNull(fromAccountId);
@@ -107,4 +125,35 @@ public class EndToEndTest {
});
}
private void assertCustomerResponse(final String customerId, final CustomerInfo customerInfo) {
eventually(
new Producer<CustomerResponse>() {
@Override
public Observable<CustomerResponse> produce() {
return Observable.just(restTemplate.getForEntity(customersQuerySideBaseUrl("/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")
);
}
}

View File

@@ -0,0 +1,55 @@
#! /bin/bash -e
# Create a customer
customer=$(curl -v --data '{
"address": {
"city": "Oakland",
"state": "CA",
"street1": "1 High Street",
"zipCode": "12345"
},
"email": "foo@bar.com",
"name": {
"firstName": "John",
"lastName": "Doe"
},
"phoneNumber": "415551212",
"ssn": "123-45-6789"
}' -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8083/customers)
customerId=$(echo $customer | jq -r .id)
echo customerId=$customerId
# Create account 1
account1=$(curl -v --data "{\"initialBalance\" : 500, \"customerId\" : \"$customerId\"}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8080/accounts)
accountId1=$(echo $account1 | jq -r ".accountId")
curl -v http://${DOCKER_HOST_IP?}:8081/accounts/$accountId1
echo accountId1=$accountId1
# Create account 2
account2=$(curl -v --data "{\"initialBalance\" : 300, \"customerId\" : \"$customerId\"}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8080/accounts)
accountId2=$(echo $account2 | jq -r ".accountId")
curl -v http://${DOCKER_HOST_IP?}:8081/accounts/$accountId2
echo accountId2=$accountId2
#
transfer=$(curl -v --data "{\"amount\" : 150,
\"fromAccountId\" : \"$accountId1\", \"toAccountId\" : \"$accountId2\"
}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8082/transfers)
echo transfer=$transfer

View File

@@ -16,6 +16,6 @@ dependencies {
}
test {
ignoreFailures true
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
}