// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/TestConfigurationHolder.java
// @Data
// @Builder
// public class TestConfigurationHolder {
// 	public static final String TEST_COMMUNICATION_TYPE_HEADER_NAME = "TEST-COMMUNICATION-TYPE";
// 	public static final ThreadLocal<TestConfigurationHolder> TEST_CONFIG = new ThreadLocal<>();
// 
// 	private TestCommunicationType testCommunicationType;
// 
// 	public enum TestCommunicationType {
// 		FEIGN, REST_TEMPLATE
// 	}
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/Ingredient.java
// @Data
// public class Ingredient {
//     private IngredientType type;
//     private Integer quantity;
// 
//     public Ingredient(IngredientType type, Integer quantity) {
//         this.type = type;
//         this.quantity = quantity;
//     }
// 
//     public Ingredient() {
//     }
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/IngredientType.java
// public enum IngredientType {
//     MALT, WATER, HOP, YEAST
// }


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.WebAsyncTask;
import io.spring.cloud.samples.brewery.common.TestConfigurationHolder;
import io.spring.cloud.samples.brewery.common.model.Ingredient;
import io.spring.cloud.samples.brewery.common.model.IngredientType;
import lombok.extern.slf4j.Slf4j;
package io.spring.cloud.samples.brewery.ingredients;



@RestController
@Slf4j
class IngredientsFetchController {
	private final StubbedIngredientsProperties stubbedIngredientsProperties;
	private final Tracer tracer;

	@Autowired
	IngredientsFetchController(StubbedIngredientsProperties stubbedIngredientsProperties, Tracer tracer) {
		this.stubbedIngredientsProperties = stubbedIngredientsProperties;
		this.tracer = tracer;
	}

	/**
	 * [SLEUTH] WebAsyncTask
	 */
	@RequestMapping(value = "/{ingredient}", method = RequestMethod.POST)
	public WebAsyncTask<Ingredient> ingredients(@PathVariable("ingredient") IngredientType ingredientType,
												@RequestHeader("PROCESS-ID") String processId,
												@RequestHeader(TestConfigurationHolder.TEST_COMMUNICATION_TYPE_HEADER_NAME) String testCommunicationType) {
		log.info("Received a request to [/{}] with process id [{}] and communication type [{}]", ingredientType,
				processId, testCommunicationType);
		return new WebAsyncTask<>(() -> {
			Span span = tracer.createSpan("inside_ingredients");
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/TestConfigurationHolder.java
// @Data
// @Builder
// public class TestConfigurationHolder {
// 	public static final String TEST_COMMUNICATION_TYPE_HEADER_NAME = "TEST-COMMUNICATION-TYPE";
// 	public static final ThreadLocal<TestConfigurationHolder> TEST_CONFIG = new ThreadLocal<>();
// 
// 	private TestCommunicationType testCommunicationType;
// 
// 	public enum TestCommunicationType {
// 		FEIGN, REST_TEMPLATE
// 	}
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/Ingredient.java
// @Data
// public class Ingredient {
//     private IngredientType type;
//     private Integer quantity;
// 
//     public Ingredient(IngredientType type, Integer quantity) {
//         this.type = type;
//         this.quantity = quantity;
//     }
// 
//     public Ingredient() {
//     }
// }
// 
// Path: common/src/main/java/io/spring/cloud/samples/brewery/common/model/IngredientType.java
// public enum IngredientType {
//     MALT, WATER, HOP, YEAST
// }


// Path: ingredients/src/main/java/io/spring/cloud/samples/brewery/ingredients/IngredientsFetchController.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.WebAsyncTask;
import io.spring.cloud.samples.brewery.common.TestConfigurationHolder;
import io.spring.cloud.samples.brewery.common.model.Ingredient;
import io.spring.cloud.samples.brewery.common.model.IngredientType;
import lombok.extern.slf4j.Slf4j;

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



@RestController
@Slf4j
class IngredientsFetchController {
	private final StubbedIngredientsProperties stubbedIngredientsProperties;
	private final Tracer tracer;

	@Autowired
	IngredientsFetchController(StubbedIngredientsProperties stubbedIngredientsProperties, Tracer tracer) {
		this.stubbedIngredientsProperties = stubbedIngredientsProperties;
		this.tracer = tracer;
	}

	/**
	 * [SLEUTH] WebAsyncTask
	 */
	@RequestMapping(value = "/{ingredient}", method = RequestMethod.POST)
	public WebAsyncTask<Ingredient> ingredients(@PathVariable("ingredient") IngredientType ingredientType,
												@RequestHeader("PROCESS-ID") String processId,
												@RequestHeader(TestConfigurationHolder.TEST_COMMUNICATION_TYPE_HEADER_NAME) String testCommunicationType) {
		log.info("Received a request to [/{}] with process id [{}] and communication type [{}]", ingredientType,
				processId, testCommunicationType);
		return new WebAsyncTask<>(() -> {
			Span span = tracer.createSpan("inside_ingredients");
			Ingredient ingredient = new Ingredient(ingredientType, stubbedIngredientsProperties.getReturnedIngredientsQuantity());