// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java
// public class TemplateDuplicateException extends RuntimeException{
// 	public TemplateDuplicateException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java
// public class TemplateInstanciationException extends RuntimeException {
// 	public TemplateInstanciationException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java
// public class TemplateNotFoundException extends RuntimeException {
// 	public TemplateNotFoundException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/test/java/model/Address.java
// public class Address {
// 	private String country;
// 	private String street;
// 	private String city;
// 
// 	public String getCountry() {
// 		return country;
// 	}
// 
// 	public void setCountry(String country) {
// 		this.country = country;
// 	}
// 
// 	public String getCity() {
// 		return city;
// 	}
// 
// 	public void setCity(String city) {
// 		this.city = city;
// 	}
// 
// 	public String getStreet() {
// 		return street;
// 	}
// 
// 	public void setStreet(String street) {
// 		this.street = street;
// 	}
// }
// 
// Path: src/test/java/model/User.java
// public class User {
// 	private long id;
// 	private String name;
// 	private String lastName;
// 	private Role role;
// 
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	private Address addr;
// 
// 	public Role getRole() {
// 		return role;
// 	}
// 
// 	public void setRole(Role role) {
// 		this.role = role;
// 	}
// 
// 	public void setAddr(Address addr) {
// 		this.addr = addr;
// 	}
// 
// 	public void setLastName(String lastName) {
// 		this.lastName = lastName;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public Address getAddr() {
// 		return addr;
// 	}
// 
// 	public String getLastName() {
// 		return lastName;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// }


import factoryduke.exceptions.TemplateNotFoundException;
import model.Address;
import model.User;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Before;
import org.junit.Test;
import factoryduke.exceptions.TemplateDuplicateException;
import factoryduke.exceptions.TemplateInstanciationException;
	public void reset() {
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty();
	}

	@Test
	public void duplicate_definition() {
		Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test"));
		FactoryRuntimeHolder.getRuntime().register(tp);

		assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
				.isInstanceOf(TemplateDuplicateException.class)
				.hasMessageContaining("Cannot define duplicate template with the same identifier")
				.hasNoCause();
	}

	@Test
	public void build_instance_with_supplier_wrong_cast() {
		FactoryRuntimeHolder.getRuntime().load();

		assertThatThrownBy(() -> {
			FactoryRuntimeHolder.getRuntime().<Address>build("admin_user", o -> {
			}).toOne();
		}).isInstanceOf(ClassCastException.class);
	}

	@Test
	public void build_instance_with_consumer_wrong_cast() {
		FactoryRuntimeHolder.getRuntime().load();

		assertThatThrownBy(() -> {
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java
// public class TemplateDuplicateException extends RuntimeException{
// 	public TemplateDuplicateException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java
// public class TemplateInstanciationException extends RuntimeException {
// 	public TemplateInstanciationException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java
// public class TemplateNotFoundException extends RuntimeException {
// 	public TemplateNotFoundException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/test/java/model/Address.java
// public class Address {
// 	private String country;
// 	private String street;
// 	private String city;
// 
// 	public String getCountry() {
// 		return country;
// 	}
// 
// 	public void setCountry(String country) {
// 		this.country = country;
// 	}
// 
// 	public String getCity() {
// 		return city;
// 	}
// 
// 	public void setCity(String city) {
// 		this.city = city;
// 	}
// 
// 	public String getStreet() {
// 		return street;
// 	}
// 
// 	public void setStreet(String street) {
// 		this.street = street;
// 	}
// }
// 
// Path: src/test/java/model/User.java
// public class User {
// 	private long id;
// 	private String name;
// 	private String lastName;
// 	private Role role;
// 
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	private Address addr;
// 
// 	public Role getRole() {
// 		return role;
// 	}
// 
// 	public void setRole(Role role) {
// 		this.role = role;
// 	}
// 
// 	public void setAddr(Address addr) {
// 		this.addr = addr;
// 	}
// 
// 	public void setLastName(String lastName) {
// 		this.lastName = lastName;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public Address getAddr() {
// 		return addr;
// 	}
// 
// 	public String getLastName() {
// 		return lastName;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// }


// Path: src/test/java/factoryduke/FactoryRuntimeTest.java
import factoryduke.exceptions.TemplateNotFoundException;
import model.Address;
import model.User;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Before;
import org.junit.Test;
import factoryduke.exceptions.TemplateDuplicateException;
import factoryduke.exceptions.TemplateInstanciationException;

	public void reset() {
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty();
	}

	@Test
	public void duplicate_definition() {
		Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test"));
		FactoryRuntimeHolder.getRuntime().register(tp);

		assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
				.isInstanceOf(TemplateDuplicateException.class)
				.hasMessageContaining("Cannot define duplicate template with the same identifier")
				.hasNoCause();
	}

	@Test
	public void build_instance_with_supplier_wrong_cast() {
		FactoryRuntimeHolder.getRuntime().load();

		assertThatThrownBy(() -> {
			FactoryRuntimeHolder.getRuntime().<Address>build("admin_user", o -> {
			}).toOne();
		}).isInstanceOf(ClassCastException.class);
	}

	@Test
	public void build_instance_with_consumer_wrong_cast() {
		FactoryRuntimeHolder.getRuntime().load();

		assertThatThrownBy(() -> {
			FactoryRuntimeHolder.getRuntime().<Address>build("user_with_fr_address", o -> {