in sources/coffeeshop/coffee-application/src/main/java/solid/humank/coffeeshop/coffee/applications/MakeCoffeeSvc.java [38:56]
public CoffeeRst make(MakeCoffeeMsg request) {
if (confirmInventorySvc.notAvailableFor(request)) {
return new CoffeeRst("INVENTORY_IS_NOT_AVAILABLE_FOR_THE_REQUEST");
}
List<CoffeeItem> items = this.translator.translate(request.getItems());
List<Coffee> madeCoffees = new ArrayList<>();
items.stream().forEach(coffeeItem -> {
CoffeeId coffeeId = this.repository.generateCoffeeId();
MakeCoffee cmd = new MakeCoffee(coffeeId, request.getTableNo(), items);
Coffee madeCoffee = Coffee.make(cmd);
this.repository.save(madeCoffee);
madeCoffees.add(madeCoffee);
});
return new CoffeeRst(madeCoffees);
}