Refactor. | lol digg (C) whatthecommit.com
This commit is contained in:
@@ -13,3 +13,7 @@ http :8080
|
||||
```
|
||||
|
||||
**NOTE:** _For better developer experience during testing, use idea cURL integration tests from `rest-client*` files. Read more: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html_
|
||||
|
||||
resources:
|
||||
|
||||
* [YouTube: Building Event Driven Systems with Spring Cloud Stream](https://www.youtube.com/watch?v=LvmPa7YKgqM&t=2673s)
|
||||
|
||||
@@ -98,8 +98,7 @@ public class User implements Function<DomainEvent, User> {
|
||||
|
||||
/* es */
|
||||
|
||||
public static User recreate(UUID userId, Collection<DomainEvent> domainEvents) {
|
||||
User snapshot = new User(userId);
|
||||
public static User recreate(User snapshot, Collection<DomainEvent> domainEvents) {
|
||||
return io.vavr.collection.List.ofAll(domainEvents)
|
||||
.foldLeft(snapshot, User::apply);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ public class InMemoryUserRepository implements UserRepository {
|
||||
|
||||
@Override
|
||||
public User find(UUID userId) {
|
||||
User snapshot = new User();
|
||||
return eventStore.containsKey(userId)
|
||||
? User.recreate(userId, eventStore.get(userId))
|
||||
: null;
|
||||
? User.recreate(snapshot, eventStore.get(userId))
|
||||
: snapshot;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user