// Path: brewing/src/main/java/io/spring/cloud/samples/brewery/common/MaturingService.java
// public interface MaturingService {
//     void distributeIngredients(Ingredients ingredients, String processId,
//         String testCommunicationType);
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/IngredientType.java
// public enum IngredientType {
//     MALT, WATER, HOP, YEAST
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/Ingredients.java
// @ToString
// public class Ingredients {
// 
//     public Ingredients() {
//     }
// 
//     public Ingredients(Iterable<Ingredient> ingredients) {
//         this.ingredients = Lists.newArrayList(ingredients);
//     }
// 
//     public List<Ingredient> ingredients = Lists.newArrayList();
// 
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/Event.java
// @Data
// public class Event implements Serializable {
// 	private String processId;
// 	private EventType eventType;
// 	private LocalDateTime eventTime = LocalDateTime.now();
// 
// 	public Event(String processId, EventType eventType) {
// 		this.processId = processId;
// 		this.eventType = eventType;
// 	}
// 
// 	public Event() {}
// 
// 	public static EventBuilder builder() {
// 		return new EventBuilder();
// 	}
// 
// 	public static class EventBuilder {
// 
// 		private String processId;
// 		private EventType eventType;
// 
// 		public EventBuilder eventType(EventType eventType) {
// 			this.eventType = eventType;
// 			return this;
// 		}
// 
// 		public EventBuilder processId(String processId) {
// 			this.processId = processId;
// 			return this;
// 		}
// 
// 		public Event build() {
// 			return new Event(this.processId, this.eventType);
// 		}
// 
// 	}
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/EventGateway.java
// @MessagingGateway
// public interface EventGateway {
// 
// 	@Gateway(requestChannel=EventSource.OUTPUT)
// 	void emitEvent(Event event);
// 
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/EventType.java
// public enum EventType {
// 	INGREDIENTS_ORDERED,
// 	BREWING_STARTED,
// 	BEER_MATURED,
// 	BEER_BOTTLED
// }


import io.spring.cloud.samples.brewery.common.MaturingService;
import io.spring.cloud.samples.brewery.common.model.IngredientType;
import io.spring.cloud.samples.brewery.common.model.Ingredients;
import io.spring.cloud.samples.brewery.common.events.Event;
import io.spring.cloud.samples.brewery.common.events.EventGateway;
import io.spring.cloud.samples.brewery.common.events.EventType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;
import static io.spring.cloud.samples.brewery.common.TestConfigurationHolder.TestCommunicationType.FEIGN;
package io.spring.cloud.samples.brewery.aggregating;



@Slf4j
class MaturingServiceUpdater {

    private final IngredientsProperties ingredientsProperties;
    private final IngredientWarehouse ingredientWarehouse;
    private final MaturingService maturingService;
    private final RestTemplate restTemplate;
    private final EventGateway eventGateway;

    public MaturingServiceUpdater(IngredientsProperties ingredientsProperties,
                                  IngredientWarehouse ingredientWarehouse,
                                  MaturingService maturingService, RestTemplate restTemplate, EventGateway eventGateway) {
        this.ingredientsProperties = ingredientsProperties;
        this.ingredientWarehouse = ingredientWarehouse;
        this.maturingService = maturingService;
        this.restTemplate = restTemplate;
        this.eventGateway = eventGateway;
    }

// Path: brewing/src/main/java/io/spring/cloud/samples/brewery/common/MaturingService.java
// public interface MaturingService {
//     void distributeIngredients(Ingredients ingredients, String processId,
//         String testCommunicationType);
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/IngredientType.java
// public enum IngredientType {
//     MALT, WATER, HOP, YEAST
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/Ingredients.java
// @ToString
// public class Ingredients {
// 
//     public Ingredients() {
//     }
// 
//     public Ingredients(Iterable<Ingredient> ingredients) {
//         this.ingredients = Lists.newArrayList(ingredients);
//     }
// 
//     public List<Ingredient> ingredients = Lists.newArrayList();
// 
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/Event.java
// @Data
// public class Event implements Serializable {
// 	private String processId;
// 	private EventType eventType;
// 	private LocalDateTime eventTime = LocalDateTime.now();
// 
// 	public Event(String processId, EventType eventType) {
// 		this.processId = processId;
// 		this.eventType = eventType;
// 	}
// 
// 	public Event() {}
// 
// 	public static EventBuilder builder() {
// 		return new EventBuilder();
// 	}
// 
// 	public static class EventBuilder {
// 
// 		private String processId;
// 		private EventType eventType;
// 
// 		public EventBuilder eventType(EventType eventType) {
// 			this.eventType = eventType;
// 			return this;
// 		}
// 
// 		public EventBuilder processId(String processId) {
// 			this.processId = processId;
// 			return this;
// 		}
// 
// 		public Event build() {
// 			return new Event(this.processId, this.eventType);
// 		}
// 
// 	}
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/EventGateway.java
// @MessagingGateway
// public interface EventGateway {
// 
// 	@Gateway(requestChannel=EventSource.OUTPUT)
// 	void emitEvent(Event event);
// 
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/events/EventType.java
// public enum EventType {
// 	INGREDIENTS_ORDERED,
// 	BREWING_STARTED,
// 	BEER_MATURED,
// 	BEER_BOTTLED
// }


// Path: brewing/src/main/java/io/spring/cloud/samples/brewery/aggregating/MaturingServiceUpdater.java
import io.spring.cloud.samples.brewery.common.MaturingService;
import io.spring.cloud.samples.brewery.common.model.IngredientType;
import io.spring.cloud.samples.brewery.common.model.Ingredients;
import io.spring.cloud.samples.brewery.common.events.Event;
import io.spring.cloud.samples.brewery.common.events.EventGateway;
import io.spring.cloud.samples.brewery.common.events.EventType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;
import static io.spring.cloud.samples.brewery.common.TestConfigurationHolder.TestCommunicationType.FEIGN;

package io.spring.cloud.samples.brewery.aggregating;



@Slf4j
class MaturingServiceUpdater {

    private final IngredientsProperties ingredientsProperties;
    private final IngredientWarehouse ingredientWarehouse;
    private final MaturingService maturingService;
    private final RestTemplate restTemplate;
    private final EventGateway eventGateway;

    public MaturingServiceUpdater(IngredientsProperties ingredientsProperties,
                                  IngredientWarehouse ingredientWarehouse,
                                  MaturingService maturingService, RestTemplate restTemplate, EventGateway eventGateway) {
        this.ingredientsProperties = ingredientsProperties;
        this.ingredientWarehouse = ingredientWarehouse;
        this.maturingService = maturingService;
        this.restTemplate = restTemplate;
        this.eventGateway = eventGateway;
    }

    public Ingredients updateIfLimitReached(Ingredients ingredients, String processId) {