// Path: microservice-consul-demo/microservice-consul-demo-order/src/main/java/com/ewolff/microservice/order/OrderApp.java
// @SpringBootApplication
// @EnableDiscoveryClient
// @RibbonClient("order")
// public class OrderApp {
// 
// 	@Bean
// 	public RestTemplate restTemplate() {
// 		return new RestTemplate();
// 	}
// 
// 	public static void main(String[] args) {
// 		SpringApplication.run(OrderApp.class, args);
// 	}
// 
// }
// 
// Path: microservice-consul-demo/microservice-consul-demo-order/src/main/java/com/ewolff/microservice/order/clients/CatalogClient.java
// @Component
// public class CatalogClient {
// 
// 	private final Logger log = LoggerFactory.getLogger(CatalogClient.class);
// 
// 	public static class ItemPagedResources extends PagedModel<Item> {
// 
// 	}
// 
// 	private RestTemplate restTemplate;
// 	private String catalogServiceHost;
// 	private long catalogServicePort;
// 	private boolean useRibbon;
// 	private LoadBalancerClient loadBalancer;
// 
// 	@Autowired
// 	public CatalogClient(@Value("${catalog.service.host:catalog}") String catalogServiceHost,
// 			@Value("${catalog.service.port:8080}") long catalogServicePort,
// 			@Value("${spring.cloud.consul.ribbon.enabled:false}") boolean useRibbon,
// 			@Autowired RestTemplate restTemplate) {
// 		super();
// 		this.restTemplate = restTemplate;
// 		this.catalogServiceHost = catalogServiceHost;
// 		this.catalogServicePort = catalogServicePort;
// 		this.useRibbon = useRibbon;
// 	}
// 
// 	@Autowired(required = false)
// 	public void setLoadBalancer(LoadBalancerClient loadBalancer) {
// 		this.loadBalancer = loadBalancer;
// 	}
// 
// 	protected RestTemplate getRestTemplate() {
// 		ObjectMapper mapper = new ObjectMapper();
// 		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 		mapper.registerModule(new Jackson2HalModule());
// 
// 		MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
// 		converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
// 		converter.setObjectMapper(mapper);
// 
// 		return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
// 	}
// 
// 	public double price(long itemId) {
// 		return getOne(itemId).getPrice();
// 	}
// 
// 	public Collection<Item> findAll() {
// 		PagedModel<Item> pagedResources = getRestTemplate().getForObject(catalogURL(), ItemPagedResources.class);
// 		return pagedResources.getContent();
// 	}
// 
// 	private String catalogURL() {
// 		String url;
// 		if (useRibbon) {
// 			ServiceInstance instance = loadBalancer.choose("CATALOG");
// 			url = String.format("http://%s:%s/catalog/", instance.getHost(), instance.getPort());
// 		} else {
// 			url = String.format("http://%s:%s/catalog/", catalogServiceHost, catalogServicePort);
// 		}
// 		log.trace("Catalog: URL {} ", url);
// 		return url;
// 	}
// 
// 	public Item getOne(long itemId) {
// 		return restTemplate.getForObject(catalogURL() + itemId, Item.class);
// 	}
// 
// }


import com.ewolff.microservice.order.OrderApp;
import com.ewolff.microservice.order.clients.CatalogClient;
import com.ewolff.microservice.order.clients.Item;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
package com.ewolff.microservice.order.logic;




@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = OrderApp.class)
@ActiveProfiles("test")
public class CatalogConsumerDrivenContractTest {

	@Autowired
	CatalogClient catalogClient;

	@Test
	public void testFindAll() {
		Collection<Item> result = catalogClient.findAll();
		assertEquals(
				1,
// Path: microservice-consul-demo/microservice-consul-demo-order/src/main/java/com/ewolff/microservice/order/OrderApp.java
// @SpringBootApplication
// @EnableDiscoveryClient
// @RibbonClient("order")
// public class OrderApp {
// 
// 	@Bean
// 	public RestTemplate restTemplate() {
// 		return new RestTemplate();
// 	}
// 
// 	public static void main(String[] args) {
// 		SpringApplication.run(OrderApp.class, args);
// 	}
// 
// }
// 
// Path: microservice-consul-demo/microservice-consul-demo-order/src/main/java/com/ewolff/microservice/order/clients/CatalogClient.java
// @Component
// public class CatalogClient {
// 
// 	private final Logger log = LoggerFactory.getLogger(CatalogClient.class);
// 
// 	public static class ItemPagedResources extends PagedModel<Item> {
// 
// 	}
// 
// 	private RestTemplate restTemplate;
// 	private String catalogServiceHost;
// 	private long catalogServicePort;
// 	private boolean useRibbon;
// 	private LoadBalancerClient loadBalancer;
// 
// 	@Autowired
// 	public CatalogClient(@Value("${catalog.service.host:catalog}") String catalogServiceHost,
// 			@Value("${catalog.service.port:8080}") long catalogServicePort,
// 			@Value("${spring.cloud.consul.ribbon.enabled:false}") boolean useRibbon,
// 			@Autowired RestTemplate restTemplate) {
// 		super();
// 		this.restTemplate = restTemplate;
// 		this.catalogServiceHost = catalogServiceHost;
// 		this.catalogServicePort = catalogServicePort;
// 		this.useRibbon = useRibbon;
// 	}
// 
// 	@Autowired(required = false)
// 	public void setLoadBalancer(LoadBalancerClient loadBalancer) {
// 		this.loadBalancer = loadBalancer;
// 	}
// 
// 	protected RestTemplate getRestTemplate() {
// 		ObjectMapper mapper = new ObjectMapper();
// 		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 		mapper.registerModule(new Jackson2HalModule());
// 
// 		MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
// 		converter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
// 		converter.setObjectMapper(mapper);
// 
// 		return new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
// 	}
// 
// 	public double price(long itemId) {
// 		return getOne(itemId).getPrice();
// 	}
// 
// 	public Collection<Item> findAll() {
// 		PagedModel<Item> pagedResources = getRestTemplate().getForObject(catalogURL(), ItemPagedResources.class);
// 		return pagedResources.getContent();
// 	}
// 
// 	private String catalogURL() {
// 		String url;
// 		if (useRibbon) {
// 			ServiceInstance instance = loadBalancer.choose("CATALOG");
// 			url = String.format("http://%s:%s/catalog/", instance.getHost(), instance.getPort());
// 		} else {
// 			url = String.format("http://%s:%s/catalog/", catalogServiceHost, catalogServicePort);
// 		}
// 		log.trace("Catalog: URL {} ", url);
// 		return url;
// 	}
// 
// 	public Item getOne(long itemId) {
// 		return restTemplate.getForObject(catalogURL() + itemId, Item.class);
// 	}
// 
// }


// Path: microservice-consul-demo/microservice-consul-demo-order/src/test/java/com/ewolff/microservice/order/logic/CatalogConsumerDrivenContractTest.java
import com.ewolff.microservice.order.OrderApp;
import com.ewolff.microservice.order.clients.CatalogClient;
import com.ewolff.microservice.order.clients.Item;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Collection;
import static org.junit.Assert.assertEquals;

package com.ewolff.microservice.order.logic;




@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = OrderApp.class)
@ActiveProfiles("test")
public class CatalogConsumerDrivenContractTest {

	@Autowired
	CatalogClient catalogClient;

	@Test
	public void testFindAll() {
		Collection<Item> result = catalogClient.findAll();
		assertEquals(
				1,
				result.stream()