Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,011 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
buildSrc/src/main/groovy/VerifyMongoDBConfigurationPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import org.gradle.api.* | ||
|
||
|
||
class VerifyMongoDBConfigurationPlugin implements Plugin<Project> { | ||
void apply(Project project) { | ||
project.test { | ||
beforeSuite { x -> | ||
if (x.parent == null) { | ||
if (System.getenv("SPRING_DATA_MONGODB_URI") == null) | ||
throw new RuntimeException("Please make sure that the environment variable SPRING_DATA_MONGODB_URI is set, e.g. export SPRING_DATA_MONGODB_URI=mongodb://192.168.59.103/mydb") | ||
} | ||
} | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...java/io/eventuate/examples/tram/ordersandcustomers/commondomain/CustomerCreatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.commondomain; | ||
|
||
import io.eventuate.tram.events.common.DomainEvent; | ||
|
||
public class CustomerCreatedEvent implements DomainEvent { | ||
private Long customerId; | ||
private String name; | ||
private Money creditLimit; | ||
|
||
public CustomerCreatedEvent() { | ||
} | ||
|
||
public CustomerCreatedEvent(Long customerId, String name, Money creditLimit) { | ||
this.customerId = customerId; | ||
this.name = name; | ||
this.creditLimit = creditLimit; | ||
} | ||
|
||
public Long getCustomerId() { | ||
return customerId; | ||
} | ||
|
||
public void setCustomerId(Long customerId) { | ||
this.customerId = customerId; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Money getCreditLimit() { | ||
return creditLimit; | ||
} | ||
|
||
public void setCreditLimit(Money creditLimit) { | ||
this.creditLimit = creditLimit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
.../src/main/java/io/eventuate/examples/tram/ordersandcustomers/commondomain/OrderState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.commondomain; | ||
|
||
public enum OrderState { PENDING, APPROVED, REJECTED } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
...java/io/eventuate/examples/tram/ordersandcustomers/customers/service/CustomerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.customers.service; | ||
|
||
import io.eventuate.examples.tram.ordersandcustomers.commondomain.CustomerCreatedEvent; | ||
import io.eventuate.examples.tram.ordersandcustomers.commondomain.Money; | ||
import io.eventuate.examples.tram.ordersandcustomers.customers.domain.Customer; | ||
import io.eventuate.examples.tram.ordersandcustomers.customers.domain.CustomerRepository; | ||
import io.eventuate.tram.events.publisher.DomainEventPublisher; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Collections; | ||
|
||
public class CustomerService { | ||
|
||
@Autowired | ||
private CustomerRepository customerRepository; | ||
|
||
@Autowired | ||
private DomainEventPublisher domainEventPublisher; | ||
|
||
public Customer createCustomer(String name, Money creditLimit) { | ||
Customer customer = new Customer(name, creditLimit); | ||
return customerRepository.save(customer); | ||
customer = customerRepository.save(customer); | ||
|
||
domainEventPublisher.publish(Customer.class, | ||
customer.getId(), | ||
Collections.singletonList(new CustomerCreatedEvent(customer.getId(), | ||
customer.getName(), customer.getCreditLimit()))); | ||
|
||
return customer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.