Merge remote-tracking branch 'remotes/upstream/wip-customer' into private-event-sourcing-examples-38

This commit is contained in:
dartpopikyardo
2016-09-27 10:26:02 +03:00
26 changed files with 38 additions and 51 deletions

View File

@@ -73,17 +73,11 @@ public class AccountQueryWorkflow {
@EventHandlerMethod @EventHandlerMethod
public void recordDebit(DispatchedEvent<AccountDebitedEvent> de) { public void recordDebit(DispatchedEvent<AccountDebitedEvent> de) {
String accountId = de.getEntityId();
String transactionId = de.getEvent().getTransactionId();
saveChange(de, -1); saveChange(de, -1);
} }
@EventHandlerMethod @EventHandlerMethod
public void recordCredit(DispatchedEvent<AccountCreditedEvent> de) { public void recordCredit(DispatchedEvent<AccountCreditedEvent> de) {
String accountId = de.getEntityId();
String transactionId = de.getEvent().getTransactionId();
saveChange(de, +1); saveChange(de, +1);
} }

View File

@@ -1,6 +1,5 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'spring-boot' apply plugin: 'spring-boot'
apply plugin: EventuateDependencyPlugin
dependencies { dependencies {
compile project(":common-auth-web") compile project(":common-auth-web")

View File

@@ -5,7 +5,7 @@ import io.eventuate.EventuateAggregateStore;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.customers.Customer; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.customers.Customer;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.customers.CustomerService; import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.customers.CustomerService;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo;
import net.chrisrichardson.eventstorestore.javaexamples.testutil.Producer; import net.chrisrichardson.eventstorestore.javaexamples.testutil.Producer;
import net.chrisrichardson.eventstorestore.javaexamples.testutil.Verifier; import net.chrisrichardson.eventstorestore.javaexamples.testutil.Verifier;

View File

@@ -1,10 +1,9 @@
package net.chrisrichardson.eventstore.javaexamples.banking.commonauth.controller; package net.chrisrichardson.eventstore.javaexamples.banking.commonauth.controller;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.UserCredentials; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.UserCredentials;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.CustomerAuthService; import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.CustomerAuthService;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.AuthRequest;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.ErrorResponse; import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.ErrorResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.User; import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -2,6 +2,7 @@ apply plugin: 'java'
dependencies { dependencies {
compile project(":common") compile project(":common")
compile project(":customers-query-side-common")
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion"

View File

@@ -1,6 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.commonauth; package net.chrisrichardson.eventstore.javaexamples.banking.commonauth;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.filter.StatelessAuthenticationFilter; import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.filter.StatelessAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;

View File

@@ -1,6 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.commonauth; package net.chrisrichardson.eventstore.javaexamples.banking.commonauth;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List; import java.util.List;

View File

@@ -1,6 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.commonauth; package net.chrisrichardson.eventstore.javaexamples.banking.commonauth;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.springframework.dao.support.DataAccessUtils; import org.springframework.dao.support.DataAccessUtils;
/** /**

View File

@@ -2,8 +2,8 @@ apply plugin: 'java'
dependencies { dependencies {
compile "commons-lang:commons-lang:2.6" compile "commons-lang:commons-lang:2.6"
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion" compile "com.fasterxml.jackson.core:jackson-databind:2.6.6"
compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
testCompile group: 'junit', name: 'junit', version: '4.11' testCompile group: 'junit', name: 'junit', version: '4.11'
} }

View File

@@ -7,7 +7,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
import java.util.Date; import java.util.Date;
public class AccountTransactionInfo extends AccountHistoryEntry{ public class AccountTransactionInfo extends AccountHistoryEntry {
private String transactionId; private String transactionId;
private String fromAccountId; private String fromAccountId;

View File

@@ -2,6 +2,7 @@ apply plugin: 'java'
dependencies { dependencies {
compile project(":common-backend") compile project(":common-backend")
compile project(":customers-query-side-common")
compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion" compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion"

View File

@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers; package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers; package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers;
import io.eventuate.CompletableFutureUtil; import io.eventuate.CompletableFutureUtil;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import java.util.List; import java.util.List;

View File

@@ -1,6 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers; package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List; import java.util.List;

View File

@@ -3,13 +3,9 @@ package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.cu
import io.eventuate.javaclient.spring.jdbc.EventuateJdbcEventStoreConfiguration; import io.eventuate.javaclient.spring.jdbc.EventuateJdbcEventStoreConfiguration;
import io.eventuate.javaclient.spring.jdbc.IdGenerator; import io.eventuate.javaclient.spring.jdbc.IdGenerator;
import io.eventuate.javaclient.spring.jdbc.IdGeneratorImpl; import io.eventuate.javaclient.spring.jdbc.IdGeneratorImpl;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.AccountCreditedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountChangeInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountTransactionInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.TransferState;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -20,8 +16,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.math.BigDecimal;
import java.util.Date;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo; import static net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils.generateCustomerInfo;

View File

@@ -0,0 +1,10 @@
apply plugin: 'java'
dependencies {
compile project(":common")
compile "commons-lang:commons-lang:2.6"
compile "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion"
testCompile group: 'junit', name: 'junit', version: '4.11'
}

View File

@@ -1,5 +1,8 @@
package net.chrisrichardson.eventstore.javaexamples.banking.common.customers; package net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.Address;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.Name;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.ToAccountInfo;
import org.springframework.data.mongodb.core.index.Indexed; import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;

View File

@@ -1,7 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside; package net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers.CustomerQueryService; import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.customers.CustomerQueryService;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@@ -1,6 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside; package net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import java.util.List; import java.util.List;

View File

@@ -63,19 +63,6 @@ apigateway:
- customerscommandside - customerscommandside
- customersqueryside - customersqueryside
- mongodb - mongodb
- mysql
- kafka
- zookeeper
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
SPRING_DATASOURCE_USERNAME: mysqluser
SPRING_DATASOURCE_PASSWORD: mysqlpw
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
EVENTUATELOCAL_CDC_DB_USER_NAME: root
EVENTUATELOCAL_CDC_DB_PASSWORD: rootpassword
accountscommandside: accountscommandside:
extends: extends:

View File

@@ -11,9 +11,6 @@ apigateway:
- customerscommandside - customerscommandside
- customersqueryside - customersqueryside
- mongodb - mongodb
environment:
EVENTUATE_API_KEY_ID: ${EVENTUATE_API_KEY_ID}
EVENTUATE_API_KEY_SECRET: ${EVENTUATE_API_KEY_SECRET}
accountscommandside: accountscommandside:
extends: extends:

View File

@@ -2,9 +2,7 @@ package net.chrisrichardson.eventstore.javaexamples.banking.web;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.CustomerInfo; 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.CustomerResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.QuerySideCustomer; import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.UserCredentials;
import net.chrisrichardson.eventstore.javaexamples.banking.commonauth.model.AuthRequest;
import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils; import net.chrisrichardson.eventstorestore.javaexamples.testutil.CustomersTestUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

View File

@@ -21,6 +21,7 @@ include 'customers-command-side-backend'
include 'customers-command-side-web' include 'customers-command-side-web'
include 'customers-command-side-service' include 'customers-command-side-service'
include 'customers-query-side-common'
include 'customers-query-side-backend' include 'customers-query-side-backend'
include 'customers-query-side-web' include 'customers-query-side-web'
include 'customers-query-side-service' include 'customers-query-side-service'

View File

@@ -4,10 +4,9 @@ import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.*;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.CreateMoneyTransferRequest; import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.CreateMoneyTransferRequest;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.CreateMoneyTransferResponse; import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.CreateMoneyTransferResponse;
import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@@ -8,6 +8,8 @@ import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import static org.junit.Assert.assertEquals;
/** /**
* Created by Main on 18.02.2016. * Created by Main on 18.02.2016.
*/ */
@@ -41,7 +43,8 @@ public class BasicAuthUtils {
httpMethod, httpMethod,
httpEntity, httpEntity,
responseType); responseType);
Assert.isTrue(HttpStatus.OK == responseEntity.getStatusCode(), "Bad response: " + responseEntity.getStatusCode());
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
return responseEntity.getBody(); return responseEntity.getBody();
} }
} }

View File

@@ -1,6 +1,7 @@
package net.chrisrichardson.eventstorestore.javaexamples.testutil; package net.chrisrichardson.eventstorestore.javaexamples.testutil;
import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*; import net.chrisrichardson.eventstore.javaexamples.banking.common.customers.*;
import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
import org.junit.Assert; import org.junit.Assert;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;