BAEL-7547: small fix
This commit is contained in:
parent
34fd8269e3
commit
23ff3bc2fc
@ -18,13 +18,16 @@ public class LoyalCustomersRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void awardPoints(String customerId, int points) {
|
public void awardPoints(String customerId, int points) {
|
||||||
var customer = find(customerId).orElseThrow();
|
var customer = find(customerId)
|
||||||
|
.orElseGet(() -> save(new LoyalCustomer(customerId, 0)));
|
||||||
|
|
||||||
customers.remove(customer);
|
customers.remove(customer);
|
||||||
customers.add(customer.addPoints(points));
|
customers.add(customer.addPoints(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(String customerId) {
|
public LoyalCustomer save(LoyalCustomer customer) {
|
||||||
customers.add(new LoyalCustomer(customerId, 0));
|
customers.add(customer);
|
||||||
|
return customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoyalCustomer(String customerId) {
|
public boolean isLoyalCustomer(String customerId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user